Re: [PATCH] drm/amdgpu: correction of ucode fw_size calculation errors

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



[AMD Public Use]


Reviewed-by: Alex Deucher <alexander.deucher@xxxxxxx>

From: amd-gfx <amd-gfx-bounces@xxxxxxxxxxxxxxxxxxxxx> on behalf of Kevin Wang <kevin1.wang@xxxxxxx>
Sent: Tuesday, April 13, 2021 7:51 AM
To: amd-gfx@xxxxxxxxxxxxxxxxxxxxx <amd-gfx@xxxxxxxxxxxxxxxxxxxxx>
Cc: Wang, Kevin(Yang) <Kevin1.Wang@xxxxxxx>
Subject: [PATCH] drm/amdgpu: correction of ucode fw_size calculation errors
 
correct big and little endian problems on different platforms.

Signed-off-by: Kevin Wang <kevin1.wang@xxxxxxx>
---
 drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c         | 8 ++++----
 drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c          | 2 +-
 drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c | 2 +-
 drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c | 2 +-
 4 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
index 85a6a10e048f..0a00a7cc8eaa 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
@@ -4354,7 +4354,7 @@ static int gfx_v10_0_mec_init(struct amdgpu_device *adev)
                          le32_to_cpu(mec_hdr->header.ucode_array_offset_bytes));
                 fw_size = le32_to_cpu(mec_hdr->header.ucode_size_bytes);
 
-               r = amdgpu_bo_create_reserved(adev, mec_hdr->header.ucode_size_bytes,
+               r = amdgpu_bo_create_reserved(adev, fw_size,
                                               PAGE_SIZE, AMDGPU_GEM_DOMAIN_GTT,
                                               &adev->gfx.mec.mec_fw_obj,
                                               &adev->gfx.mec.mec_fw_gpu_addr,
@@ -5769,7 +5769,7 @@ static int gfx_v10_0_cp_gfx_load_pfp_microcode(struct amdgpu_device *adev)
                 le32_to_cpu(pfp_hdr->header.ucode_array_offset_bytes));
         fw_size = le32_to_cpu(pfp_hdr->header.ucode_size_bytes);
 
-       r = amdgpu_bo_create_reserved(adev, pfp_hdr->header.ucode_size_bytes,
+       r = amdgpu_bo_create_reserved(adev, fw_size,
                                       PAGE_SIZE, AMDGPU_GEM_DOMAIN_GTT,
                                       &adev->gfx.pfp.pfp_fw_obj,
                                       &adev->gfx.pfp.pfp_fw_gpu_addr,
@@ -5847,7 +5847,7 @@ static int gfx_v10_0_cp_gfx_load_ce_microcode(struct amdgpu_device *adev)
                 le32_to_cpu(ce_hdr->header.ucode_array_offset_bytes));
         fw_size = le32_to_cpu(ce_hdr->header.ucode_size_bytes);
 
-       r = amdgpu_bo_create_reserved(adev, ce_hdr->header.ucode_size_bytes,
+       r = amdgpu_bo_create_reserved(adev, fw_size,
                                       PAGE_SIZE, AMDGPU_GEM_DOMAIN_GTT,
                                       &adev->gfx.ce.ce_fw_obj,
                                       &adev->gfx.ce.ce_fw_gpu_addr,
@@ -5924,7 +5924,7 @@ static int gfx_v10_0_cp_gfx_load_me_microcode(struct amdgpu_device *adev)
                 le32_to_cpu(me_hdr->header.ucode_array_offset_bytes));
         fw_size = le32_to_cpu(me_hdr->header.ucode_size_bytes);
 
-       r = amdgpu_bo_create_reserved(adev, me_hdr->header.ucode_size_bytes,
+       r = amdgpu_bo_create_reserved(adev, fw_size,
                                       PAGE_SIZE, AMDGPU_GEM_DOMAIN_GTT,
                                       &adev->gfx.me.me_fw_obj,
                                       &adev->gfx.me.me_fw_gpu_addr,
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
index 06811a1f4625..831398e15b84 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
@@ -2013,7 +2013,7 @@ static int gfx_v9_0_mec_init(struct amdgpu_device *adev)
                  le32_to_cpu(mec_hdr->header.ucode_array_offset_bytes));
         fw_size = le32_to_cpu(mec_hdr->header.ucode_size_bytes);
 
-       r = amdgpu_bo_create_reserved(adev, mec_hdr->header.ucode_size_bytes,
+       r = amdgpu_bo_create_reserved(adev, fw_size,
                                       PAGE_SIZE, AMDGPU_GEM_DOMAIN_GTT,
                                       &adev->gfx.mec.mec_fw_obj,
                                       &adev->gfx.mec.mec_fw_gpu_addr,
diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c b/drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c
index 6274cae4a065..00610def69ea 100644
--- a/drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c
+++ b/drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c
@@ -174,7 +174,7 @@ int smu_v11_0_load_microcode(struct smu_context *smu)
         hdr = (const struct smc_firmware_header_v1_0 *) adev->pm.fw->data;
         src = "" uint32_t *)(adev->pm.fw->data +
                 le32_to_cpu(hdr->header.ucode_array_offset_bytes));
-       smc_fw_size = hdr->header.ucode_size_bytes;
+       smc_fw_size = le32_to_cpu(hdr->header.ucode_size_bytes;)
 
         for (i = 1; i < smc_fw_size/4 - 1; i++) {
                 WREG32_PCIE(addr_start, src[i]);
diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c
index 0864083e7435..d7ea8215d7dc 100644
--- a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c
+++ b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c
@@ -149,7 +149,7 @@ int smu_v13_0_load_microcode(struct smu_context *smu)
         hdr = (const struct smc_firmware_header_v1_0 *) adev->pm.fw->data;
         src = "" uint32_t *)(adev->pm.fw->data +
                                  le32_to_cpu(hdr->header.ucode_array_offset_bytes));
-       smc_fw_size = hdr->header.ucode_size_bytes;
+       smc_fw_size = le32_to_cpu(hdr->header.ucode_size_bytes);
 
         for (i = 1; i < smc_fw_size/4 - 1; i++) {
                 WREG32_PCIE(addr_start, src[i]);
--
2.17.1

_______________________________________________
amd-gfx mailing list
amd-gfx@xxxxxxxxxxxxxxxxxxxxx
https://nam11.safelinks.protection.outlook.com/?url="">
_______________________________________________
amd-gfx mailing list
amd-gfx@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux