Skip to contentSkip to conversation

drm/xe: Test for imported buffers with drm_gem_is_imported()

PATCH In review Thomas Zimmermann 2 participants 2 messages Apr 14, 2025 – Apr 15, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 10/11 drm/xe: Test for imported buffers with drm_gem_is_imported()

Instead of testing import_attach for imported GEM buffers, invoke drm_gem_is_imported() to do the test. The helper tests the dma_buf itself while import_attach is just an artifact of the import. Prepares to make import_attach optional.

---
 drivers/gpu/drm/xe/xe_bo.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/xe/xe_bo.c +4 -4
index c337790c81ae..adb69e0bbcb4 100644
@@ -749,7 +749,7 @@ static int xe_bo_move_notify(struct xe_bo *bo,
 		return ret;
 
 	/* Don't call move_notify() for imported dma-bufs. */
-	if (ttm_bo->base.dma_buf && !ttm_bo->base.import_attach)
+	if (ttm_bo->base.dma_buf && !drm_gem_is_imported(&ttm_bo->base))
 		dma_buf_move_notify(ttm_bo->base.dma_buf);
 
 	/*
@@ -1514,7 +1514,7 @@ static void xe_ttm_bo_destroy(struct ttm_buffer_object *ttm_bo)
 	struct xe_tile *tile;
 	u8 id;
 
-	if (bo->ttm.base.import_attach)
+	if (drm_gem_is_imported(&bo->ttm.base))
 		drm_prime_gem_destroy(&bo->ttm.base, NULL);
 	drm_gem_object_release(&bo->ttm.base);
 
@@ -2228,7 +2228,7 @@ int xe_bo_pin(struct xe_bo *bo)
 	 * No reason we can't support pinning imported dma-bufs we just don't
 	 * expect to pin an imported dma-buf.
 	 */
-	xe_assert(xe, !bo->ttm.base.import_attach);
+	xe_assert(xe, !drm_gem_is_imported(&bo->ttm.base));
 
 	/* We only expect at most 1 pin */
 	xe_assert(xe, !xe_bo_is_pinned(bo));
@@ -2298,7 +2298,7 @@ void xe_bo_unpin(struct xe_bo *bo)
 	struct ttm_place *place = &bo->placements[0];
 	struct xe_device *xe = xe_bo_device(bo);
 
-	xe_assert(xe, !bo->ttm.base.import_attach);
+	xe_assert(xe, !drm_gem_is_imported(&bo->ttm.base));
 	xe_assert(xe, xe_bo_is_pinned(bo));
 
 	if (mem_type_is_vram(place->mem_type) || bo->flags & XE_BO_FLAG_GGTT) {
Signature · 1 line
2.49.0
maintainer Reviewed-by on v1 10/11
#1 lore raw
Quoted 6 lines · Thomas Zimmermann

Instead of testing import_attach for imported GEM buffers, invoke drm_gem_is_imported() to do the test. The helper tests the dma_buf itself while import_attach is just an artifact of the import. Prepares
to make import_attach optional.

Quoted 6 lines
Quoted 48 lines

---
 drivers/gpu/drm/xe/xe_bo.c | 8 ++++----

 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/xe/xe_bo.c +0 -0
index c337790c81ae..adb69e0bbcb4 100644
@@ -749,7 +749,7 @@ static int xe_bo_move_notify(struct xe_bo *bo,
  		return ret;


  /* Don't call move_notify() for imported dma-bufs. */

drivers/gpu/drm/xe/xe_bo.c +1 -1
-	if (ttm_bo->base.dma_buf && !ttm_bo->base.import_attach)
+	if (ttm_bo->base.dma_buf && !drm_gem_is_imported(&ttm_bo-
Quoted 1 line

base))

  dma_buf_move_notify(ttm_bo->base.dma_buf);
  /*

drivers/gpu/drm/xe/xe_bo.c +0 -0
@@ -1514,7 +1514,7 @@ static void xe_ttm_bo_destroy(struct
 ttm_buffer_object *ttm_bo)
  	struct xe_tile *tile;
  	u8 id;

drivers/gpu/drm/xe/xe_bo.c +1 -1
-	if (bo->ttm.base.import_attach)
+	if (drm_gem_is_imported(&bo->ttm.base))

  drm_prime_gem_destroy(&bo->ttm.base, NULL); drm_gem_object_release(&bo->ttm.base);

drivers/gpu/drm/xe/xe_bo.c +0 -0
@@ -2228,7 +2228,7 @@ int xe_bo_pin(struct xe_bo *bo)
  	 * No reason we can't support pinning imported dma-bufs we

just don't
  * expect to pin an imported dma-buf.
  */

drivers/gpu/drm/xe/xe_bo.c +1 -1
-	xe_assert(xe, !bo->ttm.base.import_attach);
+	xe_assert(xe, !drm_gem_is_imported(&bo->ttm.base));


  /* We only expect at most 1 pin */
  xe_assert(xe, !xe_bo_is_pinned(bo));

drivers/gpu/drm/xe/xe_bo.c +0 -0
@@ -2298,7 +2298,7 @@ void xe_bo_unpin(struct xe_bo *bo)
  	struct ttm_place *place = &bo->placements[0];
  	struct xe_device *xe = xe_bo_device(bo);

drivers/gpu/drm/xe/xe_bo.c +1 -1
-	xe_assert(xe, !bo->ttm.base.import_attach);
+	xe_assert(xe, !drm_gem_is_imported(&bo->ttm.base));

  xe_assert(xe, xe_bo_is_pinned(bo));

  if (mem_type_is_vram(place->mem_type) || bo->flags & XE_BO_FLAG_GGTT) {