AMD-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Jesse Zhang" <Jesse.Zhang@amd.com>, amd-gfx@lists.freedesktop.org
Subject: Re: [PATCH v5 02/15] drm/amdgpu/ring: During multi-queue reset, only call begin helper if needed
Date: Thu, 26 Nov 2026 09:52:25 +0000	[thread overview]
Message-ID: <sashiko-outbox-235187@kernel.org> (raw)
In-Reply-To: <20261126093417.192538-2-Jesse.Zhang@amd.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] drm/amdgpu: ring->guilty_fence check in
  amdgpu_multi_ring_reset_helper_begin()
--

commit 142729efa2e6db09ea45e10147ee07f2ee131c88
Author: Timur Kristóf <timur.kristof@gmail.com>

drm/amdgpu/ring: During multi-queue reset, only call begin helper if needed

This commit skips calling amdgpu_ring_reset_helper_begin() in
amdgpu_multi_ring_reset_helper_begin() when ring == guilty_ring and
ring->guilty_fence == guilty_fence, to preserve the ring backup from a
prior failed per-queue reset.

> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c
> index edae764eb0c42..c71e1c3b6d7bb 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c
> @@ -1027,8 +1027,10 @@ void amdgpu_multi_ring_reset_helper_begin(struct amdgpu_device *adev,
>  		 * Backup current contents of the ring.
>  		 * The helper takes care to only reemit unsignalled fences
>  		 * so we don't have to worry about that here.
> +		 * A failed ring reset of the same job already backed it up.
>  		 */
> -		amdgpu_ring_reset_helper_begin(ring, ring_guilty_fence);
> +		if (ring != guilty_ring || ring->guilty_fence != guilty_fence)
> +			amdgpu_ring_reset_helper_begin(ring, ring_guilty_fence);
>  	}
>  }

[Severity: High]
Can checking ring->guilty_fence == guilty_fence distinguish an unconsumed
backup from a failed queue reset in the current timeout from a prior reset
of the same fence that already completed?

amdgpu_ring_set_fence_errors_and_reemit() leaves ring->guilty_fence and
ring->ring_backup_entries_to_copy unchanged after re-emitting a ring so
that amdgpu_ring_backup_unprocessed_commands() can detect a second timeout
of the same fence and stop replaying:

drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c:amdgpu_ring_backup_unprocessed_commands() {
	...
	ring->ring_backup_entries_to_copy = 0;

	if (guilty_fence && ring->guilty_fence == guilty_fence) {
		ring->guilty_fence = NULL;
		return;
	}
	ring->guilty_fence = guilty_fence;
	...
}

When a soft reset succeeds and the re-emitted command stream times out
again before guilty_fence signals, ring->guilty_fence is still
guilty_fence. Skipping amdgpu_ring_reset_helper_begin() bypasses that check
and leaves ring->ring_backup_entries_to_copy at its previous non-zero count,
so amdgpu_multi_ring_reset_helper_end() keeps re-emitting the stale backup
in an infinite soft-reset loop. If new jobs were submitted after
drm_sched_wqueue_start() at the end of the first reset, their fences
advance ring->fence_drv.sync_seq without being backed up;
amdgpu_ring_set_fence_errors_and_reemit() then allocates the smaller stale
ring_backup_entries_to_copy DWord count while re-emitting all unsignaled
fences up to sync_seq, underflowing ring->count_dw and re-emitting stale
commands from ring->ring_backup[0..] for the new jobs.

Conversely, if a second timeout runs a per-queue reset first,
amdgpu_ring_backup_unprocessed_commands() sees ring->guilty_fence ==
guilty_fence and clears ring->guilty_fence to NULL; if that per-queue reset
then fails and falls back to amdgpu_device_ip_soft_reset(), this condition
sees ring->guilty_fence != guilty_fence and backs up the ring again instead
of terminating the replay loop. Also, if an engine-wide per-ring reset
callback (such as amdgpu_sdma_reset_queue_legacy() or
amdgpu_vcn_ring_reset()) fails after calling
amdgpu_ring_reset_helper_begin() on a collateral ring with a non-NULL
ring_guilty_fence, this condition still calls
amdgpu_ring_reset_helper_begin() for ring != guilty_ring and clears that
collateral ring's backup.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261126093417.192538-1-Jesse.Zhang@amd.com?part=2

  reply	other threads:[~2026-11-26  9:52 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 [this message]
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

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-235187@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