Show correct IMU version on APUs
Subsystems (2)
cover Show correct IMU version on APUs
On APUs the active IMU firmware is distributed with the BIOS. Parsing the header for the microcode loaded by the Linux kernel will show the wrong version.
This series adjusts it so that the correct version is exported.
Mario Limonciello (3):
drm/amd: Move microcode init step to early_init() drm/amd: Don't parse IMU ucode version if it won't be loaded drm/amd: Read IMU FW version from scratch register during hw_init
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c | 20 ++++++++++++-------- drivers/gpu/drm/amd/amdgpu/imu_v11_0.c | 4 ++-- 2 files changed, 14 insertions(+), 10 deletions(-)
Signature · 1 line
2.34.1
PATCH 1/3 drm/amd: Move microcode init step to early_init()
The intention for early init is to find any missing microcode early and fail the driver load if it's missing. Move this step to earlier in driver init to match other IP blocks.
--- drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +8 -8
@@ -589,6 +589,14 @@ static int gfx_v11_0_init_microcode(struct amdgpu_device *adev) adev->gfx.mec2_fw =NULL ;gfx_v11_0_check_fw_cp_gfx_shadow (adev); + +if (adev->gfx.imu.funcs && adev->gfx.imu.funcs->init_microcode) { + err = adev->gfx.imu.funcs->init_microcode (adev); +if (err) +DRM_ERROR ("Failed to init imu firmware!\n" ); +return err; + } + out:if (err) {amdgpu_ucode_release (&adev->gfx.pfp_fw);
@@ -1395,14 +1403,6 @@ static int gfx_v11_0_sw_init(void *handle) adev->gfx.gfx_current_status =AMDGPU_GFX_NORMAL_MODE ; -if (adev->gfx.imu.funcs) { -if (adev->gfx.imu.funcs->init_microcode) { - r = adev->gfx.imu.funcs->init_microcode (adev); -if (r) -DRM_ERROR ("Failed to load imu firmware!\n" ); - } - } -gfx_v11_0_me_init (adev); r =gfx_v11_0_rlc_init (adev);
Signature · 1 line
2.34.1
PATCH 2/3 drm/amd: Don't parse IMU ucode version if it won't be loaded
In reply to Mario LimoncielloWhen the IMU ucode is loaded by the PSP parsing the version that comes from Linux will vary. Rather than showing the wrong data to kernel interface consumers, avoid populating it in this case.
--- drivers/gpu/drm/amd/amdgpu/imu_v11_0.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/imu_v11_0.c +2 -2
@@ -55,7 +55,6 @@ static int imu_v11_0_init_microcode(struct amdgpu_device *adev)if (err) goto out; imu_hdr = (const struct imu_firmware_header_v1_0 *)adev->gfx.imu_fw->data; - adev->gfx.imu_fw_version =le32_to_cpu (imu_hdr->header.ucode_version);//adev->gfx.imu_feature_version = le32_to_cpu(imu_hdr->ucode_feature_version); if (adev->firmware.load_type ==AMDGPU_FW_LOAD_PSP ) {
@@ -69,7 +68,8 @@ static int imu_v11_0_init_microcode(struct amdgpu_device *adev) info->fw = adev->gfx.imu_fw; adev->firmware.fw_size +=ALIGN (le32_to_cpu (imu_hdr->imu_dram_ucode_size_bytes),PAGE_SIZE ); - } + }else + adev->gfx.imu_fw_version =le32_to_cpu (imu_hdr->header.ucode_version); out:if (err) {
Signature · 1 line
2.34.1
PATCH 3/3 drm/amd: Read IMU FW version from scratch register during hw_init
In reply to Mario LimoncielloIf the IMU version wasn't discovered from the header, such as when the firmware was directly loaded by PSP then there is no firmware version to show to userspace from sysfs or IOCTL.
The IMU F/W stores the version in the first scratch register though, so fetch it in these cases to let the driver export.
--- drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +4 -0
@@ -4373,6 +4373,10 @@ static int gfx_v11_0_hw_init(void *handle)if (r)return r; +/* get IMU version from HW if it's not set */ +if (!adev->gfx.imu_fw_version) + adev->gfx.imu_fw_version =RREG32_SOC15 (GC ,0 , regGFX_IMU_SCRATCH_0); +return r; }
Signature · 1 line
2.34.1
Re: [PATCH 3/3] drm/amd: Read IMU FW version from scratch register during hw_init
[AMD Official Use Only - General]
Series is:
________________________________
From: amd-gfx <[email protected]> on behalf of Mario Limonciello <[email protected]>
Sent: Friday, October 13, 2023 3:26 PM
To: [email protected] <[email protected]>
Cc: Limonciello, Mario <[email protected]>
Subject: [PATCH 3/3] drm/amd: Read IMU FW version from scratch register during hw_init
If the IMU version wasn't discovered from the header, such as when the firmware was directly loaded by PSP then there is no firmware version to show to userspace from sysfs or IOCTL.
The IMU F/W stores the version in the first scratch register though, so fetch it in these cases to let the driver export.
--- drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +4 -0
@@ -4373,6 +4373,10 @@ static int gfx_v11_0_hw_init(void *handle)if (r)return r; +/* get IMU version from HW if it's not set */ +if (!adev->gfx.imu_fw_version) + adev->gfx.imu_fw_version =RREG32_SOC15 (GC ,0 , regGFX_IMU_SCRATCH_0); +return r; }
--
2.34.1