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.

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 <[email protected]>

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)


Reply via email to