Detecting that a PRIME dma-buf being imported was exported by the same DRM device is a common pattern currently open-coded in drivers. This series factors it into a generic helper and converts Xe to use it.
Patch 1 adds drm_gem_prime_self_import(): when the dma-buf originates from the importing device and uses the expected dma-buf ops, it returns the backing GEM object with an extra reference, letting drivers short- circuit the generic PRIME import path and skip the extra dma-buf file reference. Patch 2 replaces Xe's driver-specific self-import detection with the new helper, exposed within Xe as xe_dma_buf_to_gem() for future use. 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 drivers/gpu/drm/drm_prime.c | 48 +++++++++++++++++++++++++++------ drivers/gpu/drm/xe/xe_dma_buf.c | 23 +++++++++------- drivers/gpu/drm/xe/xe_dma_buf.h | 2 ++ include/drm/drm_prime.h | 4 +++ 4 files changed, 59 insertions(+), 18 deletions(-) -- 2.43.0
