From: sashiko-bot@kernel.org
To: "Jesse Zhang" <Jesse.Zhang@amd.com>, amd-gfx@lists.freedesktop.org
Subject: Re: [PATCH v5 10/15] drm/amdgpu/gfx11: add a gfx engine soft reset
Date: Thu, 26 Nov 2026 09:59:17 +0000 [thread overview]
Message-ID: <sashiko-outbox-235213@kernel.org> (raw)
In-Reply-To: <20261126093417.192538-10-Jesse.Zhang@amd.com>
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] amdgpu: missing pre-pulse CP_VMID_RESET clear in
gfx_v11_0_soft_reset_gfx_cp()
- [Medium] amdgpu: gfx_ring[0] left mapped on disable_kq in
gfx_v11_0_soft_reset_engine()
--
commit 4f83c926ed3d12feae57fed7044a2f21e92280c8
Author: Jesse Zhang <Jesse.Zhang@amd.com>
drm/amdgpu/gfx11: add a gfx engine soft reset
This commit implements the soft_reset_engine() callback for the graphics
engine on GFX11 by resetting CPF/CPG, PFP/ME, and the GFX HQDs, then
restarting the kernel and usermode GFX queues.
> diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c
> index ecf8a156b7ec4..a0ed3363f84d1 100644
> --- a/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c
> @@ -6820,6 +6820,132 @@ static void gfx_v11_0_emit_mem_sync(struct amdgpu_ring *ring)
> amdgpu_ring_write(ring, gcr_cntl); /* GCR_CNTL */
> }
>
> +/* The CP DMA and the interfaces its memory requests go through */
> +#define GFX11_CP_STAT_MEM_BUSY (CP_STAT__DMA_BUSY_MASK | \
> + CP_STAT__TCIU_BUSY_MASK | \
> + CP_STAT__RCIU_BUSY_MASK | \
> + CP_STAT__UTCL2IU_BUSY_MASK)
> +
> +/* Reset CPF/CPG, PFP/ME and the gfx HQDs, then boot PFP/ME again. */
> +static int gfx_v11_0_soft_reset_gfx_cp(struct amdgpu_device *adev)
> +{
> + u32 tmp, cntl, me_cntl;
> + int i;
> +
> + amdgpu_gfx_rlc_enter_safe_mode(adev, 0);
> + /* MES fetches its queues through CPF: keep it out of the reset. */
> + amdgpu_mes_lock(&adev->mes);
> +
> + me_cntl = RREG32_SOC15(GC, 0, regCP_ME_CNTL);
> +
> + tmp = REG_SET_FIELD(me_cntl, CP_ME_CNTL, ME_HALT, 1);
> + tmp = REG_SET_FIELD(tmp, CP_ME_CNTL, PFP_HALT, 1);
> + WREG32_SOC15(GC, 0, regCP_ME_CNTL, tmp);
> + udelay(50);
> +
> + /* A CP DMA in flight during the reset leaves the ME busy after it. */
> + for (i = 0; i < adev->usec_timeout; i++) {
> + if (!(RREG32_SOC15(GC, 0, regCP_STAT) & GFX11_CP_STAT_MEM_BUSY))
> + break;
> + udelay(1);
> + }
> +
> + /* GFX_ONLY keeps compute and MES out; CPF alone leaves the stream stuck. */
> + cntl = RREG32_SOC15(GC, 0, regCP_SOFT_RESET_CNTL);
> + tmp = REG_SET_FIELD(cntl, CP_SOFT_RESET_CNTL, GFX_ONLY_SOFT_RESET, 1);
> + tmp = REG_SET_FIELD(tmp, CP_SOFT_RESET_CNTL, GFX_HQD_REG_RESET, 1);
> + WREG32_SOC15(GC, 0, regCP_SOFT_RESET_CNTL, tmp);
> +
> + tmp = RREG32_SOC15(GC, 0, regGRBM_SOFT_RESET);
> + tmp = REG_SET_FIELD(tmp, GRBM_SOFT_RESET, SOFT_RESET_CPF, 1);
> + tmp = REG_SET_FIELD(tmp, GRBM_SOFT_RESET, SOFT_RESET_CPG, 1);
> + WREG32_SOC15(GC, 0, regGRBM_SOFT_RESET, tmp);
> + tmp = RREG32_SOC15(GC, 0, regGRBM_SOFT_RESET);
> + udelay(50);
> + tmp = REG_SET_FIELD(tmp, GRBM_SOFT_RESET, SOFT_RESET_CPF, 0);
> + tmp = REG_SET_FIELD(tmp, GRBM_SOFT_RESET, SOFT_RESET_CPG, 0);
> + WREG32_SOC15(GC, 0, regGRBM_SOFT_RESET, tmp);
> + tmp = RREG32_SOC15(GC, 0, regGRBM_SOFT_RESET);
> +
> + WREG32_SOC15(GC, 0, regCP_SOFT_RESET_CNTL, cntl);
> +
> + /* The halted PFP stays busy: only wait for the memory requests. */
> + for (i = 0; i < adev->usec_timeout; i++) {
> + if (!(RREG32_SOC15(GC, 0, regCP_STAT) & GFX11_CP_STAT_MEM_BUSY))
> + break;
> + udelay(1);
> + }
> + /* A VMID reset the hung PFP didn't handle survives the reset. */
> + WREG32_SOC15(GC, 0, regCP_VMID_RESET, 0);
[Severity: Medium]
Should regCP_VMID_RESET also be cleared to 0 before asserting
SOFT_RESET_CPF and SOFT_RESET_CPG in regGRBM_SOFT_RESET, as
gfx_v12_0_soft_reset_gfx_cp() does?
When PFP is hung, the preceding per-queue and per-pipe MMIO resets in
mes_v11_0_reset_queue_mmio() and mes_v11_0_reset_gfx_pipe_mmio() write a
reset request to regCP_VMID_RESET and time out waiting for PFP to clear
it. Pulsing regGRBM_SOFT_RESET while that VMID reset is still active can
cause the CP soft reset to fail and escalate to a full GPU reset.
[ ... ]
> +static int gfx_v11_0_soft_reset_engine(struct amdgpu_ip_block *ip_block,
> + enum amdgpu_ring_type ring_type, u32 inst,
> + struct amdgpu_usermode_queue *guilty_queue)
> +{
> + struct amdgpu_device *adev = ip_block->adev;
> + int i, r;
> +
> + if (ring_type != AMDGPU_RING_TYPE_GFX || inst)
> + return -EOPNOTSUPP;
> +
> + mutex_lock(&adev->gfx.mec.reset_mutex);
> + amdgpu_gfx_off_ctrl(adev, false);
> +
> + /* A hung gfx stream can keep MES from suspending: reset anyway. */
> + amdgpu_mes_suspend(adev, 0);
> + amdgpu_userq_save_hqds(adev, AMDGPU_HW_IP_GFX);
> +
> + r = gfx_v11_0_soft_reset_gfx_cp(adev);
> + if (r) {
> + dev_err(adev->dev, "gfx CP still busy after reset, CP_STAT 0x%08x\n",
> + RREG32_SOC15(GC, 0, regCP_STAT));
> + goto fail;
> + }
> +
> + /* The reset cleared the HQD of the kernel gfx queue: map it again. */
> + r = amdgpu_gfx_disable_kgq(adev, 0);
> + if (r)
> + goto fail;
> + for (i = 0; i < adev->gfx.num_gfx_rings; i++)
> + amdgpu_gfx_mqd_reset_restore(&adev->gfx.gfx_ring[i]);
> + r = amdgpu_gfx_enable_kgq(adev, 0);
> + if (!r)
> + r = gfx_v11_0_cp_gfx_start(adev);
> + if (r)
> + goto fail;
> +
> + amdgpu_userq_restore_hqds(adev, AMDGPU_HW_IP_GFX, guilty_queue);
> + r = amdgpu_mes_resume(adev, 0);
[Severity: Medium]
Does this leave adev->gfx.gfx_ring[0] mapped on HQD 0 when
adev->gfx.disable_kq is true?
Unlike GFX12, gfx_v11_0_early_init() keeps adev->gfx.num_gfx_rings = 1
when disable_kq is set so gfx_v11_0_cp_gfx_start() can submit the clear
state on gfx_ring[0], while amdgpu_mes_init() gives HQD 0 to MES for user
queues. In gfx_v11_0_cp_resume(), the driver drains gfx_ring[0] and
unmaps it before user queues run:
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c:gfx_v11_0_cp_resume() {
...
if (adev->gfx.disable_kq) {
for (i = 0; i < adev->gfx.num_gfx_rings; i++) {
ring = &adev->gfx.gfx_ring[i];
/* we don't want to set ring->ready */
r = amdgpu_ring_test_ring(ring);
if (r)
return r;
}
amdgpu_gfx_disable_kgq(adev, 0);
}
...
}
Here, gfx_v11_0_soft_reset_engine() calls amdgpu_gfx_disable_kgq() while
gfx_ring[0] is already unmapped, then maps gfx_ring[0] and submits the
clear state without testing the ring or calling amdgpu_gfx_disable_kgq()
afterward, leaving the temporary kernel ring mapped on HQD 0 in conflict
with restored MES usermode queues.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261126093417.192538-1-Jesse.Zhang@amd.com?part=10
next prev parent reply other threads:[~2026-11-26 9:59 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-26 9:33 [PATCH v5 01/15] drm/amdgpu: pass the device to the multi ring reset helpers Jesse Zhang
2026-11-26 9:33 ` [PATCH v5 02/15] drm/amdgpu/ring: During multi-queue reset, only call begin helper if needed Jesse Zhang
2026-11-26 9:52 ` sashiko-bot
2026-11-26 9:33 ` [PATCH v5 03/15] drm/amdgpu: add an engine scope to the IP block soft reset Jesse Zhang
2026-11-26 10:00 ` sashiko-bot
2026-11-26 9:33 ` [PATCH v5 04/15] drm/amdgpu/gfx: add callbacks to save and restore a gfx HQD Jesse Zhang
2026-11-26 9:33 ` [PATCH v5 05/15] drm/amdgpu/gfx12: " Jesse Zhang
2026-11-26 9:33 ` [PATCH v5 06/15] drm/amdgpu/gfx11: " Jesse Zhang
2026-11-26 9:33 ` [PATCH v5 07/15] drm/amdgpu/userq: add a helper to signal the fences of a queue up to a point Jesse Zhang
2026-11-26 9:33 ` [PATCH v5 08/15] drm/amdgpu/userq: add helpers to keep the user queues of one engine across a reset Jesse Zhang
2026-11-26 10:03 ` sashiko-bot
2026-11-26 9:33 ` [PATCH v5 09/15] drm/amdgpu/gfx12: add a gfx engine soft reset Jesse Zhang
2026-11-26 9:57 ` sashiko-bot
2026-11-26 9:33 ` [PATCH v5 10/15] drm/amdgpu/gfx11: " Jesse Zhang
2026-11-26 9:59 ` sashiko-bot [this message]
2026-11-26 9:33 ` [PATCH v5 11/15] drm/amdgpu/gfx12: include SOFT_RESET_GFX in the " Jesse Zhang
2026-11-26 9:33 ` [PATCH v5 12/15] drm/amdgpu/gfx11: " Jesse Zhang
2026-11-26 9:57 ` sashiko-bot
2026-11-26 9:33 ` [PATCH v5 13/15] drm/amdgpu/userq: reset the gfx engine when a gfx user queue reset fails Jesse Zhang
2026-11-26 10:15 ` sashiko-bot
2026-11-26 9:33 ` [PATCH v5 14/15] drm/amdgpu/gfx12: enable the gfx engine soft reset Jesse Zhang
2026-11-26 9:33 ` [PATCH v5 15/15] drm/amdgpu/gfx11: " Jesse Zhang
2026-11-26 10:10 ` sashiko-bot
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=sashiko-outbox-235213@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=Jesse.Zhang@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=sashiko-reviews@lists.linux.dev \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox