From: Dave Airlie <airlied@gmail.com>
To: dri-devel@lists.freedesktop.org
Cc: Dave Airlie <airlied@redhat.com>,
Christian Koenig <christian.koenig@amd.com>
Subject: [PATCH 2/4] amdgpu: populate buffers before exporting them.
Date: Thu, 4 Sep 2025 12:16:40 +1000 [thread overview]
Message-ID: <20250904021643.2050497-2-airlied@gmail.com> (raw)
In-Reply-To: <20250904021643.2050497-1-airlied@gmail.com>
From: Dave Airlie <airlied@redhat.com>
Before exporting a buffer, make sure it has been populated with
pages at least once.
Reviewed-by: Christian Koenig <christian.koenig@amd.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c
index ce27cb5bb05e..8561ad7f6180 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c
@@ -343,11 +343,23 @@ struct dma_buf *amdgpu_gem_prime_export(struct drm_gem_object *gobj,
{
struct amdgpu_bo *bo = gem_to_amdgpu_bo(gobj);
struct dma_buf *buf;
+ struct ttm_operation_ctx ctx = {
+ .interruptible = true,
+ .no_wait_gpu = true,
+ /* We opt to avoid OOM on system pages allocations */
+ .gfp_retry_mayfail = true,
+ .allow_res_evict = false,
+ };
+ int ret;
if (amdgpu_ttm_tt_get_usermm(bo->tbo.ttm) ||
bo->flags & AMDGPU_GEM_CREATE_VM_ALWAYS_VALID)
return ERR_PTR(-EPERM);
+ ret = ttm_bo_setup_export(&bo->tbo, &ctx);
+ if (ret)
+ return ERR_PTR(ret);
+
buf = drm_gem_prime_export(gobj, flags);
if (!IS_ERR(buf))
buf->ops = &amdgpu_dmabuf_ops;
--
2.50.1
next prev parent reply other threads:[~2025-09-04 2:17 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-04 2:16 [PATCH 1/4] ttm/bo: add an API to populate a bo before exporting Dave Airlie
2025-09-04 2:16 ` Dave Airlie [this message]
2025-09-04 2:16 ` [PATCH 3/4] nouveau: populate buffers before exporting them Dave Airlie
2025-09-09 7:33 ` Danilo Krummrich
2025-09-04 2:16 ` [PATCH 4/4] xe: " Dave Airlie
2025-09-04 7:26 ` Thomas Hellström
2025-09-04 7:20 ` [PATCH 1/4] ttm/bo: add an API to populate a bo before exporting Thomas Hellström
2025-09-04 11:13 ` Christian König
2025-09-09 7:31 ` Danilo Krummrich
2025-09-09 7:39 ` David Airlie
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=20250904021643.2050497-2-airlied@gmail.com \
--to=airlied@gmail.com \
--cc=airlied@redhat.com \
--cc=christian.koenig@amd.com \
--cc=dri-devel@lists.freedesktop.org \
/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.