From: sashiko-bot@kernel.org
To: "Arunpravin Paneer Selvam" <Arunpravin.PaneerSelvam@amd.com>,
amd-gfx@lists.freedesktop.org
Subject: Re: [PATCH v2 2/3] drm/amdgpu: Reset cleared state of free VRAM after GPU reset
Date: Mon, 30 Nov 2026 12:34:43 +0000 [thread overview]
Message-ID: <sashiko-outbox-241064@kernel.org> (raw)
In-Reply-To: <20261130121049.26541-2-Arunpravin.PaneerSelvam@amd.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] drm/amdgpu: race on gpu_reset_counter in
amdgpu_vram_mgr_check_reset()
--
commit e2f6a53587f6a83dcd78a77fe71d3295729bf04a
Author: Arunpravin Paneer Selvam <Arunpravin.PaneerSelvam@amd.com>
drm/amdgpu: Reset cleared state of free VRAM after GPU reset
This commit tracks adev->gpu_reset_counter in struct amdgpu_vram_mgr and
resets the cleared state of free VRAM buddy blocks during allocation and
free when the counter has changed.
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
> index 249f07f309515..d947e048952d2 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
> @@ -431,6 +431,17 @@ int amdgpu_vram_mgr_query_address_block_info(struct amdgpu_vram_mgr *mgr,
> return ret;
> }
>
> +static void amdgpu_vram_mgr_check_reset(struct amdgpu_device *adev,
> + struct amdgpu_vram_mgr *mgr)
> +{
> + int reset_counter = atomic_read(&adev->gpu_reset_counter);
> +
> + if (unlikely(mgr->gpu_reset_counter != reset_counter)) {
> + gpu_buddy_reset_clear(&mgr->mm, false);
> + mgr->gpu_reset_counter = reset_counter;
> + }
> +}
[Severity: Medium]
Can amdgpu_vram_mgr_check_reset() update mgr->gpu_reset_counter out of
order with an in-progress GPU reset and leave unwiped or lost VRAM blocks
marked as GPU_BUDDY_HEADER_CLEAR?
Neither amdgpu_vram_mgr_new() nor amdgpu_vram_mgr_del() serializes
against adev->reset_domain->sem, and adev->gpu_reset_counter is updated
at two points that race with BO release and eviction:
1. During full GPU recovery, amdgpu_device_halt_activities() increments
adev->gpu_reset_counter before amdgpu_do_asic_reset() resets the hardware
and before amdgpu_device_reinit_after_reset() calls
amdgpu_inc_vram_lost():
CPU0 CPU1
amdgpu_device_gpu_recover()
amdgpu_device_halt_activities()
atomic_inc(&gpu_reset_counter)
/* counter is now N + 1 */
amdgpu_bo_release_notify()
amdgpu_ttm_clear_buffer()
amdgpu_job_alloc()
/* captures old vram_lost */
amdgpu_vram_mgr_set_cleared()
/* records N + 1 */
amdgpu_do_asic_reset()
amdgpu_device_reinit_after_reset()
amdgpu_inc_vram_lost()
amdgpu_device_sched_resume()
amdgpu_job_run()
/* skips clear job: generation != vm_generation */
ttm_bo_delayed_delete()
amdgpu_vram_mgr_del()
amdgpu_vram_mgr_check_reset()
mgr->gpu_reset_counter = N + 1
gpu_buddy_free_list(..., CLEARED)
<-- unwiped block marked clear
For pipelined eviction via amdgpu_move_blit() ->
ttm_bo_move_pipeline_evict(), amdgpu_vram_mgr_del() runs immediately in
the window between amdgpu_device_halt_activities() and
amdgpu_do_asic_reset(), consuming N + 1 and marking the freed blocks
cleared before the hardware reset wipes VRAM or cancels the clear job.
2. During per-queue or IP soft reset in amdgpu_job_timedout(),
amdgpu_ring_reset() and amdgpu_device_ip_soft_reset() invoke
amdgpu_ring_reset_helper_end() ->
amdgpu_ring_set_fence_errors_and_reemit() and drm_sched_wqueue_start()
before atomic_inc(&ring->adev->gpu_reset_counter):
drivers/gpu/drm/amd/amdgpu/amdgpu_job.c:amdgpu_job_timedout() {
...
r = amdgpu_ring_reset(ring, job->vmid, job->hw_fence);
if (!r) {
/* Start the scheduler again */
drm_sched_wqueue_start(&ring->sched);
atomic_inc(&ring->adev->gpu_reset_counter);
...
}
When a clear job's fence is force-completed or re-emitted as NOPs inside
amdgpu_ring_set_fence_errors_and_reemit(), ttm_bo_delayed_delete() ->
amdgpu_vram_mgr_del() can run on another CPU before gpu_reset_counter is
incremented, freeing the unwiped blocks as cleared while
adev->gpu_reset_counter still holds the pre-reset value. Subsequent
AMDGPU_GEM_CREATE_VRAM_CLEARED allocations will then skip clearing in
amdgpu_ttm_clear_buffer() and expose stale VRAM contents.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261130121049.26541-1-Arunpravin.PaneerSelvam@amd.com?part=2
next prev parent reply other threads:[~2026-11-30 12:34 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-30 12:10 [PATCH v2 1/3] drm/amdgpu: Don't let clear jobs inherit entity errors Arunpravin Paneer Selvam
2026-11-30 12:10 ` [PATCH v2 2/3] drm/amdgpu: Reset cleared state of free VRAM after GPU reset Arunpravin Paneer Selvam
2026-11-30 12:34 ` sashiko-bot [this message]
2026-11-30 12:10 ` [PATCH v2 3/3] drm/amdgpu: Don't free VRAM as cleared if its wipe predates a " Arunpravin Paneer Selvam
2026-11-30 12:34 ` sashiko-bot
2026-11-30 15:58 ` Christian König
2026-11-30 15:51 ` [PATCH v2 1/3] drm/amdgpu: Don't let clear jobs inherit entity errors Christian König
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-241064@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=Arunpravin.PaneerSelvam@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.