Skip to content

Commit eb6910c

Browse files
Jie1zhangalexdeucher
authored andcommitted
drm/amdgpu: Refactor VCN v5.0.1 HW init into separate instance function
Split the per-instance initialization code from vcn_v5_0_1_hw_init() into a new vcn_v5_0_1_hw_init_inst() function. This improves code organization by: 1. Separating the instance-specific initialization logic 2. Making the main init function more readable 3. Following the pattern used in queue reset The SR-IOV specific initialization remains in the main function since it has different requirements. Reviewed-by: Sonny Jiang <sonny.jiang@amd.com> Signed-off-by: Jesse Zhang <Jesse.Zhang@amd.com> Signed-off-by: Ruili Ji <ruiliji2@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
1 parent 0c1f3fe commit eb6910c

1 file changed

Lines changed: 19 additions & 8 deletions

File tree

drivers/gpu/drm/amd/amdgpu/vcn_v5_0_1.c

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,23 @@ static int vcn_v5_0_1_sw_fini(struct amdgpu_ip_block *ip_block)
253253
return 0;
254254
}
255255

256+
static int vcn_v5_0_1_hw_init_inst(struct amdgpu_device *adev, int i)
257+
{
258+
struct amdgpu_ring *ring;
259+
int vcn_inst;
260+
261+
vcn_inst = GET_INST(VCN, i);
262+
ring = &adev->vcn.inst[i].ring_enc[0];
263+
264+
if (ring->use_doorbell)
265+
adev->nbio.funcs->vcn_doorbell_range(adev, ring->use_doorbell,
266+
((adev->doorbell_index.vcn.vcn_ring0_1 << 1) +
267+
11 * vcn_inst),
268+
adev->vcn.inst[i].aid_id);
269+
270+
return 0;
271+
}
272+
256273
/**
257274
* vcn_v5_0_1_hw_init - start and test VCN block
258275
*
@@ -264,7 +281,7 @@ static int vcn_v5_0_1_hw_init(struct amdgpu_ip_block *ip_block)
264281
{
265282
struct amdgpu_device *adev = ip_block->adev;
266283
struct amdgpu_ring *ring;
267-
int i, r, vcn_inst;
284+
int i, r;
268285

269286
if (amdgpu_sriov_vf(adev)) {
270287
r = vcn_v5_0_1_start_sriov(adev);
@@ -282,14 +299,8 @@ static int vcn_v5_0_1_hw_init(struct amdgpu_ip_block *ip_block)
282299
if (RREG32_SOC15(VCN, GET_INST(VCN, 0), regVCN_RRMT_CNTL) & 0x100)
283300
adev->vcn.caps |= AMDGPU_VCN_CAPS(RRMT_ENABLED);
284301
for (i = 0; i < adev->vcn.num_vcn_inst; ++i) {
285-
vcn_inst = GET_INST(VCN, i);
286302
ring = &adev->vcn.inst[i].ring_enc[0];
287-
288-
if (ring->use_doorbell)
289-
adev->nbio.funcs->vcn_doorbell_range(adev, ring->use_doorbell,
290-
((adev->doorbell_index.vcn.vcn_ring0_1 << 1) +
291-
11 * vcn_inst),
292-
adev->vcn.inst[i].aid_id);
303+
vcn_v5_0_1_hw_init_inst(adev, i);
293304

294305
/* Re-init fw_shared, if required */
295306
vcn_v5_0_1_fw_shared_init(adev, i);

0 commit comments

Comments
 (0)