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 <[email protected]> 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/[email protected]?part=2
