From: Matthew Brost <matthew.brost@intel.com>
To: Niranjana Vishwanathapura <niranjana.vishwanathapura@intel.com>
Cc: <dri-devel@lists.freedesktop.org>, <intel-xe@lists.freedesktop.org>
Subject: Re: [PATCH 2/2] drm/xe/dma-buf: Use drm helper to detect dma-buf self-import
Date: Mon, 12 Oct 2026 14:59:51 -0700 [thread overview]
Message-ID: <as1YV/cwS0BdxCJC@gsse-cloud1.jf.intel.com> (raw)
In-Reply-To: <20261012180543.1488703-6-niranjana.vishwanathapura@intel.com>
On Mon, Oct 12, 2026 at 11:05:43AM -0700, Niranjana Vishwanathapura wrote:
> From: Farah Kassabri <farah.kassabri@intel.com>
>
> Instead of driver-specific code, use the new drm helper
> drm_gem_prime_self_import() to detect self-import of a dma-buf in Xe.
>
> Expose the helper within Xe as xe_dma_buf_to_gem() for future use.
>
> Signed-off-by: Farah Kassabri <farah.kassabri@intel.com>
> Signed-off-by: Niranjana Vishwanathapura <niranjana.vishwanathapura@intel.com>
Reviewed-by: Matthew Brost <matthew.brost@intel.com>
> ---
> drivers/gpu/drm/xe/xe_dma_buf.c | 23 +++++++++++++----------
> drivers/gpu/drm/xe/xe_dma_buf.h | 2 ++
> 2 files changed, 15 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/gpu/drm/xe/xe_dma_buf.c b/drivers/gpu/drm/xe/xe_dma_buf.c
> index 6a85b292dee7..4e1b447f4235 100644
> --- a/drivers/gpu/drm/xe/xe_dma_buf.c
> +++ b/drivers/gpu/drm/xe/xe_dma_buf.c
> @@ -239,6 +239,12 @@ static const struct dma_buf_ops xe_dmabuf_ops = {
> .vunmap = drm_gem_dmabuf_vunmap,
> };
>
> +struct drm_gem_object *xe_dma_buf_to_gem(struct drm_device *dev,
> + struct dma_buf *dma_buf)
> +{
> + return drm_gem_prime_self_import(dev, dma_buf, &xe_dmabuf_ops);
> +}
> +
> struct dma_buf *xe_gem_prime_export(struct drm_gem_object *obj, int flags)
> {
> struct xe_bo *bo = gem_to_xe_bo(obj);
> @@ -372,17 +378,14 @@ struct drm_gem_object *xe_gem_prime_import(struct drm_device *dev,
> struct dma_buf_attachment *attach;
> struct drm_gem_object *obj;
>
> - if (dma_buf->ops == &xe_dmabuf_ops) {
> - obj = dma_buf->priv;
> - if (obj->dev == dev &&
> - !XE_TEST_ONLY(test && test->force_different_devices)) {
> - /*
> - * Importing dmabuf exported from out own gem increases
> - * refcount on gem itself instead of f_count of dmabuf.
> - */
> - drm_gem_object_get(obj);
> + obj = xe_dma_buf_to_gem(dev, dma_buf);
> + if (obj) {
> + if (!XE_TEST_ONLY(test && test->force_different_devices))
> return obj;
> - }
> +
> + /* Test only: force different devices */
> + drm_gem_object_put(obj);
> + obj = NULL;
> }
>
> /*
> diff --git a/drivers/gpu/drm/xe/xe_dma_buf.h b/drivers/gpu/drm/xe/xe_dma_buf.h
> index 861dd28a862c..d0c7893a5a6f 100644
> --- a/drivers/gpu/drm/xe/xe_dma_buf.h
> +++ b/drivers/gpu/drm/xe/xe_dma_buf.h
> @@ -8,6 +8,8 @@
>
> #include <drm/drm_gem.h>
>
> +struct drm_gem_object *xe_dma_buf_to_gem(struct drm_device *dev,
> + struct dma_buf *dma_buf);
> struct dma_buf *xe_gem_prime_export(struct drm_gem_object *obj, int flags);
> struct drm_gem_object *xe_gem_prime_import(struct drm_device *dev,
> struct dma_buf *dma_buf);
> --
> 2.43.0
>
next prev parent reply other threads:[~2026-10-12 22:00 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-12 18:05 [PATCH 0/2] drm: add a self-import PRIME dma-buf helper and use it in Xe Niranjana Vishwanathapura
2026-10-12 18:05 ` [PATCH 1/2] drm/gem: add helper to detect self-imported PRIME dma-bufs Niranjana Vishwanathapura
2026-10-12 21:58 ` Matthew Brost
2026-10-12 18:05 ` [PATCH 2/2] drm/xe/dma-buf: Use drm helper to detect dma-buf self-import Niranjana Vishwanathapura
2026-10-12 21:59 ` Matthew Brost [this message]
2026-10-12 20:47 ` ✓ CI.KUnit: success for drm: add a self-import PRIME dma-buf helper and use it in Xe Patchwork
2026-10-13 0:40 ` ✓ Xe.CI.BAT: " Patchwork
2026-10-13 8:22 ` ✓ Xe.CI.FULL: " Patchwork
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=as1YV/cwS0BdxCJC@gsse-cloud1.jf.intel.com \
--to=matthew.brost@intel.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-xe@lists.freedesktop.org \
--cc=niranjana.vishwanathapura@intel.com \
/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.