Skip to content

Commit 2abe92c

Browse files
YuBiao Wangalexdeucher
authored andcommitted
drm/amdgpu: dequeue mes scheduler during fini
[Why] If mes is not dequeued during fini, mes will be in an uncleaned state during reload, then mes couldn't receive some commands which leads to reload failure. [How] Perform MES dequeue via MMIO after all the unmap jobs are done by mes and before kiq fini. v2: Move the dequeue operation inside kiq_hw_fini. Signed-off-by: YuBiao Wang <[email protected]> Reviewed-by: Jack Xiao <[email protected]> Signed-off-by: Alex Deucher <[email protected]>
1 parent 5ce4726 commit 2abe92c

File tree

1 file changed

+39
-3
lines changed

1 file changed

+39
-3
lines changed

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

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1156,6 +1156,42 @@ static int mes_v11_0_sw_fini(void *handle)
11561156
return 0;
11571157
}
11581158

1159+
static void mes_v11_0_kiq_dequeue_sched(struct amdgpu_device *adev)
1160+
{
1161+
uint32_t data;
1162+
int i;
1163+
1164+
mutex_lock(&adev->srbm_mutex);
1165+
soc21_grbm_select(adev, 3, AMDGPU_MES_SCHED_PIPE, 0, 0);
1166+
1167+
/* disable the queue if it's active */
1168+
if (RREG32_SOC15(GC, 0, regCP_HQD_ACTIVE) & 1) {
1169+
WREG32_SOC15(GC, 0, regCP_HQD_DEQUEUE_REQUEST, 1);
1170+
for (i = 0; i < adev->usec_timeout; i++) {
1171+
if (!(RREG32_SOC15(GC, 0, regCP_HQD_ACTIVE) & 1))
1172+
break;
1173+
udelay(1);
1174+
}
1175+
}
1176+
data = RREG32_SOC15(GC, 0, regCP_HQD_PQ_DOORBELL_CONTROL);
1177+
data = REG_SET_FIELD(data, CP_HQD_PQ_DOORBELL_CONTROL,
1178+
DOORBELL_EN, 0);
1179+
data = REG_SET_FIELD(data, CP_HQD_PQ_DOORBELL_CONTROL,
1180+
DOORBELL_HIT, 1);
1181+
WREG32_SOC15(GC, 0, regCP_HQD_PQ_DOORBELL_CONTROL, data);
1182+
1183+
WREG32_SOC15(GC, 0, regCP_HQD_PQ_DOORBELL_CONTROL, 0);
1184+
1185+
WREG32_SOC15(GC, 0, regCP_HQD_PQ_WPTR_LO, 0);
1186+
WREG32_SOC15(GC, 0, regCP_HQD_PQ_WPTR_HI, 0);
1187+
WREG32_SOC15(GC, 0, regCP_HQD_PQ_RPTR, 0);
1188+
1189+
soc21_grbm_select(adev, 0, 0, 0, 0);
1190+
mutex_unlock(&adev->srbm_mutex);
1191+
1192+
adev->mes.ring.sched.ready = false;
1193+
}
1194+
11591195
static void mes_v11_0_kiq_setting(struct amdgpu_ring *ring)
11601196
{
11611197
uint32_t tmp;
@@ -1207,6 +1243,9 @@ static int mes_v11_0_kiq_hw_init(struct amdgpu_device *adev)
12071243

12081244
static int mes_v11_0_kiq_hw_fini(struct amdgpu_device *adev)
12091245
{
1246+
if (adev->mes.ring.sched.ready)
1247+
mes_v11_0_kiq_dequeue_sched(adev);
1248+
12101249
mes_v11_0_enable(adev, false);
12111250
return 0;
12121251
}
@@ -1262,9 +1301,6 @@ static int mes_v11_0_hw_init(void *handle)
12621301

12631302
static int mes_v11_0_hw_fini(void *handle)
12641303
{
1265-
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
1266-
1267-
adev->mes.ring.sched.ready = false;
12681304
return 0;
12691305
}
12701306

0 commit comments

Comments
 (0)