Skip to contentSkip to conversation

drm/amdgpu/gfx11: clean up kcq reset code

PATCH In review [email protected] 2 participants 2 messages Dec 10, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 7/7 drm/amdgpu/gfx11: clean up kcq reset code

Replace kcq queue reset with existing function amdgpu_mes_reset_legacy_queue.

---
 drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c | 22 +++-------------------
 1 file changed, 3 insertions(+), 19 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +3 -19
index 67cd42031571..b741dcb0a5a3 100644
@@ -6675,30 +6675,14 @@ static int gfx_v11_0_reset_kgq(struct amdgpu_ring *ring, unsigned int vmid)
 static int gfx_v11_0_reset_kcq(struct amdgpu_ring *ring, unsigned int vmid)
 {
 	struct amdgpu_device *adev = ring->adev;
-	int i, r = 0;
+	int r = 0;
 
 	if (amdgpu_sriov_vf(adev))
 		return -EINVAL;
 
-	amdgpu_gfx_rlc_enter_safe_mode(adev, 0);
-	mutex_lock(&adev->srbm_mutex);
-	soc21_grbm_select(adev, ring->me, ring->pipe, ring->queue, 0);
-	WREG32_SOC15(GC, 0, regCP_HQD_DEQUEUE_REQUEST, 0x2);
-	WREG32_SOC15(GC, 0, regSPI_COMPUTE_QUEUE_RESET, 0x1);
-
-	/* make sure dequeue is complete*/
-	for (i = 0; i < adev->usec_timeout; i++) {
-		if (!(RREG32_SOC15(GC, 0, regCP_HQD_ACTIVE) & 1))
-			break;
-		udelay(1);
-	}
-	if (i >= adev->usec_timeout)
-		r = -ETIMEDOUT;
-	soc21_grbm_select(adev, 0, 0, 0, 0);
-	mutex_unlock(&adev->srbm_mutex);
-	amdgpu_gfx_rlc_exit_safe_mode(adev, 0);
+	r = amdgpu_mes_reset_legacy_queue(ring->adev, ring, vmid, true);
 	if (r) {
-		dev_err(adev->dev, "fail to wait on hqd deactivate\n");
+		dev_err(adev->dev, "reset via MMIO failed %d\n", r);
 		return r;
 	}
 
Signature · 1 line
2.25.1
maintainer Reviewed-by on v2 7/7
#1 lore raw

[Public]

Series is:

________________________________
From: [email protected] <[email protected]>
Sent: Tuesday, December 10, 2024 2:54 AM
To: [email protected] <[email protected]>
Cc: Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>; Zhu, Jiadong <[email protected]>; Liang, Prike <[email protected]>; Huang, Tim <[email protected]>; Zhang, Jesse(Jie) <[email protected]>
Subject: [PATCH 7/7 v2] drm/amdgpu/gfx11: clean up kcq reset code

Replace kcq queue reset with existing function amdgpu_mes_reset_legacy_queue.

---
 drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c | 22 +++-------------------
 1 file changed, 3 insertions(+), 19 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +3 -19
index 67cd42031571..b741dcb0a5a3 100644
@@ -6675,30 +6675,14 @@ static int gfx_v11_0_reset_kgq(struct amdgpu_ring *ring, unsigned int vmid)
 static int gfx_v11_0_reset_kcq(struct amdgpu_ring *ring, unsigned int vmid)
 {
         struct amdgpu_device *adev = ring->adev;
-       int i, r = 0;
+       int r = 0;
 
         if (amdgpu_sriov_vf(adev))
                 return -EINVAL;
 
-       amdgpu_gfx_rlc_enter_safe_mode(adev, 0);
-       mutex_lock(&adev->srbm_mutex);
-       soc21_grbm_select(adev, ring->me, ring->pipe, ring->queue, 0);
-       WREG32_SOC15(GC, 0, regCP_HQD_DEQUEUE_REQUEST, 0x2);
-       WREG32_SOC15(GC, 0, regSPI_COMPUTE_QUEUE_RESET, 0x1);
-
-       /* make sure dequeue is complete*/
-       for (i = 0; i < adev->usec_timeout; i++) {
-               if (!(RREG32_SOC15(GC, 0, regCP_HQD_ACTIVE) & 1))
-                       break;
-               udelay(1);
-       }
-       if (i >= adev->usec_timeout)
-               r = -ETIMEDOUT;
-       soc21_grbm_select(adev, 0, 0, 0, 0);
-       mutex_unlock(&adev->srbm_mutex);
-       amdgpu_gfx_rlc_exit_safe_mode(adev, 0);
+       r = amdgpu_mes_reset_legacy_queue(ring->adev, ring, vmid, true);
         if (r) {
-               dev_err(adev->dev, "fail to wait on hqd deactivate\n");
+               dev_err(adev->dev, "reset via MMIO failed %d\n", r);
                 return r;
         }
 

--
2.25.1