All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Benjamin Cheng" <benjamin.cheng@amd.com>, amd-gfx@lists.freedesktop.org
Subject: Re: [PATCH 1/3] drm/amdgpu/vm: stop using amdgpu_bo_fence
Date: Thu, 12 Nov 2026 17:22:09 +0000	[thread overview]
Message-ID: <sashiko-outbox-211584@kernel.org> (raw)
In-Reply-To: <20261112164408.1748006-1-benjamin.cheng@amd.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] drm/amdgpu/vm: insufficient fence slots in
  amdgpu_vm_update_range() after PT alloc
--

commit feeae3416bee7b1cf2e4fcd3fbeec98eb2fba53d
Author: Benjamin Cheng <benjamin.cheng@amd.com>

drm/amdgpu/vm: stop using amdgpu_bo_fence

This commit replaces amdgpu_bo_fence() in amdgpu_vm_update_range() with
dma_resv_reserve_fences() and dma_resv_add_fence() using
DMA_RESV_USAGE_BOOKKEEP.

> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> index 2ba33212d5071..2da64e2cfda47 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> @@ -1212,10 +1212,18 @@ int amdgpu_vm_update_range(struct amdgpu_device *adev, struct amdgpu_vm *vm,
>  	if (r)
>  		goto error_free;
>  
> +	if (!unlocked) {
> +		/* last_unlocked + SDMA commit + TLB flush */
> +		r = dma_resv_reserve_fences(vm->root.bo->tbo.base.resv, 3);
> +		if (r)
> +			goto error_free;
> +	}

[Severity: High]
Can reserving the SDMA commit and TLB flush fence slots before
amdgpu_vm_ptes_update() leave vm->root.bo->tbo.base.resv with no free
slot when a new page table BO is allocated?

When amdgpu_vm_ptes_update() allocates a new PT BO via
amdgpu_vm_pt_alloc(), the new BO shares vm->root.bo->tbo.base.resv.
During validation, ttm_bo_add_pipelined_eviction_fences() adds eviction
fences to that shared dma_resv and ends with:

drivers/gpu/drm/ttm/ttm_bo.c:ttm_bo_add_pipelined_eviction_fences() {
	...
	/* TODO: this call should be removed. */
	return dma_resv_reserve_fences(bo->base.resv, 1);
}

Because dma_resv_reserve_fences() is not additive, this only guarantees a
single free slot if the eviction fences filled all but one of the existing
slots.  amdgpu_vm_pt_alloc() then immediately calls amdgpu_vm_pt_clear(),
whose SDMA commit adds a fence on vm->delayed (or vm->immediate) without
reserving a slot, consuming that last free slot.

When amdgpu_vm_update_range() later calls vm->update_funcs->commit(), that
fence is replaced in-place on the same scheduler context, but
amdgpu_vm_tlb_flush() then adds a fence on vm->tlb_fence_context with zero
free slots remaining, hitting BUG_ON(fobj->num_fences >= fobj->max_fences)
in dma_resv_add_fence().

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261112164408.1748006-1-benjamin.cheng@amd.com?part=1

      parent reply	other threads:[~2026-11-12 17:22 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-14  2:21 [PATCH] drm/amdgpu: wait for tlb flush before freeing BO Benjamin Cheng
2026-10-14  7:17 ` Christian König
2026-10-14 12:46   ` Benjamin Cheng
2026-10-14 13:09     ` Christian König
2026-11-06 15:20 ` [PATCH v2] " Benjamin Cheng
2026-11-06 16:04   ` Christian König
2026-11-06 16:07     ` Benjamin Cheng
2026-11-09  9:58       ` Christian König
2026-11-09 14:57 ` [PATCH v3 1/2] " Benjamin Cheng
2026-11-09 14:57   ` [PATCH v3 2/2] drm/amdgpu/gem: use dma_resv_add_fence directly Benjamin Cheng
2026-11-09 15:00     ` Christian König
2026-11-09 15:02       ` Benjamin Cheng
2026-11-12 16:44 ` [PATCH 1/3] drm/amdgpu/vm: stop using amdgpu_bo_fence Benjamin Cheng
2026-11-12 16:44   ` [PATCH 2/3] drm/amdgpu/uvd: " Benjamin Cheng
2026-11-12 16:44   ` [PATCH 3/3] drm/amdgpu/object: get rid of amdgpu_bo_fence Benjamin Cheng
2026-11-12 16:52     ` sashiko-bot
2026-11-12 17:22   ` 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-211584@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=benjamin.cheng@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.