Skip to content

Commit a10c939

Browse files
jiadozhualexdeucher
authored andcommitted
drm/amdgpu/gfx11: wait for reset done before remap
There is a racing condition that cp firmware modifies MQD in reset sequence after driver updates it for remapping. We have to wait till CP_HQD_ACTIVE becoming false then remap the queue. Acked-by: Vitaly Prosyak <vitaly.prosyak@amd.com> Signed-off-by: Jiadong Zhu <Jiadong.Zhu@amd.com> Reviewed-by: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
1 parent 7d8e9e6 commit a10c939

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

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

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6582,16 +6582,29 @@ static int gfx_v11_0_reset_kgq(struct amdgpu_ring *ring, unsigned int vmid)
65826582
static int gfx_v11_0_reset_kcq(struct amdgpu_ring *ring, unsigned int vmid)
65836583
{
65846584
struct amdgpu_device *adev = ring->adev;
6585-
int r;
6585+
int i, r = 0;
65866586

65876587
gfx_v11_0_set_safe_mode(adev, 0);
65886588
mutex_lock(&adev->srbm_mutex);
65896589
soc21_grbm_select(adev, ring->me, ring->pipe, ring->queue, 0);
65906590
WREG32_SOC15(GC, 0, regCP_HQD_DEQUEUE_REQUEST, 0x2);
65916591
WREG32_SOC15(GC, 0, regSPI_COMPUTE_QUEUE_RESET, 0x1);
6592+
6593+
/* make sure dequeue is complete*/
6594+
for (i = 0; i < adev->usec_timeout; i++) {
6595+
if (!(RREG32_SOC15(GC, 0, regCP_HQD_ACTIVE) & 1))
6596+
break;
6597+
udelay(1);
6598+
}
6599+
if (i >= adev->usec_timeout)
6600+
r = -ETIMEDOUT;
65926601
soc21_grbm_select(adev, 0, 0, 0, 0);
65936602
mutex_unlock(&adev->srbm_mutex);
65946603
gfx_v11_0_unset_safe_mode(adev, 0);
6604+
if (r) {
6605+
dev_err(adev->dev, "fail to wait on hqd deactivate\n");
6606+
return r;
6607+
}
65956608

65966609
r = amdgpu_bo_reserve(ring->mqd_obj, false);
65976610
if (unlikely(r != 0)) {

0 commit comments

Comments
 (0)