drm/amdgpu: update rlc autoload function
Subsystems (2)
Alex Deucher
maintainerPATCH 1/3 drm/amdgpu: update rlc autoload function
From: Likun Gao <[email protected]>
Update rlc autoload function for gfx v12.1.0 to support muti-XCC firmware autoload.
Signed-off-by Likun Gao <[email protected]>
Reviewed-by Hawking Zhang <[email protected]>
Signed-off-by Alex Deucher <[email protected]>
--- drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c | 48 ++++++++++++++++++++++---- 1 file changed, 41 insertions(+), 7 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c +41 -7
@@ -768,6 +768,7 @@ static struct {unsigned int offset;unsigned int size;unsigned int size_x16; +unsigned int num_inst; } rlc_autoload_info[SOC24_FIRMWARE_ID_MAX ];#define RLC_TOC_OFFSET_DWUNIT 8
@@ -775,6 +776,11 @@ static struct {#define RLC_TOC_UMF_SIZE_inM 23ULL#define RLC_TOC_FORMAT_API 165ULL +#define RLC_NUM_INS_CODE0 1 +#define RLC_NUM_INS_CODE1 8 +#define RLC_NUM_INS_CODE2 2 +#define RLC_NUM_INS_CODE3 16 +static void gfx_v12_1_parse_rlc_toc (struct amdgpu_device *adev,void *rlc_toc) {RLC_TABLE_OF_CONTENT_V2 *ucode = rlc_toc;
@@ -786,6 +792,28 @@ static void gfx_v12_1_parse_rlc_toc(struct amdgpu_device *adev, void *rlc_toc) rlc_autoload_info[ucode->id].size = ucode->size_x16 ? ucode->size *RLC_SIZE_MULTIPLE *4 : ucode->size *4 ; +switch (ucode->vfflr_image_code) { +case 0 : + rlc_autoload_info[ucode->id].num_inst = +RLC_NUM_INS_CODE0 ; +break ; +case 1 : + rlc_autoload_info[ucode->id].num_inst = +RLC_NUM_INS_CODE1 ; +break ; +case 2 : + rlc_autoload_info[ucode->id].num_inst = +RLC_NUM_INS_CODE2 ; +break ; +case 3 : + rlc_autoload_info[ucode->id].num_inst = +RLC_NUM_INS_CODE3 ; +break ; +default : +dev_err (adev->dev, +"Invalid Instance number detected\n" ); +break ; + } ucode++; } }
@@ -837,25 +865,31 @@ static void gfx_v12_1_rlc_backdoor_autoload_copy_ucode(struct amdgpu_device *ade uint32_t fw_size) {uint32_t toc_offset; -uint32_t toc_fw_size; +uint32_t toc_fw_size, toc_fw_inst_size;char *ptr = adev->gfx.rlc.rlc_autoload_ptr; +int i, num_inst;if (id <=SOC24_FIRMWARE_ID_INVALID || id >=SOC24_FIRMWARE_ID_MAX )return ; toc_offset = rlc_autoload_info[id].offset; toc_fw_size = rlc_autoload_info[id].size; + num_inst = rlc_autoload_info[id].num_inst; + toc_fw_inst_size = toc_fw_size / num_inst;if (fw_size ==0 ) - fw_size = toc_fw_size; + fw_size = toc_fw_inst_size; -if (fw_size > toc_fw_size) - fw_size = toc_fw_size; +if (fw_size > toc_fw_inst_size) + fw_size = toc_fw_inst_size; -memcpy (ptr + toc_offset, fw_data, fw_size); +for (i =0 ; i < num_inst; i++) { +memcpy (ptr + toc_offset + i * toc_fw_inst_size, fw_data, fw_size); -if (fw_size < toc_fw_size) -memset (ptr + toc_offset + fw_size,0 , toc_fw_size - fw_size); +if (fw_size < toc_fw_inst_size) +memset (ptr + toc_offset + fw_size + i * toc_fw_inst_size, +0 , toc_fw_inst_size - fw_size); + } } static void
Signature · 1 line
2.51.1
Alex Deucher
maintainerPATCH 2/3 drm/amdgpu: only set XCC 0 related reg for rlc autoload
From: Likun Gao <[email protected]>
For RLC autoload, only set XCC id 0 related register to trigger rlc autoload, no need to trigger muti-times for muti-xcc.
Signed-off-by Likun Gao <[email protected]>
Reviewed-by Hawking Zhang <[email protected]>
Signed-off-by Alex Deucher <[email protected]>
--- drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c | 78 ++++++++++---------------- 1 file changed, 31 insertions(+), 47 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c +31 -47
@@ -1043,7 +1043,6 @@ static int gfx_v12_1_rlc_backdoor_autoload_enable(struct amdgpu_device *adev)uint32_t rlc_g_offset, rlc_g_size;uint64_t gpu_addr;uint32_t data; -int i, num_xcc =NUM_XCC (adev->gfx.xcc_mask);/* RLC autoload sequence 2: copy ucode */ gfx_v12_1_rlc_backdoor_autoload_copy_sdma_ucode (adev);
@@ -1055,35 +1054,33 @@ static int gfx_v12_1_rlc_backdoor_autoload_enable(struct amdgpu_device *adev) rlc_g_size = rlc_autoload_info[SOC24_FIRMWARE_ID_RLC_G_UCODE ].size; gpu_addr = adev->gfx.rlc.rlc_autoload_gpu_addr + rlc_g_offset - adev->gmc.vram_start; -for (i =0 ; i < num_xcc; i++) { -WREG32_SOC15 (GC ,GET_INST (GC , i), - regGFX_IMU_RLC_BOOTLOADER_ADDR_HI,upper_32_bits (gpu_addr)); -WREG32_SOC15 (GC ,GET_INST (GC , i), - regGFX_IMU_RLC_BOOTLOADER_ADDR_LO,lower_32_bits (gpu_addr)); - -WREG32_SOC15 (GC ,GET_INST (GC , i), - regGFX_IMU_RLC_BOOTLOADER_SIZE, rlc_g_size); - -if (adev->gfx.imu.funcs && (amdgpu_dpm >0 )) { -/* RLC autoload sequence 3: load IMU fw */ -if (adev->gfx.imu.funcs->load_microcode) - adev->gfx.imu.funcs->load_microcode (adev); -/* RLC autoload sequence 4 init IMU fw */ -if (adev->gfx.imu.funcs->setup_imu) - adev->gfx.imu.funcs->setup_imu (adev); -if (adev->gfx.imu.funcs->start_imu) - adev->gfx.imu.funcs->start_imu (adev); - -/* RLC autoload sequence 5 disable gpa mode */ -gfx_v12_1_xcc_disable_gpa_mode (adev, i); - }else { -/* unhalt rlc to start autoload without imu */ - data =RREG32_SOC15 (GC ,GET_INST (GC , i), regRLC_GPM_THREAD_ENABLE); - data =REG_SET_FIELD (data,RLC_GPM_THREAD_ENABLE ,THREAD0_ENABLE ,1 ); - data =REG_SET_FIELD (data,RLC_GPM_THREAD_ENABLE ,THREAD1_ENABLE ,1 ); -WREG32_SOC15 (GC ,GET_INST (GC , i), regRLC_GPM_THREAD_ENABLE, data); -WREG32_SOC15 (GC ,GET_INST (GC , i), regRLC_CNTL,RLC_CNTL__RLC_ENABLE_F32_MASK ); - } +WREG32_SOC15 (GC ,GET_INST (GC ,0 ), + regGFX_IMU_RLC_BOOTLOADER_ADDR_HI,upper_32_bits (gpu_addr)); +WREG32_SOC15 (GC ,GET_INST (GC ,0 ), + regGFX_IMU_RLC_BOOTLOADER_ADDR_LO,lower_32_bits (gpu_addr)); + +WREG32_SOC15 (GC ,GET_INST (GC ,0 ), + regGFX_IMU_RLC_BOOTLOADER_SIZE, rlc_g_size); + +if (adev->gfx.imu.funcs && (amdgpu_dpm >0 )) { +/* RLC autoload sequence 3: load IMU fw */ +if (adev->gfx.imu.funcs->load_microcode) + adev->gfx.imu.funcs->load_microcode (adev); +/* RLC autoload sequence 4 init IMU fw */ +if (adev->gfx.imu.funcs->setup_imu) + adev->gfx.imu.funcs->setup_imu (adev); +if (adev->gfx.imu.funcs->start_imu) + adev->gfx.imu.funcs->start_imu (adev); + +/* RLC autoload sequence 5 disable gpa mode */ +gfx_v12_1_xcc_disable_gpa_mode (adev,0 ); + }else { +/* unhalt rlc to start autoload without imu */ + data =RREG32_SOC15 (GC ,GET_INST (GC ,0 ), regRLC_GPM_THREAD_ENABLE); + data =REG_SET_FIELD (data,RLC_GPM_THREAD_ENABLE ,THREAD0_ENABLE ,1 ); + data =REG_SET_FIELD (data,RLC_GPM_THREAD_ENABLE ,THREAD1_ENABLE ,1 ); +WREG32_SOC15 (GC ,GET_INST (GC ,0 ), regRLC_GPM_THREAD_ENABLE, data); +WREG32_SOC15 (GC ,GET_INST (GC ,0 ), regRLC_CNTL,RLC_CNTL__RLC_ENABLE_F32_MASK ); }return 0 ;
@@ -1783,12 +1780,11 @@ static void gfx_v12_1_xcc_set_mec_ucode_start_addr(struct amdgpu_device *adev,mutex_unlock (&adev->srbm_mutex); } -static int gfx_v12_1_xcc_wait_for_rlc_autoload_complete (struct amdgpu_device *adev, -int xcc_id) +static int gfx_v12_1_wait_for_rlc_autoload_complete (struct amdgpu_device *adev) {uint32_t cp_status;uint32_t bootload_status; -int i; +int i, xcc_id;for (i =0 ; i < adev->usec_timeout; i++) { cp_status =RREG32_SOC15 (GC ,GET_INST (GC ,0 ), regCP_STAT);
@@ -1811,20 +1807,8 @@ static int gfx_v12_1_xcc_wait_for_rlc_autoload_complete(struct amdgpu_device *ad }if (adev->firmware.load_type ==AMDGPU_FW_LOAD_RLC_BACKDOOR_AUTO ) { -gfx_v12_1_xcc_set_mec_ucode_start_addr (adev, xcc_id); - } - -return 0 ; -} - -static int gfx_v12_1_wait_for_rlc_autoload_complete (struct amdgpu_device *adev) -{ -int xcc_id, r; - -for (xcc_id =0 ; xcc_id <NUM_XCC (adev->gfx.xcc_mask); xcc_id++) { - r =gfx_v12_1_xcc_wait_for_rlc_autoload_complete (adev, xcc_id); -if (r) -return r; +for (xcc_id =0 ; xcc_id <NUM_XCC (adev->gfx.xcc_mask); xcc_id++) +gfx_v12_1_xcc_set_mec_ucode_start_addr (adev, xcc_id); }return 0 ;
Signature · 1 line
2.51.1
Alex Deucher
maintainerPATCH 3/3 drm/amdgpu: skip SDMA autoload copy if not initialized
In reply to Alex DeucherFrom: Likun Gao <[email protected]>
Skip SDMA firmware copy for rlc autoload if SDMA not enabled.
Signed-off-by Likun Gao <[email protected]>
Reviewed-by Hawking Zhang <[email protected]>
Signed-off-by Alex Deucher <[email protected]>
--- drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c +9 -7
@@ -994,14 +994,16 @@ gfx_v12_1_rlc_backdoor_autoload_copy_sdma_ucode(struct amdgpu_device *adev)uint32_t fw_size;const struct sdma_firmware_header_v3_0 *sdma_hdr; - sdma_hdr = (const struct sdma_firmware_header_v3_0 *) - adev->sdma.instance[0 ].fw->data; - fw_data = (const __le32 *) (adev->sdma.instance[0 ].fw->data + -le32_to_cpu (sdma_hdr->ucode_offset_bytes)); - fw_size =le32_to_cpu (sdma_hdr->ucode_size_bytes); +if (adev->sdma.instance[0 ].fw) { + sdma_hdr = (const struct sdma_firmware_header_v3_0 *) + adev->sdma.instance[0 ].fw->data; + fw_data = (const __le32 *) (adev->sdma.instance[0 ].fw->data + +le32_to_cpu (sdma_hdr->ucode_offset_bytes)); + fw_size =le32_to_cpu (sdma_hdr->ucode_size_bytes); -gfx_v12_1_rlc_backdoor_autoload_copy_ucode (adev,SOC24_FIRMWARE_ID_SDMA_UCODE_TH0 , - fw_data, fw_size); +gfx_v12_1_rlc_backdoor_autoload_copy_ucode (adev,SOC24_FIRMWARE_ID_SDMA_UCODE_TH0 , + fw_data, fw_size); + } } static void
Signature · 1 line
2.51.1