Skip to content

Commit 2f3806f

Browse files
jiadozhualexdeucher
authored andcommitted
drm/amdgpu/gfx10: remap queue after reset successfully
Kiq command unmap_queues only does the dequeueing action. We have to map the queue back with clean mqd. v2: fix up error handling (Alex) 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 1741281 commit 2f3806f

File tree

1 file changed

+35
-11
lines changed

1 file changed

+35
-11
lines changed

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

Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7030,13 +7030,13 @@ static int gfx_v10_0_kiq_init_queue(struct amdgpu_ring *ring)
70307030
return 0;
70317031
}
70327032

7033-
static int gfx_v10_0_kcq_init_queue(struct amdgpu_ring *ring)
7033+
static int gfx_v10_0_kcq_init_queue(struct amdgpu_ring *ring, bool restore)
70347034
{
70357035
struct amdgpu_device *adev = ring->adev;
70367036
struct v10_compute_mqd *mqd = ring->mqd_ptr;
70377037
int mqd_idx = ring - &adev->gfx.compute_ring[0];
70387038

7039-
if (!amdgpu_in_reset(adev) && !adev->in_suspend) {
7039+
if (!restore && !amdgpu_in_reset(adev) && !adev->in_suspend) {
70407040
memset((void *)mqd, 0, sizeof(*mqd));
70417041
mutex_lock(&adev->srbm_mutex);
70427042
nv_grbm_select(adev, ring->me, ring->pipe, ring->queue, 0);
@@ -7098,7 +7098,7 @@ static int gfx_v10_0_kcq_resume(struct amdgpu_device *adev)
70987098
goto done;
70997099
r = amdgpu_bo_kmap(ring->mqd_obj, (void **)&ring->mqd_ptr);
71007100
if (!r) {
7101-
r = gfx_v10_0_kcq_init_queue(ring);
7101+
r = gfx_v10_0_kcq_init_queue(ring, false);
71027102
amdgpu_bo_kunmap(ring->mqd_obj);
71037103
ring->mqd_ptr = NULL;
71047104
}
@@ -9483,25 +9483,49 @@ static int gfx_v10_0_reset_kcq(struct amdgpu_ring *ring,
94839483
spin_lock_irqsave(&kiq->ring_lock, flags);
94849484

94859485
if (amdgpu_ring_alloc(kiq_ring, kiq->pmf->unmap_queues_size)) {
9486-
spin_unlock_irqrestore(&kiq->ring_lock, flags);
9487-
return -ENOMEM;
9486+
r = -ENOMEM;
9487+
goto out;
94889488
}
94899489

94909490
kiq->pmf->kiq_unmap_queues(kiq_ring, ring, RESET_QUEUES,
94919491
0, 0);
94929492
amdgpu_ring_commit(kiq_ring);
94939493

9494-
spin_unlock_irqrestore(&kiq->ring_lock, flags);
9494+
r = amdgpu_ring_test_ring(kiq_ring);
9495+
if (r)
9496+
goto out;
9497+
9498+
r = amdgpu_bo_reserve(ring->mqd_obj, false);
9499+
if (unlikely(r != 0)) {
9500+
dev_err(adev->dev, "fail to resv mqd_obj\n");
9501+
goto out;
9502+
}
9503+
r = amdgpu_bo_kmap(ring->mqd_obj, (void **)&ring->mqd_ptr);
9504+
if (!r) {
9505+
r = gfx_v10_0_kcq_init_queue(ring, true);
9506+
amdgpu_bo_kunmap(ring->mqd_obj);
9507+
ring->mqd_ptr = NULL;
9508+
}
9509+
amdgpu_bo_unreserve(ring->mqd_obj);
9510+
if (r) {
9511+
dev_err(adev->dev, "fail to unresv mqd_obj\n");
9512+
goto out;
9513+
}
9514+
9515+
if (amdgpu_ring_alloc(kiq_ring, kiq->pmf->map_queues_size)) {
9516+
r = -ENOMEM;
9517+
goto out;
9518+
}
9519+
kiq->pmf->kiq_map_queues(kiq_ring, ring);
9520+
amdgpu_ring_commit(kiq_ring);
94959521

94969522
r = amdgpu_ring_test_ring(kiq_ring);
9523+
9524+
out:
9525+
spin_unlock_irqrestore(&kiq->ring_lock, flags);
94979526
if (r)
94989527
return r;
94999528

9500-
/* reset the ring */
9501-
ring->wptr = 0;
9502-
*ring->wptr_cpu_addr = 0;
9503-
amdgpu_ring_clear_ring(ring);
9504-
95059529
return amdgpu_ring_test_ring(ring);
95069530
}
95079531

0 commit comments

Comments
 (0)