From: sashiko-bot@kernel.org
To: "Jesse Zhang" <Jesse.Zhang@amd.com>, amd-gfx@lists.freedesktop.org
Subject: Re: [PATCH v5 15/15] drm/amdgpu/gfx11: enable the gfx engine soft reset
Date: Thu, 26 Nov 2026 10:10:03 +0000 [thread overview]
Message-ID: <sashiko-outbox-235249@kernel.org> (raw)
In-Reply-To: <20261126093417.192538-15-Jesse.Zhang@amd.com>
Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [High] drm/amdgpu: user queue race and UAF during
gfx_v11_0_soft_reset_engine()
- [Medium] drm/amdgpu/gfx11: missing pre-pulse CP_VMID_RESET clear in
soft reset
- [Medium] drm/amdgpu/gfx11: kernel gfx queue left mapped when
disable_kq is true
--
commit 37d8357ec5fb17ab702d211aa8fb7b20ac9e9a2a
Author: Jesse Zhang <Jesse.Zhang@amd.com>
drm/amdgpu/gfx11: enable the gfx engine soft reset
This commit enables AMDGPU_RESET_TYPE_IP_BLOCK_SOFT_RESET for GFX rings on
GC 11.5.1 and 11.5.3 when MES is enabled and SR-IOV VF is not active.
> diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c
> index 824d7914bece9..a878aaee1b74b 100644
> --- a/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c
> @@ -1965,6 +1965,13 @@ static int gfx_v11_0_sw_init(struct amdgpu_ip_block *ip_block)
> break;
> }
>
> + /* Only on the GC versions it was verified on */
> + if ((amdgpu_ip_version(adev, GC_HWIP, 0) == IP_VERSION(11, 5, 1) ||
> + amdgpu_ip_version(adev, GC_HWIP, 0) == IP_VERSION(11, 5, 3)) &&
> + !amdgpu_sriov_vf(adev) && adev->enable_mes &&
> + !adev->debug_disable_ip_block_soft_reset)
> + adev->gfx.gfx_supported_reset |= AMDGPU_RESET_TYPE_IP_BLOCK_SOFT_RESET;
> +
> if (!adev->enable_mes_kiq) {
> r = amdgpu_gfx_kiq_init(adev, GFX11_MEC_HPD_SIZE, 0);
> if (r) {
[Severity: High]
Can enabling engine soft reset cause a use-after-free on struct
amdgpu_usermode_queue in amdgpu_userq_save_hqds() and
amdgpu_userq_restore_hqds()?
When funcs->soft_reset_engine is set, amdgpu_device_ip_soft_reset() only
takes down_read(&adev->reset_domain->sem) before calling
gfx_v11_0_soft_reset_engine(). Because amdgpu_userq_detach_doorbell(),
amdgpu_userq_unmap_helper(), and amdgpu_userq_map_helper() also only take
down_read(&adev->reset_domain->sem), they are not blocked during an engine
soft reset.
Inside gfx_v11_0_soft_reset_engine(), amdgpu_userq_save_hqds() and
amdgpu_userq_restore_hqds() iterate adev->userq_doorbell_xa with
xa_for_each() without taking a reference on queue or locking
uq_mgr->userq_mutex:
CPU0 CPU1
amdgpu_device_ip_soft_reset()
down_read(&adev->reset_domain->sem)
gfx_v11_0_soft_reset_engine()
amdgpu_userq_restore_hqds()
xa_for_each(..., queue)
amdgpu_userq_destroy()
mutex_lock(&uq_mgr->userq_mutex)
amdgpu_userq_detach_doorbell()
down_read(&reset_domain->sem)
xa_erase(&userq_doorbell_xa, ...)
...
uq_funcs->mqd_destroy(queue)
kfree(queue)
userq_funcs->unmap(queue)
... <-- use-after-free
Concurrent eviction and restore workers (amdgpu_userq_evict_all() and
amdgpu_userq_restore_all()) also only take a read lock on
reset_domain->sem, so they can issue MES map/unmap requests and mutate
queue->state while MES is suspended and amdgpu_userq_restore_hqds() is
updating the queues without uq_mgr->userq_mutex.
[Severity: Medium]
Should gfx_v11_0_soft_reset_gfx_cp() clear regCP_VMID_RESET before pulsing
regGRBM_SOFT_RESET, as gfx_v12_0_soft_reset_gfx_cp() does?
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c:gfx_v11_0_soft_reset_gfx_cp() {
...
/* 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);
...
}
When a prior per-queue or per-pipe reset via mes_v11_0_reset_queue_mmio()
times out because PFP or ME is hung, the VMID reset request written to
regCP_VMID_RESET remains pending when fallback reaches
gfx_v11_0_soft_reset_gfx_cp(). gfx_v11_0_soft_reset_gfx_cp() only zeroes
regCP_VMID_RESET after the reset pulse, leaving the VMID reset active
during the CP soft reset and causing the soft reset to fail and escalate to
a full GPU reset.
[Severity: Medium]
Does gfx_v11_0_soft_reset_engine() leave the kernel GFX queue mapped when
adev->gfx.disable_kq is true?
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c:gfx_v11_0_soft_reset_engine() {
...
/* 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);
...
}
On GFX11, adev->gfx.num_gfx_rings is 1 even when adev->gfx.disable_kq is
true so gfx_ring[0] can be used to submit clear-state initialization
packets, after which gfx_v11_0_cp_resume() unmaps it via
amdgpu_gfx_disable_kgq(adev, 0) so MES can use pipe 0 queue 0 for user
queues. When a hung GFX user queue triggers gfx_v11_0_soft_reset_engine()
with disable_kq set, gfx_ring[0] is mapped with amdgpu_gfx_enable_kgq() and
never unmapped afterward, leaving the legacy kernel queue mapped on pipe 0
queue 0 in conflict with MES user queues.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261126093417.192538-1-Jesse.Zhang@amd.com?part=15
prev parent reply other threads:[~2026-11-26 10:10 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
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 [this message]
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-235249@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 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.