<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<p style="font-family:Arial;font-size:10pt;color:#317100;margin:15pt;" align="Left">
[AMD Public Use]<br>
</p>
<br>
<div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Reviewed-by: Alex Deucher <alexander.deucher@amd.com><br>
</div>
<div id="appendonsend"></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> amd-gfx <amd-gfx-bounces@lists.freedesktop.org> on behalf of Kevin Wang <kevin1.wang@amd.com><br>
<b>Sent:</b> Tuesday, April 13, 2021 7:51 AM<br>
<b>To:</b> amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org><br>
<b>Cc:</b> Wang, Kevin(Yang) <Kevin1.Wang@amd.com><br>
<b>Subject:</b> [PATCH] drm/amdgpu: correction of ucode fw_size calculation errors</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">correct big and little endian problems on different platforms.<br>
<br>
Signed-off-by: Kevin Wang <kevin1.wang@amd.com><br>
---<br>
 drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c         | 8 ++++----<br>
 drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c          | 2 +-<br>
 drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c | 2 +-<br>
 drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c | 2 +-<br>
 4 files changed, 7 insertions(+), 7 deletions(-)<br>
<br>
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c<br>
index 85a6a10e048f..0a00a7cc8eaa 100644<br>
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c<br>
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c<br>
@@ -4354,7 +4354,7 @@ static int gfx_v10_0_mec_init(struct amdgpu_device *adev)<br>
                          le32_to_cpu(mec_hdr->header.ucode_array_offset_bytes));<br>
                 fw_size = le32_to_cpu(mec_hdr->header.ucode_size_bytes);<br>
 <br>
-               r = amdgpu_bo_create_reserved(adev, mec_hdr->header.ucode_size_bytes,<br>
+               r = amdgpu_bo_create_reserved(adev, fw_size,<br>
                                               PAGE_SIZE, AMDGPU_GEM_DOMAIN_GTT,<br>
                                               &adev->gfx.mec.mec_fw_obj,<br>
                                               &adev->gfx.mec.mec_fw_gpu_addr,<br>
@@ -5769,7 +5769,7 @@ static int gfx_v10_0_cp_gfx_load_pfp_microcode(struct amdgpu_device *adev)<br>
                 le32_to_cpu(pfp_hdr->header.ucode_array_offset_bytes));<br>
         fw_size = le32_to_cpu(pfp_hdr->header.ucode_size_bytes);<br>
 <br>
-       r = amdgpu_bo_create_reserved(adev, pfp_hdr->header.ucode_size_bytes,<br>
+       r = amdgpu_bo_create_reserved(adev, fw_size,<br>
                                       PAGE_SIZE, AMDGPU_GEM_DOMAIN_GTT,<br>
                                       &adev->gfx.pfp.pfp_fw_obj,<br>
                                       &adev->gfx.pfp.pfp_fw_gpu_addr,<br>
@@ -5847,7 +5847,7 @@ static int gfx_v10_0_cp_gfx_load_ce_microcode(struct amdgpu_device *adev)<br>
                 le32_to_cpu(ce_hdr->header.ucode_array_offset_bytes));<br>
         fw_size = le32_to_cpu(ce_hdr->header.ucode_size_bytes);<br>
 <br>
-       r = amdgpu_bo_create_reserved(adev, ce_hdr->header.ucode_size_bytes,<br>
+       r = amdgpu_bo_create_reserved(adev, fw_size,<br>
                                       PAGE_SIZE, AMDGPU_GEM_DOMAIN_GTT,<br>
                                       &adev->gfx.ce.ce_fw_obj,<br>
                                       &adev->gfx.ce.ce_fw_gpu_addr,<br>
@@ -5924,7 +5924,7 @@ static int gfx_v10_0_cp_gfx_load_me_microcode(struct amdgpu_device *adev)<br>
                 le32_to_cpu(me_hdr->header.ucode_array_offset_bytes));<br>
         fw_size = le32_to_cpu(me_hdr->header.ucode_size_bytes);<br>
 <br>
-       r = amdgpu_bo_create_reserved(adev, me_hdr->header.ucode_size_bytes,<br>
+       r = amdgpu_bo_create_reserved(adev, fw_size,<br>
                                       PAGE_SIZE, AMDGPU_GEM_DOMAIN_GTT,<br>
                                       &adev->gfx.me.me_fw_obj,<br>
                                       &adev->gfx.me.me_fw_gpu_addr,<br>
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c<br>
index 06811a1f4625..831398e15b84 100644<br>
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c<br>
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c<br>
@@ -2013,7 +2013,7 @@ static int gfx_v9_0_mec_init(struct amdgpu_device *adev)<br>
                  le32_to_cpu(mec_hdr->header.ucode_array_offset_bytes));<br>
         fw_size = le32_to_cpu(mec_hdr->header.ucode_size_bytes);<br>
 <br>
-       r = amdgpu_bo_create_reserved(adev, mec_hdr->header.ucode_size_bytes,<br>
+       r = amdgpu_bo_create_reserved(adev, fw_size,<br>
                                       PAGE_SIZE, AMDGPU_GEM_DOMAIN_GTT,<br>
                                       &adev->gfx.mec.mec_fw_obj,<br>
                                       &adev->gfx.mec.mec_fw_gpu_addr,<br>
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<br>
index 6274cae4a065..00610def69ea 100644<br>
--- a/drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c<br>
+++ b/drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c<br>
@@ -174,7 +174,7 @@ int smu_v11_0_load_microcode(struct smu_context *smu)<br>
         hdr = (const struct smc_firmware_header_v1_0 *) adev->pm.fw->data;<br>
         src = (const uint32_t *)(adev->pm.fw->data +<br>
                 le32_to_cpu(hdr->header.ucode_array_offset_bytes));<br>
-       smc_fw_size = hdr->header.ucode_size_bytes;<br>
+       smc_fw_size = le32_to_cpu(hdr->header.ucode_size_bytes;)<br>
 <br>
         for (i = 1; i < smc_fw_size/4 - 1; i++) {<br>
                 WREG32_PCIE(addr_start, src[i]);<br>
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<br>
index 0864083e7435..d7ea8215d7dc 100644<br>
--- a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c<br>
+++ b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c<br>
@@ -149,7 +149,7 @@ int smu_v13_0_load_microcode(struct smu_context *smu)<br>
         hdr = (const struct smc_firmware_header_v1_0 *) adev->pm.fw->data;<br>
         src = (const uint32_t *)(adev->pm.fw->data +<br>
                                  le32_to_cpu(hdr->header.ucode_array_offset_bytes));<br>
-       smc_fw_size = hdr->header.ucode_size_bytes;<br>
+       smc_fw_size = le32_to_cpu(hdr->header.ucode_size_bytes);<br>
 <br>
         for (i = 1; i < smc_fw_size/4 - 1; i++) {<br>
                 WREG32_PCIE(addr_start, src[i]);<br>
-- <br>
2.17.1<br>
<br>
_______________________________________________<br>
amd-gfx mailing list<br>
amd-gfx@lists.freedesktop.org<br>
<a href="https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Famd-gfx&amp;data=04%7C01%7Calexander.deucher%40amd.com%7C3992236102744469006b08d8fe728650%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637539115132533430%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=pQO64zy%2F99rHa7Vr9uZd%2F9q04R6DDPL%2BnOiw%2Fo2oScY%3D&amp;reserved=0">https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Famd-gfx&amp;data=04%7C01%7Calexander.deucher%40amd.com%7C3992236102744469006b08d8fe728650%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637539115132533430%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=pQO64zy%2F99rHa7Vr9uZd%2F9q04R6DDPL%2BnOiw%2Fo2oScY%3D&amp;reserved=0</a><br>
</div>
</span></font></div>
</div>
</body>
</html>