Skip to contentSkip to conversation

tests/xe: Use NEEDS_VISIBLE_VRAM flag

PATCH Superseded Lukasz Laguna 2 participants 6 messages Jun 16, 2025

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover tests/xe: Use NEEDS_VISIBLE_VRAM flag

Set DRM_XE_GEM_CREATE_FLAG_NEEDS_VISIBLE_VRAM flag when creating BOs that will be CPU-mapped, to ensure that the corresponding VRAM allocation will use the CPU accessible part of VRAM.

This is essential for small-bar systems, where omitting the flag may cause failures or SIGBUS crashes due to the CPU accessing non-visible VRAM.

Additionally, in xe_exec_atomic test, replace I915_GEM_CREATE_EXT_FLAG_NEEDS_CPU_ACCESS with the correct DRM_XE_GEM_CREATE_FLAG_NEEDS_VISIBLE_VRAM.

v2: Split patches (Kamil)

Lukasz Laguna (2):
tests/intel/xe_*: Use NEEDS_VISIBLE_VRAM flag where it's missing tests/intel/xe_exec_atomic: Fix incorrect GEM create flag

 tests/intel/xe_exec_atomic.c | 2 +-
 tests/intel/xe_pat.c         | 3 ++-
 tests/intel/xe_spin_batch.c  | 3 ++-
 3 files changed, 5 insertions(+), 3 deletions(-)
Signature · 1 line
2.40.0
#1 lore raw

PATCH v2 1/2 tests/intel/xe_*: Use NEEDS_VISIBLE_VRAM flag where it's missing

Set DRM_XE_GEM_CREATE_FLAG_NEEDS_VISIBLE_VRAM flag when creating BOs that will be CPU-mapped, to ensure that the corresponding VRAM allocation will use the CPU accessible part of VRAM.

This is essential for small-bar systems, where omitting the flag may cause failures or SIGBUS crashes due to the CPU accessing non-visible VRAM.

---
 tests/intel/xe_pat.c        | 3 ++-
 tests/intel/xe_spin_batch.c | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)
tests/intel/xe_pat.c +2 -1
index 88d8de9dd..8bb0ac167 100644
@@ -582,7 +582,8 @@ static void prime_self_import_coh(void)
 	fd1 = drm_open_driver(DRIVER_XE);
 	fd2 = drm_open_driver(DRIVER_XE);
 
