From: sashiko-bot@kernel.org
To: "Perry Yuan" <perry.yuan@amd.com>, amd-gfx@lists.freedesktop.org
Subject: Re: [PATCH 3/3] drm/ttm: Narrow the eviction lock scope when adding move fences
Date: Tue, 01 Dec 2026 09:07:48 +0000 [thread overview]
Message-ID: <sashiko-outbox-242911@kernel.org> (raw)
In-Reply-To: <20261201090028.86494-3-perry.yuan@amd.com>
Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [High] drm/amdgpu: insufficient fence slot reservation in
amdgpu_dma_buf_move_notify() [1]
--
commit d22882cc6158883831770886db4d0852012b8d1a
Author: Perry Yuan <perry.yuan@amd.com>
drm/ttm: Narrow the eviction lock scope when adding move fences
This commit snapshots pending eviction fences under man->eviction_lock
and adds them to the BO's reservation object after releasing the lock.
> diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
> index 53c68e29ebc21..f833982073c6a 100644
> --- a/drivers/gpu/drm/ttm/ttm_bo.c
> +++ b/drivers/gpu/drm/ttm/ttm_bo.c
> @@ -908,33 +908,38 @@ void ttm_bo_unpin(struct ttm_buffer_object *bo)
> EXPORT_SYMBOL(ttm_bo_unpin);
>
> /*
> - * Add the pipelined eviction fencesto the BO as kernel dependency and reserve new
> - * fence slots.
> + * Add pending eviction fences to the BO as kernel dependencies and reserve
> + * new fence slots.
> */
> static int ttm_bo_add_pipelined_eviction_fences(struct ttm_buffer_object *bo,
> struct ttm_resource_manager *man,
> bool no_wait_gpu)
> {
> + struct dma_fence *fences[TTM_NUM_MOVE_FENCES];
> struct dma_fence *fence;
> - int i;
> + int i, count = 0;
>
> spin_lock(&man->eviction_lock);
> for (i = 0; i < TTM_NUM_MOVE_FENCES; i++) {
> fence = man->eviction_fences[i];
> - if (!fence)
> + if (!fence || dma_fence_is_signaled(fence))
> continue;
>
> if (no_wait_gpu) {
> - if (!dma_fence_is_signaled(fence)) {
> - spin_unlock(&man->eviction_lock);
> - return -EBUSY;
> - }
> - } else {
> - dma_resv_add_fence(bo->base.resv, fence, DMA_RESV_USAGE_KERNEL);
> + spin_unlock(&man->eviction_lock);
> + return -EBUSY;
> }
> +
> + /* The manager may replace this fence once we drop the lock. */
> + fences[count++] = dma_fence_get(fence);
> }
> spin_unlock(&man->eviction_lock);
>
> + for (i = 0; i < count; i++) {
> + dma_resv_add_fence(bo->base.resv, fences[i], DMA_RESV_USAGE_KERNEL);
> + dma_fence_put(fences[i]);
> + }
> +
> /* TODO: this call should be removed. */
> return dma_resv_reserve_fences(bo->base.resv, 1);
> }
[Severity: High]
This problem wasn't introduced by this patch, but can reserving only 1
fence slot here after consuming up to TTM_NUM_MOVE_FENCES slots hit the
BUG_ON() in dma_resv_add_fence() during amdgpu_dma_buf_move_notify()
[1]?
amdgpu_dma_buf_move_notify() reserves 2 fence slots on the VM root BO
reservation object for the page table update fence and the TLB flush
fence (when vm->need_tlb_fence is enabled). If amdgpu_vm_update_range()
allocates a new page table BO sharing that reservation object,
ttm_bo_alloc_resource() reserves TTM_NUM_MOVE_FENCES slots and
ttm_bo_add_pipelined_eviction_fences() can consume all
TTM_NUM_MOVE_FENCES of them before calling
dma_resv_reserve_fences(bo->base.resv, 1).
Because dma_resv_reserve_fences() is not additive, if the reservation
object started with TTM_NUM_MOVE_FENCES + 1 free slots, neither
reservation call reallocates the list and only 1 free slot remains after
BO creation. amdgpu_vm_sdma_commit() takes that slot for vm->delayed,
and amdgpu_vm_tlb_flush() then overflows fobj->max_fences when adding
vm->last_tlb_inv.
[1] https://sashiko.dev/#/bug/linux-8e6fd858-557e-4ca0-9558-be9bf089c7d4
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261201090028.86494-1-perry.yuan@amd.com?part=3
next prev parent reply other threads:[~2026-12-01 9:08 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-01 9:00 [PATCH 1/3] drm/amdgpu: keep PTL disable requests across GPU reset and resume Perry Yuan
2026-12-01 9:00 ` [PATCH 2/3] drm/amdkfd: Fix leaked PTL disable request on process exit Perry Yuan
2026-12-01 9:00 ` [PATCH 3/3] drm/ttm: Narrow the eviction lock scope when adding move fences Perry Yuan
2026-12-01 9:07 ` sashiko-bot [this message]
2026-12-01 13:40 ` 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-242911@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=amd-gfx@lists.freedesktop.org \
--cc=perry.yuan@amd.com \
--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.