diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2021-01-05 21:23:18 +0000 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2021-01-06 01:13:33 +0000 |
commit | ac697f7bb9b4c2db92084d1a691be4a8a68d335f (patch) | |
tree | b1aae00f9de614acb32046e4c860573d120790f2 /tests/i915/gem_spin_batch.c | |
parent | 97f6913862e48814ea3ef25f486ffa6ffd79eb1b (diff) |
i915/gem_spin_batch: Check for userptr before use
If the device cannot handle coherent memory, it will disallow userptr.
Check before use.
Closes: https://gitlab.freedesktop.org/drm/intel/-/issues/2904
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Acked-by: Mika Kuoppala <mika.kuoppala@linux.intel.com>
Diffstat (limited to 'tests/i915/gem_spin_batch.c')
-rw-r--r-- | tests/i915/gem_spin_batch.c | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/tests/i915/gem_spin_batch.c b/tests/i915/gem_spin_batch.c index c2ce2373..2ec27885 100644 --- a/tests/i915/gem_spin_batch.c +++ b/tests/i915/gem_spin_batch.c @@ -176,6 +176,25 @@ static void spin_all(int i915, unsigned int flags) } } +static bool has_userptr(int fd) +{ + struct drm_i915_gem_userptr userptr; + int err; + + memset(&userptr, 0, sizeof(userptr)); + userptr.user_size = 8192; + userptr.user_ptr = -4096; + + err = 0; + if (drmIoctl(fd, DRM_IOCTL_I915_GEM_USERPTR, &userptr)) { + err = errno; + igt_assume(err); + } + errno = 0; + + return err == EFAULT; +} + igt_main { const struct intel_execution_engine2 *e2; @@ -235,8 +254,10 @@ igt_main igt_subtest("spin-each") spin_on_all_engines(fd, 0, 3); - igt_subtest("user-each") + igt_subtest("user-each") { + igt_require(has_userptr(fd)); spin_on_all_engines(fd, IGT_SPIN_USERPTR, 3); + } igt_fixture { igt_stop_hang_detector(); |