-	dst_handle = xe_bo_create_caching(fd1, 0, size, all_memory_regions(fd1), 0,
+	dst_handle = xe_bo_create_caching(fd1, 0, size, all_memory_regions(fd1),
+					  DRM_XE_GEM_CREATE_FLAG_NEEDS_VISIBLE_VRAM,
 					  DRM_XE_GEM_CPU_CACHING_WC);
 
 	dma_buf_fd = prime_handle_to_fd(fd1, dst_handle);
tests/intel/xe_spin_batch.c +2 -1
index 21b08ba06..48a888e35 100644
@@ -442,7 +442,8 @@ static void exec_store(int fd, struct drm_xe_engine_class_instance *eci,
 	vm = xe_vm_create(fd, 0, 0);
 	exec_queue = xe_exec_queue_create(fd, vm, eci, 0);
 	bb_size = xe_bb_size(fd, sizeof(*data));
-	bb = xe_bo_create(fd, vm, bb_size, vram_if_possible(fd, eci->gt_id), 0);
+	bb = xe_bo_create(fd, vm, bb_size, vram_if_possible(fd, eci->gt_id),
+			  DRM_XE_GEM_CREATE_FLAG_NEEDS_VISIBLE_VRAM);
 	bb_addr = intel_allocator_alloc_with_strategy(ahnd, bb, bb_size, 0,
 						      ALLOC_STRATEGY_LOW_TO_HIGH);
 	data = xe_bo_map(fd, bb, bb_size);
Signature · 1 line
2.40.0
Reviewed-by on v2 1/2
#2 lore raw

Re: [PATCH i-g-t v2 1/2] tests/intel/xe_*: Use NEEDS_VISIBLE_VRAM flag where it's missing

Quoted 10 lines · Lukasz Laguna

Set DRM_XE_GEM_CREATE_FLAG_NEEDS_VISIBLE_VRAM flag when creating BOs that will be CPU-mapped, to ensure that the corresponding VRAM allocation will use the CPU accessible part of VRAM.

This is essential for small-bar systems, where omitting the flag may cause failures or SIGBUS crashes due to the CPU accessing non-visible VRAM.

Quoted 33 lines
---
  tests/intel/xe_pat.c        | 3 ++-
  tests/intel/xe_spin_batch.c | 3 ++-
  2 files changed, 4 insertions(+), 2 deletions(-)
tests/intel/xe_pat.c +2 -1
index 88d8de9dd..8bb0ac167 100644
@@ -582,7 +582,8 @@ static void prime_self_import_coh(void)
  	fd1 = drm_open_driver(DRIVER_XE);
  	fd2 = drm_open_driver(DRIVER_XE);
 
-	dst_handle = xe_bo_create_caching(fd1, 0, size, all_memory_regions(fd1), 0,
+	dst_handle = xe_bo_create_caching(fd1, 0, size, all_memory_regions(fd1),
+					  DRM_XE_GEM_CREATE_FLAG_NEEDS_VISIBLE_VRAM,
  					  DRM_XE_GEM_CPU_CACHING_WC);
 
  	dma_buf_fd = prime_handle_to_fd(fd1, dst_handle);
tests/intel/xe_spin_batch.c +2 -1
index 21b08ba06..48a888e35 100644
@@ -442,7 +442,8 @@ static void exec_store(int fd, struct drm_xe_engine_class_instance *eci,
  	vm = xe_vm_create(fd, 0, 0);
  	exec_queue = xe_exec_queue_create(fd, vm, eci, 0);
  	bb_size = xe_bb_size(fd, sizeof(*data));
-	bb = xe_bo_create(fd, vm, bb_size, vram_if_possible(fd, eci->gt_id), 0);
+	bb = xe_bo_create(fd, vm, bb_size, vram_if_possible(fd, eci->gt_id),
+			  DRM_XE_GEM_CREATE_FLAG_NEEDS_VISIBLE_VRAM);
  	bb_addr = intel_allocator_alloc_with_strategy(ahnd, bb, bb_size, 0,
  						      ALLOC_STRATEGY_LOW_TO_HIGH);
  	data = xe_bo_map(fd, bb, bb_size);
#3 lore raw

Re: [PATCH i-g-t v2 1/2] tests/intel/xe_*: Use NEEDS_VISIBLE_VRAM flag where it's missing

Quoted 5 lines · Matthew Auld
Quoted 4 lines · Lukasz Laguna

Set DRM_XE_GEM_CREATE_FLAG_NEEDS_VISIBLE_VRAM flag when creating BOs that will be CPU-mapped, to ensure that the corresponding VRAM allocation will use the CPU accessible part of VRAM.

Quoted 9 lines
Quoted 6 lines

This is essential for small-bar systems, where omitting the flag may cause failures or SIGBUS crashes due to the CPU accessing non-visible VRAM.

Thanks for review. It turned out that few other tests need the same fix, so I've sent another version. If you have a minute, please take a look:
https://patchwork.freedesktop.org/series/150313/#rev2

Quoted 36 lines
Quoted 35 lines

---
  tests/intel/xe_pat.c        | 3 ++-
  tests/intel/xe_spin_batch.c | 3 ++-

  2 files changed, 4 insertions(+), 2 deletions(-)
tests/intel/xe_pat.c +2 -0
index 88d8de9dd..8bb0ac167 100644
@@ -582,7 +582,8 @@ static void prime_self_import_coh(void)
       fd1 = drm_open_driver(DRIVER_XE);
       fd2 = drm_open_driver(DRIVER_XE);
   -    dst_handle = xe_bo_create_caching(fd1, 0, size, all_memory_regions(fd1), 0,
+    dst_handle = xe_bo_create_caching(fd1, 0, size, 
 all_memory_regions(fd1),
+ DRM_XE_GEM_CREATE_FLAG_NEEDS_VISIBLE_VRAM,
                         DRM_XE_GEM_CPU_CACHING_WC);
         dma_buf_fd = prime_handle_to_fd(fd1, dst_handle);
tests/intel/xe_spin_batch.c +2 -1
index 21b08ba06..48a888e35 100644
@@ -442,7 +442,8 @@ static void exec_store(int fd, struct 
 drm_xe_engine_class_instance *eci,
       vm = xe_vm_create(fd, 0, 0);
       exec_queue = xe_exec_queue_create(fd, vm, eci, 0);
       bb_size = xe_bb_size(fd, sizeof(*data));
-    bb = xe_bo_create(fd, vm, bb_size, vram_if_possible(fd, 
 eci->gt_id), 0);
+    bb = xe_bo_create(fd, vm, bb_size, vram_if_possible(fd, 
 eci->gt_id),
+              DRM_XE_GEM_CREATE_FLAG_NEEDS_VISIBLE_VRAM);

      bb_addr = intel_allocator_alloc_with_strategy(ahnd, bb, bb_size, 0, ALLOC_STRATEGY_LOW_TO_HIGH); data = xe_bo_map(fd, bb, bb_size);

#4 lore raw

PATCH v2 2/2 tests/intel/xe_exec_atomic: Fix incorrect GEM create flag

In reply to Lukasz Laguna

Replace I915_GEM_CREATE_EXT_FLAG_NEEDS_CPU_ACCESS with the correct DRM_XE_GEM_CREATE_FLAG_NEEDS_VISIBLE_VRAM.

---
 tests/intel/xe_exec_atomic.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tests/intel/xe_exec_atomic.c +1 -1
index 825d7d190..39c739b64 100644
@@ -85,7 +85,7 @@ static void basic_inst(int fd, int inst_type, struct drm_xe_engine_class_instanc
 	bo_size = xe_bb_size(fd, bo_size);
 
 	bo = xe_bo_create(fd, vm, bo_size, placement,
-			  I915_GEM_CREATE_EXT_FLAG_NEEDS_CPU_ACCESS);
+			  DRM_XE_GEM_CREATE_FLAG_NEEDS_VISIBLE_VRAM);
 
 	exec_queue = xe_exec_queue_create(fd, vm, eci, 0);
 	bind_engine = xe_bind_exec_queue_create(fd, vm, 0);
Signature · 1 line
2.40.0
Reviewed-by on v2 2/2
#5 lore raw

Re: [PATCH i-g-t v2 2/2] tests/intel/xe_exec_atomic: Fix incorrect GEM create flag

Quoted 5 lines · Lukasz Laguna

Replace I915_GEM_CREATE_EXT_FLAG_NEEDS_CPU_ACCESS with the correct DRM_XE_GEM_CREATE_FLAG_NEEDS_VISIBLE_VRAM.

Quoted 17 lines
---
  tests/intel/xe_exec_atomic.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
tests/intel/xe_exec_atomic.c +1 -1
index 825d7d190..39c739b64 100644
@@ -85,7 +85,7 @@ static void basic_inst(int fd, int inst_type, struct drm_xe_engine_class_instanc
  	bo_size = xe_bb_size(fd, bo_size);
 
  	bo = xe_bo_create(fd, vm, bo_size, placement,
-			  I915_GEM_CREATE_EXT_FLAG_NEEDS_CPU_ACCESS);
+			  DRM_XE_GEM_CREATE_FLAG_NEEDS_VISIBLE_VRAM);
 
  	exec_queue = xe_exec_queue_create(fd, vm, eci, 0);
  	bind_engine = xe_bind_exec_queue_create(fd, vm, 0);