diff --git a/lib/drmtest.c b/lib/drmtest.c index 70a124b8..2ddaff02 100644 --- a/lib/drmtest.c +++ b/lib/drmtest.c @@ -270,6 +270,21 @@ void gem_set_tiling(int fd, uint32_t handle, int tiling, int stride) assert(st.tiling_mode == tiling); } +#define LOCAL_I915_PARAM_HAS_VEBOX 22 +int gem_has_vebox(int fd) +{ + struct drm_i915_getparam gp; + int val; + + gp.param = LOCAL_I915_PARAM_HAS_VEBOX; + gp.value = &val; + + if (ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp, sizeof(gp))) + return 0; + + return val != 0; +} + struct local_drm_i915_gem_cacheing { uint32_t handle; uint32_t cacheing; diff --git a/lib/drmtest.h b/lib/drmtest.h index 78732a0a..f15c074c 100644 --- a/lib/drmtest.h +++ b/lib/drmtest.h @@ -47,6 +47,7 @@ int drm_open_any_master(void); void gem_quiescent_gpu(int fd); /* ioctl wrappers and similar stuff for bare metal testing */ +int gem_has_vebox(int fd); void gem_set_tiling(int fd, uint32_t handle, int tiling, int stride); int gem_has_cacheing(int fd); void gem_set_cacheing(int fd, uint32_t handle, int cacheing); diff --git a/tests/gem_ring_sync_loop.c b/tests/gem_ring_sync_loop.c index 3607fcae..7bb8cef9 100644 --- a/tests/gem_ring_sync_loop.c +++ b/tests/gem_ring_sync_loop.c @@ -55,7 +55,6 @@ static drm_intel_bo *target_buffer; #define MI_COND_BATCH_BUFFER_END (0x36<<23 | 1) #define MI_DO_COMPARE (1<<21) -#define LOCAL_I915_PARAM_HAS_VEBOX 22 static int get_num_rings(int fd) { @@ -82,10 +81,7 @@ get_num_rings(int fd) else goto skip; - gp.param = LOCAL_I915_PARAM_HAS_VEBOX; - ret = drmIoctl(fd, DRM_IOCTL_I915_GETPARAM, &gp); - - if ((ret == 0) & (*gp.value > 0)) + if (gem_has_vebox(fd)) num_rings++; else goto skip; diff --git a/tests/gem_storedw_loop_vebox.c b/tests/gem_storedw_loop_vebox.c index 2e8836da..9d7e22c1 100644 --- a/tests/gem_storedw_loop_vebox.c +++ b/tests/gem_storedw_loop_vebox.c @@ -46,7 +46,6 @@ static drm_intel_bufmgr *bufmgr; struct intel_batchbuffer *batch; static drm_intel_bo *target_buffer; -static int has_ppgtt = 0; /* * Testcase: Basic vebox MI check using MI_STORE_DATA_IMM @@ -59,8 +58,6 @@ store_dword_loop(int divider) uint32_t *buf; cmd = MI_STORE_DWORD_IMM; - if (!has_ppgtt) - cmd |= MI_MEM_VIRTUAL; for (i = 0; i < SLOW_QUICK(0x100000, 0x10); i++) { BEGIN_BATCH(4); @@ -103,28 +100,12 @@ cont: int main(int argc, char **argv) { int fd; - int devid; - - if (argc != 1) { - fprintf(stderr, "usage: %s\n", argv[0]); - exit(-1); - } fd = drm_open_any(); - devid = intel_get_drm_devid(fd); - - if (!HAS_VEBOX_RING(devid)) { - fprintf(stderr, "Doesn't have vebox ring\n"); - return 77; - } - - has_ppgtt = gem_uses_aliasing_ppgtt(fd); /* This only works with ppgtt */ - if (!has_ppgtt) { - fprintf(stderr, "no ppgtt detected, which is required\n"); + if (!gem_has_vebox(fd) || !gem_uses_aliasing_ppgtt(fd)) return 77; - } bufmgr = drm_intel_bufmgr_gem_init(fd, 4096); if (!bufmgr) { @@ -133,7 +114,7 @@ int main(int argc, char **argv) } drm_intel_bufmgr_gem_enable_reuse(bufmgr); - batch = intel_batchbuffer_alloc(bufmgr, devid); + batch = intel_batchbuffer_alloc(bufmgr, intel_get_drm_devid(fd)); if (!batch) { fprintf(stderr, "failed to create batch buffer\n"); exit(-1);