On 9/23/26 23:28, Mukul Joshi wrote:
> An imported dma-buf BO backed by a VRAM-capable exporter holds no host
> pages of its own, yet when validated into TTM_PL_TT it is charged against
> the GTT page budget; importing many such buffers can exhaust that budget
> and fail with -ENOMEM even though no host memory is used. Set
> AMDGPU_GEM_CREATE_PREEMPTIBLE on these imports so they land in the PREEMPT
> domain instead, which is GTT-like and still bound (keeping the exporter
> resident) but carries no host-page limit.
>
> Signed-off-by: Mukul Joshi <[email protected]>
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c
> index 4031ebe075d8..5bac2474af03 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c
> @@ -472,6 +472,15 @@ amdgpu_dma_buf_create_obj(struct drm_device *dev, struct
> dma_buf *dma_buf)
> AMDGPU_GEM_CREATE_COHERENT |
> AMDGPU_GEM_CREATE_EXT_COHERENT |
> AMDGPU_GEM_CREATE_UNCACHED);
> +
> + /*
> + * A VRAM-capable import is backed by the exporter's device
> + * memory, not host pages of its own. Place it in the PREEMPT
> + * domain (GTT-like, but with no host-page budget) so many such
> + * imports cannot exhaust the GTT limit.
> + */
> + if (other->preferred_domains & AMDGPU_GEM_DOMAIN_VRAM)
> + flags |= AMDGPU_GEM_CREATE_PREEMPTIBLE;
You also need to check if the attachment results in P2P access, otherwise the
DMA-buf will be moved to system memory.
Take a look at the amdgpu_gem_prime_import(), since the BO is not published yet
just unconditionally clearing the AMDGPU_GEM_CREATE_PREEMPTIBLE flag there
again should do the trick.
Apart from that looks good to me,
Christian.
> }
>
> ret = amdgpu_gem_object_create(adev, dma_buf->size, PAGE_SIZE,