From: Niranjana Vishwanathapura <niranjana.vishwanathapura@intel.com>
To: Thomas Zimmermann <tzimmermann@suse.de>
Cc: <dri-devel@lists.freedesktop.org>,
<intel-xe@lists.freedesktop.org>, <matthew.brost@intel.com>
Subject: Re: [PATCH v2 0/6] drm: consolidate self-imported PRIME dma-buf detection
Date: Wed, 14 Oct 2026 10:34:40 -0700 [thread overview]
Message-ID: <as-9MFZcI9DR5HWI@nvishwa1-desk> (raw)
In-Reply-To: <6184d9de-0936-43ad-b9c9-496fc65212d9@suse.de>
On Wed, Oct 14, 2026 at 09:31:00AM +0200, Thomas Zimmermann wrote:
>Hi
>
>Am 13.10.26 um 20:29 schrieb Niranjana Vishwanathapura:
>>On Tue, Oct 13, 2026 at 09:17:17AM +0200, Thomas Zimmermann wrote:
>>>Hi,
>>>
>>>I don't think we should merge this series.
>>>
>>>Testing for the functions struct is a hack, which we do because it
>>>works in practice. We don't any other good identifier for the
>>>source of the imported dma_buf. We want to hide this from the
>>>outside world as much as possible. Putting it into an exported
>>>interface goes in the wrong direction.
>>>
>>
>>Ok, I understand. Given it is just a utility function that is helpful
>>across drivers, would defining drm_gem_prime_self_import() as a static
>>inline helper in drm_prime.h is permissible?
>
>It's not about the EXPORT_SYMBOL. Please see my reply to Matthew for
>details.
>
>I think it would be OK to do something like this in the header file:
>
>static inline bool __drm_gem_is_exported_dma_buf(dev, ops, dma_buf)
>{
> /* do the prime test here, but with the given ops. */
>}
>
>Double-underscore prefix in symbols means 'implementation detail'. The
>existing drm_gem_is_prime_exported_dma_buf() can be implemented on
>top; existing callers should continue to use
>drm_gem_prime_eported_dma_buf(). Other drivers can use the new helper
>for the test, as they use the same logic internally.
>
drm_gem_is_prime_exported_dma_buf() do not take object reference.
The code duplicated in multliple drivers take object reference. So, we
need the helper routine to take object reference.
Niranjana
>Best regards
>Thomas
>
>
>>
>>Niranjana
>>
>>>Best regards
>>>Thomas
>>>
>>>
>>>Am 13.10.26 um 03:06 schrieb Niranjana Vishwanathapura:
>>>>Detecting that a PRIME dma-buf being imported was exported by the same
>>>>DRM device is a pattern currently open-coded in many drivers (compare
>>>>dma_buf->ops against the driver's own ops, check obj->dev == dev, then
>>>>return the GEM object with an extra reference). This series adds
>>>>generic
>>>>helpers for it and converts several drivers to use them.
>>>>
>>>>Patch 1 adds drm_gem_prime_self_import(dev, dma_buf, ops): for a
>>>>dma-buf
>>>>self-exported via the given ops, it returns the backing GEM object with
>>>>a reference, letting a driver short-circuit the generic PRIME
>>>>import and
>>>>skip the extra dma-buf file reference. Patch 2 converts Xe to it.
>>>>
>>>>Patch 3 adds drm_gem_prime_dma_buf_to_gem(), a thin wrapper that
>>>>uses the
>>>>core PRIME ops, and replaces the
>>>>drm_gem_is_prime_exported_dma_buf() bool
>>>>predicate with it so the shmem importer resolves the object directly
>>>>(the sole caller already wanted the referenced object).
>>>>
>>>>Patches 4-6 convert panthor, panfrost and amdgpu to
>>>>drm_gem_prime_self_import(), removing the duplicated open-coded checks.
>>>>
>>>>No intended functional change.
>>>>
>>>>Assisted-by: GitHub-Copilot:claude-opus-4.8
>>>>Signed-off-by: Niranjana Vishwanathapura
>>>><niranjana.vishwanathapura@intel.com>
>>>>
>>>>Farah Kassabri (2):
>>>> drm/gem: add helper to detect self-imported PRIME dma-bufs
>>>> drm/xe/dma-buf: Use drm helper to detect dma-buf self-import
>>>>
>>>>Niranjana Vishwanathapura (4):
>>>> drm/gem: add drm_gem_prime_dma_buf_to_gem() self-import helper
>>>> drm/panthor: use drm_gem_prime_self_import() helper
>>>> drm/panfrost: use drm_gem_prime_self_import() helper
>>>> drm/amdgpu: use drm_gem_prime_self_import() helper
>>>>
>>>> drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c | 14 +---
>>>> drivers/gpu/drm/drm_gem_shmem_helper.c | 14 ++--
>>>> drivers/gpu/drm/drm_prime.c | 74 +++++++++++++++------
>>>> drivers/gpu/drm/panfrost/panfrost_gem.c | 10 +--
>>>> drivers/gpu/drm/panthor/panthor_gem.c | 10 +--
>>>> drivers/gpu/drm/xe/xe_dma_buf.c | 23 ++++---
>>>> drivers/gpu/drm/xe/xe_dma_buf.h | 2 +
>>>> include/drm/drm_prime.h | 8 ++-
>>>> 8 files changed, 91 insertions(+), 64 deletions(-)
>>>>
>>>
>>>--
>>>--
>>>Thomas Zimmermann
>>>Graphics Driver Developer
>>>SUSE Software Solutions Germany GmbH
>>>Frankenstr. 146, 90461 Nürnberg, Germany, www.suse.com
>>>GF: Stefan Gaiser, Jochen Jaser, Abhinav Puri, (HRB 36809, AG Nürnberg)
>>>
>>>
>
>--
>--
>Thomas Zimmermann
>Graphics Driver Developer
>SUSE Software Solutions Germany GmbH
>Frankenstr. 146, 90461 Nürnberg, Germany, www.suse.com
>GF: Stefan Gaiser, Jochen Jaser, Abhinav Puri, (HRB 36809, AG Nürnberg)
>
>
next prev parent reply other threads:[~2026-10-14 17:34 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-13 1:06 [PATCH v2 0/6] drm: consolidate self-imported PRIME dma-buf detection Niranjana Vishwanathapura
2026-10-13 1:06 ` [PATCH v2 1/6] drm/gem: add helper to detect self-imported PRIME dma-bufs Niranjana Vishwanathapura
2026-10-13 1:06 ` [PATCH v2 2/6] drm/xe/dma-buf: Use drm helper to detect dma-buf self-import Niranjana Vishwanathapura
2026-10-13 1:06 ` [PATCH v2 3/6] drm/gem: add drm_gem_prime_dma_buf_to_gem() self-import helper Niranjana Vishwanathapura
2026-10-13 1:36 ` Matthew Brost
2026-10-13 7:17 ` Thomas Zimmermann
2026-10-13 18:37 ` Matthew Brost
2026-10-14 7:22 ` Thomas Zimmermann
2026-10-13 1:06 ` [PATCH v2 4/6] drm/panthor: use drm_gem_prime_self_import() helper Niranjana Vishwanathapura
2026-10-13 1:06 ` [PATCH v2 5/6] drm/panfrost: " Niranjana Vishwanathapura
2026-10-13 1:06 ` [PATCH v2 6/6] drm/amdgpu: " Niranjana Vishwanathapura
2026-10-13 1:38 ` [PATCH v2 0/6] drm: consolidate self-imported PRIME dma-buf detection Matthew Brost
2026-10-13 7:17 ` Thomas Zimmermann
2026-10-13 18:29 ` Niranjana Vishwanathapura
2026-10-14 7:31 ` Thomas Zimmermann
2026-10-14 17:34 ` Niranjana Vishwanathapura [this message]
2026-10-14 19:09 ` Niranjana Vishwanathapura
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=as-9MFZcI9DR5HWI@nvishwa1-desk \
--to=niranjana.vishwanathapura@intel.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-xe@lists.freedesktop.org \
--cc=matthew.brost@intel.com \
--cc=tzimmermann@suse.de \
/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.