[Intel-gfx] [PATCH i-g-t] i915/gem_userptr: Be defensive when testing userptr capabilities

Chris Wilson chris at chris-wilson.co.uk
Mon Oct 7 07:37:29 UTC 2019


Not every device naturally supports snooping and userptr, so be prepared
for the initial probe to fail.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=111910
Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
---
 tests/i915/gem_userptr_blits.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/tests/i915/gem_userptr_blits.c b/tests/i915/gem_userptr_blits.c
index 2359c13f4..18e806fed 100644
--- a/tests/i915/gem_userptr_blits.c
+++ b/tests/i915/gem_userptr_blits.c
@@ -78,12 +78,14 @@ static uint32_t linear[WIDTH*HEIGHT];
 
 static bool has_gtt_mmap(int i915)
 {
-	void *ptr, *map;
+	void *ptr, *map = NULL;
 	uint32_t handle;
 
 	igt_assert(posix_memalign(&ptr, PAGE_SIZE, PAGE_SIZE) == 0);
 
-	gem_userptr(i915, ptr, 4096, 0, 0, &handle);
+	if (__gem_userptr(i915, ptr, 4096, 0,
+			  LOCAL_I915_USERPTR_UNSYNCHRONIZED, &handle))
+		goto out_ptr;
 	igt_assert(handle != 0);
 
 	map = __gem_mmap__gtt(i915, handle, 4096, PROT_WRITE);
@@ -91,6 +93,7 @@ static bool has_gtt_mmap(int i915)
 		munmap(map, 4096);
 
 	gem_close(i915, handle);
+out_ptr:
 	free(ptr);
 
 	return map != NULL;
-- 
2.23.0



More information about the Intel-gfx mailing list