summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2020-05-05 12:34:03 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2020-05-07 14:19:37 +0100
commitce0ec5c84bb4beaf578d96ea50c90d798aee11cd (patch)
treeae8f4c0640ebdb714c86831c0613170c8f7548df
parent50868ab3c532a86aa147fb555b69a1078c572b13 (diff)
lib/i915: Split igt_require_gem() into i915/
igt_require_gem() is a pecularity of i915/, move it out of the core. Similar opportunistic move of gem_reopen_driver() and gem_quiescent_gpu(). Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r--lib/Makefile.sources2
-rw-r--r--lib/drmtest.c22
-rw-r--r--lib/drmtest.h2
-rw-r--r--lib/i915/gem.c117
-rw-r--r--lib/i915/gem.h33
-rw-r--r--lib/i915/gem_ring.c1
-rw-r--r--lib/i915/gem_submission.c22
-rw-r--r--lib/i915/gem_submission.h2
-rw-r--r--lib/i915/gem_vm.h1
-rw-r--r--lib/igt_debugfs.c5
-rw-r--r--lib/igt_dummyload.c11
-rw-r--r--lib/igt_gt.c3
-rw-r--r--lib/ioctl_wrappers.c49
-rw-r--r--lib/ioctl_wrappers.h1
-rw-r--r--lib/meson.build1
-rw-r--r--tests/amdgpu/amd_prime.c7
-rw-r--r--tests/core_hotunplug.c1
-rw-r--r--tests/debugfs_test.c2
-rw-r--r--tests/i915/gem_bad_blit.c4
-rw-r--r--tests/i915/gem_bad_reloc.c4
-rw-r--r--tests/i915/gem_blits.c1
-rw-r--r--tests/i915/gem_busy.c3
-rw-r--r--tests/i915/gem_caching.c3
-rw-r--r--tests/i915/gem_close.c1
-rw-r--r--tests/i915/gem_close_race.c4
-rw-r--r--tests/i915/gem_concurrent_all.c5
-rw-r--r--tests/i915/gem_create.c6
-rw-r--r--tests/i915/gem_cs_prefetch.c1
-rw-r--r--tests/i915/gem_cs_tlb.c4
-rw-r--r--tests/i915/gem_ctx_clone.c5
-rw-r--r--tests/i915/gem_ctx_create.c4
-rw-r--r--tests/i915/gem_ctx_engines.c4
-rw-r--r--tests/i915/gem_ctx_exec.c3
-rw-r--r--tests/i915/gem_ctx_freq.c1
-rw-r--r--tests/i915/gem_ctx_isolation.c1
-rw-r--r--tests/i915/gem_ctx_param.c1
-rw-r--r--tests/i915/gem_ctx_persistence.c3
-rw-r--r--tests/i915/gem_ctx_ringsize.c3
-rw-r--r--tests/i915/gem_ctx_shared.c4
-rw-r--r--tests/i915/gem_ctx_sseu.c4
-rw-r--r--tests/i915/gem_ctx_switch.c4
-rw-r--r--tests/i915/gem_ctx_thrash.c6
-rw-r--r--tests/i915/gem_eio.c3
-rw-r--r--tests/i915/gem_evict_alignment.c3
-rw-r--r--tests/i915/gem_evict_everything.c4
-rw-r--r--tests/i915/gem_exec_alignment.c3
-rw-r--r--tests/i915/gem_exec_async.c1
-rw-r--r--tests/i915/gem_exec_await.c9
-rw-r--r--tests/i915/gem_exec_bad_domains.c4
-rw-r--r--tests/i915/gem_exec_balancer.c3
-rw-r--r--tests/i915/gem_exec_big.c4
-rw-r--r--tests/i915/gem_exec_capture.c1
-rw-r--r--tests/i915/gem_exec_create.c4
-rw-r--r--tests/i915/gem_exec_fence.c11
-rw-r--r--tests/i915/gem_exec_flush.c1
-rw-r--r--tests/i915/gem_exec_gttfill.c1
-rw-r--r--tests/i915/gem_exec_latency.c3
-rw-r--r--tests/i915/gem_exec_lut_handle.c4
-rw-r--r--tests/i915/gem_exec_nop.c12
-rw-r--r--tests/i915/gem_exec_parallel.c1
-rw-r--r--tests/i915/gem_exec_params.c8
-rw-r--r--tests/i915/gem_exec_reloc.c1
-rw-r--r--tests/i915/gem_exec_schedule.c3
-rw-r--r--tests/i915/gem_exec_store.c4
-rw-r--r--tests/i915/gem_exec_suspend.c1
-rw-r--r--tests/i915/gem_exec_whisper.c1
-rw-r--r--tests/i915/gem_fenced_exec_thrash.c1
-rw-r--r--tests/i915/gem_gpgpu_fill.c4
-rw-r--r--tests/i915/gem_gtt_hog.c3
-rw-r--r--tests/i915/gem_linear_blits.c3
-rw-r--r--tests/i915/gem_media_fill.c4
-rw-r--r--tests/i915/gem_media_vme.c4
-rw-r--r--tests/i915/gem_mmap_gtt.c1
-rw-r--r--tests/i915/gem_mmap_offset.c1
-rw-r--r--tests/i915/gem_non_secure_batch.c6
-rw-r--r--tests/i915/gem_partial_pwrite_pread.c3
-rw-r--r--tests/i915/gem_pipe_control_store_loop.c4
-rw-r--r--tests/i915/gem_ppgtt.c5
-rw-r--r--tests/i915/gem_pread_after_blit.c3
-rw-r--r--tests/i915/gem_pwrite_snooped.c4
-rw-r--r--tests/i915/gem_read_read_speed.c5
-rw-r--r--tests/i915/gem_render_copy.c5
-rw-r--r--tests/i915/gem_render_copy_redux.c3
-rw-r--r--tests/i915/gem_render_linear_blits.c3
-rw-r--r--tests/i915/gem_render_tiled_blits.c3
-rw-r--r--tests/i915/gem_request_retire.c3
-rw-r--r--tests/i915/gem_reset_stats.c5
-rw-r--r--tests/i915/gem_ringfill.c3
-rw-r--r--tests/i915/gem_set_tiling_vs_blt.c4
-rw-r--r--tests/i915/gem_shrink.c1
-rw-r--r--tests/i915/gem_softpin.c1
-rw-r--r--tests/i915/gem_spin_batch.c1
-rw-r--r--tests/i915/gem_streaming_writes.c4
-rw-r--r--tests/i915/gem_sync.c1
-rw-r--r--tests/i915/gem_tiled_blits.c3
-rw-r--r--tests/i915/gem_tiled_fence_blits.c1
-rw-r--r--tests/i915/gem_tiled_partial_pwrite_pread.c3
-rw-r--r--tests/i915/gem_unfence_active_buffers.c4
-rw-r--r--tests/i915/gem_unref_active_buffers.c4
-rw-r--r--tests/i915/gem_userptr_blits.c3
-rw-r--r--tests/i915/gem_vm_create.c3
-rw-r--r--tests/i915/gem_wait.c1
-rw-r--r--tests/i915/gem_workarounds.c5
-rw-r--r--tests/i915/gen3_mixed_blits.c5
-rw-r--r--tests/i915/gen3_render_linear_blits.c5
-rw-r--r--tests/i915/gen3_render_mixed_blits.c5
-rw-r--r--tests/i915/gen3_render_tiledx_blits.c5
-rw-r--r--tests/i915/gen3_render_tiledy_blits.c3
-rw-r--r--tests/i915/gen7_exec_parse.c3
-rw-r--r--tests/i915/gen9_exec_parse.c3
-rw-r--r--tests/i915/i915_hangman.c3
-rw-r--r--tests/i915/i915_pm_rc6_residency.c1
-rw-r--r--tests/i915/i915_pm_rpm.c1
-rw-r--r--tests/i915/i915_pm_rps.c1
-rw-r--r--tests/i915/i915_pm_sseu.c5
-rw-r--r--tests/i915/i915_suspend.c3
-rw-r--r--tests/i915/sysfs_heartbeat_interval.c8
-rw-r--r--tests/i915/sysfs_preempt_timeout.c8
-rw-r--r--tests/i915/sysfs_timeslice_duration.c5
-rw-r--r--tests/kms_busy.c5
-rw-r--r--tests/kms_cursor_legacy.c1
-rw-r--r--tests/kms_draw_crc.c1
-rw-r--r--tests/kms_fence_pin_leak.c3
-rw-r--r--tests/kms_flip_tiling.c4
-rw-r--r--tests/kms_frontbuffer_tracking.c7
-rw-r--r--tests/perf.c3
-rw-r--r--tests/perf_pmu.c3
-rw-r--r--tests/prime_busy.c5
-rw-r--r--tests/prime_mmap_coherency.c1
-rw-r--r--tests/prime_vgem.c6
130 files changed, 432 insertions, 237 deletions
diff --git a/lib/Makefile.sources b/lib/Makefile.sources
index 1e2c88ae..6449574c 100644
--- a/lib/Makefile.sources
+++ b/lib/Makefile.sources
@@ -3,6 +3,8 @@ lib_source_list = \
drmtest.c \
drmtest.h \
i830_reg.h \
+ i915/gem.c \
+ i915/gem.h \
i915/gem_context.c \
i915/gem_context.h \
i915/gem_engine_topology.c \
diff --git a/lib/drmtest.c b/lib/drmtest.c
index d6ee39e0..85f96ae1 100644
--- a/lib/drmtest.c
+++ b/lib/drmtest.c
@@ -48,6 +48,7 @@
#include "drmtest.h"
#include "i915_drm.h"
+#include "i915/gem.h"
#include "intel_chipset.h"
#include "intel_io.h"
#include "igt_debugfs.h"
@@ -162,27 +163,6 @@ static const char *forced_driver(void)
return NULL;
}
-#define LOCAL_I915_EXEC_VEBOX (4 << 0)
-/**
- * gem_quiescent_gpu:
- * @fd: open i915 drm file descriptor
- *
- * Ensure the gpu is idle by launching a nop execbuf and stalling for it. This
- * is automatically run when opening a drm device node and is also installed as
- * an exit handler to have the best assurance that the test is run in a pristine
- * and controlled environment.
- *
- * This function simply allows tests to make additional calls in-between, if so
- * desired.
- */
-void gem_quiescent_gpu(int fd)
-{
- igt_terminate_spins();
-
- igt_drop_caches_set(fd,
- DROP_ACTIVE | DROP_RETIRE | DROP_IDLE | DROP_FREED);
-}
-
static int modprobe(const char *driver)
{
return igt_kmod_load(driver, "");
diff --git a/lib/drmtest.h b/lib/drmtest.h
index d5f0fc25..c56bfafa 100644
--- a/lib/drmtest.h
+++ b/lib/drmtest.h
@@ -94,8 +94,6 @@ int __drm_open_driver_another(int idx, int chipset);
int __drm_open_driver(int chipset);
int __drm_open_driver_render(int chipset);
-void gem_quiescent_gpu(int fd);
-
void igt_require_amdgpu(int fd);
void igt_require_intel(int fd);
void igt_require_vc4(int fd);
diff --git a/lib/i915/gem.c b/lib/i915/gem.c
new file mode 100644
index 00000000..cabd2376
--- /dev/null
+++ b/lib/i915/gem.c
@@ -0,0 +1,117 @@
+/*
+ * Copyright © 2007,2014,2020 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ *
+ */
+
+#include <fcntl.h>
+#include <sys/ioctl.h>
+
+#include "i915/gem.h"
+#include "igt.h"
+#include "igt_debugfs.h"
+#include "igt_sysfs.h"
+
+static void reset_device(int i915)
+{
+ int dir;
+
+ dir = igt_debugfs_dir(i915);
+ igt_require(dir >= 0);
+
+ if (ioctl(i915, DRM_IOCTL_I915_GEM_THROTTLE)) {
+ igt_info("Found wedged device, trying to reset and continue\n");
+ igt_sysfs_set(dir, "i915_wedged", "-1");
+ }
+ igt_sysfs_set(dir, "i915_next_seqno", "1");
+
+ close(dir);
+}
+
+void igt_require_gem(int i915)
+{
+ int err;
+
+ igt_require_intel(i915);
+
+ /*
+ * We only want to use the throttle-ioctl for its -EIO reporting
+ * of a wedged device, not for actually waiting on outstanding
+ * requests! So create a new drm_file for the device that is clean.
+ */
+ i915 = gem_reopen_driver(i915);
+
+ /*
+ * Reset the global seqno at the start of each test. This ensures that
+ * the test will not wrap unless it explicitly sets up seqno wrapping
+ * itself, which avoids accidentally hanging when setting up long
+ * sequences of batches.
+ */
+ reset_device(i915);
+
+ err = 0;
+ if (ioctl(i915, DRM_IOCTL_I915_GEM_THROTTLE)) {
+ err = -errno;
+ igt_assume(err);
+ }
+
+ close(i915);
+
+ igt_require_f(err == 0, "Unresponsive i915/GEM device\n");
+}
+
+/**
+ * gem_quiescent_gpu:
+ * @i915: open i915 drm file descriptor
+ *
+ * Ensure the gpu is idle by launching a nop execbuf and stalling for it. This
+ * is automatically run when opening a drm device node and is also installed as
+ * an exit handler to have the best assurance that the test is run in a pristine
+ * and controlled environment.
+ *
+ * This function simply allows tests to make additional calls in-between, if so
+ * desired.
+ */
+void gem_quiescent_gpu(int i915)
+{
+ igt_terminate_spins();
+
+ igt_drop_caches_set(i915,
+ DROP_ACTIVE | DROP_RETIRE | DROP_IDLE | DROP_FREED);
+}
+
+/**
+ * gem_reopen_driver:
+ * @i915: re-open the i915 drm file descriptor
+ *
+ * Re-opens the drm fd which is useful in instances where a clean default
+ * context is needed.
+ */
+int gem_reopen_driver(int i915)
+{
+ char path[256];
+
+ snprintf(path, sizeof(path), "/proc/self/fd/%d", i915);
+ i915 = open(path, O_RDWR);
+ igt_assert_fd(i915);
+
+ return i915;
+}
diff --git a/lib/i915/gem.h b/lib/i915/gem.h
new file mode 100644
index 00000000..e5403f09
--- /dev/null
+++ b/lib/i915/gem.h
@@ -0,0 +1,33 @@
+/*
+ * Copyright © 2007,2014,2020 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ *
+ */
+
+#ifndef I915_GEM_H
+#define I915_GEM_H
+
+void igt_require_gem(int i915);
+void gem_quiescent_gpu(int i915);
+
+int gem_reopen_driver(int i915);
+
+#endif /* I915_GEM_H */
diff --git a/lib/i915/gem_ring.c b/lib/i915/gem_ring.c
index 99f4741c..a57bf4c5 100644
--- a/lib/i915/gem_ring.c
+++ b/lib/i915/gem_ring.c
@@ -26,6 +26,7 @@
#include <sys/ioctl.h>
#include <sys/time.h>
+#include "gem.h"
#include "gem_ring.h"
#include "gem_submission.h"
diff --git a/lib/i915/gem_submission.c b/lib/i915/gem_submission.c
index 72de0c22..c5adcdc7 100644
--- a/lib/i915/gem_submission.c
+++ b/lib/i915/gem_submission.c
@@ -28,7 +28,9 @@
#include <i915_drm.h>
+#include "i915/gem.h"
#include "i915/gem_engine_topology.h"
+#include "i915/gem_submission.h"
#include "igt_core.h"
#include "igt_gt.h"
@@ -37,8 +39,6 @@
#include "intel_reg.h"
#include "ioctl_wrappers.h"
-#include "i915/gem_submission.h"
-
/**
* SECTION:gem_submission
* @short_description: Helpers for determining submission method
@@ -159,24 +159,6 @@ bool gem_has_guc_submission(int fd)
return gem_submission_method(fd) & GEM_SUBMISSION_GUC;
}
-/**
- * gem_reopen_driver:
- * @fd: re-open the i915 drm file descriptor
- *
- * Re-opens the drm fd which is useful in instances where a clean default
- * context is needed.
- */
-int gem_reopen_driver(int fd)
-{
- char path[256];
-
- snprintf(path, sizeof(path), "/proc/self/fd/%d", fd);
- fd = open(path, O_RDWR);
- igt_assert_fd(fd);
-
- return fd;
-}
-
static bool is_wedged(int i915)
{
int err = 0;
diff --git a/lib/i915/gem_submission.h b/lib/i915/gem_submission.h
index acd24bcb..b030ed9f 100644
--- a/lib/i915/gem_submission.h
+++ b/lib/i915/gem_submission.h
@@ -48,6 +48,4 @@ void gem_require_blitter(int i915);
void gem_test_engine(int fd, unsigned int engine);
-int gem_reopen_driver(int fd);
-
#endif /* GEM_SUBMISSION_H */
diff --git a/lib/i915/gem_vm.h b/lib/i915/gem_vm.h
index 27af899d..acbb663e 100644
--- a/lib/i915/gem_vm.h
+++ b/lib/i915/gem_vm.h
@@ -24,6 +24,7 @@
#ifndef GEM_VM_H
#define GEM_VM_H
+#include <stdbool.h>
#include <stdint.h>
bool gem_has_vm(int i915);
diff --git a/lib/igt_debugfs.c b/lib/igt_debugfs.c
index 9e6c5c99..05067078 100644
--- a/lib/igt_debugfs.c
+++ b/lib/igt_debugfs.c
@@ -1110,13 +1110,10 @@ static int get_object_count(int fd)
*/
int igt_get_stable_obj_count(int driver)
{
- int obj_count;
- gem_quiescent_gpu(driver);
- obj_count = get_object_count(driver);
/* The test relies on the system being in the same state before and
* after the test so any difference in the object count is a result of
* leaks during the test. */
- return obj_count;
+ return get_object_count(driver);
}
void __igt_debugfs_dump(int device, const char *filename, int level)
diff --git a/lib/igt_dummyload.c b/lib/igt_dummyload.c
index ae0fb937..d4cc9be6 100644
--- a/lib/igt_dummyload.c
+++ b/lib/igt_dummyload.c
@@ -30,19 +30,20 @@
#include <i915_drm.h>
-#include "igt_core.h"
#include "drmtest.h"
+#include "i915/gem.h"
+#include "i915/gem_engine_topology.h"
+#include "i915/gem_mman.h"
+#include "i915/gem_submission.h"
+#include "igt_core.h"
#include "igt_device.h"
#include "igt_dummyload.h"
#include "igt_gt.h"
+#include "igt_vgem.h"
#include "intel_chipset.h"
#include "intel_reg.h"
#include "ioctl_wrappers.h"
#include "sw_sync.h"
-#include "igt_vgem.h"
-#include "i915/gem_engine_topology.h"
-#include "i915/gem_mman.h"
-#include "i915/gem_submission.h"
/**
* SECTION:igt_dummyload
diff --git a/lib/igt_gt.c b/lib/igt_gt.c
index 256c7cbc..64b62c8c 100644
--- a/lib/igt_gt.c
+++ b/lib/igt_gt.c
@@ -32,6 +32,8 @@
#include <fcntl.h>
#include "drmtest.h"
+#include "i915/gem.h"
+#include "i915/gem_engine_topology.h"
#include "igt_aux.h"
#include "igt_core.h"
#include "igt_gt.h"
@@ -41,7 +43,6 @@
#include "intel_reg.h"
#include "intel_chipset.h"
#include "igt_dummyload.h"
-#include "i915/gem_engine_topology.h"
/**
* SECTION:igt_gt
diff --git a/lib/ioctl_wrappers.c b/lib/ioctl_wrappers.c
index 25d04b3e..61f93bd8 100644
--- a/lib/ioctl_wrappers.c
+++ b/lib/ioctl_wrappers.c
@@ -1158,55 +1158,6 @@ void gem_require_caching(int fd)
errno = 0;
}
-static void reset_device(int fd)
-{
- int dir;
-
- dir = igt_debugfs_dir(fd);
- igt_require(dir >= 0);
-
- if (ioctl(fd, DRM_IOCTL_I915_GEM_THROTTLE)) {
- igt_info("Found wedged device, trying to reset and continue\n");
- igt_sysfs_set(dir, "i915_wedged", "-1");
- }
- igt_sysfs_set(dir, "i915_next_seqno", "1");
-
- close(dir);
-}
-
-void igt_require_gem(int fd)
-{
- char path[256];
- int err;
-
- igt_require_intel(fd);
-
- /*
- * We only want to use the throttle-ioctl for its -EIO reporting
- * of a wedged device, not for actually waiting on outstanding
- * requests! So create a new drm_file for the device that is clean.
- */
- snprintf(path, sizeof(path), "/proc/self/fd/%d", fd);
- fd = open(path, O_RDWR);
- igt_assert_lte(0, fd);
-
- /*
- * Reset the global seqno at the start of each test. This ensures that
- * the test will not wrap unless it explicitly sets up seqno wrapping
- * itself, which avoids accidentally hanging when setting up long
- * sequences of batches.
- */
- reset_device(fd);
-
- err = 0;
- if (ioctl(fd, DRM_IOCTL_I915_GEM_THROTTLE))
- err = -errno;
-
- close(fd);
-
- igt_require_f(err == 0, "Unresponsive i915/GEM device\n");
-}
-
/**
* gem_require_ring:
* @fd: open i915 drm file descriptor
diff --git a/lib/ioctl_wrappers.h b/lib/ioctl_wrappers.h
index 799d9026..9f1f5c5c 100644
--- a/lib/ioctl_wrappers.h
+++ b/lib/ioctl_wrappers.h
@@ -120,7 +120,6 @@ void gem_sw_finish(int fd, uint32_t handle);
bool gem_bo_busy(int fd, uint32_t handle);
/* feature test helpers */
-void igt_require_gem(int fd);
bool gem_has_llc(int fd);
bool gem_has_bsd(int fd);
bool gem_has_blt(int fd);
diff --git a/lib/meson.build b/lib/meson.build
index e2060430..f2b845c9 100644
--- a/lib/meson.build
+++ b/lib/meson.build
@@ -1,5 +1,6 @@
lib_sources = [
'drmtest.c',
+ 'i915/gem.c',
'i915/gem_context.c',
'i915/gem_engine_topology.c',
'i915/gem_scheduler.c',
diff --git a/tests/amdgpu/amd_prime.c b/tests/amdgpu/amd_prime.c
index fdb8a028..0242dc77 100644
--- a/tests/amdgpu/amd_prime.c
+++ b/tests/amdgpu/amd_prime.c
@@ -21,14 +21,15 @@
* IN THE SOFTWARE.
*/
-#include "igt.h"
-#include "igt_vgem.h"
-
#include <amdgpu.h>
#include <amdgpu_drm.h>
#include <sys/poll.h>
+#include "i915/gem.h"
+#include "igt.h"
+#include "igt_vgem.h"
+
#define GFX_COMPUTE_NOP 0xffff1000
#define SDMA_NOP 0x0
diff --git a/tests/core_hotunplug.c b/tests/core_hotunplug.c
index ded53fd5..e03f3b94 100644
--- a/tests/core_hotunplug.c
+++ b/tests/core_hotunplug.c
@@ -29,6 +29,7 @@
#include <sys/types.h>
#include <unistd.h>
+#include "i915/gem.h"
#include "igt.h"
#include "igt_device_scan.h"
#include "igt_kmod.h"
diff --git a/tests/debugfs_test.c b/tests/debugfs_test.c
index 73b82eda..f6cf1fa0 100644
--- a/tests/debugfs_test.c
+++ b/tests/debugfs_test.c
@@ -21,6 +21,8 @@
* IN THE SOFTWARE.
*/
#include "config.h"
+
+#include "i915/gem.h"
#include "igt.h"
#include "igt_sysfs.h"
#include <fcntl.h>
diff --git a/tests/i915/gem_bad_blit.c b/tests/i915/gem_bad_blit.c
index 27a34038..848e1975 100644
--- a/tests/i915/gem_bad_blit.c
+++ b/tests/i915/gem_bad_blit.c
@@ -41,7 +41,6 @@
* resulted.
*/
-#include "igt.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
@@ -50,7 +49,10 @@
#include <errno.h>
#include <sys/stat.h>
#include <sys/time.h>
+
#include "drm.h"
+#include "i915/gem.h"
+#include "igt.h"
#include "intel_bufmgr.h"
static drm_intel_bufmgr *bufmgr;
diff --git a/tests/i915/gem_bad_reloc.c b/tests/i915/gem_bad_reloc.c
index 57efc77c..7eb7fa53 100644
--- a/tests/i915/gem_bad_reloc.c
+++ b/tests/i915/gem_bad_reloc.c
@@ -25,7 +25,6 @@
*
*/
-#include "igt.h"
#include <unistd.h>
#include <stdlib.h>
#include <stdint.h>
@@ -37,7 +36,10 @@
#include <sys/stat.h>
#include <sys/ioctl.h>
#include <sys/time.h>
+
#include "drm.h"
+#include "i915/gem.h"
+#include "igt.h"
IGT_TEST_DESCRIPTION("Simulates SNA behaviour using negative self-relocations"
" for STATE_BASE_ADDRESS command packets.");
diff --git a/tests/i915/gem_blits.c b/tests/i915/gem_blits.c
index 3d3b9027..65f7c3dd 100644
--- a/tests/i915/gem_blits.c
+++ b/tests/i915/gem_blits.c
@@ -22,6 +22,7 @@
*
*/
+#include "i915/gem.h"
#include "igt.h"
#include "igt_x86.h"
diff --git a/tests/i915/gem_busy.c b/tests/i915/gem_busy.c
index b3d9ed02..0d036ea2 100644
--- a/tests/i915/gem_busy.c
+++ b/tests/i915/gem_busy.c
@@ -25,10 +25,11 @@
#include <signal.h>
#include <sys/ioctl.h>
+#include "i915/gem.h"
+#include "i915/gem_ring.h"
#include "igt.h"
#include "igt_rand.h"
#include "igt_vgem.h"
-#include "i915/gem_ring.h"
#define LOCAL_EXEC_NO_RELOC (1<<11)
#define PAGE_ALIGN(x) ALIGN(x, 4096)
diff --git a/tests/i915/gem_caching.c b/tests/i915/gem_caching.c
index 7c1f6410..0ffffa05 100644
--- a/tests/i915/gem_caching.c
+++ b/tests/i915/gem_caching.c
@@ -26,7 +26,6 @@
*
*/
-#include "igt.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
@@ -38,6 +37,8 @@
#include <drm.h>
+#include "i915/gem.h"
+#include "igt.h"
#include "intel_bufmgr.h"
IGT_TEST_DESCRIPTION("Test snoop consistency when touching partial"
diff --git a/tests/i915/gem_close.c b/tests/i915/gem_close.c
index 0e364514..4fdc1ad7 100644
--- a/tests/i915/gem_close.c
+++ b/tests/i915/gem_close.c
@@ -21,6 +21,7 @@
* IN THE SOFTWARE.
*/
+#include "i915/gem.h"
#include "igt.h"
static bool has_duplicate(int err)
diff --git a/tests/i915/gem_close_race.c b/tests/i915/gem_close_race.c
index 57e00480..db570e8f 100644
--- a/tests/i915/gem_close_race.c
+++ b/tests/i915/gem_close_race.c
@@ -25,7 +25,6 @@
*
*/
-#include "igt.h"
#include <pthread.h>
#include <unistd.h>
#include <signal.h>
@@ -40,7 +39,10 @@
#include <sys/ioctl.h>
#include <sys/time.h>
#include <sys/syscall.h>
+
#include "drm.h"
+#include "i915/gem.h"
+#include "igt.h"
#define OBJECT_SIZE (256 * 1024)
diff --git a/tests/i915/gem_concurrent_all.c b/tests/i915/gem_concurrent_all.c
index 22f429e8..fecb2b22 100644
--- a/tests/i915/gem_concurrent_all.c
+++ b/tests/i915/gem_concurrent_all.c
@@ -35,8 +35,6 @@
* Based on gem_gtt_concurrent_blt.
*/
-#include "igt.h"
-#include "igt_vgem.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
@@ -50,6 +48,9 @@
#include <drm.h>
+#include "i915/gem.h"
+#include "igt.h"
+#include "igt_vgem.h"
#include "intel_bufmgr.h"
IGT_TEST_DESCRIPTION("Test of pread/pwrite/mmap behavior when writing to active"
diff --git a/tests/i915/gem_create.c b/tests/i915/gem_create.c
index aba2f852..e376f8ae 100644
--- a/tests/i915/gem_create.c
+++ b/tests/i915/gem_create.c
@@ -47,8 +47,8 @@
#include <pthread.h>
#include <stdatomic.h>
-#include <drm.h>
-
+#include "drm.h"
+#include "drmtest.h"
#include "ioctl_wrappers.h"
#include "intel_bufmgr.h"
#include "intel_batchbuffer.h"
@@ -56,8 +56,6 @@
#include "intel_chipset.h"
#include "igt_aux.h"
#include "igt_x86.h"
-#include "drmtest.h"
-#include "drm.h"
#include "i915/gem_mman.h"
#include "i915_drm.h"
diff --git a/tests/i915/gem_cs_prefetch.c b/tests/i915/gem_cs_prefetch.c
index 3498aa1e..f329ba7e 100644
--- a/tests/i915/gem_cs_prefetch.c
+++ b/tests/i915/gem_cs_prefetch.c
@@ -35,6 +35,7 @@
* This test for a bug where we've failed to plug a scratch pte entry into the
* very last gtt pte.
*/
+#include "i915/gem.h"
#include "igt.h"
IGT_TEST_DESCRIPTION("Test the CS prefetch behaviour on batches.");
diff --git a/tests/i915/gem_cs_tlb.c b/tests/i915/gem_cs_tlb.c
index f64e4df2..3e9d882b 100644
--- a/tests/i915/gem_cs_tlb.c
+++ b/tests/i915/gem_cs_tlb.c
@@ -35,7 +35,6 @@
* https://bugs.launchpad.net/ubuntu/+source/xserver-xorg-video-intel/+bug/1063252
*/
-#include "igt.h"
#include <unistd.h>
#include <stdlib.h>
#include <stdint.h>
@@ -50,6 +49,9 @@
#include <drm.h>
+#include "i915/gem.h"
+#include "igt.h"
+
IGT_TEST_DESCRIPTION("Check whether we correctly invalidate the cs tlb.");
#define BATCH_SIZE (1024*1024)
diff --git a/tests/i915/gem_ctx_clone.c b/tests/i915/gem_ctx_clone.c
index 471031d4..b72269bc 100644
--- a/tests/i915/gem_ctx_clone.c
+++ b/tests/i915/gem_ctx_clone.c
@@ -21,10 +21,11 @@
* IN THE SOFTWARE.
*/
-#include "igt.h"
-#include "igt_gt.h"
+#include "i915/gem.h"
#include "i915/gem_vm.h"
#include "i915_drm.h"
+#include "igt.h"
+#include "igt_gt.h"
static int ctx_create_ioctl(int i915, struct drm_i915_gem_context_create_ext *arg)
{
diff --git a/tests/i915/gem_ctx_create.c b/tests/i915/gem_ctx_create.c
index 2d477226..f651710a 100644
--- a/tests/i915/gem_ctx_create.c
+++ b/tests/i915/gem_ctx_create.c
@@ -25,13 +25,13 @@
*
*/
-#include "igt.h"
-
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <time.h>
+#include "i915/gem.h"
+#include "igt.h"
#include "igt_rand.h"
#include "sw_sync.h"
diff --git a/tests/i915/gem_ctx_engines.c b/tests/i915/gem_ctx_engines.c
index 62f30598..7d6d8e66 100644
--- a/tests/i915/gem_ctx_engines.c
+++ b/tests/i915/gem_ctx_engines.c
@@ -22,8 +22,6 @@
*
*/
-#include "igt.h"
-
#include <unistd.h>
#include <stdlib.h>
#include <stdint.h>
@@ -38,7 +36,9 @@
#include <drm.h>
+#include "i915/gem.h"
#include "i915/gem_context.h"
+#include "igt.h"
#include "sw_sync.h"
#define engine_class(e, n) ((e)->engines[(n)].engine_class)
diff --git a/tests/i915/gem_ctx_exec.c b/tests/i915/gem_ctx_exec.c
index ad2f9e54..23036a95 100644
--- a/tests/i915/gem_ctx_exec.c
+++ b/tests/i915/gem_ctx_exec.c
@@ -24,7 +24,6 @@
* Ben Widawsky <ben@bwidawsk.net>
*
*/
-#include "igt.h"
#include <limits.h>
#include <unistd.h>
#include <signal.h>
@@ -41,6 +40,8 @@
#include <drm.h>
+#include "i915/gem.h"
+#include "igt.h"
#include "igt_dummyload.h"
#include "igt_sysfs.h"
#include "sw_sync.h"
diff --git a/tests/i915/gem_ctx_freq.c b/tests/i915/gem_ctx_freq.c
index 5d2d3ec3..a34472de 100644
--- a/tests/i915/gem_ctx_freq.c
+++ b/tests/i915/gem_ctx_freq.c
@@ -29,6 +29,7 @@
#include <stdint.h>
#include <unistd.h>
+#include "i915/gem.h"
#include "igt.h"
#include "igt_perf.h"
#include "igt_sysfs.h"
diff --git a/tests/i915/gem_ctx_isolation.c b/tests/i915/gem_ctx_isolation.c
index dadab287..9fdf78bb 100644
--- a/tests/i915/gem_ctx_isolation.c
+++ b/tests/i915/gem_ctx_isolation.c
@@ -21,6 +21,7 @@
* IN THE SOFTWARE.
*/
+#include "i915/gem.h"
#include "igt.h"
#include "igt_dummyload.h"
diff --git a/tests/i915/gem_ctx_param.c b/tests/i915/gem_ctx_param.c
index b2940abc..72dcb973 100644
--- a/tests/i915/gem_ctx_param.c
+++ b/tests/i915/gem_ctx_param.c
@@ -28,6 +28,7 @@
#include <limits.h>
#include "igt.h"
+#include "i915/gem.h"
#include "i915/gem_vm.h"
IGT_TEST_DESCRIPTION("Basic test for context set/get param input validation.");
diff --git a/tests/i915/gem_ctx_persistence.c b/tests/i915/gem_ctx_persistence.c
index 3d52987d..a5450662 100644
--- a/tests/i915/gem_ctx_persistence.c
+++ b/tests/i915/gem_ctx_persistence.c
@@ -28,7 +28,8 @@
#include <sys/types.h>
#include <unistd.h>
-#include "drmtest.h" /* gem_quiescent_gpu()! */
+#include "drmtest.h"
+#include "i915/gem.h"
#include "i915/gem_context.h"
#include "i915/gem_engine_topology.h"
#include "i915/gem_ring.h"
diff --git a/tests/i915/gem_ctx_ringsize.c b/tests/i915/gem_ctx_ringsize.c
index ef321c52..f748ee51 100644
--- a/tests/i915/gem_ctx_ringsize.c
+++ b/tests/i915/gem_ctx_ringsize.c
@@ -29,7 +29,8 @@
#include <sys/types.h>
#include <unistd.h>
-#include "drmtest.h" /* gem_quiescent_gpu()! */
+#include "drmtest.h"
+#include "i915/gem.h"
#include "i915/gem_context.h"
#include "i915/gem_engine_topology.h"
#include "ioctl_wrappers.h" /* gem_wait()! */
diff --git a/tests/i915/gem_ctx_shared.c b/tests/i915/gem_ctx_shared.c
index c9d30e43..43ff60ad 100644
--- a/tests/i915/gem_ctx_shared.c
+++ b/tests/i915/gem_ctx_shared.c
@@ -22,8 +22,6 @@
*
*/
-#include "igt.h"
-
#include <unistd.h>
#include <stdlib.h>
#include <stdint.h>
@@ -38,7 +36,9 @@
#include <drm.h>
+#include "i915/gem.h"
#include "i915/gem_engine_topology.h"
+#include "igt.h"
#include "igt_rand.h"
#include "igt_vgem.h"
#include "sw_sync.h"
diff --git a/tests/i915/gem_ctx_sseu.c b/tests/i915/gem_ctx_sseu.c
index 3bef11b5..749ce336 100644
--- a/tests/i915/gem_ctx_sseu.c
+++ b/tests/i915/gem_ctx_sseu.c
@@ -25,7 +25,6 @@
*
*/
-#include "igt.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -37,6 +36,9 @@
#include <sys/mman.h>
#include <sys/wait.h>
+#include "i915/gem.h"
+#include "igt.h"
+#include "igt.h"
#include "igt_dummyload.h"
#include "igt_perf.h"
#include "igt_sysfs.h"
diff --git a/tests/i915/gem_ctx_switch.c b/tests/i915/gem_ctx_switch.c
index 5f94dac8..3d34c356 100644
--- a/tests/i915/gem_ctx_switch.c
+++ b/tests/i915/gem_ctx_switch.c
@@ -25,7 +25,6 @@
*
*/
-#include "igt.h"
#include <limits.h>
#include <unistd.h>
#include <stdlib.h>
@@ -39,7 +38,10 @@
#include <sys/ioctl.h>
#include <sys/time.h>
#include <time.h>
+
#include "drm.h"
+#include "i915/gem.h"
+#include "igt.h"
#define LOCAL_I915_EXEC_NO_RELOC (1<<11)
#define LOCAL_I915_EXEC_HANDLE_LUT (1<<12)
diff --git a/tests/i915/gem_ctx_thrash.c b/tests/i915/gem_ctx_thrash.c
index ae38a7ab..dc7259c1 100644
--- a/tests/i915/gem_ctx_thrash.c
+++ b/tests/i915/gem_ctx_thrash.c
@@ -22,8 +22,6 @@
*
*/
-#include "igt.h"
-#include "igt_sysfs.h"
#include <stdio.h>
#include <string.h>
#include <errno.h>
@@ -32,6 +30,10 @@
#include <sys/stat.h>
#include <sys/resource.h>
+#include "i915/gem.h"
+#include "igt.h"
+#include "igt_sysfs.h"
+
IGT_TEST_DESCRIPTION("Fill the Gobal GTT with context objects and VMs\n");
#define NUM_THREADS (2*sysconf(_SC_NPROCESSORS_ONLN))
diff --git a/tests/i915/gem_eio.c b/tests/i915/gem_eio.c
index 1ec60941..a1259067 100644
--- a/tests/i915/gem_eio.c
+++ b/tests/i915/gem_eio.c
@@ -41,6 +41,8 @@
#include <drm.h>
+#include "i915/gem.h"
+#include "i915/gem_ring.h"
#include "igt.h"
#include "igt_device.h"
#include "igt_fb.h"
@@ -48,7 +50,6 @@
#include "igt_stats.h"
#include "igt_sysfs.h"
#include "sw_sync.h"
-#include "i915/gem_ring.h"
IGT_TEST_DESCRIPTION("Test that specific ioctls report a wedged GPU (EIO).");
diff --git a/tests/i915/gem_evict_alignment.c b/tests/i915/gem_evict_alignment.c
index da13fb65..d4a5877a 100644
--- a/tests/i915/gem_evict_alignment.c
+++ b/tests/i915/gem_evict_alignment.c
@@ -30,7 +30,6 @@
* Testcase: run a couple of big batches to force the unbind on misalignment code.
*/
-#include "igt.h"
#include <unistd.h>
#include <stdlib.h>
#include <stdint.h>
@@ -45,6 +44,8 @@
#include <drm.h>
+#include "i915/gem.h"
+#include "igt.h"
IGT_TEST_DESCRIPTION("Run a couple of big batches to force the unbind on"
" misalignment code.");
diff --git a/tests/i915/gem_evict_everything.c b/tests/i915/gem_evict_everything.c
index 2580a0b2..5d4d15c4 100644
--- a/tests/i915/gem_evict_everything.c
+++ b/tests/i915/gem_evict_everything.c
@@ -30,7 +30,6 @@
* Testcase: run a couple of big batches to force the eviction code.
*/
-#include "igt.h"
#include <unistd.h>
#include <stdlib.h>
#include <stdint.h>
@@ -42,7 +41,10 @@
#include <sys/stat.h>
#include <sys/ioctl.h>
#include <sys/time.h>
+
#include "drm.h"
+#include "i915/gem.h"
+#include "igt.h"
#include "eviction_common.c"
diff --git a/tests/i915/gem_exec_alignment.c b/tests/i915/gem_exec_alignment.c
index 86279911..17a14bef 100644
--- a/tests/i915/gem_exec_alignment.c
+++ b/tests/i915/gem_exec_alignment.c
@@ -27,7 +27,6 @@
/* Exercises the basic execbuffer using object alignments */
-#include "igt.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
@@ -42,6 +41,8 @@
#include <sched.h>
#include "drm.h"
+#include "i915/gem.h"
+#include "igt.h"
IGT_TEST_DESCRIPTION("Exercises the basic execbuffer using object alignments");
diff --git a/tests/i915/gem_exec_async.c b/tests/i915/gem_exec_async.c
index 70f9d20c..f4198eed 100644
--- a/tests/i915/gem_exec_async.c
+++ b/tests/i915/gem_exec_async.c
@@ -21,6 +21,7 @@
* IN THE SOFTWARE.
*/
+#include "i915/gem.h"
#include "igt.h"
#define LOCAL_OBJECT_ASYNC (1 << 6)
diff --git a/tests/i915/gem_exec_await.c b/tests/i915/gem_exec_await.c
index 7817b483..4c1771e2 100644
--- a/tests/i915/gem_exec_await.c
+++ b/tests/i915/gem_exec_await.c
@@ -22,14 +22,15 @@
*
*/
+#include <sys/ioctl.h>
+#include <sys/signal.h>
+
+#include "i915/gem.h"
+#include "i915/gem_ring.h"
#include "igt.h"
#include "igt_rand.h"
#include "igt_sysfs.h"
#include "igt_vgem.h"
-#include "i915/gem_ring.h"
-
-#include <sys/ioctl.h>
-#include <sys/signal.h>
#define LOCAL_I915_EXEC_NO_RELOC (1<<11)
#define LOCAL_I915_EXEC_HANDLE_LUT (1<<12)
diff --git a/tests/i915/gem_exec_bad_domains.c b/tests/i915/gem_exec_bad_domains.c
index cd2c8956..733964f4 100644
--- a/tests/i915/gem_exec_bad_domains.c
+++ b/tests/i915/gem_exec_bad_domains.c
@@ -25,7 +25,6 @@
*
*/
-#include "igt.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
@@ -34,7 +33,10 @@
#include <errno.h>
#include <sys/stat.h>
#include <sys/time.h>
+
#include "drm.h"
+#include "i915/gem.h"
+#include "igt.h"
#include "intel_bufmgr.h"
/* Testcase: Test whether the kernel rejects relocations with non-gpu domains
diff --git a/tests/i915/gem_exec_balancer.c b/tests/i915/gem_exec_balancer.c
index 60a90184..d4944e3f 100644
--- a/tests/i915/gem_exec_balancer.c
+++ b/tests/i915/gem_exec_balancer.c
@@ -23,10 +23,11 @@
#include <sched.h>
+#include "i915/gem.h"
+#include "i915/gem_ring.h"
#include "igt.h"
#include "igt_gt.h"
#include "igt_perf.h"
-#include "i915/gem_ring.h"
#include "sw_sync.h"
IGT_TEST_DESCRIPTION("Exercise in-kernel load-balancing");
diff --git a/tests/i915/gem_exec_big.c b/tests/i915/gem_exec_big.c
index a5869330..63de42d5 100644
--- a/tests/i915/gem_exec_big.c
+++ b/tests/i915/gem_exec_big.c
@@ -32,7 +32,6 @@
* Mostly useful to stress-test the error-capture code
*/
-#include "igt.h"
#include <unistd.h>
#include <stdlib.h>
#include <stdint.h>
@@ -44,7 +43,10 @@
#include <sys/stat.h>
#include <sys/ioctl.h>
#include <sys/time.h>
+
#include "drm.h"
+#include "i915/gem.h"
+#include "igt.h"
IGT_TEST_DESCRIPTION("Run a large nop batch to stress test the error capture"
" code.");
diff --git a/tests/i915/gem_exec_capture.c b/tests/i915/gem_exec_capture.c
index bc13d863..dc721c1a 100644
--- a/tests/i915/gem_exec_capture.c
+++ b/tests/i915/gem_exec_capture.c
@@ -23,6 +23,7 @@
#include <zlib.h>
+#include "i915/gem.h"
#include "igt.h"
#include "igt_device.h"
#include "igt_rand.h"
diff --git a/tests/i915/gem_exec_create.c b/tests/i915/gem_exec_create.c
index e3ceb3f5..d3dd78ff 100644
--- a/tests/i915/gem_exec_create.c
+++ b/tests/i915/gem_exec_create.c
@@ -25,7 +25,6 @@
*
*/
-#include "igt.h"
#include <unistd.h>
#include <stdlib.h>
#include <stdint.h>
@@ -38,7 +37,10 @@
#include <sys/ioctl.h>
#include <sys/time.h>
#include <time.h>
+
#include "drm.h"
+#include "i915/gem.h"
+#include "igt.h"
#define LOCAL_I915_EXEC_NO_RELOC (1<<11)
#define LOCAL_I915_EXEC_HANDLE_LUT (1<<12)
diff --git a/tests/i915/gem_exec_fence.c b/tests/i915/gem_exec_fence.c
index 1baa0a36..20a5d49d 100644
--- a/tests/i915/gem_exec_fence.c
+++ b/tests/i915/gem_exec_fence.c
@@ -21,16 +21,17 @@
* IN THE SOFTWARE.
*/
+#include <sys/ioctl.h>
+#include <sys/poll.h>
+#include <sys/signal.h>
+
+#include "i915/gem.h"
+#include "i915/gem_ring.h"
#include "igt.h"
#include "igt_syncobj.h"
#include "igt_sysfs.h"
#include "igt_vgem.h"
#include "sw_sync.h"
-#include "i915/gem_ring.h"
-
-#include <sys/ioctl.h>
-#include <sys/poll.h>
-#include <sys/signal.h>
IGT_TEST_DESCRIPTION("Check that execbuf waits for explicit fences");
diff --git a/tests/i915/gem_exec_flush.c b/tests/i915/gem_exec_flush.c
index 513cde36..7d9fcbfc 100644
--- a/tests/i915/gem_exec_flush.c
+++ b/tests/i915/gem_exec_flush.c
@@ -23,6 +23,7 @@
#include <time.h>
+#include "i915/gem.h"
#include "igt.h"
#include "igt_x86.h"
diff --git a/tests/i915/gem_exec_gttfill.c b/tests/i915/gem_exec_gttfill.c
index 235fa6e0..7a6d7c0f 100644
--- a/tests/i915/gem_exec_gttfill.c
+++ b/tests/i915/gem_exec_gttfill.c
@@ -21,6 +21,7 @@
* IN THE SOFTWARE.
*/
+#include "i915/gem.h"
#include "igt.h"
#include "igt_rand.h"
diff --git a/tests/i915/gem_exec_latency.c b/tests/i915/gem_exec_latency.c
index d2159f31..0b85fd2e 100644
--- a/tests/i915/gem_exec_latency.c
+++ b/tests/i915/gem_exec_latency.c
@@ -22,7 +22,6 @@
*
*/
-#include "igt.h"
#include <unistd.h>
#include <stdlib.h>
#include <stdint.h>
@@ -40,11 +39,13 @@
#include "drm.h"
+#include "igt.h"
#include "igt_sysfs.h"
#include "igt_vgem.h"
#include "igt_dummyload.h"
#include "igt_stats.h"
+#include "i915/gem.h"
#include "i915/gem_ring.h"
#define LOCAL_I915_EXEC_NO_RELOC (1<<11)
diff --git a/tests/i915/gem_exec_lut_handle.c b/tests/i915/gem_exec_lut_handle.c
index 6f227628..bd69e941 100644
--- a/tests/i915/gem_exec_lut_handle.c
+++ b/tests/i915/gem_exec_lut_handle.c
@@ -27,7 +27,6 @@
/* Exercises the basic execbuffer using the handle LUT interface */
-#include "igt.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
@@ -36,7 +35,10 @@
#include <errno.h>
#include <sys/stat.h>
#include <sys/time.h>
+
#include "drm.h"
+#include "i915/gem.h"
+#include "igt.h"
IGT_TEST_DESCRIPTION("Exercises the basic execbuffer using the handle LUT"
" interface.");
diff --git a/tests/i915/gem_exec_nop.c b/tests/i915/gem_exec_nop.c
index 64ddb3db..357449c5 100644
--- a/tests/i915/gem_exec_nop.c
+++ b/tests/i915/gem_exec_nop.c
@@ -25,11 +25,6 @@
*
*/
-#include "igt.h"
-#include "igt_device.h"
-#include "igt_rand.h"
-#include "igt_sysfs.h"
-
#include <unistd.h>
#include <stdlib.h>
#include <stdint.h>
@@ -43,7 +38,14 @@
#include <sys/poll.h>
#include <sys/time.h>
#include <time.h>
+
#include "drm.h"
+#include "i915/gem.h"
+#include "igt.h"
+#include "igt_device.h"
+#include "igt_rand.h"
+#include "igt_sysfs.h"
+
#define LOCAL_I915_EXEC_NO_RELOC (1<<11)
#define LOCAL_I915_EXEC_HANDLE_LUT (1<<12)
diff --git a/tests/i915/gem_exec_parallel.c b/tests/i915/gem_exec_parallel.c
index 66fe1853..6d7cb3b8 100644
--- a/tests/i915/gem_exec_parallel.c
+++ b/tests/i915/gem_exec_parallel.c
@@ -29,6 +29,7 @@
#include <pthread.h>
+#include "i915/gem.h"
#include "igt.h"
#include "igt_gt.h"
diff --git a/tests/i915/gem_exec_params.c b/tests/i915/gem_exec_params.c
index 45581738..bea857ad 100644
--- a/tests/i915/gem_exec_params.c
+++ b/tests/i915/gem_exec_params.c
@@ -25,9 +25,6 @@
*
*/
-#include "igt.h"
-#include "igt_device.h"
-
#include <unistd.h>
#include <stdlib.h>
#include <stdint.h>
@@ -39,8 +36,11 @@
#include <sys/stat.h>
#include <sys/ioctl.h>
#include <sys/time.h>
-#include "drm.h"
+#include "drm.h"
+#include "i915/gem.h"
+#include "igt.h"
+#include "igt_device.h"
#define LOCAL_I915_EXEC_VEBOX (4<<0)
#define LOCAL_I915_EXEC_BSD_MASK (3<<13)
diff --git a/tests/i915/gem_exec_reloc.c b/tests/i915/gem_exec_reloc.c
index 2a18c3b2..f6fa55a3 100644
--- a/tests/i915/gem_exec_reloc.c
+++ b/tests/i915/gem_exec_reloc.c
@@ -24,6 +24,7 @@
#include <signal.h>
#include <sys/ioctl.h>
+#include "i915/gem.h"
#include "igt.h"
#include "igt_dummyload.h"
#include "sw_sync.h"
diff --git a/tests/i915/gem_exec_schedule.c b/tests/i915/gem_exec_schedule.c
index 0e0056ce..e9e6f5be 100644
--- a/tests/i915/gem_exec_schedule.c
+++ b/tests/i915/gem_exec_schedule.c
@@ -34,12 +34,13 @@
#include <signal.h>
#include <unistd.h>
+#include "i915/gem.h"
+#include "i915/gem_ring.h"
#include "igt.h"
#include "igt_rand.h"
#include "igt_rapl.h"
#include "igt_sysfs.h"
#include "igt_vgem.h"
-#include "i915/gem_ring.h"
#include "sw_sync.h"
#define LO 0
diff --git a/tests/i915/gem_exec_store.c b/tests/i915/gem_exec_store.c
index 677db6f6..b37d63af 100644
--- a/tests/i915/gem_exec_store.c
+++ b/tests/i915/gem_exec_store.c
@@ -27,10 +27,12 @@
* Simplest non-NOOP only batch with verification.
*/
+#include <strings.h>
+
+#include "i915/gem.h"
#include "igt.h"
#include "igt_device.h"
#include "igt_gt.h"
-#include <strings.h>
#define LOCAL_I915_EXEC_BSD_SHIFT (13)
#define LOCAL_I915_EXEC_BSD_MASK (3 << LOCAL_I915_EXEC_BSD_SHIFT)
diff --git a/tests/i915/gem_exec_suspend.c b/tests/i915/gem_exec_suspend.c
index f0c53daf..8f2a781b 100644
--- a/tests/i915/gem_exec_suspend.c
+++ b/tests/i915/gem_exec_suspend.c
@@ -30,6 +30,7 @@
#include <fcntl.h>
#include <unistd.h>
+#include "i915/gem.h"
#include "igt.h"
#include "igt_dummyload.h"
#include "igt_gt.h"
diff --git a/tests/i915/gem_exec_whisper.c b/tests/i915/gem_exec_whisper.c
index 153854d1..6e894342 100644
--- a/tests/i915/gem_exec_whisper.c
+++ b/tests/i915/gem_exec_whisper.c
@@ -27,6 +27,7 @@
* Pass around a value to write into a scratch buffer between lots of batches
*/
+#include "i915/gem.h"
#include "igt.h"
#include "igt_debugfs.h"
#include "igt_rapl.h"
diff --git a/tests/i915/gem_fenced_exec_thrash.c b/tests/i915/gem_fenced_exec_thrash.c
index db1b15aa..b577a04f 100644
--- a/tests/i915/gem_fenced_exec_thrash.c
+++ b/tests/i915/gem_fenced_exec_thrash.c
@@ -30,6 +30,7 @@
#include <inttypes.h>
#include <errno.h>
+#include "i915/gem.h"
#include "igt.h"
IGT_TEST_DESCRIPTION("Test execbuf fence accounting.");
diff --git a/tests/i915/gem_gpgpu_fill.c b/tests/i915/gem_gpgpu_fill.c
index b2d401d6..fb1758bd 100644
--- a/tests/i915/gem_gpgpu_fill.c
+++ b/tests/i915/gem_gpgpu_fill.c
@@ -30,7 +30,6 @@
* workload for the GPGPU pipeline.
*/
-#include "igt.h"
#include <stdbool.h>
#include <unistd.h>
#include <stdlib.h>
@@ -42,7 +41,10 @@
#include <errno.h>
#include <sys/stat.h>
#include <sys/time.h>
+
#include "drm.h"
+#include "i915/gem.h"
+#include "igt.h"
#include "intel_bufmgr.h"
#define WIDTH 64
diff --git a/tests/i915/gem_gtt_hog.c b/tests/i915/gem_gtt_hog.c
index 1ebef776..1372245b 100644
--- a/tests/i915/gem_gtt_hog.c
+++ b/tests/i915/gem_gtt_hog.c
@@ -25,7 +25,6 @@
*
*/
-#include "igt.h"
#include <unistd.h>
#include <stdlib.h>
#include <stdint.h>
@@ -40,6 +39,8 @@
#include <sys/wait.h>
#include "drm.h"
+#include "i915/gem.h"
+#include "igt.h"
static const uint32_t canary = 0xdeadbeef;
diff --git a/tests/i915/gem_linear_blits.c b/tests/i915/gem_linear_blits.c
index 0c6211c2..cae42d52 100644
--- a/tests/i915/gem_linear_blits.c
+++ b/tests/i915/gem_linear_blits.c
@@ -33,7 +33,6 @@
* The goal is to simply ensure the basics work.
*/
-#include "igt.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
@@ -45,6 +44,8 @@
#include <drm.h>
+#include "i915/gem.h"
+#include "igt.h"
IGT_TEST_DESCRIPTION("Test doing many blits with a working set larger than the"
" aperture size.");
diff --git a/tests/i915/gem_media_fill.c b/tests/i915/gem_media_fill.c
index c880bae9..3f0fec57 100644
--- a/tests/i915/gem_media_fill.c
+++ b/tests/i915/gem_media_fill.c
@@ -30,7 +30,6 @@
* workload for the Media pipeline.
*/
-#include "igt.h"
#include <stdbool.h>
#include <unistd.h>
#include <stdlib.h>
@@ -42,7 +41,10 @@
#include <errno.h>
#include <sys/stat.h>
#include <sys/time.h>
+
#include "drm.h"
+#include "i915/gem.h"
+#include "igt.h"
#include "intel_bufmgr.h"
IGT_TEST_DESCRIPTION("Basic test for the media_fill() function, a very simple"
diff --git a/tests/i915/gem_media_vme.c b/tests/i915/gem_media_vme.c
index 20f5ca35..c3af1b12 100644
--- a/tests/i915/gem_media_vme.c
+++ b/tests/i915/gem_media_vme.c
@@ -20,7 +20,6 @@
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*/
-#include "igt.h"
#include <stdbool.h>
#include <unistd.h>
#include <stdlib.h>
@@ -32,7 +31,10 @@
#include <errno.h>
#include <sys/stat.h>
#include <sys/time.h>
+
#include "drm.h"
+#include "i915/gem.h"
+#include "igt.h"
#include "intel_bufmgr.h"
IGT_TEST_DESCRIPTION("A very simple workload for the VME media block.");
diff --git a/tests/i915/gem_mmap_gtt.c b/tests/i915/gem_mmap_gtt.c
index 38b4d02d..d4f3f7cb 100644
--- a/tests/i915/gem_mmap_gtt.c
+++ b/tests/i915/gem_mmap_gtt.c
@@ -41,6 +41,7 @@
#include <sys/wait.h>
#include "drm.h"
+#include "i915/gem.h"
#include "igt.h"
#include "igt_sysfs.h"
#include "igt_x86.h"
diff --git a/tests/i915/gem_mmap_offset.c b/tests/i915/gem_mmap_offset.c
index 93336a22..23d26075 100644
--- a/tests/i915/gem_mmap_offset.c
+++ b/tests/i915/gem_mmap_offset.c
@@ -31,6 +31,7 @@
#include <sys/wait.h>
#include "drm.h"
+#include "i915/gem.h"
#include "igt.h"
#include "igt_x86.h"
diff --git a/tests/i915/gem_non_secure_batch.c b/tests/i915/gem_non_secure_batch.c
index 5f339914..0bc2c3b5 100644
--- a/tests/i915/gem_non_secure_batch.c
+++ b/tests/i915/gem_non_secure_batch.c
@@ -25,7 +25,6 @@
*
*/
-#include "igt.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
@@ -34,9 +33,12 @@
#include <errno.h>
#include <sys/stat.h>
#include <sys/time.h>
+
#include "drm.h"
-#include "intel_bufmgr.h"
#include "i830_reg.h"
+#include "i915/gem.h"
+#include "igt.h"
+#include "intel_bufmgr.h"
IGT_TEST_DESCRIPTION("Basic check of non-secure batches.");
diff --git a/tests/i915/gem_partial_pwrite_pread.c b/tests/i915/gem_partial_pwrite_pread.c
index afd43694..277a7390 100644
--- a/tests/i915/gem_partial_pwrite_pread.c
+++ b/tests/i915/gem_partial_pwrite_pread.c
@@ -25,7 +25,6 @@
*
*/
-#include "igt.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
@@ -37,6 +36,8 @@
#include <drm.h>
+#include "i915/gem.h"
+#include "igt.h"
IGT_TEST_DESCRIPTION("Test pwrite/pread consistency when touching partial"
" cachelines.");
diff --git a/tests/i915/gem_pipe_control_store_loop.c b/tests/i915/gem_pipe_control_store_loop.c
index e44e9fb5..863a4871 100644
--- a/tests/i915/gem_pipe_control_store_loop.c
+++ b/tests/i915/gem_pipe_control_store_loop.c
@@ -31,7 +31,6 @@
* Writes a counter-value into an always newly allocated target bo (by disabling
* buffer reuse). Decently trashes on tlb inconsistencies, too.
*/
-#include "igt.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
@@ -40,7 +39,10 @@
#include <errno.h>
#include <sys/stat.h>
#include <sys/time.h>
+
#include "drm.h"
+#include "i915/gem.h"
+#include "igt.h"
#include "intel_bufmgr.h"
IGT_TEST_DESCRIPTION("Test (TLB-)Coherency of pipe_control QW writes.");
diff --git a/tests/i915/gem_ppgtt.c b/tests/i915/gem_ppgtt.c
index 4c7d3ba2..8c02e4af 100644
--- a/tests/i915/gem_ppgtt.c
+++ b/tests/i915/gem_ppgtt.c
@@ -21,7 +21,6 @@
* IN THE SOFTWARE.
*/
-#include "igt.h"
#include <stdbool.h>
#include <unistd.h>
#include <stdlib.h>
@@ -36,8 +35,10 @@
#include <drm.h>
-#include "intel_bufmgr.h"
+#include "i915/gem.h"
+#include "igt.h"
#include "igt_debugfs.h"
+#include "intel_bufmgr.h"
#define WIDTH 512
#define STRIDE (WIDTH*4)
diff --git a/tests/i915/gem_pread_after_blit.c b/tests/i915/gem_pread_after_blit.c
index e12b5d65..81454c93 100644
--- a/tests/i915/gem_pread_after_blit.c
+++ b/tests/i915/gem_pread_after_blit.c
@@ -34,7 +34,6 @@
* ranged-buffer-flush paths in the kernel.
*/
-#include "igt.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
@@ -46,6 +45,8 @@
#include <drm.h>
+#include "i915/gem.h"
+#include "igt.h"
IGT_TEST_DESCRIPTION("Test pread behavior when getting values out of"
" just-drawn-to buffers.");
diff --git a/tests/i915/gem_pwrite_snooped.c b/tests/i915/gem_pwrite_snooped.c
index 14f4c44a..4a339524 100644
--- a/tests/i915/gem_pwrite_snooped.c
+++ b/tests/i915/gem_pwrite_snooped.c
@@ -22,7 +22,6 @@
*
*/
-#include "igt.h"
#include <unistd.h>
#include <stdlib.h>
#include <stdint.h>
@@ -34,7 +33,10 @@
#include <sys/stat.h>
#include <sys/ioctl.h>
#include <sys/time.h>
+
#include "drm.h"
+#include "i915/gem.h"
+#include "igt.h"
IGT_TEST_DESCRIPTION(
"pwrite to a snooped bo then make it uncached and check that the GPU sees the data.");
diff --git a/tests/i915/gem_read_read_speed.c b/tests/i915/gem_read_read_speed.c
index 2aab2204..06b66935 100644
--- a/tests/i915/gem_read_read_speed.c
+++ b/tests/i915/gem_read_read_speed.c
@@ -26,8 +26,6 @@
* This is a test of performance with multiple readers from the same source.
*/
-#include "igt.h"
-#include "igt_sysfs.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
@@ -41,6 +39,9 @@
#include <drm.h>
+#include "i915/gem.h"
+#include "igt.h"
+#include "igt_sysfs.h"
#include "intel_bufmgr.h"
IGT_TEST_DESCRIPTION("Test speed of concurrent reads between engines.");
diff --git a/tests/i915/gem_render_copy.c b/tests/i915/gem_render_copy.c
index 22016424..1e1e79b9 100644
--- a/tests/i915/gem_render_copy.c
+++ b/tests/i915/gem_render_copy.c
@@ -29,8 +29,6 @@
* workload for the 3D engine.
*/
-#include "igt.h"
-#include "igt_x86.h"
#include <stdbool.h>
#include <unistd.h>
#include <cairo.h>
@@ -46,6 +44,9 @@
#include <drm.h>
+#include "i915/gem.h"
+#include "igt.h"
+#include "igt_x86.h"
#include "intel_bufmgr.h"
#include "rendercopy_bufmgr.h"
diff --git a/tests/i915/gem_render_copy_redux.c b/tests/i915/gem_render_copy_redux.c
index 2388fc24..a3f77e84 100644
--- a/tests/i915/gem_render_copy_redux.c
+++ b/tests/i915/gem_render_copy_redux.c
@@ -32,7 +32,6 @@
* the execbuffer interface with a simple render workload.
*/
-#include "igt.h"
#include <stdbool.h>
#include <unistd.h>
#include <stdlib.h>
@@ -47,6 +46,8 @@
#include <drm.h>
+#include "i915/gem.h"
+#include "igt.h"
#include "intel_bufmgr.h"
IGT_TEST_DESCRIPTION("Advanced test for the render_copy() function.");
diff --git a/tests/i915/gem_render_linear_blits.c b/tests/i915/gem_render_linear_blits.c
index 666a43cd..55a9e6be 100644
--- a/tests/i915/gem_render_linear_blits.c
+++ b/tests/i915/gem_render_linear_blits.c
@@ -35,7 +35,6 @@
#include "config.h"
-#include "igt.h"
#include <stdlib.h>
#include <sys/ioctl.h>
#include <stdio.h>
@@ -48,6 +47,8 @@
#include <drm.h>
+#include "i915/gem.h"
+#include "igt.h"
#include "intel_bufmgr.h"
#define WIDTH 512
diff --git a/tests/i915/gem_render_tiled_blits.c b/tests/i915/gem_render_tiled_blits.c
index 5f49b3fe..bd76066a 100644
--- a/tests/i915/gem_render_tiled_blits.c
+++ b/tests/i915/gem_render_tiled_blits.c
@@ -33,7 +33,6 @@
* The goal is to simply ensure the basics work.
*/
-#include "igt.h"
#include <stdlib.h>
#include <sys/ioctl.h>
#include <stdio.h>
@@ -46,6 +45,8 @@
#include <drm.h>
+#include "i915/gem.h"
+#include "igt.h"
#include "intel_bufmgr.h"
#define WIDTH 512
diff --git a/tests/i915/gem_request_retire.c b/tests/i915/gem_request_retire.c
index 7efea0b6..4a1ec115 100644
--- a/tests/i915/gem_request_retire.c
+++ b/tests/i915/gem_request_retire.c
@@ -30,7 +30,6 @@
* Collection of tests targeting request retirement code paths.
*/
-#include "igt.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
@@ -47,6 +46,8 @@
#include "drm.h"
#include "i915_drm.h"
+#include "i915/gem.h"
+#include "igt.h"
#include "intel_bufmgr.h"
IGT_TEST_DESCRIPTION("Collection of tests targeting request retirement code"
diff --git a/tests/i915/gem_reset_stats.c b/tests/i915/gem_reset_stats.c
index 9c7b6645..e2d2dd8b 100644
--- a/tests/i915/gem_reset_stats.c
+++ b/tests/i915/gem_reset_stats.c
@@ -25,8 +25,6 @@
*
*/
-#include "igt.h"
-#include "igt_sysfs.h"
#include <limits.h>
#include <stdbool.h>
#include <unistd.h>
@@ -42,6 +40,9 @@
#include <time.h>
#include <signal.h>
+#include "i915/gem.h"
+#include "igt.h"
+#include "igt_sysfs.h"
#define RS_NO_ERROR 0
#define RS_BATCH_ACTIVE (1 << 0)
diff --git a/tests/i915/gem_ringfill.c b/tests/i915/gem_ringfill.c
index 4c73f4d9..a2157bd6 100644
--- a/tests/i915/gem_ringfill.c
+++ b/tests/i915/gem_ringfill.c
@@ -31,11 +31,12 @@
* catching failure to manage the ring properly near full.
*/
+#include "i915/gem.h"
+#include "i915/gem_ring.h"
#include "igt.h"
#include "igt_device.h"
#include "igt_gt.h"
#include "igt_vgem.h"
-#include "i915/gem_ring.h"
#include <signal.h>
#include <sys/ioctl.h>
diff --git a/tests/i915/gem_set_tiling_vs_blt.c b/tests/i915/gem_set_tiling_vs_blt.c
index 16edaf39..cb164154 100644
--- a/tests/i915/gem_set_tiling_vs_blt.c
+++ b/tests/i915/gem_set_tiling_vs_blt.c
@@ -44,7 +44,6 @@
* transitions (i.e. changing stride).
*/
-#include "igt.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
@@ -54,7 +53,10 @@
#include <sys/stat.h>
#include <sys/time.h>
#include <stdbool.h>
+
#include "drm.h"
+#include "i915/gem.h"
+#include "igt.h"
#include "intel_bufmgr.h"
IGT_TEST_DESCRIPTION("Check for proper synchronization of tiling changes vs."
diff --git a/tests/i915/gem_shrink.c b/tests/i915/gem_shrink.c
index e434613e..c9964ccc 100644
--- a/tests/i915/gem_shrink.c
+++ b/tests/i915/gem_shrink.c
@@ -27,6 +27,7 @@
* Exercise the shrinker by overallocating GEM objects
*/
+#include "i915/gem.h"
#include "igt.h"
#include "igt_gt.h"
#include "igt_debugfs.h"
diff --git a/tests/i915/gem_softpin.c b/tests/i915/gem_softpin.c
index 4204323e..684dcfd4 100644
--- a/tests/i915/gem_softpin.c
+++ b/tests/i915/gem_softpin.c
@@ -26,6 +26,7 @@
*
*/
+#include "i915/gem.h"
#include "igt.h"
#define EXEC_OBJECT_PINNED (1<<4)
diff --git a/tests/i915/gem_spin_batch.c b/tests/i915/gem_spin_batch.c
index 1142a77c..e7dd58ec 100644
--- a/tests/i915/gem_spin_batch.c
+++ b/tests/i915/gem_spin_batch.c
@@ -22,6 +22,7 @@
*
*/
+#include "i915/gem.h"
#include "igt.h"
#define MAX_ERROR 5 /* % */
diff --git a/tests/i915/gem_streaming_writes.c b/tests/i915/gem_streaming_writes.c
index e83d69de..bd44e134 100644
--- a/tests/i915/gem_streaming_writes.c
+++ b/tests/i915/gem_streaming_writes.c
@@ -25,7 +25,6 @@
*
*/
-#include "igt.h"
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
@@ -36,7 +35,10 @@
#include <errno.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
+
#include "drm.h"
+#include "i915/gem.h"
+#include "igt.h"
#define OBJECT_SIZE 1024*1024
#define CHUNK_SIZE 32
diff --git a/tests/i915/gem_sync.c b/tests/i915/gem_sync.c
index b50ad4f2..6b3c76ec 100644
--- a/tests/i915/gem_sync.c
+++ b/tests/i915/gem_sync.c
@@ -24,6 +24,7 @@
#include <time.h>
#include <pthread.h>
+#include "i915/gem.h"
#include "igt_debugfs.h"
#include "igt_dummyload.h"
#include "igt_gt.h"
diff --git a/tests/i915/gem_tiled_blits.c b/tests/i915/gem_tiled_blits.c
index 7fd11e05..36e96785 100644
--- a/tests/i915/gem_tiled_blits.c
+++ b/tests/i915/gem_tiled_blits.c
@@ -41,7 +41,6 @@
* resulted.
*/
-#include "igt.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
@@ -53,6 +52,8 @@
#include <drm.h>
+#include "i915/gem.h"
+#include "igt.h"
IGT_TEST_DESCRIPTION("Test doing many tiled blits, with a working set larger"
" than the aperture size.");
diff --git a/tests/i915/gem_tiled_fence_blits.c b/tests/i915/gem_tiled_fence_blits.c
index f927c819..99ec78f9 100644
--- a/tests/i915/gem_tiled_fence_blits.c
+++ b/tests/i915/gem_tiled_fence_blits.c
@@ -41,6 +41,7 @@
* resulted.
*/
+#include "i915/gem.h"
#include "igt.h"
#include "igt_x86.h"
diff --git a/tests/i915/gem_tiled_partial_pwrite_pread.c b/tests/i915/gem_tiled_partial_pwrite_pread.c
index 399c118f..7de5358b 100644
--- a/tests/i915/gem_tiled_partial_pwrite_pread.c
+++ b/tests/i915/gem_tiled_partial_pwrite_pread.c
@@ -25,7 +25,6 @@
*
*/
-#include "igt.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
@@ -37,6 +36,8 @@
#include <drm.h>
+#include "i915/gem.h"
+#include "igt.h"
IGT_TEST_DESCRIPTION("Test pwrite/pread consistency when touching partial"
" cachelines.");
diff --git a/tests/i915/gem_unfence_active_buffers.c b/tests/i915/gem_unfence_active_buffers.c
index c1670dd5..1e69c70d 100644
--- a/tests/i915/gem_unfence_active_buffers.c
+++ b/tests/i915/gem_unfence_active_buffers.c
@@ -38,7 +38,6 @@
* problem - the race window is too small.
*/
-#include "igt.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
@@ -48,7 +47,10 @@
#include <sys/stat.h>
#include <sys/time.h>
#include <stdbool.h>
+
#include "drm.h"
+#include "i915/gem.h"
+#include "igt.h"
#include "intel_bufmgr.h"
IGT_TEST_DESCRIPTION("Check for use-after-free in the fence stealing code.");
diff --git a/tests/i915/gem_unref_active_buffers.c b/tests/i915/gem_unref_active_buffers.c
index 2adf0f1a..75394794 100644
--- a/tests/i915/gem_unref_active_buffers.c
+++ b/tests/i915/gem_unref_active_buffers.c
@@ -32,7 +32,6 @@
* will be the last one to hold a reference on them. Usually libdrm bo caching
* prevents that by keeping another reference.
*/
-#include "igt.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
@@ -41,7 +40,10 @@
#include <errno.h>
#include <sys/stat.h>
#include <sys/time.h>
+
#include "drm.h"
+#include "i915/gem.h"
+#include "igt.h"
#include "intel_bufmgr.h"
IGT_TEST_DESCRIPTION("Test unreferencing of active buffers.");
diff --git a/tests/i915/gem_userptr_blits.c b/tests/i915/gem_userptr_blits.c
index 17f4d10f..05f96e75 100644
--- a/tests/i915/gem_userptr_blits.c
+++ b/tests/i915/gem_userptr_blits.c
@@ -38,7 +38,6 @@
#include <linux/userfaultfd.h>
-#include "igt.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
@@ -61,6 +60,8 @@
#include "drm.h"
#include "i915_drm.h"
+#include "i915/gem.h"
+#include "igt.h"
#include "intel_bufmgr.h"
#include "eviction_common.c"
diff --git a/tests/i915/gem_vm_create.c b/tests/i915/gem_vm_create.c
index a6d2dd91..e8af68f1 100644
--- a/tests/i915/gem_vm_create.c
+++ b/tests/i915/gem_vm_create.c
@@ -21,9 +21,10 @@
* IN THE SOFTWARE.
*/
+#include "i915/gem.h"
+#include "i915/gem_vm.h"
#include "igt.h"
#include "igt_dummyload.h"
-#include "i915/gem_vm.h"
static int vm_create_ioctl(int i915, struct drm_i915_gem_vm_control *ctl)
{
diff --git a/tests/i915/gem_wait.c b/tests/i915/gem_wait.c
index 43b3a658..7b2b1c2b 100644
--- a/tests/i915/gem_wait.c
+++ b/tests/i915/gem_wait.c
@@ -27,6 +27,7 @@
#include <sys/poll.h>
+#include "i915/gem.h"
#include "igt.h"
#include "igt_vgem.h"
diff --git a/tests/i915/gem_workarounds.c b/tests/i915/gem_workarounds.c
index 2fce445d..4f043d7d 100644
--- a/tests/i915/gem_workarounds.c
+++ b/tests/i915/gem_workarounds.c
@@ -25,10 +25,11 @@
*
*/
-#include "igt.h"
-
#include <fcntl.h>
+#include "i915/gem.h"
+#include "igt.h"
+
#define PAGE_SIZE 4096
#define PAGE_ALIGN(x) ALIGN(x, PAGE_SIZE)
diff --git a/tests/i915/gen3_mixed_blits.c b/tests/i915/gen3_mixed_blits.c
index 1a954b65..10a8cd3e 100644
--- a/tests/i915/gen3_mixed_blits.c
+++ b/tests/i915/gen3_mixed_blits.c
@@ -33,7 +33,6 @@
* The goal is to simply ensure the basics work.
*/
-#include "igt.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
@@ -43,9 +42,11 @@
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/ioctl.h>
-#include "drm.h"
+#include "drm.h"
+#include "i915/gem.h"
#include "i915_reg.h"
+#include "igt.h"
#define WIDTH (512)
#define HEIGHT (512)
diff --git a/tests/i915/gen3_render_linear_blits.c b/tests/i915/gen3_render_linear_blits.c
index c2cbc0b8..d88a2c93 100644
--- a/tests/i915/gen3_render_linear_blits.c
+++ b/tests/i915/gen3_render_linear_blits.c
@@ -33,7 +33,6 @@
* The goal is to simply ensure the basics work.
*/
-#include "igt.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
@@ -42,9 +41,11 @@
#include <errno.h>
#include <sys/stat.h>
#include <sys/time.h>
-#include "drm.h"
+#include "drm.h"
+#include "i915/gem.h"
#include "i915_reg.h"
+#include "igt.h"
#define WIDTH 512
#define HEIGHT 512
diff --git a/tests/i915/gen3_render_mixed_blits.c b/tests/i915/gen3_render_mixed_blits.c
index 8cb7af34..cda175bd 100644
--- a/tests/i915/gen3_render_mixed_blits.c
+++ b/tests/i915/gen3_render_mixed_blits.c
@@ -33,7 +33,6 @@
* The goal is to simply ensure the basics work.
*/
-#include "igt.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
@@ -43,9 +42,11 @@
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/ioctl.h>
-#include "drm.h"
+#include "drm.h"
+#include "i915/gem.h"
#include "i915_reg.h"
+#include "igt.h"
#define WIDTH 512
#define HEIGHT 512
diff --git a/tests/i915/gen3_render_tiledx_blits.c b/tests/i915/gen3_render_tiledx_blits.c
index 3939c07b..579205f3 100644
--- a/tests/i915/gen3_render_tiledx_blits.c
+++ b/tests/i915/gen3_render_tiledx_blits.c
@@ -33,7 +33,6 @@
* The goal is to simply ensure the basics work.
*/
-#include "igt.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
@@ -43,9 +42,11 @@
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/ioctl.h>
-#include "drm.h"
+#include "drm.h"
+#include "i915/gem.h"
#include "i915_reg.h"
+#include "igt.h"
#define WIDTH 512
#define HEIGHT 512
diff --git a/tests/i915/gen3_render_tiledy_blits.c b/tests/i915/gen3_render_tiledy_blits.c
index f0e6535f..931e91a3 100644
--- a/tests/i915/gen3_render_tiledy_blits.c
+++ b/tests/i915/gen3_render_tiledy_blits.c
@@ -33,7 +33,6 @@
* The goal is to simply ensure the basics work.
*/
-#include "igt.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
@@ -45,7 +44,9 @@
#include <sys/ioctl.h>
#include "drm.h"
+#include "i915/gem.h"
#include "i915_reg.h"
+#include "igt.h"
#define WIDTH 512
#define HEIGHT 512
diff --git a/tests/i915/gen7_exec_parse.c b/tests/i915/gen7_exec_parse.c
index 5578340f..2ba438c9 100644
--- a/tests/i915/gen7_exec_parse.c
+++ b/tests/i915/gen7_exec_parse.c
@@ -22,7 +22,6 @@
*
*/
-#include "igt.h"
#include <stdlib.h>
#include <stdint.h>
#include <stdio.h>
@@ -30,6 +29,8 @@
#include <drm.h>
+#include "igt.h"
+#include "i915/gem.h"
#include "sw_sync.h"
#define DERRMR 0x44050
diff --git a/tests/i915/gen9_exec_parse.c b/tests/i915/gen9_exec_parse.c
index 854c5986..8cd82f56 100644
--- a/tests/i915/gen9_exec_parse.c
+++ b/tests/i915/gen9_exec_parse.c
@@ -28,8 +28,9 @@
#include <stdio.h>
#include <stdlib.h>
-#include "igt.h"
+#include "i915/gem.h"
#include "i915/gem_submission.h"
+#include "igt.h"
#include "sw_sync.h"
/* To help craft commands known to be invalid across all engines */
diff --git a/tests/i915/i915_hangman.c b/tests/i915/i915_hangman.c
index 13cd6208..2b341c4b 100644
--- a/tests/i915/i915_hangman.c
+++ b/tests/i915/i915_hangman.c
@@ -26,12 +26,13 @@
*
*/
-#include "igt.h"
#include <limits.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
+#include "i915/gem.h"
+#include "igt.h"
#include "igt_sysfs.h"
#include "igt_debugfs.h"
diff --git a/tests/i915/i915_pm_rc6_residency.c b/tests/i915/i915_pm_rc6_residency.c
index 9dc26a81..144bcd02 100644
--- a/tests/i915/i915_pm_rc6_residency.c
+++ b/tests/i915/i915_pm_rc6_residency.c
@@ -33,6 +33,7 @@
#include <errno.h>
#include <time.h>
+#include "i915/gem.h"
#include "igt.h"
#include "igt_perf.h"
#include "igt_rapl.h"
diff --git a/tests/i915/i915_pm_rpm.c b/tests/i915/i915_pm_rpm.c
index fedef872..47e74856 100644
--- a/tests/i915/i915_pm_rpm.c
+++ b/tests/i915/i915_pm_rpm.c
@@ -45,6 +45,7 @@
#include <drm.h>
+#include "i915/gem.h"
#include "igt.h"
#include "igt_kmod.h"
#include "igt_sysfs.h"
diff --git a/tests/i915/i915_pm_rps.c b/tests/i915/i915_pm_rps.c
index 68b66c16..943a5098 100644
--- a/tests/i915/i915_pm_rps.c
+++ b/tests/i915/i915_pm_rps.c
@@ -36,6 +36,7 @@
#include <time.h>
#include <sys/wait.h>
+#include "i915/gem.h"
#include "igt.h"
#include "igt_dummyload.h"
#include "igt_sysfs.h"
diff --git a/tests/i915/i915_pm_sseu.c b/tests/i915/i915_pm_sseu.c
index c2dee118..461c70cc 100644
--- a/tests/i915/i915_pm_sseu.c
+++ b/tests/i915/i915_pm_sseu.c
@@ -24,13 +24,16 @@
* Jeff McGee <jeff.mcgee@intel.com>
*/
-#include "igt.h"
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <time.h>
+
#include "i915_drm.h"
+
+#include "i915/gem.h"
+#include "igt.h"
#include "intel_bufmgr.h"
IGT_TEST_DESCRIPTION("Tests slice/subslice/EU power gating functionality.\n");
diff --git a/tests/i915/i915_suspend.c b/tests/i915/i915_suspend.c
index 83a4fa54..15340edc 100644
--- a/tests/i915/i915_suspend.c
+++ b/tests/i915/i915_suspend.c
@@ -26,7 +26,6 @@
*
*/
-#include "igt.h"
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
@@ -39,6 +38,8 @@
#include <drm.h>
+#include "i915/gem.h"
+#include "igt.h"
#include "igt_device.h"
#define OBJECT_SIZE (16*1024*1024)
diff --git a/tests/i915/sysfs_heartbeat_interval.c b/tests/i915/sysfs_heartbeat_interval.c
index 662f4865..6266f3e8 100644
--- a/tests/i915/sysfs_heartbeat_interval.c
+++ b/tests/i915/sysfs_heartbeat_interval.c
@@ -31,15 +31,15 @@
#include <sys/wait.h>
#include <unistd.h>
-#include "drmtest.h" /* gem_quiescent_gpu()! */
+#include "drmtest.h"
+#include "i915/gem.h"
+#include "i915/gem_context.h"
#include "i915/gem_engine_topology.h"
+#include "igt_debugfs.h"
#include "igt_dummyload.h"
#include "igt_sysfs.h"
-#include "ioctl_wrappers.h" /* igt_require_gem()! */
#include "sw_sync.h"
-#include "igt_debugfs.h"
-
#define ATTR "heartbeat_interval_ms"
#define RESET_TIMEOUT 50 /* milliseconds, at least one jiffie for kworker */
diff --git a/tests/i915/sysfs_preempt_timeout.c b/tests/i915/sysfs_preempt_timeout.c
index a7e93a4d..785289cb 100644
--- a/tests/i915/sysfs_preempt_timeout.c
+++ b/tests/i915/sysfs_preempt_timeout.c
@@ -29,15 +29,15 @@
#include <sys/types.h>
#include <unistd.h>
-#include "drmtest.h" /* gem_quiescent_gpu()! */
+#include "drmtest.h"
+#include "i915/gem.h"
+#include "i915/gem_context.h"
#include "i915/gem_engine_topology.h"
+#include "igt_debugfs.h"
#include "igt_dummyload.h"
#include "igt_sysfs.h"
-#include "ioctl_wrappers.h" /* igt_require_gem()! */
#include "sw_sync.h"
-#include "igt_debugfs.h"
-
#define ATTR "preempt_timeout_ms"
#define RESET_TIMEOUT 50 /* milliseconds, at least one jiffie for kworker */
diff --git a/tests/i915/sysfs_timeslice_duration.c b/tests/i915/sysfs_timeslice_duration.c
index b983df43..1eeac830 100644
--- a/tests/i915/sysfs_timeslice_duration.c
+++ b/tests/i915/sysfs_timeslice_duration.c
@@ -29,12 +29,13 @@
#include <sys/types.h>
#include <unistd.h>
-#include "drmtest.h" /* gem_quiescent_gpu()! */
+#include "drmtest.h"
+#include "i915/gem.h"
#include "i915/gem_engine_topology.h"
#include "i915/gem_mman.h"
#include "igt_dummyload.h"
#include "igt_sysfs.h"
-#include "ioctl_wrappers.h" /* igt_require_gem()! */
+#include "ioctl_wrappers.h"
#include "intel_chipset.h"
#include "intel_reg.h"
#include "sw_sync.h"
diff --git a/tests/kms_busy.c b/tests/kms_busy.c
index 7e495fe2..be4273bc 100644
--- a/tests/kms_busy.c
+++ b/tests/kms_busy.c
@@ -21,12 +21,13 @@
* IN THE SOFTWARE.
*/
-#include "igt.h"
-
#include <sys/poll.h>
#include <signal.h>
#include <time.h>
+#include "i915/gem.h"
+#include "igt.h"
+
IGT_TEST_DESCRIPTION("Basic check of KMS ABI with busy framebuffers.");
static igt_output_t *
diff --git a/tests/kms_cursor_legacy.c b/tests/kms_cursor_legacy.c
index ba66e1bd..9306e54b 100644
--- a/tests/kms_cursor_legacy.c
+++ b/tests/kms_cursor_legacy.c
@@ -25,6 +25,7 @@
#include <sched.h>
#include <sys/poll.h>
+#include "i915/gem.h"
#include "igt.h"
#include "igt_rand.h"
#include "igt_stats.h"
diff --git a/tests/kms_draw_crc.c b/tests/kms_draw_crc.c
index fa7433ab..70b9b05f 100644
--- a/tests/kms_draw_crc.c
+++ b/tests/kms_draw_crc.c
@@ -24,6 +24,7 @@
/* This program tests whether the igt_draw library actually works. */
+#include "i915/gem.h"
#include "igt.h"
#define MAX_CONNECTORS 32
diff --git a/tests/kms_fence_pin_leak.c b/tests/kms_fence_pin_leak.c
index 1ac65e8a..b59efc0a 100644
--- a/tests/kms_fence_pin_leak.c
+++ b/tests/kms_fence_pin_leak.c
@@ -22,13 +22,14 @@
*
*/
-#include "igt.h"
#include <errno.h>
#include <limits.h>
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
+#include "i915/gem.h"
+#include "igt.h"
IGT_TEST_DESCRIPTION("Exercises full ppgtt fence pin_count leak in the "
"kernel.");
diff --git a/tests/kms_flip_tiling.c b/tests/kms_flip_tiling.c
index 17cf816d..fb79de15 100644
--- a/tests/kms_flip_tiling.c
+++ b/tests/kms_flip_tiling.c
@@ -24,12 +24,14 @@
* Ander Conselvan de Oliveira <ander.conselvan.de.oliveira@intel.com>
*/
-#include "igt.h"
#include <errno.h>
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
+#include "i915/gem.h"
+#include "igt.h"
+
IGT_TEST_DESCRIPTION("Test page flips and tiling scenarios");
typedef struct {
diff --git a/tests/kms_frontbuffer_tracking.c b/tests/kms_frontbuffer_tracking.c
index 34723922..5d55560d 100644
--- a/tests/kms_frontbuffer_tracking.c
+++ b/tests/kms_frontbuffer_tracking.c
@@ -24,15 +24,16 @@
*
*/
-#include "igt.h"
-#include "igt_sysfs.h"
-#include "igt_psr.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <poll.h>
#include <pthread.h>
+#include "i915/gem.h"
+#include "igt.h"
+#include "igt_sysfs.h"
+#include "igt_psr.h"
IGT_TEST_DESCRIPTION("Test the Kernel's frontbuffer tracking mechanism and "
"its related features: FBC, PSR and DRRS");
diff --git a/tests/perf.c b/tests/perf.c
index b1e2a2e6..d4ebae30 100644
--- a/tests/perf.c
+++ b/tests/perf.c
@@ -38,9 +38,10 @@
#include <poll.h>
#include <math.h>
+#include "i915/gem.h"
+#include "i915/perf.h"
#include "igt.h"
#include "igt_sysfs.h"
-#include "i915/perf.h"
#include "drm.h"
IGT_TEST_DESCRIPTION("Test the i915 perf metrics streaming interface");
diff --git a/tests/perf_pmu.c b/tests/perf_pmu.c
index 5384b526..e54a0d47 100644
--- a/tests/perf_pmu.c
+++ b/tests/perf_pmu.c
@@ -38,6 +38,8 @@
#include <poll.h>
#include <sched.h>
+#include "i915/gem.h"
+#include "i915/gem_ring.h"
#include "igt.h"
#include "igt_core.h"
#include "igt_device.h"
@@ -45,7 +47,6 @@
#include "igt_perf.h"
#include "igt_sysfs.h"
#include "igt_pm.h"
-#include "i915/gem_ring.h"
#include "sw_sync.h"
IGT_TEST_DESCRIPTION("Test the i915 pmu perf interface");
diff --git a/tests/prime_busy.c b/tests/prime_busy.c
index caab95a3..aec76393 100644
--- a/tests/prime_busy.c
+++ b/tests/prime_busy.c
@@ -21,10 +21,11 @@
* IN THE SOFTWARE.
*/
-#include "igt.h"
-
#include <sys/poll.h>
+#include "i915/gem.h"
+#include "igt.h"
+
IGT_TEST_DESCRIPTION("Basic check of polling for prime fences.");
static bool prime_busy(struct pollfd *pfd, bool excl)
diff --git a/tests/prime_mmap_coherency.c b/tests/prime_mmap_coherency.c
index 32d78ee1..2a074957 100644
--- a/tests/prime_mmap_coherency.c
+++ b/tests/prime_mmap_coherency.c
@@ -29,6 +29,7 @@
* TODO: need to show the need for prime_sync_end().
*/
+#include "i915/gem.h"
#include "igt.h"
IGT_TEST_DESCRIPTION("Test dma-buf mmap on !llc platforms mostly and provoke"
diff --git a/tests/prime_vgem.c b/tests/prime_vgem.c
index d28ee0fa..38e2026a 100644
--- a/tests/prime_vgem.c
+++ b/tests/prime_vgem.c
@@ -21,13 +21,13 @@
* IN THE SOFTWARE.
*/
-#include "igt.h"
-#include "igt_vgem.h"
-
#include <sys/ioctl.h>
#include <sys/poll.h>
#include <time.h>
+#include "i915/gem.h"
+#include "igt.h"
+#include "igt_vgem.h"
#include "intel_batchbuffer.h" /* igt_blitter_src_copy() */
IGT_TEST_DESCRIPTION("Basic check of polling for prime/vgem fences.");