Skip to content

Commit c1d3f62

Browse files
Lijo Lazaralexdeucher
authored andcommitted
drm/amdgpu: Fix mqd init on GFX v9.4.3
For MQD init, an XCC's queue is selected with GRBM select. However, for initialization of MQD, values read from logical XCC0 registers are used. This results in garbage values being read from XCC0 whose queue is not selected. Change to read from the right XCC for MQD initialization. Signed-off-by: Lijo Lazar <[email protected]> Reviewed-by: Hawking Zhang <[email protected]> Signed-off-by: Alex Deucher <[email protected]>
1 parent 5ca1cee commit c1d3f62

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1456,7 +1456,7 @@ static void gfx_v9_4_3_mqd_set_priority(struct amdgpu_ring *ring, struct v9_mqd
14561456
}
14571457
}
14581458

1459-
static int gfx_v9_4_3_mqd_init(struct amdgpu_ring *ring)
1459+
static int gfx_v9_4_3_xcc_mqd_init(struct amdgpu_ring *ring, int xcc_id)
14601460
{
14611461
struct amdgpu_device *adev = ring->adev;
14621462
struct v9_mqd *mqd = ring->mqd_ptr;
@@ -1483,14 +1483,14 @@ static int gfx_v9_4_3_mqd_init(struct amdgpu_ring *ring)
14831483
mqd->cp_hqd_eop_base_addr_hi = upper_32_bits(eop_base_addr);
14841484

14851485
/* set the EOP size, register value is 2^(EOP_SIZE+1) dwords */
1486-
tmp = RREG32_SOC15(GC, GET_INST(GC, 0), regCP_HQD_EOP_CONTROL);
1486+
tmp = RREG32_SOC15(GC, GET_INST(GC, xcc_id), regCP_HQD_EOP_CONTROL);
14871487
tmp = REG_SET_FIELD(tmp, CP_HQD_EOP_CONTROL, EOP_SIZE,
14881488
(order_base_2(GFX9_MEC_HPD_SIZE / 4) - 1));
14891489

14901490
mqd->cp_hqd_eop_control = tmp;
14911491

14921492
/* enable doorbell? */
1493-
tmp = RREG32_SOC15(GC, GET_INST(GC, 0), regCP_HQD_PQ_DOORBELL_CONTROL);
1493+
tmp = RREG32_SOC15(GC, GET_INST(GC, xcc_id), regCP_HQD_PQ_DOORBELL_CONTROL);
14941494

14951495
if (ring->use_doorbell) {
14961496
tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_DOORBELL_CONTROL,
@@ -1520,7 +1520,7 @@ static int gfx_v9_4_3_mqd_init(struct amdgpu_ring *ring)
15201520
mqd->cp_mqd_base_addr_hi = upper_32_bits(ring->mqd_gpu_addr);
15211521

15221522
/* set MQD vmid to 0 */
1523-
tmp = RREG32_SOC15(GC, GET_INST(GC, 0), regCP_MQD_CONTROL);
1523+
tmp = RREG32_SOC15(GC, GET_INST(GC, xcc_id), regCP_MQD_CONTROL);
15241524
tmp = REG_SET_FIELD(tmp, CP_MQD_CONTROL, VMID, 0);
15251525
mqd->cp_mqd_control = tmp;
15261526

@@ -1530,7 +1530,7 @@ static int gfx_v9_4_3_mqd_init(struct amdgpu_ring *ring)
15301530
mqd->cp_hqd_pq_base_hi = upper_32_bits(hqd_gpu_addr);
15311531

15321532
/* set up the HQD, this is similar to CP_RB0_CNTL */
1533-
tmp = RREG32_SOC15(GC, GET_INST(GC, 0), regCP_HQD_PQ_CONTROL);
1533+
tmp = RREG32_SOC15(GC, GET_INST(GC, xcc_id), regCP_HQD_PQ_CONTROL);
15341534
tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_CONTROL, QUEUE_SIZE,
15351535
(order_base_2(ring->ring_size / 4) - 1));
15361536
tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_CONTROL, RPTR_BLOCK_SIZE,
@@ -1557,23 +1557,23 @@ static int gfx_v9_4_3_mqd_init(struct amdgpu_ring *ring)
15571557

15581558
/* reset read and write pointers, similar to CP_RB0_WPTR/_RPTR */
15591559
ring->wptr = 0;
1560-
mqd->cp_hqd_pq_rptr = RREG32_SOC15(GC, GET_INST(GC, 0), regCP_HQD_PQ_RPTR);
1560+
mqd->cp_hqd_pq_rptr = RREG32_SOC15(GC, GET_INST(GC, xcc_id), regCP_HQD_PQ_RPTR);
15611561

15621562
/* set the vmid for the queue */
15631563
mqd->cp_hqd_vmid = 0;
15641564

1565-
tmp = RREG32_SOC15(GC, GET_INST(GC, 0), regCP_HQD_PERSISTENT_STATE);
1565+
tmp = RREG32_SOC15(GC, GET_INST(GC, xcc_id), regCP_HQD_PERSISTENT_STATE);
15661566
tmp = REG_SET_FIELD(tmp, CP_HQD_PERSISTENT_STATE, PRELOAD_SIZE, 0x53);
15671567
mqd->cp_hqd_persistent_state = tmp;
15681568

15691569
/* set MIN_IB_AVAIL_SIZE */
1570-
tmp = RREG32_SOC15(GC, GET_INST(GC, 0), regCP_HQD_IB_CONTROL);
1570+
tmp = RREG32_SOC15(GC, GET_INST(GC, xcc_id), regCP_HQD_IB_CONTROL);
15711571
tmp = REG_SET_FIELD(tmp, CP_HQD_IB_CONTROL, MIN_IB_AVAIL_SIZE, 3);
15721572
mqd->cp_hqd_ib_control = tmp;
15731573

15741574
/* set static priority for a queue/ring */
15751575
gfx_v9_4_3_mqd_set_priority(ring, mqd);
1576-
mqd->cp_hqd_quantum = RREG32_SOC15(GC, GET_INST(GC, 0), regCP_HQD_QUANTUM);
1576+
mqd->cp_hqd_quantum = RREG32_SOC15(GC, GET_INST(GC, xcc_id), regCP_HQD_QUANTUM);
15771577

15781578
/* map_queues packet doesn't need activate the queue,
15791579
* so only kiq need set this field.
@@ -1771,7 +1771,7 @@ static int gfx_v9_4_3_xcc_kiq_init_queue(struct amdgpu_ring *ring, int xcc_id)
17711771
((struct v9_mqd_allocation *)mqd)->dynamic_rb_mask = 0xFFFFFFFF;
17721772
mutex_lock(&adev->srbm_mutex);
17731773
soc15_grbm_select(adev, ring->me, ring->pipe, ring->queue, 0, GET_INST(GC, xcc_id));
1774-
gfx_v9_4_3_mqd_init(ring);
1774+
gfx_v9_4_3_xcc_mqd_init(ring, xcc_id);
17751775
gfx_v9_4_3_xcc_kiq_init_register(ring, xcc_id);
17761776
soc15_grbm_select(adev, 0, 0, 0, 0, GET_INST(GC, xcc_id));
17771777
mutex_unlock(&adev->srbm_mutex);
@@ -1802,7 +1802,7 @@ static int gfx_v9_4_3_xcc_kcq_init_queue(struct amdgpu_ring *ring, int xcc_id)
18021802
((struct v9_mqd_allocation *)mqd)->dynamic_rb_mask = 0xFFFFFFFF;
18031803
mutex_lock(&adev->srbm_mutex);
18041804
soc15_grbm_select(adev, ring->me, ring->pipe, ring->queue, 0, GET_INST(GC, xcc_id));
1805-
gfx_v9_4_3_mqd_init(ring);
1805+
gfx_v9_4_3_xcc_mqd_init(ring, xcc_id);
18061806
soc15_grbm_select(adev, 0, 0, 0, 0, GET_INST(GC, xcc_id));
18071807
mutex_unlock(&adev->srbm_mutex);
18081808

0 commit comments

Comments
 (0)