drm/amdgpu/vcn3.0: handle harvesting in firmware setup
Subsystems (2)
Alex Deucher
maintainerPATCH 1/4 drm/amdgpu/vcn3.0: handle harvesting in firmware setup
Only enable firmware for the instance that is enabled.
v2: use AMDGPU_UCODE_ID_VCN + i
--- drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c +8 -8
@@ -123,6 +123,7 @@ static int vcn_v3_0_sw_init(void *handle) {struct amdgpu_ring *ring;int i, j, r; +unsigned int idx;int vcn_doorbell_index =0 ;struct amdgpu_device *adev = (struct amdgpu_device *)handle;
@@ -133,14 +134,13 @@ static int vcn_v3_0_sw_init(void *handle)if (adev->firmware.load_type ==AMDGPU_FW_LOAD_PSP ) {const struct common_firmware_header *hdr; hdr = (const struct common_firmware_header *)adev->vcn.fw->data; - adev->firmware.ucode[AMDGPU_UCODE_ID_VCN ].ucode_id =AMDGPU_UCODE_ID_VCN ; - adev->firmware.ucode[AMDGPU_UCODE_ID_VCN ].fw = adev->vcn.fw; - adev->firmware.fw_size += -ALIGN (le32_to_cpu (hdr->ucode_size_bytes),PAGE_SIZE ); - -if (adev->vcn.num_vcn_inst ==VCN_INSTANCES_SIENNA_CICHLID ) { - adev->firmware.ucode[AMDGPU_UCODE_ID_VCN1 ].ucode_id =AMDGPU_UCODE_ID_VCN1 ; - adev->firmware.ucode[AMDGPU_UCODE_ID_VCN1 ].fw = adev->vcn.fw; + +for (i =0 ; i < adev->vcn.num_vcn_inst; i++) { +if (adev->vcn.harvest_config & (1 << i)) +continue ; + idx =AMDGPU_UCODE_ID_VCN + i; + adev->firmware.ucode[idx].ucode_id = idx; + adev->firmware.ucode[idx].fw = adev->vcn.fw; adev->firmware.fw_size +=ALIGN (le32_to_cpu (hdr->ucode_size_bytes),PAGE_SIZE ); }
Signature · 1 line
2.31.1
Alex Deucher
maintainerPATCH 2/4 drm/amdgpu: Consolidate VCN firmware setup code
Roughly the same code was present in all VCN versions. Consolidate it into a single function.
v2: use AMDGPU_UCODE_ID_VCN + i, check if num_inst >= 2
--- drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c | 27 +++++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.h | 2 ++ drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c | 10 +-------- drivers/gpu/drm/amd/amdgpu/vcn_v2_0.c | 10 +-------- drivers/gpu/drm/amd/amdgpu/vcn_v2_5.c | 17 +--------------- drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c | 17 +--------------- 6 files changed, 33 insertions(+), 50 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c +27 -0
@@ -949,3 +949,30 @@ enum amdgpu_ring_priority_level amdgpu_vcn_get_enc_ring_prio(int ring)return AMDGPU_RING_PRIO_0 ; } } + +void amdgpu_vcn_setup_ucode (struct amdgpu_device *adev) +{ +int i; +unsigned int idx; + +if (adev->firmware.load_type ==AMDGPU_FW_LOAD_PSP ) { +const struct common_firmware_header *hdr; + hdr = (const struct common_firmware_header *)adev->vcn.fw->data; + +for (i =0 ; i < adev->vcn.num_vcn_inst; i++) { +if (adev->vcn.harvest_config & (1 << i)) +continue ; +/* currently only support 2 FW instances */ +if (i >=2 ) { +dev_info (adev->dev,"More then 2 VCN FW instances!\n" ); +break ; + } + idx =AMDGPU_UCODE_ID_VCN + i; + adev->firmware.ucode[idx].ucode_id = idx; + adev->firmware.ucode[idx].fw = adev->vcn.fw; + adev->firmware.fw_size += +ALIGN (le32_to_cpu (hdr->ucode_size_bytes),PAGE_SIZE ); + } +dev_info (adev->dev,"Will use PSP to load VCN firmware\n" ); + } +}
drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.h +2 -0
@@ -310,4 +310,6 @@ int amdgpu_vcn_enc_ring_test_ib(struct amdgpu_ring *ring, long timeout);enum amdgpu_ring_priority_level amdgpu_vcn_get_enc_ring_prio (int ring); +void amdgpu_vcn_setup_ucode (struct amdgpu_device *adev); +#endif
drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c +1 -9
@@ -111,15 +111,7 @@ static int vcn_v1_0_sw_init(void *handle)/* Override the work func */ adev->vcn.idle_work.work.func = vcn_v1_0_idle_work_handler; -if (adev->firmware.load_type ==AMDGPU_FW_LOAD_PSP ) { -const struct common_firmware_header *hdr; - hdr = (const struct common_firmware_header *)adev->vcn.fw->data; - adev->firmware.ucode[AMDGPU_UCODE_ID_VCN ].ucode_id =AMDGPU_UCODE_ID_VCN ; - adev->firmware.ucode[AMDGPU_UCODE_ID_VCN ].fw = adev->vcn.fw; - adev->firmware.fw_size += -ALIGN (le32_to_cpu (hdr->ucode_size_bytes),PAGE_SIZE ); -dev_info (adev->dev,"Will use PSP to load VCN firmware\n" ); - } +amdgpu_vcn_setup_ucode (adev); r =amdgpu_vcn_resume (adev);if (r)
drivers/gpu/drm/amd/amdgpu/vcn_v2_0.c +1 -9
@@ -115,15 +115,7 @@ static int vcn_v2_0_sw_init(void *handle)if (r)return r; -if (adev->firmware.load_type ==AMDGPU_FW_LOAD_PSP ) { -const struct common_firmware_header *hdr; - hdr = (const struct common_firmware_header *)adev->vcn.fw->data; - adev->firmware.ucode[AMDGPU_UCODE_ID_VCN ].ucode_id =AMDGPU_UCODE_ID_VCN ; - adev->firmware.ucode[AMDGPU_UCODE_ID_VCN ].fw = adev->vcn.fw; - adev->firmware.fw_size += -ALIGN (le32_to_cpu (hdr->ucode_size_bytes),PAGE_SIZE ); -dev_info (adev->dev,"Will use PSP to load VCN firmware\n" ); - } +amdgpu_vcn_setup_ucode (adev); r =amdgpu_vcn_resume (adev);if (r)
drivers/gpu/drm/amd/amdgpu/vcn_v2_5.c +1 -16
@@ -139,22 +139,7 @@ static int vcn_v2_5_sw_init(void *handle)if (r)return r; -if (adev->firmware.load_type ==AMDGPU_FW_LOAD_PSP ) { -const struct common_firmware_header *hdr; - hdr = (const struct common_firmware_header *)adev->vcn.fw->data; - adev->firmware.ucode[AMDGPU_UCODE_ID_VCN ].ucode_id =AMDGPU_UCODE_ID_VCN ; - adev->firmware.ucode[AMDGPU_UCODE_ID_VCN ].fw = adev->vcn.fw; - adev->firmware.fw_size += -ALIGN (le32_to_cpu (hdr->ucode_size_bytes),PAGE_SIZE ); - -if (adev->vcn.num_vcn_inst ==VCN25_MAX_HW_INSTANCES_ARCTURUS ) { - adev->firmware.ucode[AMDGPU_UCODE_ID_VCN1 ].ucode_id =AMDGPU_UCODE_ID_VCN1 ; - adev->firmware.ucode[AMDGPU_UCODE_ID_VCN1 ].fw = adev->vcn.fw; - adev->firmware.fw_size += -ALIGN (le32_to_cpu (hdr->ucode_size_bytes),PAGE_SIZE ); - } -dev_info (adev->dev,"Will use PSP to load VCN firmware\n" ); - } +amdgpu_vcn_setup_ucode (adev); r =amdgpu_vcn_resume (adev);if (r)
drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c +1 -16
@@ -123,7 +123,6 @@ static int vcn_v3_0_sw_init(void *handle) {struct amdgpu_ring *ring;int i, j, r; -unsigned int idx;int vcn_doorbell_index =0 ;struct amdgpu_device *adev = (struct amdgpu_device *)handle;
@@ -131,21 +130,7 @@ static int vcn_v3_0_sw_init(void *handle)if (r)return r; -if (adev->firmware.load_type ==AMDGPU_FW_LOAD_PSP ) { -const struct common_firmware_header *hdr; - hdr = (const struct common_firmware_header *)adev->vcn.fw->data; - -for (i =0 ; i < adev->vcn.num_vcn_inst; i++) { -if (adev->vcn.harvest_config & (1 << i)) -continue ; - idx =AMDGPU_UCODE_ID_VCN + i; - adev->firmware.ucode[idx].ucode_id = idx; - adev->firmware.ucode[idx].fw = adev->vcn.fw; - adev->firmware.fw_size += -ALIGN (le32_to_cpu (hdr->ucode_size_bytes),PAGE_SIZE ); - } -dev_info (adev->dev,"Will use PSP to load VCN firmware\n" ); - } +amdgpu_vcn_setup_ucode (adev); r =amdgpu_vcn_resume (adev);if (r)
Signature · 1 line
2.31.1
Alex Deucher
maintainerPATCH 3/4 drm/amdgpu/vcn2.0: remove intermediate variable
In reply to Alex DeucherNo need to use the tmp variable, just use the constant directly.
--- drivers/gpu/drm/amd/amdgpu/vcn_v2_0.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/vcn_v2_0.c +2 -3
@@ -1876,15 +1876,14 @@ static int vcn_v2_0_start_sriov(struct amdgpu_device *adev)/* mc resume*/ if (adev->firmware.load_type ==AMDGPU_FW_LOAD_PSP ) { - tmp =AMDGPU_UCODE_ID_VCN ;MMSCH_V2_0_INSERT_DIRECT_WT (SOC15_REG_OFFSET (UVD , i, mmUVD_LMI_VCPU_CACHE_64BIT_BAR_LOW), - adev->firmware.ucode[tmp].tmr_mc_addr_lo); + adev->firmware.ucode[AMDGPU_UCODE_ID_VCN ].tmr_mc_addr_lo);MMSCH_V2_0_INSERT_DIRECT_WT (SOC15_REG_OFFSET (UVD , i, mmUVD_LMI_VCPU_CACHE_64BIT_BAR_HIGH), - adev->firmware.ucode[tmp].tmr_mc_addr_hi); + adev->firmware.ucode[AMDGPU_UCODE_ID_VCN ].tmr_mc_addr_hi); offset =0 ; }else { MMSCH_V2_0_INSERT_DIRECT_WT(
Signature · 1 line
2.31.1
Alex Deucher
maintainerPATCH 4/4 drm/amdgpu/vcn3.0: remove intermediate variable
In reply to Alex DeucherNo need to use the id variable, just use the constant plus instance offset directly.
--- drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-)
drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c +2 -9
@@ -60,11 +60,6 @@ static int amdgpu_ih_clientid_vcns[] = { SOC15_IH_CLIENTID_VCN1 }; -static int amdgpu_ucode_id_vcns[] = { -AMDGPU_UCODE_ID_VCN , -AMDGPU_UCODE_ID_VCN1 -}; -static int vcn_v3_0_start_sriov (struct amdgpu_device *adev);static void vcn_v3_0_set_dec_ring_funcs (struct amdgpu_device *adev);static void vcn_v3_0_set_enc_ring_funcs (struct amdgpu_device *adev);
@@ -1278,7 +1273,6 @@ static int vcn_v3_0_start_sriov(struct amdgpu_device *adev)uint32_t param, resp, expected;uint32_t offset, cache_size;uint32_t tmp, timeout; -uint32_t id;struct amdgpu_mm_table *table = &adev->virt.mm_table;uint32_t *table_loc;
@@ -1322,13 +1316,12 @@ static int vcn_v3_0_start_sriov(struct amdgpu_device *adev) cache_size =AMDGPU_GPU_PAGE_ALIGN (adev->vcn.fw->size +4 );if (adev->firmware.load_type ==AMDGPU_FW_LOAD_PSP ) { - id = amdgpu_ucode_id_vcns[i];MMSCH_V3_0_INSERT_DIRECT_WT (SOC15_REG_OFFSET (VCN , i, mmUVD_LMI_VCPU_CACHE_64BIT_BAR_LOW), - adev->firmware.ucode[id].tmr_mc_addr_lo); + adev->firmware.ucode[AMDGPU_UCODE_ID_VCN + i].tmr_mc_addr_lo);MMSCH_V3_0_INSERT_DIRECT_WT (SOC15_REG_OFFSET (VCN , i, mmUVD_LMI_VCPU_CACHE_64BIT_BAR_HIGH), - adev->firmware.ucode[id].tmr_mc_addr_hi); + adev->firmware.ucode[AMDGPU_UCODE_ID_VCN + i].tmr_mc_addr_hi); offset =0 ; MMSCH_V3_0_INSERT_DIRECT_WT(SOC15_REG_OFFSET(VCN, i, mmUVD_VCPU_CACHE_OFFSET0),
Signature · 1 line
2.31.1
Re: [PATCH 4/4] drm/amdgpu/vcn3.0: remove intermediate variable
The series are:
Quoted 48 lines · Alex Deucher
No need to use the id variable, just use the constant plus instance offset directly.
Signed-off-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-)drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c +2
-9@@ -60,11 +60,6 @@ static int amdgpu_ih_clientid_vcns[] = { SOC15_IH_CLIENTID_VCN1 }; -static int amdgpu_ucode_id_vcns[] = { -AMDGPU_UCODE_ID_VCN , -AMDGPU_UCODE_ID_VCN1 -}; -static int vcn_v3_0_start_sriov (struct amdgpu_device *adev);static void vcn_v3_0_set_dec_ring_funcs (struct amdgpu_device *adev);static void vcn_v3_0_set_enc_ring_funcs (struct amdgpu_device *adev);@@ -1278,7 +1273,6 @@ static int vcn_v3_0_start_sriov(struct amdgpu_device *adev)uint32_t param, resp, expected;uint32_t offset, cache_size;uint32_t tmp, timeout; -uint32_t id;struct amdgpu_mm_table *table = &adev->virt.mm_table;uint32_t *table_loc;@@ -1322,13 +1316,12 @@ static int vcn_v3_0_start_sriov(struct amdgpu_device *adev) cache_size =AMDGPU_GPU_PAGE_ALIGN (adev->vcn.fw->size +4 );if (adev->firmware.load_type ==AMDGPU_FW_LOAD_PSP ) { - id = amdgpu_ucode_id_vcns[i];MMSCH_V3_0_INSERT_DIRECT_WT (SOC15_REG_OFFSET (VCN , i, mmUVD_LMI_VCPU_CACHE_64BIT_BAR_LOW), - adev->firmware.ucode[id].tmr_mc_addr_lo); + adev->firmware.ucode[AMDGPU_UCODE_ID_VCN + i].tmr_mc_addr_lo);MMSCH_V3_0_INSERT_DIRECT_WT (SOC15_REG_OFFSET (VCN , i, mmUVD_LMI_VCPU_CACHE_64BIT_BAR_HIGH), - adev->firmware.ucode[id].tmr_mc_addr_hi); + adev->firmware.ucode[AMDGPU_UCODE_ID_VCN + i].tmr_mc_addr_hi); offset =0 ; MMSCH_V3_0_INSERT_DIRECT_WT(SOC15_REG_OFFSET(VCN, i, mmUVD_VCPU_CACHE_OFFSET0),