amd-gfx.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drm/amdgpu: correction of ucode fw_size calculation errors
@ 2021-04-13 11:51 Kevin Wang
  2021-04-13 14:42 ` Deucher, Alexander
  0 siblings, 1 reply; 2+ messages in thread
From: Kevin Wang @ 2021-04-13 11:51 UTC (permalink / raw)
  To: amd-gfx; +Cc: Kevin Wang

correct big and little endian problems on different platforms.

Signed-off-by: Kevin Wang <kevin1.wang@amd.com>
---
 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 = (const 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 = (const 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@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] drm/amdgpu: correction of ucode fw_size calculation errors
  2021-04-13 11:51 [PATCH] drm/amdgpu: correction of ucode fw_size calculation errors Kevin Wang
@ 2021-04-13 14:42 ` Deucher, Alexander
  0 siblings, 0 replies; 2+ messages in thread
From: Deucher, Alexander @ 2021-04-13 14:42 UTC (permalink / raw)
  To: Wang, Kevin(Yang), amd-gfx


[-- Attachment #1.1: Type: text/plain, Size: 6332 bytes --]

[AMD Public Use]

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
________________________________
From: amd-gfx <amd-gfx-bounces@lists.freedesktop.org> on behalf of Kevin Wang <kevin1.wang@amd.com>
Sent: Tuesday, April 13, 2021 7:51 AM
To: amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org>
Cc: Wang, Kevin(Yang) <Kevin1.Wang@amd.com>
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@amd.com>
---
 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 = (const 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 = (const 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@lists.freedesktop.org
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

[-- Attachment #1.2: Type: text/html, Size: 13180 bytes --]

[-- Attachment #2: Type: text/plain, Size: 154 bytes --]

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-04-13 14:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-13 11:51 [PATCH] drm/amdgpu: correction of ucode fw_size calculation errors Kevin Wang
2021-04-13 14:42 ` Deucher, Alexander

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).