From: Christoph Berliner <caberliner@gmail.com>
To: amd-gfx@lists.freedesktop.org
Cc: alexander.deucher@amd.com, christian.koenig@amd.com,
Jiqian.Chen@amd.com, Christoph Berliner <caberliner@gmail.com>
Subject: [PATCH 1/2] drm/amdgpu/gfx9: factor out HQD deactivation and fix its timeout check
Date: Fri, 20 Nov 2026 18:24:06 +0100 [thread overview]
Message-ID: <20261120172407.64651-2-caberliner@gmail.com> (raw)
In-Reply-To: <20261120172407.64651-1-caberliner@gmail.com>
gfx_v9_0_deactivate_kcq_hqd() polls CP_HQD_ACTIVE for adev->usec_timeout
iterations, but then compares the loop counter against
AMDGPU_MAX_USEC_TIMEOUT. Unless both values happen to be equal, the
manual CP_HQD_ACTIVE=0 fallback for a timed-out dequeue request is never
reached. Compare against the actual loop bound.
Move the per-queue deactivation into gfx_v9_0_deactivate_hqd() so it can
be reused for queues that are not kernel compute rings, and use
dev_dbg() instead of DRM_DEBUG() while at it. No functional change other
than the timeout check.
Fixes: c3988a7ad479 ("drm/amdgpu/gfx9: Fix Ring and IB test fail after mode2")
Assisted-by: Claude Code
Signed-off-by: Christoph Berliner <caberliner@gmail.com>
---
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 50 ++++++++++++++++-----------
1 file changed, 29 insertions(+), 21 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
index 9d87ebbc4..b60b6fa88 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
@@ -4076,35 +4076,43 @@ static int gfx_v9_0_hw_init(struct amdgpu_ip_block *ip_block)
return r;
}
+/* caller must hold srbm_mutex and have selected me/pipe/queue */
+static bool gfx_v9_0_deactivate_hqd(struct amdgpu_device *adev,
+ u32 me, u32 pipe, u32 queue)
+{
+ int j;
+
+ /* disable the queue if it's active */
+ if (!(RREG32_SOC15(GC, 0, mmCP_HQD_ACTIVE) & CP_HQD_ACTIVE__ACTIVE_MASK))
+ return false;
+
+ WREG32_SOC15(GC, 0, mmCP_HQD_DEQUEUE_REQUEST, 1);
+ for (j = 0; j < adev->usec_timeout; j++) {
+ if (!(RREG32_SOC15(GC, 0, mmCP_HQD_ACTIVE) &
+ CP_HQD_ACTIVE__ACTIVE_MASK))
+ break;
+ udelay(1);
+ }
+ if (j == adev->usec_timeout) {
+ dev_dbg(adev->dev, "comp_%u_%u_%u dequeue request failed.\n",
+ me, pipe, queue);
+ /* Manual disable if dequeue request times out */
+ WREG32_SOC15(GC, 0, mmCP_HQD_ACTIVE, 0);
+ }
+ WREG32_SOC15(GC, 0, mmCP_HQD_DEQUEUE_REQUEST, 0);
+
+ return true;
+}
+
static void gfx_v9_0_deactivate_kcq_hqd(struct amdgpu_device *adev)
{
amdgpu_gfx_rlc_enter_safe_mode(adev, 0);
for (int i = 0; i < adev->gfx.num_compute_rings; i++) {
- u32 tmp;
struct amdgpu_ring *ring = &adev->gfx.compute_ring[i];
mutex_lock(&adev->srbm_mutex);
soc15_grbm_select(adev, ring->me, ring->pipe, ring->queue, 0, 0);
- tmp = RREG32_SOC15(GC, 0, mmCP_HQD_ACTIVE);
- /* disable the queue if it's active */
- if (tmp & CP_HQD_ACTIVE__ACTIVE_MASK) {
- int j;
-
- WREG32_SOC15(GC, 0, mmCP_HQD_DEQUEUE_REQUEST, 1);
- for (j = 0; j < adev->usec_timeout; j++) {
- tmp = RREG32_SOC15(GC, 0, mmCP_HQD_ACTIVE);
- if (!(tmp & CP_HQD_ACTIVE__ACTIVE_MASK))
- break;
- udelay(1);
- }
- if (j == AMDGPU_MAX_USEC_TIMEOUT) {
- DRM_DEBUG("comp_%u_%u_%u dequeue request failed.\n",
- ring->me, ring->pipe, ring->queue);
- /* Manual disable if dequeue request times out */
- WREG32_SOC15(GC, 0, mmCP_HQD_ACTIVE, 0);
- }
- WREG32_SOC15(GC, 0, mmCP_HQD_DEQUEUE_REQUEST, 0);
- }
+ gfx_v9_0_deactivate_hqd(adev, ring->me, ring->pipe, ring->queue);
soc15_grbm_select(adev, 0, 0, 0, 0, 0);
mutex_unlock(&adev->srbm_mutex);
}
--
2.56.1
next prev parent reply other threads:[~2026-11-20 17:38 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-20 17:24 [PATCH 0/2] drm/amdgpu/gfx9: make KFD usable again after MODE2 on Renoir Christoph Berliner
2026-11-20 17:24 ` Christoph Berliner [this message]
2026-11-20 17:24 ` [PATCH 2/2] drm/amdgpu/gfx9: deactivate all compute HQDs before " Christoph Berliner
2026-11-20 19:25 ` [PATCH 0/2] drm/amdgpu/gfx9: make KFD usable again after " Alex Deucher
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261120172407.64651-2-caberliner@gmail.com \
--to=caberliner@gmail.com \
--cc=Jiqian.Chen@amd.com \
--cc=alexander.deucher@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=christian.koenig@amd.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.