Skip to contentSkip to conversation

drm/amdgpu: check rlc_g firmware pointer is valid before using it

PATCH In review shaoyunl 2 participants 3 messages Jan 10, 2020 – Jan 14, 2020

Subsystems (2)
lore
Share & tools
lore

shaoyunl

author
#0 lore raw

PATCH 1/1 drm/amdgpu: check rlc_g firmware pointer is valid before using it

In SRIOV, rlc_g firmware is loaded by host, guest driver won't load it which will cause the rlc_fw pointer is null

Change-Id Id16f65171dd427d623af4c5bc75f674019e63dec
---
 drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +5 -4
index 379e46c..07e22f2 100644
@@ -808,10 +808,11 @@ static int gfx_v10_0_init_microcode(struct amdgpu_device *adev)
 		info = &adev->firmware.ucode[AMDGPU_UCODE_ID_RLC_G];
 		info->ucode_id = AMDGPU_UCODE_ID_RLC_G;
 		info->fw = adev->gfx.rlc_fw;
-		header = (const struct common_firmware_header *)info->fw->data;
-		adev->firmware.fw_size +=
-			ALIGN(le32_to_cpu(header->ucode_size_bytes), PAGE_SIZE);
-
+		if (info->fw) {
+			header = (const struct common_firmware_header *)info->fw->data;
+			adev->firmware.fw_size +=
+				ALIGN(le32_to_cpu(header->ucode_size_bytes), PAGE_SIZE);
+		}
 		if (adev->gfx.rlc.is_rlc_v2_1 &&
 		    adev->gfx.rlc.save_restore_list_cntl_size_bytes &&
 		    adev->gfx.rlc.save_restore_list_gpm_size_bytes &&
Signature · 6 lines
2.7.4

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
author
#1 lore raw

ping.

Quoted 19 lines · shaoyunl

In SRIOV, rlc_g firmware is loaded by host, guest driver won't load it which will cause the rlc_fw pointer is null

Change-Id Id16f65171dd427d623af4c5bc75f674019e63dec
---
  drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 9 +++++----
  1 file changed, 5 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +0 -2
index 379e46c..07e22f2 100644
@@ -808,10 +808,11 @@ static int gfx_v10_0_init_microcode(struct amdgpu_device *adev)
  		info = &adev->firmware.ucode[AMDGPU_UCODE_ID_RLC_G];
  		info->ucode_id = AMDGPU_UCODE_ID_RLC_G;
  		info->fw = adev->gfx.rlc_fw;
-		header = (const struct common_firmware_header *)info->fw->data;
-		adev->firmware.fw_size +=

drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c static int gfx_v10_0_init_microcode(struct amdgpu_device *adev) · line 818

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +5 -2
-			ALIGN(le32_to_cpu(header->ucode_size_bytes), PAGE_SIZE);
-
+		if (info->fw) {
+			header = (const struct common_firmware_header *)info->fw->data;
+			adev->firmware.fw_size +=
+				ALIGN(le32_to_cpu(header->ucode_size_bytes), PAGE_SIZE);
+		}
  		if (adev->gfx.rlc.is_rlc_v2_1 &&
  		    adev->gfx.rlc.save_restore_list_cntl_size_bytes &&
  		    adev->gfx.rlc.save_restore_list_gpm_size_bytes &&

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

Reviewed-by
#2 lore raw

[AMD Official Use Only - Internal Distribution Only]

Regards,
Hawking
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of shaoyunl
Sent: Tuesday, January 14, 2020 00:20
To: [email protected]
Subject: Re: [PATCH] drm/amdgpu: check rlc_g firmware pointer is valid before using it

ping.

Quoted 20 lines · shaoyunl

In SRIOV, rlc_g firmware is loaded by host, guest driver won't load it which will cause the rlc_fw pointer is null

Change-Id Id16f65171dd427d623af4c5bc75f674019e63dec
---
  drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 9 +++++----
  1 file changed, 5 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +0 -2
index 379e46c..07e22f2 100644
@@ -808,10 +808,11 @@ static int gfx_v10_0_init_microcode(struct amdgpu_device *adev)
  		info = &adev->firmware.ucode[AMDGPU_UCODE_ID_RLC_G];
  		info->ucode_id = AMDGPU_UCODE_ID_RLC_G;
  		info->fw = adev->gfx.rlc_fw;
-		header = (const struct common_firmware_header *)info->fw->data;
-		adev->firmware.fw_size +=

drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c static int gfx_v10_0_init_microcode(struct amdgpu_device *adev) · line 818

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +5 -2
-			ALIGN(le32_to_cpu(header->ucode_size_bytes), PAGE_SIZE);
-
+		if (info->fw) {
+			header = (const struct common_firmware_header *)info->fw->data;
+			adev->firmware.fw_size +=
+				ALIGN(le32_to_cpu(header->ucode_size_bytes), PAGE_SIZE);
+		}
  		if (adev->gfx.rlc.is_rlc_v2_1 &&
  		    adev->gfx.rlc.save_restore_list_cntl_size_bytes &&
  		    adev->gfx.rlc.save_restore_list_gpm_size_bytes &&

_______________________________________________
amd-gfx mailing list
[email protected]
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Famd-gfx&amp;data=02%7C01%7Chawking.zhang%40amd.com%7C07f331f5dcd34309309608d798447956%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637145292188230052&amp;sdata=CgDYPwyn688ERtFq3ldST2nMMejq1a1RxdDRAjKK9jc%3D&amp;reserved=0
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx