switch to common helper for rlc fw init
Subsystems (2)
cover switch to common helper for rlc fw init
Replace IP specific implementation with common rlc helper for rlc firmware initialization.
This also helps reduce duplicated code when introduce new ip block support.
Hawking Zhang (10):
drm/amdgpu: add helper to init rlc fw in header v2_0 drm/amdgpu: add helper to init rlc fw in header v2_1 drm/amdgpu: add helper to init rlc fw in header v2_2 drm/amdgpu: add helper to init rlc fw in header v2_3 drm/amdgpu: add helper to init rlc fw in header v2_4 drm/amdgpu: add helper to init rlc firmware drm/amdgpu/gfx8: switch to amdgpu_gfx_rlc_init_microcode drm/amdgpu/gfx9: switch to amdgpu_gfx_rlc_init_microcode drm/amdgpu/gfx10: switch to amdgpu_gfx_rlc_init_microcode drm/amdgpu/gfx11: switch to amdgpu_gfx_rlc_init_microcode
drivers/gpu/drm/amd/amdgpu/amdgpu_rlc.c | 264 ++++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_rlc.h | 4 +- drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 191 +---------------- drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c | 156 +------------- drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c | 60 +----- drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 106 +--------- 6 files changed, 289 insertions(+), 492 deletions(-)
Signature · 1 line
2.17.1
PATCH 1/10 drm/amdgpu: add helper to init rlc fw in header v2_0
To initialize rlc firmware in header v2_0
--- drivers/gpu/drm/amd/amdgpu/amdgpu_rlc.c | 64 +++++++++++++++++++++++++ 1 file changed, 64 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_rlc.c +64 -0
@@ -272,3 +272,67 @@ void amdgpu_gfx_rlc_fini(struct amdgpu_device *adev) &adev->gfx.rlc.cp_table_gpu_addr, (void **)&adev->gfx.rlc.cp_table_ptr); } + +static int amdgpu_gfx_rlc_init_microcode_v2_0 (struct amdgpu_device *adev) +{ +const struct common_firmware_header *common_hdr; +const struct rlc_firmware_header_v2_0 *rlc_hdr; +struct amdgpu_firmware_info *info; +unsigned int *tmp; +unsigned int i; + + rlc_hdr = (const struct rlc_firmware_header_v2_0 *)adev->gfx.rlc_fw->data; + + adev->gfx.rlc_fw_version =le32_to_cpu (rlc_hdr->header.ucode_version); + adev->gfx.rlc_feature_version =le32_to_cpu (rlc_hdr->ucode_feature_version); + adev->gfx.rlc.save_and_restore_offset = +le32_to_cpu (rlc_hdr->save_and_restore_offset); + adev->gfx.rlc.clear_state_descriptor_offset = +le32_to_cpu (rlc_hdr->clear_state_descriptor_offset); + adev->gfx.rlc.avail_scratch_ram_locations = +le32_to_cpu (rlc_hdr->avail_scratch_ram_locations); + adev->gfx.rlc.reg_restore_list_size = +le32_to_cpu (rlc_hdr->reg_restore_list_size); + adev->gfx.rlc.reg_list_format_start = +le32_to_cpu (rlc_hdr->reg_list_format_start); + adev->gfx.rlc.reg_list_format_separate_start = +le32_to_cpu (rlc_hdr->reg_list_format_separate_start); + adev->gfx.rlc.starting_offsets_start = +le32_to_cpu (rlc_hdr->starting_offsets_start); + adev->gfx.rlc.reg_list_format_size_bytes = +le32_to_cpu (rlc_hdr->reg_list_format_size_bytes); + adev->gfx.rlc.reg_list_size_bytes = +le32_to_cpu (rlc_hdr->reg_list_size_bytes); + adev->gfx.rlc.register_list_format = +kmalloc (le32_to_cpu (adev->gfx.rlc.reg_list_format_size_bytes) + +le32_to_cpu (adev->gfx.rlc.reg_list_size_bytes),GFP_KERNEL ); +if (!adev->gfx.rlc.register_list_format) { +dev_err (adev->dev,"failed to allocate memory for rlc register_list_format\n" ); +return -ENOMEM ; + } + + tmp = (unsigned int *)((uintptr_t )rlc_hdr + +le32_to_cpu (rlc_hdr->reg_list_format_array_offset_bytes)); +for (i =0 ; i < (rlc_hdr->reg_list_format_size_bytes >>2 ); i++) + adev->gfx.rlc.register_list_format[i] =le32_to_cpu (tmp[i]); + + adev->gfx.rlc.register_restore = adev->gfx.rlc.register_list_format + i; + + tmp = (unsigned int *)((uintptr_t )rlc_hdr + +le32_to_cpu (rlc_hdr->reg_list_array_offset_bytes)); +for (i =0 ; i < (rlc_hdr->reg_list_size_bytes >>2 ); i++) + adev->gfx.rlc.register_restore[i] =le32_to_cpu (tmp[i]); + +if (adev->firmware.load_type ==AMDGPU_FW_LOAD_PSP ) { + info = &adev->firmware.ucode[AMDGPU_UCODE_ID_RLC_G ]; + info->ucode_id =AMDGPU_UCODE_ID_RLC_G ; + info->fw = adev->gfx.rlc_fw; +if (info->fw) { + common_hdr = (const struct common_firmware_header *)info->fw->data; + adev->firmware.fw_size += +ALIGN (le32_to_cpu (common_hdr->ucode_size_bytes),PAGE_SIZE ); + } + } + +return 0 ; +}
Signature · 1 line
2.17.1
PATCH 2/10 drm/amdgpu: add helper to init rlc fw in header v2_1
In reply to Hawking ZhangTo initialize rlc firmware in header v2_1
--- drivers/gpu/drm/amd/amdgpu/amdgpu_rlc.c | 40 +++++++++++++++++++++++++ 1 file changed, 40 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_rlc.c +40 -0
@@ -336,3 +336,43 @@ static int amdgpu_gfx_rlc_init_microcode_v2_0(struct amdgpu_device *adev)return 0 ; } + +static void amdgpu_gfx_rlc_init_microcode_v2_1 (struct amdgpu_device *adev) +{ +const struct rlc_firmware_header_v2_1 *rlc_hdr; +struct amdgpu_firmware_info *info; + + rlc_hdr = (const struct rlc_firmware_header_v2_1 *)adev->gfx.rlc_fw->data; + adev->gfx.rlc_srlc_fw_version =le32_to_cpu (rlc_hdr->save_restore_list_cntl_ucode_ver); + adev->gfx.rlc_srlc_feature_version =le32_to_cpu (rlc_hdr->save_restore_list_cntl_feature_ver); + adev->gfx.rlc.save_restore_list_cntl_size_bytes =le32_to_cpu (rlc_hdr->save_restore_list_cntl_size_bytes); + adev->gfx.rlc.save_restore_list_cntl = (u8 *)rlc_hdr +le32_to_cpu (rlc_hdr->save_restore_list_cntl_offset_bytes); + adev->gfx.rlc_srlg_fw_version =le32_to_cpu (rlc_hdr->save_restore_list_gpm_ucode_ver); + adev->gfx.rlc_srlg_feature_version =le32_to_cpu (rlc_hdr->save_restore_list_gpm_feature_ver); + adev->gfx.rlc.save_restore_list_gpm_size_bytes =le32_to_cpu (rlc_hdr->save_restore_list_gpm_size_bytes); + adev->gfx.rlc.save_restore_list_gpm = (u8 *)rlc_hdr +le32_to_cpu (rlc_hdr->save_restore_list_gpm_offset_bytes); + adev->gfx.rlc_srls_fw_version =le32_to_cpu (rlc_hdr->save_restore_list_srm_ucode_ver); + adev->gfx.rlc_srls_feature_version =le32_to_cpu (rlc_hdr->save_restore_list_srm_feature_ver); + adev->gfx.rlc.save_restore_list_srm_size_bytes =le32_to_cpu (rlc_hdr->save_restore_list_srm_size_bytes); + adev->gfx.rlc.save_restore_list_srm = (u8 *)rlc_hdr +le32_to_cpu (rlc_hdr->save_restore_list_srm_offset_bytes); + adev->gfx.rlc.reg_list_format_direct_reg_list_length = +le32_to_cpu (rlc_hdr->reg_list_format_direct_reg_list_length); + +if (adev->firmware.load_type ==AMDGPU_FW_LOAD_PSP ) { +if (adev->gfx.rlc.save_restore_list_gpm_size_bytes) { + info = &adev->firmware.ucode[AMDGPU_UCODE_ID_RLC_RESTORE_LIST_GPM_MEM ]; + info->ucode_id =AMDGPU_UCODE_ID_RLC_RESTORE_LIST_GPM_MEM ; + info->fw = adev->gfx.rlc_fw; + adev->firmware.fw_size += +ALIGN (le32_to_cpu (adev->gfx.rlc.save_restore_list_gpm_size_bytes),PAGE_SIZE ); + } + +if (adev->gfx.rlc.save_restore_list_srm_size_bytes) { + info = &adev->firmware.ucode[AMDGPU_UCODE_ID_RLC_RESTORE_LIST_SRM_MEM ]; + info->ucode_id =AMDGPU_UCODE_ID_RLC_RESTORE_LIST_SRM_MEM ; + info->fw = adev->gfx.rlc_fw; + adev->firmware.fw_size += +ALIGN (le32_to_cpu (adev->gfx.rlc.save_restore_list_srm_size_bytes),PAGE_SIZE ); + } + } +}
Signature · 1 line
2.17.1
PATCH 3/10 drm/amdgpu: add helper to init rlc fw in header v2_2
In reply to Hawking ZhangTo initialize rlc firmware in header v2_2
--- drivers/gpu/drm/amd/amdgpu/amdgpu_rlc.c | 30 +++++++++++++++++++++++++ 1 file changed, 30 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_rlc.c +30 -0
@@ -376,3 +376,33 @@ static void amdgpu_gfx_rlc_init_microcode_v2_1(struct amdgpu_device *adev) } } } + +static void amdgpu_gfx_rlc_init_microcode_v2_2 (struct amdgpu_device *adev) +{ +const struct rlc_firmware_header_v2_2 *rlc_hdr; +struct amdgpu_firmware_info *info; + + rlc_hdr = (const struct rlc_firmware_header_v2_2 *)adev->gfx.rlc_fw->data; + adev->gfx.rlc.rlc_iram_ucode_size_bytes =le32_to_cpu (rlc_hdr->rlc_iram_ucode_size_bytes); + adev->gfx.rlc.rlc_iram_ucode = (u8 *)rlc_hdr +le32_to_cpu (rlc_hdr->rlc_iram_ucode_offset_bytes); + adev->gfx.rlc.rlc_dram_ucode_size_bytes =le32_to_cpu (rlc_hdr->rlc_dram_ucode_size_bytes); + adev->gfx.rlc.rlc_dram_ucode = (u8 *)rlc_hdr +le32_to_cpu (rlc_hdr->rlc_dram_ucode_offset_bytes); + +if (adev->firmware.load_type ==AMDGPU_FW_LOAD_PSP ) { +if (adev->gfx.rlc.rlc_iram_ucode_size_bytes) { + info = &adev->firmware.ucode[AMDGPU_UCODE_ID_RLC_IRAM ]; + info->ucode_id =AMDGPU_UCODE_ID_RLC_IRAM ; + info->fw = adev->gfx.rlc_fw; + adev->firmware.fw_size += +ALIGN (le32_to_cpu (adev->gfx.rlc.rlc_iram_ucode_size_bytes),PAGE_SIZE ); + } + +if (adev->gfx.rlc.rlc_dram_ucode_size_bytes) { + info = &adev->firmware.ucode[AMDGPU_UCODE_ID_RLC_DRAM ]; + info->ucode_id =AMDGPU_UCODE_ID_RLC_DRAM ; + info->fw = adev->gfx.rlc_fw; + adev->firmware.fw_size += +ALIGN (le32_to_cpu (adev->gfx.rlc.rlc_dram_ucode_size_bytes),PAGE_SIZE ); + } + } +}
Signature · 1 line
2.17.1
RE: [PATCH 03/10] drm/amdgpu: add helper to init rlc fw in header v2_2
[AMD Official Use Only - General]
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Hawking Zhang
Sent: Friday, September 16, 2022 1:01 AM
To: [email protected]; Gao, Likun <[email protected]>; Deucher, Alexander <[email protected]>
Cc: Zhang, Hawking <[email protected]>
Subject: [PATCH 03/10] drm/amdgpu: add helper to init rlc fw in header v2_2
To initialize rlc firmware in header v2_2
--- drivers/gpu/drm/amd/amdgpu/amdgpu_rlc.c | 30 +++++++++++++++++++++++++ 1 file changed, 30 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_rlc.c +30 -0
@@ -376,3 +376,33 @@ static void amdgpu_gfx_rlc_init_microcode_v2_1(struct amdgpu_device *adev) } } } + +static void amdgpu_gfx_rlc_init_microcode_v2_2 (struct amdgpu_device +*adev) { +const struct rlc_firmware_header_v2_2 *rlc_hdr; +struct amdgpu_firmware_info *info; + + rlc_hdr = (const struct rlc_firmware_header_v2_2 *)adev->gfx.rlc_fw->data; + adev->gfx.rlc.rlc_iram_ucode_size_bytes =le32_to_cpu (rlc_hdr->rlc_iram_ucode_size_bytes); + adev->gfx.rlc.rlc_iram_ucode = (u8 *)rlc_hdr +le32_to_cpu (rlc_hdr->rlc_iram_ucode_offset_bytes); + adev->gfx.rlc.rlc_dram_ucode_size_bytes =le32_to_cpu (rlc_hdr->rlc_dram_ucode_size_bytes); + adev->gfx.rlc.rlc_dram_ucode = (u8 *)rlc_hdr + +le32_to_cpu (rlc_hdr->rlc_dram_ucode_offset_bytes); + +if (adev->firmware.load_type ==AMDGPU_FW_LOAD_PSP ) { +if (adev->gfx.rlc.rlc_iram_ucode_size_bytes) { + info = &adev->firmware.ucode[AMDGPU_UCODE_ID_RLC_IRAM ]; + info->ucode_id =AMDGPU_UCODE_ID_RLC_IRAM ; + info->fw = adev->gfx.rlc_fw; + adev->firmware.fw_size += +ALIGN (le32_to_cpu (adev->gfx.rlc.rlc_iram_ucode_size_bytes),PAGE_SIZE ); + } + +if (adev->gfx.rlc.rlc_dram_ucode_size_bytes) { + info = &adev->firmware.ucode[AMDGPU_UCODE_ID_RLC_DRAM ]; + info->ucode_id =AMDGPU_UCODE_ID_RLC_DRAM ; + info->fw = adev->gfx.rlc_fw; + adev->firmware.fw_size += +ALIGN (le32_to_cpu (adev->gfx.rlc.rlc_dram_ucode_size_bytes),PAGE_SIZE ); + } + }
[Kevin]:
according to code logic in above, the following code is not needed to convert again. ALIGN(le32_to_cpu(adev->gfx.rlc.rlc_dram_ucode_size_bytes), PAGE_SIZE);
Best Regards,
Kevin
+}
--
2.17.1
Re: [PATCH 03/10] drm/amdgpu: add helper to init rlc fw in header v2_2
[AMD Official Use Only - General]
[Kevin]:
according to code logic in above, the following code is not needed to convert again. ALIGN(le32_to_cpu(adev->gfx.rlc.rlc_dram_ucode_size_bytes), PAGE_SIZE);
Good catch. will make the change when push the code.
Regards,
Hawking
From: Wang, Yang(Kevin) <[email protected]>
Date: Monday, September 19, 2022 at 01:15
To: Zhang, Hawking <[email protected]>, [email protected] <[email protected]>, Gao, Likun <[email protected]>, Deucher, Alexander <[email protected]>
Cc: Zhang, Hawking <[email protected]>
Subject: RE: [PATCH 03/10] drm/amdgpu: add helper to init rlc fw in header v2_2
[AMD Official Use Only - General]
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Hawking Zhang
Sent: Friday, September 16, 2022 1:01 AM
To: [email protected]; Gao, Likun <[email protected]>; Deucher, Alexander <[email protected]>
Cc: Zhang, Hawking <[email protected]>
Subject: [PATCH 03/10] drm/amdgpu: add helper to init rlc fw in header v2_2
To initialize rlc firmware in header v2_2
--- drivers/gpu/drm/amd/amdgpu/amdgpu_rlc.c | 30 +++++++++++++++++++++++++ 1 file changed, 30 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_rlc.c +30 -0
@@ -376,3 +376,33 @@ static void amdgpu_gfx_rlc_init_microcode_v2_1(struct amdgpu_device *adev) } } } + +static void amdgpu_gfx_rlc_init_microcode_v2_2 (struct amdgpu_device +*adev) { +const struct rlc_firmware_header_v2_2 *rlc_hdr; +struct amdgpu_firmware_info *info; + + rlc_hdr = (const struct rlc_firmware_header_v2_2 *)adev->gfx.rlc_fw->data; + adev->gfx.rlc.rlc_iram_ucode_size_bytes =le32_to_cpu (rlc_hdr->rlc_iram_ucode_size_bytes); + adev->gfx.rlc.rlc_iram_ucode = (u8 *)rlc_hdr +le32_to_cpu (rlc_hdr->rlc_iram_ucode_offset_bytes); + adev->gfx.rlc.rlc_dram_ucode_size_bytes =le32_to_cpu (rlc_hdr->rlc_dram_ucode_size_bytes); + adev->gfx.rlc.rlc_dram_ucode = (u8 *)rlc_hdr + +le32_to_cpu (rlc_hdr->rlc_dram_ucode_offset_bytes); + +if (adev->firmware.load_type ==AMDGPU_FW_LOAD_PSP ) { +if (adev->gfx.rlc.rlc_iram_ucode_size_bytes) { + info = &adev->firmware.ucode[AMDGPU_UCODE_ID_RLC_IRAM ]; + info->ucode_id =AMDGPU_UCODE_ID_RLC_IRAM ; + info->fw = adev->gfx.rlc_fw; + adev->firmware.fw_size += +ALIGN (le32_to_cpu (adev->gfx.rlc.rlc_iram_ucode_size_bytes),PAGE_SIZE ); + } + +if (adev->gfx.rlc.rlc_dram_ucode_size_bytes) { + info = &adev->firmware.ucode[AMDGPU_UCODE_ID_RLC_DRAM ]; + info->ucode_id =AMDGPU_UCODE_ID_RLC_DRAM ; + info->fw = adev->gfx.rlc_fw; + adev->firmware.fw_size += +ALIGN (le32_to_cpu (adev->gfx.rlc.rlc_dram_ucode_size_bytes),PAGE_SIZE ); + } + }
[Kevin]:
according to code logic in above, the following code is not needed to convert again. ALIGN(le32_to_cpu(adev->gfx.rlc.rlc_dram_ucode_size_bytes), PAGE_SIZE);
Best Regards,
Kevin
+}
--
2.17.1
PATCH 4/10 drm/amdgpu: add helper to init rlc fw in header v2_3
In reply to Hawking ZhangTo initialize rlc firmware in header v2_3
--- drivers/gpu/drm/amd/amdgpu/amdgpu_rlc.c | 35 +++++++++++++++++++++++++ 1 file changed, 35 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_rlc.c +35 -0
@@ -406,3 +406,38 @@ static void amdgpu_gfx_rlc_init_microcode_v2_2(struct amdgpu_device *adev) } } } + +static void amdgpu_gfx_rlc_init_microcode_v2_3 (struct amdgpu_device *adev) +{ +const struct rlc_firmware_header_v2_3 *rlc_hdr; +struct amdgpu_firmware_info *info; + + rlc_hdr = (const struct rlc_firmware_header_v2_3 *)adev->gfx.rlc_fw->data; + adev->gfx.rlcp_ucode_version =le32_to_cpu (rlc_hdr->rlcp_ucode_version); + adev->gfx.rlcp_ucode_feature_version =le32_to_cpu (rlc_hdr->rlcp_ucode_feature_version); + adev->gfx.rlc.rlcp_ucode_size_bytes =le32_to_cpu (rlc_hdr->rlcp_ucode_size_bytes); + adev->gfx.rlc.rlcp_ucode = (u8 *)rlc_hdr +le32_to_cpu (rlc_hdr->rlcp_ucode_offset_bytes); + + adev->gfx.rlcv_ucode_version =le32_to_cpu (rlc_hdr->rlcv_ucode_version); + adev->gfx.rlcv_ucode_feature_version =le32_to_cpu (rlc_hdr->rlcv_ucode_feature_version); + adev->gfx.rlc.rlcv_ucode_size_bytes =le32_to_cpu (rlc_hdr->rlcv_ucode_size_bytes); + adev->gfx.rlc.rlcv_ucode = (u8 *)rlc_hdr +le32_to_cpu (rlc_hdr->rlcv_ucode_offset_bytes); + +if (adev->firmware.load_type ==AMDGPU_FW_LOAD_PSP ) { +if (adev->gfx.rlc.rlcp_ucode_size_bytes) { + info = &adev->firmware.ucode[AMDGPU_UCODE_ID_RLC_P ]; + info->ucode_id =AMDGPU_UCODE_ID_RLC_P ; + info->fw = adev->gfx.rlc_fw; + adev->firmware.fw_size += +ALIGN (le32_to_cpu (adev->gfx.rlc.rlcp_ucode_size_bytes),PAGE_SIZE ); + } + +if (adev->gfx.rlc.rlcv_ucode_size_bytes) { + info = &adev->firmware.ucode[AMDGPU_UCODE_ID_RLC_V ]; + info->ucode_id =AMDGPU_UCODE_ID_RLC_V ; + info->fw = adev->gfx.rlc_fw; + adev->firmware.fw_size += +ALIGN (le32_to_cpu (adev->gfx.rlc.rlcv_ucode_size_bytes),PAGE_SIZE ); + } + } +}
Signature · 1 line
2.17.1
PATCH 5/10 drm/amdgpu: add helper to init rlc fw in header v2_4
In reply to Hawking ZhangTo initialize rlc firmware in header v2_4
--- drivers/gpu/drm/amd/amdgpu/amdgpu_rlc.c | 60 +++++++++++++++++++++++++ 1 file changed, 60 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_rlc.c +60 -0
@@ -441,3 +441,63 @@ static void amdgpu_gfx_rlc_init_microcode_v2_3(struct amdgpu_device *adev) } } } + +static void amdgpu_gfx_rlc_init_microcode_v2_4 (struct amdgpu_device *adev) +{ +const struct rlc_firmware_header_v2_4 *rlc_hdr; +struct amdgpu_firmware_info *info; + + rlc_hdr = (const struct rlc_firmware_header_v2_4 *)adev->gfx.rlc_fw->data; + adev->gfx.rlc.global_tap_delays_ucode_size_bytes =le32_to_cpu (rlc_hdr->global_tap_delays_ucode_size_bytes); + adev->gfx.rlc.global_tap_delays_ucode = (u8 *)rlc_hdr +le32_to_cpu (rlc_hdr->global_tap_delays_ucode_offset_bytes); + adev->gfx.rlc.se0_tap_delays_ucode_size_bytes =le32_to_cpu (rlc_hdr->se0_tap_delays_ucode_size_bytes); + adev->gfx.rlc.se0_tap_delays_ucode = (u8 *)rlc_hdr +le32_to_cpu (rlc_hdr->se0_tap_delays_ucode_offset_bytes); + adev->gfx.rlc.se1_tap_delays_ucode_size_bytes =le32_to_cpu (rlc_hdr->se1_tap_delays_ucode_size_bytes); + adev->gfx.rlc.se1_tap_delays_ucode = (u8 *)rlc_hdr +le32_to_cpu (rlc_hdr->se1_tap_delays_ucode_offset_bytes); + adev->gfx.rlc.se2_tap_delays_ucode_size_bytes =le32_to_cpu (rlc_hdr->se2_tap_delays_ucode_size_bytes); + adev->gfx.rlc.se2_tap_delays_ucode = (u8 *)rlc_hdr +le32_to_cpu (rlc_hdr->se2_tap_delays_ucode_offset_bytes); + adev->gfx.rlc.se3_tap_delays_ucode_size_bytes =le32_to_cpu (rlc_hdr->se3_tap_delays_ucode_size_bytes); + adev->gfx.rlc.se3_tap_delays_ucode = (u8 *)rlc_hdr +le32_to_cpu (rlc_hdr->se3_tap_delays_ucode_offset_bytes); + +if (adev->firmware.load_type ==AMDGPU_FW_LOAD_PSP ) { +if (adev->gfx.rlc.global_tap_delays_ucode_size_bytes) { + info = &adev->firmware.ucode[AMDGPU_UCODE_ID_GLOBAL_TAP_DELAYS ]; + info->ucode_id =AMDGPU_UCODE_ID_GLOBAL_TAP_DELAYS ; + info->fw = adev->gfx.rlc_fw; + adev->firmware.fw_size += +ALIGN (le32_to_cpu (adev->gfx.rlc.global_tap_delays_ucode_size_bytes),PAGE_SIZE ); + } + +if (adev->gfx.rlc.se0_tap_delays_ucode_size_bytes) { + info = &adev->firmware.ucode[AMDGPU_UCODE_ID_SE0_TAP_DELAYS ]; + info->ucode_id =AMDGPU_UCODE_ID_SE0_TAP_DELAYS ; + info->fw = adev->gfx.rlc_fw; + adev->firmware.fw_size += +ALIGN (le32_to_cpu (adev->gfx.rlc.se0_tap_delays_ucode_size_bytes),PAGE_SIZE ); + } + +if (adev->gfx.rlc.se1_tap_delays_ucode_size_bytes) { + info = &adev->firmware.ucode[AMDGPU_UCODE_ID_SE1_TAP_DELAYS ]; + info->ucode_id =AMDGPU_UCODE_ID_SE1_TAP_DELAYS ; + info->fw = adev->gfx.rlc_fw; + adev->firmware.fw_size += +ALIGN (le32_to_cpu (adev->gfx.rlc.se1_tap_delays_ucode_size_bytes),PAGE_SIZE ); + } + +if (adev->gfx.rlc.se2_tap_delays_ucode_size_bytes) { + info = &adev->firmware.ucode[AMDGPU_UCODE_ID_SE2_TAP_DELAYS ]; + info->ucode_id =AMDGPU_UCODE_ID_SE2_TAP_DELAYS ; + info->fw = adev->gfx.rlc_fw; + adev->firmware.fw_size += +ALIGN (le32_to_cpu (adev->gfx.rlc.se2_tap_delays_ucode_size_bytes),PAGE_SIZE ); + } + +if (adev->gfx.rlc.se3_tap_delays_ucode_size_bytes) { + info = &adev->firmware.ucode[AMDGPU_UCODE_ID_SE3_TAP_DELAYS ]; + info->ucode_id =AMDGPU_UCODE_ID_SE3_TAP_DELAYS ; + info->fw = adev->gfx.rlc_fw; + adev->firmware.fw_size += +ALIGN (le32_to_cpu (adev->gfx.rlc.se3_tap_delays_ucode_size_bytes),PAGE_SIZE ); + } + } +}
Signature · 1 line
2.17.1
PATCH 6/10 drm/amdgpu: add helper to init rlc firmware
In reply to Hawking ZhangTo initialzie rlc firmware according to rlc
firmware header version
--- drivers/gpu/drm/amd/amdgpu/amdgpu_rlc.c | 35 +++++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_rlc.h | 4 ++- 2 files changed, 38 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_rlc.c +35 -0
@@ -501,3 +501,38 @@ static void amdgpu_gfx_rlc_init_microcode_v2_4(struct amdgpu_device *adev) } } } + +int amdgpu_gfx_rlc_init_microcode (struct amdgpu_device *adev, +uint16_t version_major, +uint16_t version_minor) +{ +int err; + +if (version_major <2 ) { +/* only support rlc_hdr v2.x and onwards */ +dev_err (adev->dev,"unsupported rlc fw hdr\n" ); +return -EINVAL ; + } + +/* is_rlc_v2_1 is still used in APU code path */ +if (version_major ==2 && version_minor ==1 ) + adev->gfx.rlc.is_rlc_v2_1 = true; + +if (version_minor >=0 ) { + err =amdgpu_gfx_rlc_init_microcode_v2_0 (adev); +if (err) { +dev_err (adev->dev,"fail to init rlc v2_0 microcode\n" ); +return err; + } + } +if (version_minor >=1 ) +amdgpu_gfx_rlc_init_microcode_v2_1 (adev); +if (version_minor >=2 ) +amdgpu_gfx_rlc_init_microcode_v2_2 (adev); +if (version_minor >=3 ) +amdgpu_gfx_rlc_init_microcode_v2_3 (adev); +if (version_minor >=4 ) +amdgpu_gfx_rlc_init_microcode_v2_4 (adev); + +return 0 ; +}
drivers/gpu/drm/amd/amdgpu/amdgpu_rlc.h +3 -1
@@ -267,5 +267,7 @@ int amdgpu_gfx_rlc_init_csb(struct amdgpu_device *adev);int amdgpu_gfx_rlc_init_cpt (struct amdgpu_device *adev);void amdgpu_gfx_rlc_setup_cp_table (struct amdgpu_device *adev);void amdgpu_gfx_rlc_fini (struct amdgpu_device *adev); - +int amdgpu_gfx_rlc_init_microcode (struct amdgpu_device *adev, +uint16_t version_major, +uint16_t version_minor);#endif
Signature · 1 line
2.17.1
PATCH 7/10 drm/amdgpu/gfx8: switch to amdgpu_gfx_rlc_init_microcode
In reply to Hawking Zhangswitch to common helper to initialize rlc firmware for gfx8
--- drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c | 60 +++++---------------------- 1 file changed, 11 insertions(+), 49 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +11 -49
@@ -951,7 +951,7 @@ static int gfx_v8_0_init_microcode(struct amdgpu_device *adev)const struct common_firmware_header *header =NULL ;const struct gfx_firmware_header_v1_0 *cp_hdr;const struct rlc_firmware_header_v2_0 *rlc_hdr; -unsigned int *tmp =NULL , i; +uint16_t version_major, version_minor;DRM_DEBUG ("\n" );
@@ -1064,49 +1064,18 @@ static int gfx_v8_0_init_microcode(struct amdgpu_device *adev)if (err) goto out; err =amdgpu_ucode_validate (adev->gfx.rlc_fw); - rlc_hdr = (const struct rlc_firmware_header_v2_0 *)adev->gfx.rlc_fw->data; - adev->gfx.rlc_fw_version =le32_to_cpu (rlc_hdr->header.ucode_version); - adev->gfx.rlc_feature_version =le32_to_cpu (rlc_hdr->ucode_feature_version); - - adev->gfx.rlc.save_and_restore_offset = -le32_to_cpu (rlc_hdr->save_and_restore_offset); - adev->gfx.rlc.clear_state_descriptor_offset = -le32_to_cpu (rlc_hdr->clear_state_descriptor_offset); - adev->gfx.rlc.avail_scratch_ram_locations = -le32_to_cpu (rlc_hdr->avail_scratch_ram_locations); - adev->gfx.rlc.reg_restore_list_size = -le32_to_cpu (rlc_hdr->reg_restore_list_size); - adev->gfx.rlc.reg_list_format_start = -le32_to_cpu (rlc_hdr->reg_list_format_start); - adev->gfx.rlc.reg_list_format_separate_start = -le32_to_cpu (rlc_hdr->reg_list_format_separate_start); - adev->gfx.rlc.starting_offsets_start = -le32_to_cpu (rlc_hdr->starting_offsets_start); - adev->gfx.rlc.reg_list_format_size_bytes = -le32_to_cpu (rlc_hdr->reg_list_format_size_bytes); - adev->gfx.rlc.reg_list_size_bytes = -le32_to_cpu (rlc_hdr->reg_list_size_bytes); - - adev->gfx.rlc.register_list_format = -kmalloc (adev->gfx.rlc.reg_list_format_size_bytes + - adev->gfx.rlc.reg_list_size_bytes,GFP_KERNEL ); - -if (!adev->gfx.rlc.register_list_format) { - err = -ENOMEM ; +if (err) goto out; + rlc_hdr = (const struct rlc_firmware_header_v2_0 *)adev->gfx.rlc_fw->data; +if (!rlc_hdr) { +dev_err (adev->dev,"invalid rlc fw data\n" ); +return -EINVAL ; } - - tmp = (unsigned int *)((uintptr_t )rlc_hdr + -le32_to_cpu (rlc_hdr->reg_list_format_array_offset_bytes)); -for (i =0 ; i < (adev->gfx.rlc.reg_list_format_size_bytes >>2 ); i++) - adev->gfx.rlc.register_list_format[i] =le32_to_cpu (tmp[i]); - - adev->gfx.rlc.register_restore = adev->gfx.rlc.register_list_format + i; - - tmp = (unsigned int *)((uintptr_t )rlc_hdr + -le32_to_cpu (rlc_hdr->reg_list_array_offset_bytes)); -for (i =0 ; i < (adev->gfx.rlc.reg_list_size_bytes >>2 ); i++) - adev->gfx.rlc.register_restore[i] =le32_to_cpu (tmp[i]); + version_major =le16_to_cpu (rlc_hdr->header.header_version_major); + version_minor =le16_to_cpu (rlc_hdr->header.header_version_minor); + err =amdgpu_gfx_rlc_init_microcode (adev, version_major, version_minor); +if (err) + goto out;if (adev->asic_type >=CHIP_POLARIS10 && adev->asic_type <=CHIP_POLARIS12 ) {snprintf (fw_name,sizeof (fw_name),"amdgpu/%s_mec_2.bin" , chip_name);
@@ -1178,13 +1147,6 @@ static int gfx_v8_0_init_microcode(struct amdgpu_device *adev) adev->firmware.fw_size +=ALIGN (le32_to_cpu (header->ucode_size_bytes),PAGE_SIZE ); - 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 ); - info = &adev->firmware.ucode[AMDGPU_UCODE_ID_CP_MEC1 ]; info->ucode_id =AMDGPU_UCODE_ID_CP_MEC1 ; info->fw = adev->gfx.mec_fw;
Signature · 1 line
2.17.1
RE: [PATCH 07/10] drm/amdgpu/gfx8: switch to amdgpu_gfx_rlc_init_microcode
[AMD Official Use Only - General]
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Hawking Zhang
Sent: Friday, September 16, 2022 1:02 AM
To: [email protected]; Gao, Likun <[email protected]>; Deucher, Alexander <[email protected]>
Cc: Zhang, Hawking <[email protected]>
Subject: [PATCH 07/10] drm/amdgpu/gfx8: switch to amdgpu_gfx_rlc_init_microcode
switch to common helper to initialize rlc firmware for gfx8
--- drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c | 60 +++++---------------------- 1 file changed, 11 insertions(+), 49 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +6 -30
@@ -951,7 +951,7 @@ static int gfx_v8_0_init_microcode(struct amdgpu_device *adev)const struct common_firmware_header *header =NULL ;const struct gfx_firmware_header_v1_0 *cp_hdr;const struct rlc_firmware_header_v2_0 *rlc_hdr; -unsigned int *tmp =NULL , i; +uint16_t version_major, version_minor;DRM_DEBUG ("\n" );
@@ -1064,49 +1064,18 @@ static int gfx_v8_0_init_microcode(struct amdgpu_device *adev)if (err) goto out; err =amdgpu_ucode_validate (adev->gfx.rlc_fw); - rlc_hdr = (const struct rlc_firmware_header_v2_0 *)adev->gfx.rlc_fw->data; - adev->gfx.rlc_fw_version =le32_to_cpu (rlc_hdr->header.ucode_version); - adev->gfx.rlc_feature_version =le32_to_cpu (rlc_hdr->ucode_feature_version); - - adev->gfx.rlc.save_and_restore_offset = -le32_to_cpu (rlc_hdr->save_and_restore_offset); - adev->gfx.rlc.clear_state_descriptor_offset = -le32_to_cpu (rlc_hdr->clear_state_descriptor_offset); - adev->gfx.rlc.avail_scratch_ram_locations = -le32_to_cpu (rlc_hdr->avail_scratch_ram_locations); - adev->gfx.rlc.reg_restore_list_size = -le32_to_cpu (rlc_hdr->reg_restore_list_size); - adev->gfx.rlc.reg_list_format_start = -le32_to_cpu (rlc_hdr->reg_list_format_start); - adev->gfx.rlc.reg_list_format_separate_start = -le32_to_cpu (rlc_hdr->reg_list_format_separate_start); - adev->gfx.rlc.starting_offsets_start = -le32_to_cpu (rlc_hdr->starting_offsets_start); - adev->gfx.rlc.reg_list_format_size_bytes = -le32_to_cpu (rlc_hdr->reg_list_format_size_bytes); - adev->gfx.rlc.reg_list_size_bytes = -le32_to_cpu (rlc_hdr->reg_list_size_bytes); - - adev->gfx.rlc.register_list_format = -kmalloc (adev->gfx.rlc.reg_list_format_size_bytes + - adev->gfx.rlc.reg_list_size_bytes,GFP_KERNEL ); - -if (!adev->gfx.rlc.register_list_format) { - err = -ENOMEM ; +if (err) goto out; + rlc_hdr = (const struct rlc_firmware_header_v2_0 *)adev->gfx.rlc_fw->data; +if (!rlc_hdr) { +dev_err (adev->dev,"invalid rlc fw data\n" ); +return -EINVAL ; }
[Kevin]:
If variable of rlc_hdr is "NULL", the driver will get a data abort in amdgpu_ucode_validate() first, so I think the function "dev_err()" should never be called. May be this error has been returned in previous position. (maybe in err = request_firmware()).
Thanks.
Best Regards,
Kevin
-
- tmp = (unsigned int *)((uintptr_t)rlc_hdr +
- le32_to_cpu(rlc_hdr->reg_list_format_array_offset_bytes));
- for (i = 0 ; i < (adev->gfx.rlc.reg_list_format_size_bytes >> 2); i++)
- adev->gfx.rlc.register_list_format[i] = le32_to_cpu(tmp[i]);
-
- adev->gfx.rlc.register_restore = adev->gfx.rlc.register_list_format + i;
-
- tmp = (unsigned int *)((uintptr_t)rlc_hdr +
- le32_to_cpu(rlc_hdr->reg_list_array_offset_bytes));
- for (i = 0 ; i < (adev->gfx.rlc.reg_list_size_bytes >> 2); i++)
- adev->gfx.rlc.register_restore[i] = le32_to_cpu(tmp[i]);
+ version_major = le16_to_cpu(rlc_hdr->header.header_version_major); + version_minor = le16_to_cpu(rlc_hdr->header.header_version_minor); + err = amdgpu_gfx_rlc_init_microcode(adev, version_major, version_minor); + if (err)
+ goto out;
if (adev->asic_type >= CHIP_POLARIS10 && adev->asic_type <= CHIP_POLARIS12) {
snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_mec_2.bin", chip_name); @@ -1178,13 +1147,6 @@ static int gfx_v8_0_init_microcode(struct amdgpu_device *adev)
adev->firmware.fw_size +=
ALIGN(le32_to_cpu(header->ucode_size_bytes), PAGE_SIZE);- 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);
-
info = &adev->firmware.ucode[AMDGPU_UCODE_ID_CP_MEC1];
info->ucode_id = AMDGPU_UCODE_ID_CP_MEC1;
info->fw = adev->gfx.mec_fw;--
2.17.1
PATCH 8/10 drm/amdgpu/gfx9: switch to amdgpu_gfx_rlc_init_microcode
In reply to Hawking Zhangswitch to common helper to initialize rlc firmware for gfx9
--- drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 106 +------------------------- 1 file changed, 3 insertions(+), 103 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +3 -103
@@ -1091,27 +1091,6 @@ static void gfx_v9_0_free_microcode(struct amdgpu_device *adev)kfree (adev->gfx.rlc.register_list_format); } -static void gfx_v9_0_init_rlc_ext_microcode (struct amdgpu_device *adev) -{ -const struct rlc_firmware_header_v2_1 *rlc_hdr; - - rlc_hdr = (const struct rlc_firmware_header_v2_1 *)adev->gfx.rlc_fw->data; - adev->gfx.rlc_srlc_fw_version =le32_to_cpu (rlc_hdr->save_restore_list_cntl_ucode_ver); - adev->gfx.rlc_srlc_feature_version =le32_to_cpu (rlc_hdr->save_restore_list_cntl_feature_ver); - adev->gfx.rlc.save_restore_list_cntl_size_bytes =le32_to_cpu (rlc_hdr->save_restore_list_cntl_size_bytes); - adev->gfx.rlc.save_restore_list_cntl = (u8 *)rlc_hdr +le32_to_cpu (rlc_hdr->save_restore_list_cntl_offset_bytes); - adev->gfx.rlc_srlg_fw_version =le32_to_cpu (rlc_hdr->save_restore_list_gpm_ucode_ver); - adev->gfx.rlc_srlg_feature_version =le32_to_cpu (rlc_hdr->save_restore_list_gpm_feature_ver); - adev->gfx.rlc.save_restore_list_gpm_size_bytes =le32_to_cpu (rlc_hdr->save_restore_list_gpm_size_bytes); - adev->gfx.rlc.save_restore_list_gpm = (u8 *)rlc_hdr +le32_to_cpu (rlc_hdr->save_restore_list_gpm_offset_bytes); - adev->gfx.rlc_srls_fw_version =le32_to_cpu (rlc_hdr->save_restore_list_srm_ucode_ver); - adev->gfx.rlc_srls_feature_version =le32_to_cpu (rlc_hdr->save_restore_list_srm_feature_ver); - adev->gfx.rlc.save_restore_list_srm_size_bytes =le32_to_cpu (rlc_hdr->save_restore_list_srm_size_bytes); - adev->gfx.rlc.save_restore_list_srm = (u8 *)rlc_hdr +le32_to_cpu (rlc_hdr->save_restore_list_srm_offset_bytes); - adev->gfx.rlc.reg_list_format_direct_reg_list_length = -le32_to_cpu (rlc_hdr->reg_list_format_direct_reg_list_length); -} -static void gfx_v9_0_check_fw_write_wait (struct amdgpu_device *adev) { adev->gfx.me_fw_write_wait = false;
@@ -1353,11 +1332,7 @@ static int gfx_v9_0_init_rlc_microcode(struct amdgpu_device *adev, {char fw_name[30 ];int err; -struct amdgpu_firmware_info *info =NULL ; -const struct common_firmware_header *header =NULL ;const struct rlc_firmware_header_v2_0 *rlc_hdr; -unsigned int *tmp =NULL ; -unsigned int i =0 ;uint16_t version_major;uint16_t version_minor;uint32_t smu_version;
@@ -1386,88 +1361,13 @@ static int gfx_v9_0_init_rlc_microcode(struct amdgpu_device *adev,if (err) goto out; err =amdgpu_ucode_validate (adev->gfx.rlc_fw); +if (err) + goto out; rlc_hdr = (const struct rlc_firmware_header_v2_0 *)adev->gfx.rlc_fw->data; version_major =le16_to_cpu (rlc_hdr->header.header_version_major); version_minor =le16_to_cpu (rlc_hdr->header.header_version_minor); -if (version_major ==2 && version_minor ==1 ) - adev->gfx.rlc.is_rlc_v2_1 = true; - - adev->gfx.rlc_fw_version =le32_to_cpu (rlc_hdr->header.ucode_version); - adev->gfx.rlc_feature_version =le32_to_cpu (rlc_hdr->ucode_feature_version); - adev->gfx.rlc.save_and_restore_offset = -le32_to_cpu (rlc_hdr->save_and_restore_offset); - adev->gfx.rlc.clear_state_descriptor_offset = -le32_to_cpu (rlc_hdr->clear_state_descriptor_offset); - adev->gfx.rlc.avail_scratch_ram_locations = -le32_to_cpu (rlc_hdr->avail_scratch_ram_locations); - adev->gfx.rlc.reg_restore_list_size = -le32_to_cpu (rlc_hdr->reg_restore_list_size); - adev->gfx.rlc.reg_list_format_start = -le32_to_cpu (rlc_hdr->reg_list_format_start); - adev->gfx.rlc.reg_list_format_separate_start = -le32_to_cpu (rlc_hdr->reg_list_format_separate_start); - adev->gfx.rlc.starting_offsets_start = -le32_to_cpu (rlc_hdr->starting_offsets_start); - adev->gfx.rlc.reg_list_format_size_bytes = -le32_to_cpu (rlc_hdr->reg_list_format_size_bytes); - adev->gfx.rlc.reg_list_size_bytes = -le32_to_cpu (rlc_hdr->reg_list_size_bytes); - adev->gfx.rlc.register_list_format = -kmalloc (adev->gfx.rlc.reg_list_format_size_bytes + - adev->gfx.rlc.reg_list_size_bytes,GFP_KERNEL ); -if (!adev->gfx.rlc.register_list_format) { - err = -ENOMEM ; - goto out; - } - - tmp = (unsigned int *)((uintptr_t )rlc_hdr + -le32_to_cpu (rlc_hdr->reg_list_format_array_offset_bytes)); -for (i =0 ; i < (adev->gfx.rlc.reg_list_format_size_bytes >>2 ); i++) - adev->gfx.rlc.register_list_format[i] =le32_to_cpu (tmp[i]); - - adev->gfx.rlc.register_restore = adev->gfx.rlc.register_list_format + i; - - tmp = (unsigned int *)((uintptr_t )rlc_hdr + -le32_to_cpu (rlc_hdr->reg_list_array_offset_bytes)); -for (i =0 ; i < (adev->gfx.rlc.reg_list_size_bytes >>2 ); i++) - adev->gfx.rlc.register_restore[i] =le32_to_cpu (tmp[i]); - -if (adev->gfx.rlc.is_rlc_v2_1) -gfx_v9_0_init_rlc_ext_microcode (adev); - -if (adev->firmware.load_type ==AMDGPU_FW_LOAD_PSP ) { - 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 (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 && - adev->gfx.rlc.save_restore_list_srm_size_bytes) { - info = &adev->firmware.ucode[AMDGPU_UCODE_ID_RLC_RESTORE_LIST_CNTL ]; - info->ucode_id =AMDGPU_UCODE_ID_RLC_RESTORE_LIST_CNTL ; - info->fw = adev->gfx.rlc_fw; - adev->firmware.fw_size += -ALIGN (adev->gfx.rlc.save_restore_list_cntl_size_bytes,PAGE_SIZE ); - - info = &adev->firmware.ucode[AMDGPU_UCODE_ID_RLC_RESTORE_LIST_GPM_MEM ]; - info->ucode_id =AMDGPU_UCODE_ID_RLC_RESTORE_LIST_GPM_MEM ; - info->fw = adev->gfx.rlc_fw; - adev->firmware.fw_size += -ALIGN (adev->gfx.rlc.save_restore_list_gpm_size_bytes,PAGE_SIZE ); - - info = &adev->firmware.ucode[AMDGPU_UCODE_ID_RLC_RESTORE_LIST_SRM_MEM ]; - info->ucode_id =AMDGPU_UCODE_ID_RLC_RESTORE_LIST_SRM_MEM ; - info->fw = adev->gfx.rlc_fw; - adev->firmware.fw_size += -ALIGN (adev->gfx.rlc.save_restore_list_srm_size_bytes,PAGE_SIZE ); - } - } - + err =amdgpu_gfx_rlc_init_microcode (adev, version_major, version_minor); out:if (err) { dev_err(adev->dev,
Signature · 1 line
2.17.1
PATCH 9/10 drm/amdgpu/gfx10: switch to amdgpu_gfx_rlc_init_microcode
In reply to Hawking Zhangswitch to common helper to initialize rlc firmware for gfx10
--- drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 191 +------------------------ 1 file changed, 4 insertions(+), 187 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +4 -187
@@ -3943,56 +3943,6 @@ static void gfx_v10_0_check_fw_write_wait(struct amdgpu_device *adev)DRM_WARN_ONCE ("CP firmware version too old, please update!" ); } - -static void gfx_v10_0_init_rlc_ext_microcode (struct amdgpu_device *adev) -{ -const struct rlc_firmware_header_v2_1 *rlc_hdr; - - rlc_hdr = (const struct rlc_firmware_header_v2_1 *)adev->gfx.rlc_fw->data; - adev->gfx.rlc_srlc_fw_version =le32_to_cpu (rlc_hdr->save_restore_list_cntl_ucode_ver); - adev->gfx.rlc_srlc_feature_version =le32_to_cpu (rlc_hdr->save_restore_list_cntl_feature_ver); - adev->gfx.rlc.save_restore_list_cntl_size_bytes =le32_to_cpu (rlc_hdr->save_restore_list_cntl_size_bytes); - adev->gfx.rlc.save_restore_list_cntl = (u8 *)rlc_hdr +le32_to_cpu (rlc_hdr->save_restore_list_cntl_offset_bytes); - adev->gfx.rlc_srlg_fw_version =le32_to_cpu (rlc_hdr->save_restore_list_gpm_ucode_ver); - adev->gfx.rlc_srlg_feature_version =le32_to_cpu (rlc_hdr->save_restore_list_gpm_feature_ver); - adev->gfx.rlc.save_restore_list_gpm_size_bytes =le32_to_cpu (rlc_hdr->save_restore_list_gpm_size_bytes); - adev->gfx.rlc.save_restore_list_gpm = (u8 *)rlc_hdr +le32_to_cpu (rlc_hdr->save_restore_list_gpm_offset_bytes); - adev->gfx.rlc_srls_fw_version =le32_to_cpu (rlc_hdr->save_restore_list_srm_ucode_ver); - adev->gfx.rlc_srls_feature_version =le32_to_cpu (rlc_hdr->save_restore_list_srm_feature_ver); - adev->gfx.rlc.save_restore_list_srm_size_bytes =le32_to_cpu (rlc_hdr->save_restore_list_srm_size_bytes); - adev->gfx.rlc.save_restore_list_srm = (u8 *)rlc_hdr +le32_to_cpu (rlc_hdr->save_restore_list_srm_offset_bytes); - adev->gfx.rlc.reg_list_format_direct_reg_list_length = -le32_to_cpu (rlc_hdr->reg_list_format_direct_reg_list_length); -} - -static void gfx_v10_0_init_rlc_iram_dram_microcode (struct amdgpu_device *adev) -{ -const struct rlc_firmware_header_v2_2 *rlc_hdr; - - rlc_hdr = (const struct rlc_firmware_header_v2_2 *)adev->gfx.rlc_fw->data; - adev->gfx.rlc.rlc_iram_ucode_size_bytes =le32_to_cpu (rlc_hdr->rlc_iram_ucode_size_bytes); - adev->gfx.rlc.rlc_iram_ucode = (u8 *)rlc_hdr +le32_to_cpu (rlc_hdr->rlc_iram_ucode_offset_bytes); - adev->gfx.rlc.rlc_dram_ucode_size_bytes =le32_to_cpu (rlc_hdr->rlc_dram_ucode_size_bytes); - adev->gfx.rlc.rlc_dram_ucode = (u8 *)rlc_hdr +le32_to_cpu (rlc_hdr->rlc_dram_ucode_offset_bytes); -} - -static void gfx_v10_0_init_tap_delays_microcode (struct amdgpu_device *adev) -{ -const struct rlc_firmware_header_v2_4 *rlc_hdr; - - rlc_hdr = (const struct rlc_firmware_header_v2_4 *)adev->gfx.rlc_fw->data; - adev->gfx.rlc.global_tap_delays_ucode_size_bytes =le32_to_cpu (rlc_hdr->global_tap_delays_ucode_size_bytes); - adev->gfx.rlc.global_tap_delays_ucode = (u8 *)rlc_hdr +le32_to_cpu (rlc_hdr->global_tap_delays_ucode_offset_bytes); - adev->gfx.rlc.se0_tap_delays_ucode_size_bytes =le32_to_cpu (rlc_hdr->se0_tap_delays_ucode_size_bytes); - adev->gfx.rlc.se0_tap_delays_ucode = (u8 *)rlc_hdr +le32_to_cpu (rlc_hdr->se0_tap_delays_ucode_offset_bytes); - adev->gfx.rlc.se1_tap_delays_ucode_size_bytes =le32_to_cpu (rlc_hdr->se1_tap_delays_ucode_size_bytes); - adev->gfx.rlc.se1_tap_delays_ucode = (u8 *)rlc_hdr +le32_to_cpu (rlc_hdr->se1_tap_delays_ucode_offset_bytes); - adev->gfx.rlc.se2_tap_delays_ucode_size_bytes =le32_to_cpu (rlc_hdr->se2_tap_delays_ucode_size_bytes); - adev->gfx.rlc.se2_tap_delays_ucode = (u8 *)rlc_hdr +le32_to_cpu (rlc_hdr->se2_tap_delays_ucode_offset_bytes); - adev->gfx.rlc.se3_tap_delays_ucode_size_bytes =le32_to_cpu (rlc_hdr->se3_tap_delays_ucode_size_bytes); - adev->gfx.rlc.se3_tap_delays_ucode = (u8 *)rlc_hdr +le32_to_cpu (rlc_hdr->se3_tap_delays_ucode_offset_bytes); -} -static bool gfx_v10_0_navi10_gfxoff_should_enable (struct amdgpu_device *adev) {bool ret = false;
@@ -4032,8 +3982,6 @@ static int gfx_v10_0_init_microcode(struct amdgpu_device *adev)const struct common_firmware_header *header =NULL ;const struct gfx_firmware_header_v1_0 *cp_hdr;const struct rlc_firmware_header_v2_0 *rlc_hdr; -unsigned int *tmp =NULL ; -unsigned int i =0 ;uint16_t version_major;uint16_t version_minor;
@@ -4123,59 +4071,14 @@ static int gfx_v10_0_init_microcode(struct amdgpu_device *adev)if (err) goto out; err =amdgpu_ucode_validate (adev->gfx.rlc_fw); +if (err) + goto out; rlc_hdr = (const struct rlc_firmware_header_v2_0 *)adev->gfx.rlc_fw->data; version_major =le16_to_cpu (rlc_hdr->header.header_version_major); version_minor =le16_to_cpu (rlc_hdr->header.header_version_minor); - - adev->gfx.rlc_fw_version =le32_to_cpu (rlc_hdr->header.ucode_version); - adev->gfx.rlc_feature_version =le32_to_cpu (rlc_hdr->ucode_feature_version); - adev->gfx.rlc.save_and_restore_offset = -le32_to_cpu (rlc_hdr->save_and_restore_offset); - adev->gfx.rlc.clear_state_descriptor_offset = -le32_to_cpu (rlc_hdr->clear_state_descriptor_offset); - adev->gfx.rlc.avail_scratch_ram_locations = -le32_to_cpu (rlc_hdr->avail_scratch_ram_locations); - adev->gfx.rlc.reg_restore_list_size = -le32_to_cpu (rlc_hdr->reg_restore_list_size); - adev->gfx.rlc.reg_list_format_start = -le32_to_cpu (rlc_hdr->reg_list_format_start); - adev->gfx.rlc.reg_list_format_separate_start = -le32_to_cpu (rlc_hdr->reg_list_format_separate_start); - adev->gfx.rlc.starting_offsets_start = -le32_to_cpu (rlc_hdr->starting_offsets_start); - adev->gfx.rlc.reg_list_format_size_bytes = -le32_to_cpu (rlc_hdr->reg_list_format_size_bytes); - adev->gfx.rlc.reg_list_size_bytes = -le32_to_cpu (rlc_hdr->reg_list_size_bytes); - adev->gfx.rlc.register_list_format = -kmalloc (adev->gfx.rlc.reg_list_format_size_bytes + - adev->gfx.rlc.reg_list_size_bytes,GFP_KERNEL ); -if (!adev->gfx.rlc.register_list_format) { - err = -ENOMEM ; + err =amdgpu_gfx_rlc_init_microcode (adev, version_major, version_minor); +if (err) goto out; - } - - tmp = (unsigned int *)((uintptr_t )rlc_hdr + -le32_to_cpu (rlc_hdr->reg_list_format_array_offset_bytes)); -for (i =0 ; i < (rlc_hdr->reg_list_format_size_bytes >>2 ); i++) - adev->gfx.rlc.register_list_format[i] =le32_to_cpu (tmp[i]); - - adev->gfx.rlc.register_restore = adev->gfx.rlc.register_list_format + i; - - tmp = (unsigned int *)((uintptr_t )rlc_hdr + -le32_to_cpu (rlc_hdr->reg_list_array_offset_bytes)); -for (i =0 ; i < (rlc_hdr->reg_list_size_bytes >>2 ); i++) - adev->gfx.rlc.register_restore[i] =le32_to_cpu (tmp[i]); - -if (version_major ==2 ) { -if (version_minor >=1 ) -gfx_v10_0_init_rlc_ext_microcode (adev); -if (version_minor >=2 ) -gfx_v10_0_init_rlc_iram_dram_microcode (adev); -if (version_minor ==4 ) { -gfx_v10_0_init_tap_delays_microcode (adev); - } - } }snprintf (fw_name,sizeof (fw_name),"amdgpu/%s_mec%s.bin" , chip_name, wks);
@@ -4228,92 +4131,6 @@ static int gfx_v10_0_init_microcode(struct amdgpu_device *adev) adev->firmware.fw_size +=ALIGN (le32_to_cpu (header->ucode_size_bytes),PAGE_SIZE ); - info = &adev->firmware.ucode[AMDGPU_UCODE_ID_RLC_G ]; - info->ucode_id =AMDGPU_UCODE_ID_RLC_G ; - info->fw = adev->gfx.rlc_fw; -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.save_restore_list_cntl_size_bytes && - adev->gfx.rlc.save_restore_list_gpm_size_bytes && - adev->gfx.rlc.save_restore_list_srm_size_bytes) { - info = &adev->firmware.ucode[AMDGPU_UCODE_ID_RLC_RESTORE_LIST_CNTL ]; - info->ucode_id =AMDGPU_UCODE_ID_RLC_RESTORE_LIST_CNTL ; - info->fw = adev->gfx.rlc_fw; - adev->firmware.fw_size += -ALIGN (adev->gfx.rlc.save_restore_list_cntl_size_bytes,PAGE_SIZE ); - - info = &adev->firmware.ucode[AMDGPU_UCODE_ID_RLC_RESTORE_LIST_GPM_MEM ]; - info->ucode_id =AMDGPU_UCODE_ID_RLC_RESTORE_LIST_GPM_MEM ; - info->fw = adev->gfx.rlc_fw; - adev->firmware.fw_size += -ALIGN (adev->gfx.rlc.save_restore_list_gpm_size_bytes,PAGE_SIZE ); - - info = &adev->firmware.ucode[AMDGPU_UCODE_ID_RLC_RESTORE_LIST_SRM_MEM ]; - info->ucode_id =AMDGPU_UCODE_ID_RLC_RESTORE_LIST_SRM_MEM ; - info->fw = adev->gfx.rlc_fw; - adev->firmware.fw_size += -ALIGN (adev->gfx.rlc.save_restore_list_srm_size_bytes,PAGE_SIZE ); - -if (adev->gfx.rlc.rlc_iram_ucode_size_bytes && - adev->gfx.rlc.rlc_dram_ucode_size_bytes) { - info = &adev->firmware.ucode[AMDGPU_UCODE_ID_RLC_IRAM ]; - info->ucode_id =AMDGPU_UCODE_ID_RLC_IRAM ; - info->fw = adev->gfx.rlc_fw; - adev->firmware.fw_size += -ALIGN (adev->gfx.rlc.rlc_iram_ucode_size_bytes,PAGE_SIZE ); - - info = &adev->firmware.ucode[AMDGPU_UCODE_ID_RLC_DRAM ]; - info->ucode_id =AMDGPU_UCODE_ID_RLC_DRAM ; - info->fw = adev->gfx.rlc_fw; - adev->firmware.fw_size += -ALIGN (adev->gfx.rlc.rlc_dram_ucode_size_bytes,PAGE_SIZE ); - } - - } - -if (adev->gfx.rlc.global_tap_delays_ucode_size_bytes) { - info = &adev->firmware.ucode[AMDGPU_UCODE_ID_GLOBAL_TAP_DELAYS ]; - info->ucode_id =AMDGPU_UCODE_ID_GLOBAL_TAP_DELAYS ; - info->fw = adev->gfx.rlc_fw; - adev->firmware.fw_size += -ALIGN (adev->gfx.rlc.global_tap_delays_ucode_size_bytes,PAGE_SIZE ); - } - -if (adev->gfx.rlc.se0_tap_delays_ucode_size_bytes) { - info = &adev->firmware.ucode[AMDGPU_UCODE_ID_SE0_TAP_DELAYS ]; - info->ucode_id =AMDGPU_UCODE_ID_SE0_TAP_DELAYS ; - info->fw = adev->gfx.rlc_fw; - adev->firmware.fw_size += -ALIGN (adev->gfx.rlc.se0_tap_delays_ucode_size_bytes,PAGE_SIZE ); - } - -if (adev->gfx.rlc.se1_tap_delays_ucode_size_bytes) { - info = &adev->firmware.ucode[AMDGPU_UCODE_ID_SE1_TAP_DELAYS ]; - info->ucode_id =AMDGPU_UCODE_ID_SE1_TAP_DELAYS ; - info->fw = adev->gfx.rlc_fw; - adev->firmware.fw_size += -ALIGN (adev->gfx.rlc.se1_tap_delays_ucode_size_bytes,PAGE_SIZE ); - } - -if (adev->gfx.rlc.se2_tap_delays_ucode_size_bytes) { - info = &adev->firmware.ucode[AMDGPU_UCODE_ID_SE2_TAP_DELAYS ]; - info->ucode_id =AMDGPU_UCODE_ID_SE2_TAP_DELAYS ; - info->fw = adev->gfx.rlc_fw; - adev->firmware.fw_size += -ALIGN (adev->gfx.rlc.se2_tap_delays_ucode_size_bytes,PAGE_SIZE ); - } - -if (adev->gfx.rlc.se3_tap_delays_ucode_size_bytes) { - info = &adev->firmware.ucode[AMDGPU_UCODE_ID_SE3_TAP_DELAYS ]; - info->ucode_id =AMDGPU_UCODE_ID_SE3_TAP_DELAYS ; - info->fw = adev->gfx.rlc_fw; - adev->firmware.fw_size += -ALIGN (adev->gfx.rlc.se3_tap_delays_ucode_size_bytes,PAGE_SIZE ); - } - info = &adev->firmware.ucode[AMDGPU_UCODE_ID_CP_MEC1 ]; info->ucode_id =AMDGPU_UCODE_ID_CP_MEC1 ; info->fw = adev->gfx.mec_fw;
Signature · 1 line
2.17.1
Deucher, Alexander
maintainerRe: [PATCH 09/10] drm/amdgpu/gfx10: switch to amdgpu_gfx_rlc_init_microcode
[Public]
This set seems to break RLC firmware loading on sienna cichlid.
Alex
________________________________
From: Zhang, Hawking <[email protected]>
Sent: Thursday, September 15, 2022 1:01 PM
To: [email protected] <[email protected]>; Gao, Likun <[email protected]>; Deucher, Alexander <[email protected]>
Cc: Zhang, Hawking <[email protected]>
Subject: [PATCH 09/10] drm/amdgpu/gfx10: switch to amdgpu_gfx_rlc_init_microcode
switch to common helper to initialize rlc firmware for gfx10
--- drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 191 +------------------------ 1 file changed, 4 insertions(+), 187 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +4 -187
@@ -3943,56 +3943,6 @@ static void gfx_v10_0_check_fw_write_wait(struct amdgpu_device *adev)DRM_WARN_ONCE ("CP firmware version too old, please update!" ); } - -static void gfx_v10_0_init_rlc_ext_microcode (struct amdgpu_device *adev) -{ -const struct rlc_firmware_header_v2_1 *rlc_hdr; - - rlc_hdr = (const struct rlc_firmware_header_v2_1 *)adev->gfx.rlc_fw->data; - adev->gfx.rlc_srlc_fw_version =le32_to_cpu (rlc_hdr->save_restore_list_cntl_ucode_ver); - adev->gfx.rlc_srlc_feature_version =le32_to_cpu (rlc_hdr->save_restore_list_cntl_feature_ver); - adev->gfx.rlc.save_restore_list_cntl_size_bytes =le32_to_cpu (rlc_hdr->save_restore_list_cntl_size_bytes); - adev->gfx.rlc.save_restore_list_cntl = (u8 *)rlc_hdr +le32_to_cpu (rlc_hdr->save_restore_list_cntl_offset_bytes); - adev->gfx.rlc_srlg_fw_version =le32_to_cpu (rlc_hdr->save_restore_list_gpm_ucode_ver); - adev->gfx.rlc_srlg_feature_version =le32_to_cpu (rlc_hdr->save_restore_list_gpm_feature_ver); - adev->gfx.rlc.save_restore_list_gpm_size_bytes =le32_to_cpu (rlc_hdr->save_restore_list_gpm_size_bytes); - adev->gfx.rlc.save_restore_list_gpm = (u8 *)rlc_hdr +le32_to_cpu (rlc_hdr->save_restore_list_gpm_offset_bytes); - adev->gfx.rlc_srls_fw_version =le32_to_cpu (rlc_hdr->save_restore_list_srm_ucode_ver); - adev->gfx.rlc_srls_feature_version =le32_to_cpu (rlc_hdr->save_restore_list_srm_feature_ver); - adev->gfx.rlc.save_restore_list_srm_size_bytes =le32_to_cpu (rlc_hdr->save_restore_list_srm_size_bytes); - adev->gfx.rlc.save_restore_list_srm = (u8 *)rlc_hdr +le32_to_cpu (rlc_hdr->save_restore_list_srm_offset_bytes); - adev->gfx.rlc.reg_list_format_direct_reg_list_length = -le32_to_cpu (rlc_hdr->reg_list_format_direct_reg_list_length); -} - -static void gfx_v10_0_init_rlc_iram_dram_microcode (struct amdgpu_device *adev) -{ -const struct rlc_firmware_header_v2_2 *rlc_hdr; - - rlc_hdr = (const struct rlc_firmware_header_v2_2 *)adev->gfx.rlc_fw->data; - adev->gfx.rlc.rlc_iram_ucode_size_bytes =le32_to_cpu (rlc_hdr->rlc_iram_ucode_size_bytes); - adev->gfx.rlc.rlc_iram_ucode = (u8 *)rlc_hdr +le32_to_cpu (rlc_hdr->rlc_iram_ucode_offset_bytes); - adev->gfx.rlc.rlc_dram_ucode_size_bytes =le32_to_cpu (rlc_hdr->rlc_dram_ucode_size_bytes); - adev->gfx.rlc.rlc_dram_ucode = (u8 *)rlc_hdr +le32_to_cpu (rlc_hdr->rlc_dram_ucode_offset_bytes); -} - -static void gfx_v10_0_init_tap_delays_microcode (struct amdgpu_device *adev) -{ -const struct rlc_firmware_header_v2_4 *rlc_hdr; - - rlc_hdr = (const struct rlc_firmware_header_v2_4 *)adev->gfx.rlc_fw->data; - adev->gfx.rlc.global_tap_delays_ucode_size_bytes =le32_to_cpu (rlc_hdr->global_tap_delays_ucode_size_bytes); - adev->gfx.rlc.global_tap_delays_ucode = (u8 *)rlc_hdr +le32_to_cpu (rlc_hdr->global_tap_delays_ucode_offset_bytes); - adev->gfx.rlc.se0_tap_delays_ucode_size_bytes =le32_to_cpu (rlc_hdr->se0_tap_delays_ucode_size_bytes); - adev->gfx.rlc.se0_tap_delays_ucode = (u8 *)rlc_hdr +le32_to_cpu (rlc_hdr->se0_tap_delays_ucode_offset_bytes); - adev->gfx.rlc.se1_tap_delays_ucode_size_bytes =le32_to_cpu (rlc_hdr->se1_tap_delays_ucode_size_bytes); - adev->gfx.rlc.se1_tap_delays_ucode = (u8 *)rlc_hdr +le32_to_cpu (rlc_hdr->se1_tap_delays_ucode_offset_bytes); - adev->gfx.rlc.se2_tap_delays_ucode_size_bytes =le32_to_cpu (rlc_hdr->se2_tap_delays_ucode_size_bytes); - adev->gfx.rlc.se2_tap_delays_ucode = (u8 *)rlc_hdr +le32_to_cpu (rlc_hdr->se2_tap_delays_ucode_offset_bytes); - adev->gfx.rlc.se3_tap_delays_ucode_size_bytes =le32_to_cpu (rlc_hdr->se3_tap_delays_ucode_size_bytes); - adev->gfx.rlc.se3_tap_delays_ucode = (u8 *)rlc_hdr +le32_to_cpu (rlc_hdr->se3_tap_delays_ucode_offset_bytes); -} -static bool gfx_v10_0_navi10_gfxoff_should_enable (struct amdgpu_device *adev) {bool ret = false;
@@ -4032,8 +3982,6 @@ static int gfx_v10_0_init_microcode(struct amdgpu_device *adev)const struct common_firmware_header *header =NULL ;const struct gfx_firmware_header_v1_0 *cp_hdr;const struct rlc_firmware_header_v2_0 *rlc_hdr; -unsigned int *tmp =NULL ; -unsigned int i =0 ;uint16_t version_major;uint16_t version_minor;
@@ -4123,59 +4071,14 @@ static int gfx_v10_0_init_microcode(struct amdgpu_device *adev)if (err) goto out; err =amdgpu_ucode_validate (adev->gfx.rlc_fw); +if (err) + goto out; rlc_hdr = (const struct rlc_firmware_header_v2_0 *)adev->gfx.rlc_fw->data; version_major =le16_to_cpu (rlc_hdr->header.header_version_major); version_minor =le16_to_cpu (rlc_hdr->header.header_version_minor); - - adev->gfx.rlc_fw_version =le32_to_cpu (rlc_hdr->header.ucode_version); - adev->gfx.rlc_feature_version =le32_to_cpu (rlc_hdr->ucode_feature_version); - adev->gfx.rlc.save_and_restore_offset = -le32_to_cpu (rlc_hdr->save_and_restore_offset); - adev->gfx.rlc.clear_state_descriptor_offset = -le32_to_cpu (rlc_hdr->clear_state_descriptor_offset); - adev->gfx.rlc.avail_scratch_ram_locations = -le32_to_cpu (rlc_hdr->avail_scratch_ram_locations); - adev->gfx.rlc.reg_restore_list_size = -le32_to_cpu (rlc_hdr->reg_restore_list_size); - adev->gfx.rlc.reg_list_format_start = -le32_to_cpu (rlc_hdr->reg_list_format_start); - adev->gfx.rlc.reg_list_format_separate_start = -le32_to_cpu (rlc_hdr->reg_list_format_separate_start); - adev->gfx.rlc.starting_offsets_start = -le32_to_cpu (rlc_hdr->starting_offsets_start); - adev->gfx.rlc.reg_list_format_size_bytes = -le32_to_cpu (rlc_hdr->reg_list_format_size_bytes); - adev->gfx.rlc.reg_list_size_bytes = -le32_to_cpu (rlc_hdr->reg_list_size_bytes); - adev->gfx.rlc.register_list_format = -kmalloc (adev->gfx.rlc.reg_list_format_size_bytes + - adev->gfx.rlc.reg_list_size_bytes,GFP_KERNEL ); -if (!adev->gfx.rlc.register_list_format) { - err = -ENOMEM ; + err =amdgpu_gfx_rlc_init_microcode (adev, version_major, version_minor); +if (err) goto out; - } - - tmp = (unsigned int *)((uintptr_t )rlc_hdr + -le32_to_cpu (rlc_hdr->reg_list_format_array_offset_bytes)); -for (i =0 ; i < (rlc_hdr->reg_list_format_size_bytes >>2 ); i++) - adev->gfx.rlc.register_list_format[i] =le32_to_cpu (tmp[i]); - - adev->gfx.rlc.register_restore = adev->gfx.rlc.register_list_format + i; - - tmp = (unsigned int *)((uintptr_t )rlc_hdr + -le32_to_cpu (rlc_hdr->reg_list_array_offset_bytes)); -for (i =0 ; i < (rlc_hdr->reg_list_size_bytes >>2 ); i++) - adev->gfx.rlc.register_restore[i] =le32_to_cpu (tmp[i]); - -if (version_major ==2 ) { -if (version_minor >=1 ) -gfx_v10_0_init_rlc_ext_microcode (adev); -if (version_minor >=2 ) -gfx_v10_0_init_rlc_iram_dram_microcode (adev); -if (version_minor ==4 ) { -gfx_v10_0_init_tap_delays_microcode (adev); - } - } }snprintf (fw_name,sizeof (fw_name),"amdgpu/%s_mec%s.bin" , chip_name, wks);
@@ -4228,92 +4131,6 @@ static int gfx_v10_0_init_microcode(struct amdgpu_device *adev) adev->firmware.fw_size +=ALIGN (le32_to_cpu (header->ucode_size_bytes),PAGE_SIZE ); - info = &adev->firmware.ucode[AMDGPU_UCODE_ID_RLC_G ]; - info->ucode_id =AMDGPU_UCODE_ID_RLC_G ; - info->fw = adev->gfx.rlc_fw; -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.save_restore_list_cntl_size_bytes && - adev->gfx.rlc.save_restore_list_gpm_size_bytes && - adev->gfx.rlc.save_restore_list_srm_size_bytes) { - info = &adev->firmware.ucode[AMDGPU_UCODE_ID_RLC_RESTORE_LIST_CNTL ]; - info->ucode_id =AMDGPU_UCODE_ID_RLC_RESTORE_LIST_CNTL ; - info->fw = adev->gfx.rlc_fw; - adev->firmware.fw_size += -ALIGN (adev->gfx.rlc.save_restore_list_cntl_size_bytes,PAGE_SIZE ); - - info = &adev->firmware.ucode[AMDGPU_UCODE_ID_RLC_RESTORE_LIST_GPM_MEM ]; - info->ucode_id =AMDGPU_UCODE_ID_RLC_RESTORE_LIST_GPM_MEM ; - info->fw = adev->gfx.rlc_fw; - adev->firmware.fw_size += -ALIGN (adev->gfx.rlc.save_restore_list_gpm_size_bytes,PAGE_SIZE ); - - info = &adev->firmware.ucode[AMDGPU_UCODE_ID_RLC_RESTORE_LIST_SRM_MEM ]; - info->ucode_id =AMDGPU_UCODE_ID_RLC_RESTORE_LIST_SRM_MEM ; - info->fw = adev->gfx.rlc_fw; - adev->firmware.fw_size += -ALIGN (adev->gfx.rlc.save_restore_list_srm_size_bytes,PAGE_SIZE ); - -if (adev->gfx.rlc.rlc_iram_ucode_size_bytes && - adev->gfx.rlc.rlc_dram_ucode_size_bytes) { - info = &adev->firmware.ucode[AMDGPU_UCODE_ID_RLC_IRAM ]; - info->ucode_id =AMDGPU_UCODE_ID_RLC_IRAM ; - info->fw = adev->gfx.rlc_fw; - adev->firmware.fw_size += -ALIGN (adev->gfx.rlc.rlc_iram_ucode_size_bytes,PAGE_SIZE ); - - info = &adev->firmware.ucode[AMDGPU_UCODE_ID_RLC_DRAM ]; - info->ucode_id =AMDGPU_UCODE_ID_RLC_DRAM ; - info->fw = adev->gfx.rlc_fw; - adev->firmware.fw_size += -ALIGN (adev->gfx.rlc.rlc_dram_ucode_size_bytes,PAGE_SIZE ); - } - - } - -if (adev->gfx.rlc.global_tap_delays_ucode_size_bytes) { - info = &adev->firmware.ucode[AMDGPU_UCODE_ID_GLOBAL_TAP_DELAYS ]; - info->ucode_id =AMDGPU_UCODE_ID_GLOBAL_TAP_DELAYS ; - info->fw = adev->gfx.rlc_fw; - adev->firmware.fw_size += -ALIGN (adev->gfx.rlc.global_tap_delays_ucode_size_bytes,PAGE_SIZE ); - } - -if (adev->gfx.rlc.se0_tap_delays_ucode_size_bytes) { - info = &adev->firmware.ucode[AMDGPU_UCODE_ID_SE0_TAP_DELAYS ]; - info->ucode_id =AMDGPU_UCODE_ID_SE0_TAP_DELAYS ; - info->fw = adev->gfx.rlc_fw; - adev->firmware.fw_size += -ALIGN (adev->gfx.rlc.se0_tap_delays_ucode_size_bytes,PAGE_SIZE ); - } - -if (adev->gfx.rlc.se1_tap_delays_ucode_size_bytes) { - info = &adev->firmware.ucode[AMDGPU_UCODE_ID_SE1_TAP_DELAYS ]; - info->ucode_id =AMDGPU_UCODE_ID_SE1_TAP_DELAYS ; - info->fw = adev->gfx.rlc_fw; - adev->firmware.fw_size += -ALIGN (adev->gfx.rlc.se1_tap_delays_ucode_size_bytes,PAGE_SIZE ); - } - -if (adev->gfx.rlc.se2_tap_delays_ucode_size_bytes) { - info = &adev->firmware.ucode[AMDGPU_UCODE_ID_SE2_TAP_DELAYS ]; - info->ucode_id =AMDGPU_UCODE_ID_SE2_TAP_DELAYS ; - info->fw = adev->gfx.rlc_fw; - adev->firmware.fw_size += -ALIGN (adev->gfx.rlc.se2_tap_delays_ucode_size_bytes,PAGE_SIZE ); - } - -if (adev->gfx.rlc.se3_tap_delays_ucode_size_bytes) { - info = &adev->firmware.ucode[AMDGPU_UCODE_ID_SE3_TAP_DELAYS ]; - info->ucode_id =AMDGPU_UCODE_ID_SE3_TAP_DELAYS ; - info->fw = adev->gfx.rlc_fw; - adev->firmware.fw_size += -ALIGN (adev->gfx.rlc.se3_tap_delays_ucode_size_bytes,PAGE_SIZE ); - } - info = &adev->firmware.ucode[AMDGPU_UCODE_ID_CP_MEC1 ]; info->ucode_id =AMDGPU_UCODE_ID_CP_MEC1 ; info->fw = adev->gfx.mec_fw;
--
2.17.1
RE: [PATCH 09/10] drm/amdgpu/gfx10: switch to amdgpu_gfx_rlc_init_microcode
[Public]
Hi Alex,
Sienna cichlid rlc firmware binary needs to be updated to match with the kernel change.
I shall add this comment to commit description.
Regards,
Hawking
From: Deucher, Alexander <[email protected]>
Sent: Saturday, September 24, 2022 05:36
To: Zhang, Hawking <[email protected]>; [email protected]; Gao, Likun <[email protected]>
Subject: Re: [PATCH 09/10] drm/amdgpu/gfx10: switch to amdgpu_gfx_rlc_init_microcode
[Public]
This set seems to break RLC firmware loading on sienna cichlid.
Alex
________________________________
From: Zhang, Hawking <[email protected]<mailto:[email protected]>>
Sent: Thursday, September 15, 2022 1:01 PM
To: [email protected]<mailto:[email protected]> <[email protected]<mailto:[email protected]>>; Gao, Likun <[email protected]<mailto:[email protected]>>; Deucher, Alexander <[email protected]<mailto:[email protected]>>
Cc: Zhang, Hawking <[email protected]<mailto:[email protected]>>
Subject: [PATCH 09/10] drm/amdgpu/gfx10: switch to amdgpu_gfx_rlc_init_microcode
switch to common helper to initialize rlc firmware for gfx10
--- drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 191 +------------------------ 1 file changed, 4 insertions(+), 187 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +4 -187
@@ -3943,56 +3943,6 @@ static void gfx_v10_0_check_fw_write_wait(struct amdgpu_device *adev)DRM_WARN_ONCE ("CP firmware version too old, please update!" ); } - -static void gfx_v10_0_init_rlc_ext_microcode (struct amdgpu_device *adev) -{ -const struct rlc_firmware_header_v2_1 *rlc_hdr; - - rlc_hdr = (const struct rlc_firmware_header_v2_1 *)adev->gfx.rlc_fw->data; - adev->gfx.rlc_srlc_fw_version =le32_to_cpu (rlc_hdr->save_restore_list_cntl_ucode_ver); - adev->gfx.rlc_srlc_feature_version =le32_to_cpu (rlc_hdr->save_restore_list_cntl_feature_ver); - adev->gfx.rlc.save_restore_list_cntl_size_bytes =le32_to_cpu (rlc_hdr->save_restore_list_cntl_size_bytes); - adev->gfx.rlc.save_restore_list_cntl = (u8 *)rlc_hdr +le32_to_cpu (rlc_hdr->save_restore_list_cntl_offset_bytes); - adev->gfx.rlc_srlg_fw_version =le32_to_cpu (rlc_hdr->save_restore_list_gpm_ucode_ver); - adev->gfx.rlc_srlg_feature_version =le32_to_cpu (rlc_hdr->save_restore_list_gpm_feature_ver); - adev->gfx.rlc.save_restore_list_gpm_size_bytes =le32_to_cpu (rlc_hdr->save_restore_list_gpm_size_bytes); - adev->gfx.rlc.save_restore_list_gpm = (u8 *)rlc_hdr +le32_to_cpu (rlc_hdr->save_restore_list_gpm_offset_bytes); - adev->gfx.rlc_srls_fw_version =le32_to_cpu (rlc_hdr->save_restore_list_srm_ucode_ver); - adev->gfx.rlc_srls_feature_version =le32_to_cpu (rlc_hdr->save_restore_list_srm_feature_ver); - adev->gfx.rlc.save_restore_list_srm_size_bytes =le32_to_cpu (rlc_hdr->save_restore_list_srm_size_bytes); - adev->gfx.rlc.save_restore_list_srm = (u8 *)rlc_hdr +le32_to_cpu (rlc_hdr->save_restore_list_srm_offset_bytes); - adev->gfx.rlc.reg_list_format_direct_reg_list_length = -le32_to_cpu (rlc_hdr->reg_list_format_direct_reg_list_length); -} - -static void gfx_v10_0_init_rlc_iram_dram_microcode (struct amdgpu_device *adev) -{ -const struct rlc_firmware_header_v2_2 *rlc_hdr; - - rlc_hdr = (const struct rlc_firmware_header_v2_2 *)adev->gfx.rlc_fw->data; - adev->gfx.rlc.rlc_iram_ucode_size_bytes =le32_to_cpu (rlc_hdr->rlc_iram_ucode_size_bytes); - adev->gfx.rlc.rlc_iram_ucode = (u8 *)rlc_hdr +le32_to_cpu (rlc_hdr->rlc_iram_ucode_offset_bytes); - adev->gfx.rlc.rlc_dram_ucode_size_bytes =le32_to_cpu (rlc_hdr->rlc_dram_ucode_size_bytes); - adev->gfx.rlc.rlc_dram_ucode = (u8 *)rlc_hdr +le32_to_cpu (rlc_hdr->rlc_dram_ucode_offset_bytes); -} - -static void gfx_v10_0_init_tap_delays_microcode (struct amdgpu_device *adev) -{ -const struct rlc_firmware_header_v2_4 *rlc_hdr; - - rlc_hdr = (const struct rlc_firmware_header_v2_4 *)adev->gfx.rlc_fw->data; - adev->gfx.rlc.global_tap_delays_ucode_size_bytes =le32_to_cpu (rlc_hdr->global_tap_delays_ucode_size_bytes); - adev->gfx.rlc.global_tap_delays_ucode = (u8 *)rlc_hdr +le32_to_cpu (rlc_hdr->global_tap_delays_ucode_offset_bytes); - adev->gfx.rlc.se0_tap_delays_ucode_size_bytes =le32_to_cpu (rlc_hdr->se0_tap_delays_ucode_size_bytes); - adev->gfx.rlc.se0_tap_delays_ucode = (u8 *)rlc_hdr +le32_to_cpu (rlc_hdr->se0_tap_delays_ucode_offset_bytes); - adev->gfx.rlc.se1_tap_delays_ucode_size_bytes =le32_to_cpu (rlc_hdr->se1_tap_delays_ucode_size_bytes); - adev->gfx.rlc.se1_tap_delays_ucode = (u8 *)rlc_hdr +le32_to_cpu (rlc_hdr->se1_tap_delays_ucode_offset_bytes); - adev->gfx.rlc.se2_tap_delays_ucode_size_bytes =le32_to_cpu (rlc_hdr->se2_tap_delays_ucode_size_bytes); - adev->gfx.rlc.se2_tap_delays_ucode = (u8 *)rlc_hdr +le32_to_cpu (rlc_hdr->se2_tap_delays_ucode_offset_bytes); - adev->gfx.rlc.se3_tap_delays_ucode_size_bytes =le32_to_cpu (rlc_hdr->se3_tap_delays_ucode_size_bytes); - adev->gfx.rlc.se3_tap_delays_ucode = (u8 *)rlc_hdr +le32_to_cpu (rlc_hdr->se3_tap_delays_ucode_offset_bytes); -} -static bool gfx_v10_0_navi10_gfxoff_should_enable (struct amdgpu_device *adev) {bool ret = false;
@@ -4032,8 +3982,6 @@ static int gfx_v10_0_init_microcode(struct amdgpu_device *adev)const struct common_firmware_header *header =NULL ;const struct gfx_firmware_header_v1_0 *cp_hdr;const struct rlc_firmware_header_v2_0 *rlc_hdr; -unsigned int *tmp =NULL ; -unsigned int i =0 ;uint16_t version_major;uint16_t version_minor;
@@ -4123,59 +4071,14 @@ static int gfx_v10_0_init_microcode(struct amdgpu_device *adev)if (err) goto out; err =amdgpu_ucode_validate (adev->gfx.rlc_fw); +if (err) + goto out; rlc_hdr = (const struct rlc_firmware_header_v2_0 *)adev->gfx.rlc_fw->data; version_major =le16_to_cpu (rlc_hdr->header.header_version_major); version_minor =le16_to_cpu (rlc_hdr->header.header_version_minor); - - adev->gfx.rlc_fw_version =le32_to_cpu (rlc_hdr->header.ucode_version); - adev->gfx.rlc_feature_version =le32_to_cpu (rlc_hdr->ucode_feature_version); - adev->gfx.rlc.save_and_restore_offset = -le32_to_cpu (rlc_hdr->save_and_restore_offset); - adev->gfx.rlc.clear_state_descriptor_offset = -le32_to_cpu (rlc_hdr->clear_state_descriptor_offset); - adev->gfx.rlc.avail_scratch_ram_locations = -le32_to_cpu (rlc_hdr->avail_scratch_ram_locations); - adev->gfx.rlc.reg_restore_list_size = -le32_to_cpu (rlc_hdr->reg_restore_list_size); - adev->gfx.rlc.reg_list_format_start = -le32_to_cpu (rlc_hdr->reg_list_format_start); - adev->gfx.rlc.reg_list_format_separate_start = -le32_to_cpu (rlc_hdr->reg_list_format_separate_start); - adev->gfx.rlc.starting_offsets_start = -le32_to_cpu (rlc_hdr->starting_offsets_start); - adev->gfx.rlc.reg_list_format_size_bytes = -le32_to_cpu (rlc_hdr->reg_list_format_size_bytes); - adev->gfx.rlc.reg_list_size_bytes = -le32_to_cpu (rlc_hdr->reg_list_size_bytes); - adev->gfx.rlc.register_list_format = -kmalloc (adev->gfx.rlc.reg_list_format_size_bytes + - adev->gfx.rlc.reg_list_size_bytes,GFP_KERNEL ); -if (!adev->gfx.rlc.register_list_format) { - err = -ENOMEM ; + err =amdgpu_gfx_rlc_init_microcode (adev, version_major, version_minor); +if (err) goto out; - } - - tmp = (unsigned int *)((uintptr_t )rlc_hdr + -le32_to_cpu (rlc_hdr->reg_list_format_array_offset_bytes)); -for (i =0 ; i < (rlc_hdr->reg_list_format_size_bytes >>2 ); i++) - adev->gfx.rlc.register_list_format[i] =le32_to_cpu (tmp[i]); - - adev->gfx.rlc.register_restore = adev->gfx.rlc.register_list_format + i; - - tmp = (unsigned int *)((uintptr_t )rlc_hdr + -le32_to_cpu (rlc_hdr->reg_list_array_offset_bytes)); -for (i =0 ; i < (rlc_hdr->reg_list_size_bytes >>2 ); i++) - adev->gfx.rlc.register_restore[i] =le32_to_cpu (tmp[i]); - -if (version_major ==2 ) { -if (version_minor >=1 ) -gfx_v10_0_init_rlc_ext_microcode (adev); -if (version_minor >=2 ) -gfx_v10_0_init_rlc_iram_dram_microcode (adev); -if (version_minor ==4 ) { -gfx_v10_0_init_tap_delays_microcode (adev); - } - } }snprintf (fw_name,sizeof (fw_name),"amdgpu/%s_mec%s.bin" , chip_name, wks);
@@ -4228,92 +4131,6 @@ static int gfx_v10_0_init_microcode(struct amdgpu_device *adev) adev->firmware.fw_size +=ALIGN (le32_to_cpu (header->ucode_size_bytes),PAGE_SIZE ); - info = &adev->firmware.ucode[AMDGPU_UCODE_ID_RLC_G ]; - info->ucode_id =AMDGPU_UCODE_ID_RLC_G ; - info->fw = adev->gfx.rlc_fw; -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.save_restore_list_cntl_size_bytes && - adev->gfx.rlc.save_restore_list_gpm_size_bytes && - adev->gfx.rlc.save_restore_list_srm_size_bytes) { - info = &adev->firmware.ucode[AMDGPU_UCODE_ID_RLC_RESTORE_LIST_CNTL ]; - info->ucode_id =AMDGPU_UCODE_ID_RLC_RESTORE_LIST_CNTL ; - info->fw = adev->gfx.rlc_fw; - adev->firmware.fw_size += -ALIGN (adev->gfx.rlc.save_restore_list_cntl_size_bytes,PAGE_SIZE ); - - info = &adev->firmware.ucode[AMDGPU_UCODE_ID_RLC_RESTORE_LIST_GPM_MEM ]; - info->ucode_id =AMDGPU_UCODE_ID_RLC_RESTORE_LIST_GPM_MEM ; - info->fw = adev->gfx.rlc_fw; - adev->firmware.fw_size += -ALIGN (adev->gfx.rlc.save_restore_list_gpm_size_bytes,PAGE_SIZE ); - - info = &adev->firmware.ucode[AMDGPU_UCODE_ID_RLC_RESTORE_LIST_SRM_MEM ]; - info->ucode_id =AMDGPU_UCODE_ID_RLC_RESTORE_LIST_SRM_MEM ; - info->fw = adev->gfx.rlc_fw; - adev->firmware.fw_size += -ALIGN (adev->gfx.rlc.save_restore_list_srm_size_bytes,PAGE_SIZE ); - -if (adev->gfx.rlc.rlc_iram_ucode_size_bytes && - adev->gfx.rlc.rlc_dram_ucode_size_bytes) { - info = &adev->firmware.ucode[AMDGPU_UCODE_ID_RLC_IRAM ]; - info->ucode_id =AMDGPU_UCODE_ID_RLC_IRAM ; - info->fw = adev->gfx.rlc_fw; - adev->firmware.fw_size += -ALIGN (adev->gfx.rlc.rlc_iram_ucode_size_bytes,PAGE_SIZE ); - - info = &adev->firmware.ucode[AMDGPU_UCODE_ID_RLC_DRAM ]; - info->ucode_id =AMDGPU_UCODE_ID_RLC_DRAM ; - info->fw = adev->gfx.rlc_fw; - adev->firmware.fw_size += -ALIGN (adev->gfx.rlc.rlc_dram_ucode_size_bytes,PAGE_SIZE ); - } - - } - -if (adev->gfx.rlc.global_tap_delays_ucode_size_bytes) { - info = &adev->firmware.ucode[AMDGPU_UCODE_ID_GLOBAL_TAP_DELAYS ]; - info->ucode_id =AMDGPU_UCODE_ID_GLOBAL_TAP_DELAYS ; - info->fw = adev->gfx.rlc_fw; - adev->firmware.fw_size += -ALIGN (adev->gfx.rlc.global_tap_delays_ucode_size_bytes,PAGE_SIZE ); - } - -if (adev->gfx.rlc.se0_tap_delays_ucode_size_bytes) { - info = &adev->firmware.ucode[AMDGPU_UCODE_ID_SE0_TAP_DELAYS ]; - info->ucode_id =AMDGPU_UCODE_ID_SE0_TAP_DELAYS ; - info->fw = adev->gfx.rlc_fw; - adev->firmware.fw_size += -ALIGN (adev->gfx.rlc.se0_tap_delays_ucode_size_bytes,PAGE_SIZE ); - } - -if (adev->gfx.rlc.se1_tap_delays_ucode_size_bytes) { - info = &adev->firmware.ucode[AMDGPU_UCODE_ID_SE1_TAP_DELAYS ]; - info->ucode_id =AMDGPU_UCODE_ID_SE1_TAP_DELAYS ; - info->fw = adev->gfx.rlc_fw; - adev->firmware.fw_size += -ALIGN (adev->gfx.rlc.se1_tap_delays_ucode_size_bytes,PAGE_SIZE ); - } - -if (adev->gfx.rlc.se2_tap_delays_ucode_size_bytes) { - info = &adev->firmware.ucode[AMDGPU_UCODE_ID_SE2_TAP_DELAYS ]; - info->ucode_id =AMDGPU_UCODE_ID_SE2_TAP_DELAYS ; - info->fw = adev->gfx.rlc_fw; - adev->firmware.fw_size += -ALIGN (adev->gfx.rlc.se2_tap_delays_ucode_size_bytes,PAGE_SIZE ); - } - -if (adev->gfx.rlc.se3_tap_delays_ucode_size_bytes) { - info = &adev->firmware.ucode[AMDGPU_UCODE_ID_SE3_TAP_DELAYS ]; - info->ucode_id =AMDGPU_UCODE_ID_SE3_TAP_DELAYS ; - info->fw = adev->gfx.rlc_fw; - adev->firmware.fw_size += -ALIGN (adev->gfx.rlc.se3_tap_delays_ucode_size_bytes,PAGE_SIZE ); - } - info = &adev->firmware.ucode[AMDGPU_UCODE_ID_CP_MEC1 ]; info->ucode_id =AMDGPU_UCODE_ID_CP_MEC1 ; info->fw = adev->gfx.mec_fw;
--
2.17.1
Re: RE: [PATCH 09/10] drm/amdgpu/gfx10: switch to amdgpu_gfx_rlc_init_microcode
Quoted 17 lines · Hawking
[Public]
Hi Alex,
Sienna cichlid rlc firmware binary needs to be updated to match with the kernel change.
I shall add this comment to commit description.
Regards,
HawkingFrom: Deucher, Alexander <[email protected]>
Sent: Saturday, September 24, 2022 05:36
To: Zhang, Hawking <[email protected]>; [email protected]; Gao, Likun <[email protected]>
Subject: Re: [PATCH 09/10] drm/amdgpu/gfx10: switch toamdgpu_gfx_rlc_init_microcode
Quoted 3 lines
[Public]
This set seems to break RLC firmware loading on sienna cichlid.
This also broke beige goby. Please fix or revert. Requesting to upgrade firmware is unacceptable.
Signature · 2 lines
Best regards, Dmitry
Deucher, Alexander
maintainerRe: RE: [PATCH 09/10] drm/amdgpu/gfx10: switch to amdgpu_gfx_rlc_init_microcode
[AMD Official Use Only - General]
This should be fixed in a backwards compatible way with this patch:
https://patchwork.freedesktop.org/patch/504869/
Alex
________________________________
From: Dmitry Osipenko <[email protected]>
Sent: Wednesday, September 28, 2022 1:40 PM
To: Zhang, Hawking <[email protected]>; Deucher, Alexander <[email protected]>; [email protected] <[email protected]>; Gao, Likun <[email protected]>
Subject: Re: RE: [PATCH 09/10] drm/amdgpu/gfx10: switch to amdgpu_gfx_rlc_init_microcode
Quoted 17 lines · Hawking
[Public]
Hi Alex,
Sienna cichlid rlc firmware binary needs to be updated to match with the kernel change.
I shall add this comment to commit description.
Regards,
HawkingFrom: Deucher, Alexander <[email protected]>
Sent: Saturday, September 24, 2022 05:36
To: Zhang, Hawking <[email protected]>; [email protected]; Gao, Likun <[email protected]>
Subject: Re: [PATCH 09/10] drm/amdgpu/gfx10: switch toamdgpu_gfx_rlc_init_microcode
Quoted 3 lines
[Public]
This set seems to break RLC firmware loading on sienna cichlid.
This also broke beige goby. Please fix or revert. Requesting to upgrade firmware is unacceptable.
--
Best regards,
Dmitry
Re: [PATCH 09/10] drm/amdgpu/gfx10: switch to amdgpu_gfx_rlc_init_microcode
Quoted 4 lines · Alexander
[AMD Official Use Only - General]
This should be fixed in a backwards compatible way with this patch:
https://patchwork.freedesktop.org/patch/504869/
Good to know that it's already addressed, thank you very much for the quick reply.
Signature · 2 lines
Best regards, Dmitry
Re: [PATCH 09/10] drm/amdgpu/gfx10: switch to amdgpu_gfx_rlc_init_microcode
Quoted 8 lines · Dmitry Osipenko
Quoted 4 lines · Alexander
[AMD Official Use Only - General]
This should be fixed in a backwards compatible way with this patch:
https://patchwork.freedesktop.org/patch/504869/Good to know that it's already addressed, thank you very much for the quick reply.
Unfortunately, that patch doesn't help beige goby. Please fix.
Signature · 2 lines
Best regards, Dmitry
Re: [PATCH 09/10] drm/amdgpu/gfx10: switch to amdgpu_gfx_rlc_init_microcode
Quoted 5 lines · Dmitry Osipenko
Quoted 3 lines · Dmitry Osipenko
Quoted 2 lines · Alexander
[AMD Official Use Only - General]
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
This should be fixed in a backwards compatible way with this patch:
https://patchwork.freedesktop.org/patch/504869/Good to know that it's already addressed, thank you very much for the quick reply.
Unfortunately, that patch doesn't help beige goby. Please fix.
https://patchwork.freedesktop.org/patch/505248/
Alex
Quoted 5 lines
--
Best regards,
Dmitry
Re: [PATCH 09/10] drm/amdgpu/gfx10: switch to amdgpu_gfx_rlc_init_microcode
Quoted 10 lines · Alex Deucher
Quoted 8 lines · Dmitry Osipenko
Quoted 6 lines · Dmitry Osipenko
Quoted 4 lines · Alexander
[AMD Official Use Only - General]
This should be fixed in a backwards compatible way with this patch:
https://patchwork.freedesktop.org/patch/504869/
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
Good to know that it's already addressed, thank you very much for the quick reply.
Unfortunately, that patch doesn't help beige goby. Please fix.
That helped, thank you.
Signature · 2 lines
Best regards, Dmitry
PATCH 10/10 drm/amdgpu/gfx11: switch to amdgpu_gfx_rlc_init_microcode
In reply to Hawking Zhangswitch to common helper to initialize rlc firmware for gfx11
--- drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c | 156 +------------------------ 1 file changed, 4 insertions(+), 152 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +4 -152
@@ -438,54 +438,6 @@ static void gfx_v11_0_free_microcode(struct amdgpu_device *adev)kfree (adev->gfx.rlc.register_list_format); } -static void gfx_v11_0_init_rlc_ext_microcode (struct amdgpu_device *adev) -{ -const struct rlc_firmware_header_v2_1 *rlc_hdr; - - rlc_hdr = (const struct rlc_firmware_header_v2_1 *)adev->gfx.rlc_fw->data; - adev->gfx.rlc_srlc_fw_version =le32_to_cpu (rlc_hdr->save_restore_list_cntl_ucode_ver); - adev->gfx.rlc_srlc_feature_version =le32_to_cpu (rlc_hdr->save_restore_list_cntl_feature_ver); - adev->gfx.rlc.save_restore_list_cntl_size_bytes =le32_to_cpu (rlc_hdr->save_restore_list_cntl_size_bytes); - adev->gfx.rlc.save_restore_list_cntl = (u8 *)rlc_hdr +le32_to_cpu (rlc_hdr->save_restore_list_cntl_offset_bytes); - adev->gfx.rlc_srlg_fw_version =le32_to_cpu (rlc_hdr->save_restore_list_gpm_ucode_ver); - adev->gfx.rlc_srlg_feature_version =le32_to_cpu (rlc_hdr->save_restore_list_gpm_feature_ver); - adev->gfx.rlc.save_restore_list_gpm_size_bytes =le32_to_cpu (rlc_hdr->save_restore_list_gpm_size_bytes); - adev->gfx.rlc.save_restore_list_gpm = (u8 *)rlc_hdr +le32_to_cpu (rlc_hdr->save_restore_list_gpm_offset_bytes); - adev->gfx.rlc_srls_fw_version =le32_to_cpu (rlc_hdr->save_restore_list_srm_ucode_ver); - adev->gfx.rlc_srls_feature_version =le32_to_cpu (rlc_hdr->save_restore_list_srm_feature_ver); - adev->gfx.rlc.save_restore_list_srm_size_bytes =le32_to_cpu (rlc_hdr->save_restore_list_srm_size_bytes); - adev->gfx.rlc.save_restore_list_srm = (u8 *)rlc_hdr +le32_to_cpu (rlc_hdr->save_restore_list_srm_offset_bytes); - adev->gfx.rlc.reg_list_format_direct_reg_list_length = -le32_to_cpu (rlc_hdr->reg_list_format_direct_reg_list_length); -} - -static void gfx_v11_0_init_rlc_iram_dram_microcode (struct amdgpu_device *adev) -{ -const struct rlc_firmware_header_v2_2 *rlc_hdr; - - rlc_hdr = (const struct rlc_firmware_header_v2_2 *)adev->gfx.rlc_fw->data; - adev->gfx.rlc.rlc_iram_ucode_size_bytes =le32_to_cpu (rlc_hdr->rlc_iram_ucode_size_bytes); - adev->gfx.rlc.rlc_iram_ucode = (u8 *)rlc_hdr +le32_to_cpu (rlc_hdr->rlc_iram_ucode_offset_bytes); - adev->gfx.rlc.rlc_dram_ucode_size_bytes =le32_to_cpu (rlc_hdr->rlc_dram_ucode_size_bytes); - adev->gfx.rlc.rlc_dram_ucode = (u8 *)rlc_hdr +le32_to_cpu (rlc_hdr->rlc_dram_ucode_offset_bytes); -} - -static void gfx_v11_0_init_rlcp_rlcv_microcode (struct amdgpu_device *adev) -{ -const struct rlc_firmware_header_v2_3 *rlc_hdr; - - rlc_hdr = (const struct rlc_firmware_header_v2_3 *)adev->gfx.rlc_fw->data; - adev->gfx.rlcp_ucode_version =le32_to_cpu (rlc_hdr->rlcp_ucode_version); - adev->gfx.rlcp_ucode_feature_version =le32_to_cpu (rlc_hdr->rlcp_ucode_feature_version); - adev->gfx.rlc.rlcp_ucode_size_bytes =le32_to_cpu (rlc_hdr->rlcp_ucode_size_bytes); - adev->gfx.rlc.rlcp_ucode = (u8 *)rlc_hdr +le32_to_cpu (rlc_hdr->rlcp_ucode_offset_bytes); - - adev->gfx.rlcv_ucode_version =le32_to_cpu (rlc_hdr->rlcv_ucode_version); - adev->gfx.rlcv_ucode_feature_version =le32_to_cpu (rlc_hdr->rlcv_ucode_feature_version); - adev->gfx.rlc.rlcv_ucode_size_bytes =le32_to_cpu (rlc_hdr->rlcv_ucode_size_bytes); - adev->gfx.rlc.rlcv_ucode = (u8 *)rlc_hdr +le32_to_cpu (rlc_hdr->rlcv_ucode_offset_bytes); -} -static int gfx_v11_0_init_microcode (struct amdgpu_device *adev) {char fw_name[40 ];
@@ -496,8 +448,6 @@ static int gfx_v11_0_init_microcode(struct amdgpu_device *adev)const struct gfx_firmware_header_v1_0 *cp_hdr;const struct gfx_firmware_header_v2_0 *cp_hdr_v2_0;const struct rlc_firmware_header_v2_0 *rlc_hdr; -unsigned int *tmp =NULL ; -unsigned int i =0 ;uint16_t version_major;uint16_t version_minor;
@@ -552,58 +502,14 @@ static int gfx_v11_0_init_microcode(struct amdgpu_device *adev)if (err) goto out; err =amdgpu_ucode_validate (adev->gfx.rlc_fw); +if (err) + goto out; rlc_hdr = (const struct rlc_firmware_header_v2_0 *)adev->gfx.rlc_fw->data; version_major =le16_to_cpu (rlc_hdr->header.header_version_major); version_minor =le16_to_cpu (rlc_hdr->header.header_version_minor); - - adev->gfx.rlc_fw_version =le32_to_cpu (rlc_hdr->header.ucode_version); - adev->gfx.rlc_feature_version =le32_to_cpu (rlc_hdr->ucode_feature_version); - adev->gfx.rlc.save_and_restore_offset = -le32_to_cpu (rlc_hdr->save_and_restore_offset); - adev->gfx.rlc.clear_state_descriptor_offset = -le32_to_cpu (rlc_hdr->clear_state_descriptor_offset); - adev->gfx.rlc.avail_scratch_ram_locations = -le32_to_cpu (rlc_hdr->avail_scratch_ram_locations); - adev->gfx.rlc.reg_restore_list_size = -le32_to_cpu (rlc_hdr->reg_restore_list_size); - adev->gfx.rlc.reg_list_format_start = -le32_to_cpu (rlc_hdr->reg_list_format_start); - adev->gfx.rlc.reg_list_format_separate_start = -le32_to_cpu (rlc_hdr->reg_list_format_separate_start); - adev->gfx.rlc.starting_offsets_start = -le32_to_cpu (rlc_hdr->starting_offsets_start); - adev->gfx.rlc.reg_list_format_size_bytes = -le32_to_cpu (rlc_hdr->reg_list_format_size_bytes); - adev->gfx.rlc.reg_list_size_bytes = -le32_to_cpu (rlc_hdr->reg_list_size_bytes); - adev->gfx.rlc.register_list_format = -kmalloc (adev->gfx.rlc.reg_list_format_size_bytes + - adev->gfx.rlc.reg_list_size_bytes,GFP_KERNEL ); -if (!adev->gfx.rlc.register_list_format) { - err = -ENOMEM ; + err =amdgpu_gfx_rlc_init_microcode (adev, version_major, version_minor); +if (err) goto out; - } - - tmp = (unsigned int *)((uintptr_t )rlc_hdr + -le32_to_cpu (rlc_hdr->reg_list_format_array_offset_bytes)); -for (i =0 ; i < (rlc_hdr->reg_list_format_size_bytes >>2 ); i++) - adev->gfx.rlc.register_list_format[i] =le32_to_cpu (tmp[i]); - - adev->gfx.rlc.register_restore = adev->gfx.rlc.register_list_format + i; - - tmp = (unsigned int *)((uintptr_t )rlc_hdr + -le32_to_cpu (rlc_hdr->reg_list_array_offset_bytes)); -for (i =0 ; i < (rlc_hdr->reg_list_size_bytes >>2 ); i++) - adev->gfx.rlc.register_restore[i] =le32_to_cpu (tmp[i]); - -if (version_major ==2 ) { -if (version_minor >=1 ) -gfx_v11_0_init_rlc_ext_microcode (adev); -if (version_minor >=2 ) -gfx_v11_0_init_rlc_iram_dram_microcode (adev); -if (version_minor ==3 ) -gfx_v11_0_init_rlcp_rlcv_microcode (adev); - } }snprintf (fw_name,sizeof (fw_name),"amdgpu/%s_mec.bin" , ucode_prefix);
@@ -738,60 +644,6 @@ static int gfx_v11_0_init_microcode(struct amdgpu_device *adev) adev->firmware.fw_size +=ALIGN (le32_to_cpu (cp_hdr->jt_size) *4 ,PAGE_SIZE ); } - - info = &adev->firmware.ucode[AMDGPU_UCODE_ID_RLC_G ]; - info->ucode_id =AMDGPU_UCODE_ID_RLC_G ; - info->fw = adev->gfx.rlc_fw; -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.save_restore_list_gpm_size_bytes && - adev->gfx.rlc.save_restore_list_srm_size_bytes) { - info = &adev->firmware.ucode[AMDGPU_UCODE_ID_RLC_RESTORE_LIST_GPM_MEM ]; - info->ucode_id =AMDGPU_UCODE_ID_RLC_RESTORE_LIST_GPM_MEM ; - info->fw = adev->gfx.rlc_fw; - adev->firmware.fw_size += -ALIGN (adev->gfx.rlc.save_restore_list_gpm_size_bytes,PAGE_SIZE ); - - info = &adev->firmware.ucode[AMDGPU_UCODE_ID_RLC_RESTORE_LIST_SRM_MEM ]; - info->ucode_id =AMDGPU_UCODE_ID_RLC_RESTORE_LIST_SRM_MEM ; - info->fw = adev->gfx.rlc_fw; - adev->firmware.fw_size += -ALIGN (adev->gfx.rlc.save_restore_list_srm_size_bytes,PAGE_SIZE ); - } - -if (adev->gfx.rlc.rlc_iram_ucode_size_bytes && - adev->gfx.rlc.rlc_dram_ucode_size_bytes) { - info = &adev->firmware.ucode[AMDGPU_UCODE_ID_RLC_IRAM ]; - info->ucode_id =AMDGPU_UCODE_ID_RLC_IRAM ; - info->fw = adev->gfx.rlc_fw; - adev->firmware.fw_size += -ALIGN (adev->gfx.rlc.rlc_iram_ucode_size_bytes,PAGE_SIZE ); - - info = &adev->firmware.ucode[AMDGPU_UCODE_ID_RLC_DRAM ]; - info->ucode_id =AMDGPU_UCODE_ID_RLC_DRAM ; - info->fw = adev->gfx.rlc_fw; - adev->firmware.fw_size += -ALIGN (adev->gfx.rlc.rlc_dram_ucode_size_bytes,PAGE_SIZE ); - } - -if (adev->gfx.rlc.rlcp_ucode_size_bytes) { - info = &adev->firmware.ucode[AMDGPU_UCODE_ID_RLC_P ]; - info->ucode_id =AMDGPU_UCODE_ID_RLC_P ; - info->fw = adev->gfx.rlc_fw; - adev->firmware.fw_size += -ALIGN (adev->gfx.rlc.rlcp_ucode_size_bytes,PAGE_SIZE ); - } - -if (adev->gfx.rlc.rlcv_ucode_size_bytes) { - info = &adev->firmware.ucode[AMDGPU_UCODE_ID_RLC_V ]; - info->ucode_id =AMDGPU_UCODE_ID_RLC_V ; - info->fw = adev->gfx.rlc_fw; - adev->firmware.fw_size += -ALIGN (adev->gfx.rlc.rlcv_ucode_size_bytes,PAGE_SIZE ); - } } out:
Signature · 1 line
2.17.1
Nice cleanup, feel free to add an Acked-by: Christian König <[email protected]> to the whole series.
Regards,
Christian.
Am 15.09.22 um 19:01 schrieb Hawking Zhang:
Quoted 26 lines
Replace IP specific implementation with common rlc helper for rlc firmware initialization.
This also helps reduce duplicated code when introduce new ip block support.
Hawking Zhang (10):
drm/amdgpu: add helper to init rlc fw in headerv2_0drm/amdgpu: add helper to init rlc fw in headerv2_1drm/amdgpu: add helper to init rlc fw in headerv2_2drm/amdgpu: add helper to init rlc fw in headerv2_3drm/amdgpu: add helper to init rlc fw in headerv2_4drm/amdgpu: add helper to init rlc firmware drm/amdgpu/gfx8: switch toamdgpu_gfx_rlc_init_microcodedrm/amdgpu/gfx9: switch toamdgpu_gfx_rlc_init_microcodedrm/amdgpu/gfx10: switch toamdgpu_gfx_rlc_init_microcodedrm/amdgpu/gfx11: switch toamdgpu_gfx_rlc_init_microcodedrivers/gpu/drm/amd/amdgpu/amdgpu_rlc.c | 264 ++++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_rlc.h | 4 +- drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 191 +---------------- drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c | 156 +------------- drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c | 60 +----- drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 106 +--------- 6 files changed, 289 insertions(+), 492 deletions(-)