tests/xe: Use NEEDS_VISIBLE_VRAM flag
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
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
@@ -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
@@ -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
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_VRAMflag 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.
Suggested-by Matthew Auld <[email protected]>Signed-off-by Lukasz Laguna <[email protected]>
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@@ -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@@ -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);
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_VRAMflag 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.
Suggested-by Matthew Auld <[email protected]>Signed-off-by Lukasz Laguna <[email protected]>Reviewed-by Matthew Auld <[email protected]>
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@@ -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@@ -442,7 +442,8 @@ static void exec_store(int fd, structdrm_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);
PATCH v2 2/2 tests/intel/xe_exec_atomic: Fix incorrect GEM create flag
In reply to Lukasz LagunaReplace 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
@@ -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
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_ACCESSwith the correctDRM_XE_GEM_CREATE_FLAG_NEEDS_VISIBLE_VRAM.Suggested-by Matthew Auld <[email protected]>Signed-off-by Lukasz Laguna <[email protected]>
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@@ -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 );