drm/amdgpu: check rlc_g firmware pointer is valid before using it
Subsystems (2)
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
--- 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
@@ -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
ping.
Quoted 19 lines · shaoyunl
In SRIOV,
rlc_gfirmware is loaded by host, guest driver won't load it which will cause therlc_fwpointer is nullChange-Id Id16f65171dd427d623af4c5bc75f674019e63decSigned-off-by shaoyunl <[email protected]>--- 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@@ -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
Zhang, Hawking
Reviewed-by[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_gfirmware is loaded by host, guest driver won't load it which will cause therlc_fwpointer is nullChange-Id Id16f65171dd427d623af4c5bc75f674019e63decSigned-off-by shaoyunl <[email protected]>--- 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@@ -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&data=02%7C01%7Chawking.zhang%40amd.com%7C07f331f5dcd34309309608d798447956%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637145292188230052&sdata=CgDYPwyn688ERtFq3ldST2nMMejq1a1RxdDRAjKK9jc%3D&reserved=0
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx