All of lore.kernel.org
 help / color / mirror / Atom feed
* [igt-dev] [PATCH i-g-t] lib/i915: Split igt_require_gem() into i915/
@ 2020-05-07  8:45 Chris Wilson
  2020-05-07  9:28 ` [igt-dev] ✓ Fi.CI.BAT: success for lib/i915: Split igt_require_gem() into i915/ (rev2) Patchwork
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Chris Wilson @ 2020-05-07  8:45 UTC (permalink / raw)
  To: igt-dev; +Cc: Chris Wilson

igt_require_gem() is a pecularity of i915/, move it out of the core.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
---
 lib/Makefile.sources                        |   2 +
 lib/drmtest.c                               |  22 +---
 lib/drmtest.h                               |   2 -
 lib/i915/gem.c                              | 117 ++++++++++++++++++++
 lib/i915/gem.h                              |  33 ++++++
 lib/i915/gem_ring.c                         |   1 +
 lib/i915/gem_submission.c                   |  22 +---
 lib/i915/gem_submission.h                   |   2 -
 lib/i915/gem_vm.h                           |   1 +
 lib/igt_debugfs.c                           |   5 +-
 lib/igt_dummyload.c                         |  11 +-
 lib/igt_gt.c                                |   3 +-
 lib/ioctl_wrappers.c                        |  49 --------
 lib/ioctl_wrappers.h                        |   1 -
 lib/meson.build                             |   1 +
 tests/amdgpu/amd_prime.c                    |   7 +-
 tests/core_hotunplug.c                      |   1 +
 tests/debugfs_test.c                        |   2 +
 tests/i915/gem_bad_blit.c                   |   4 +-
 tests/i915/gem_bad_reloc.c                  |   4 +-
 tests/i915/gem_blits.c                      |   1 +
 tests/i915/gem_busy.c                       |   3 +-
 tests/i915/gem_caching.c                    |   3 +-
 tests/i915/gem_close.c                      |   1 +
 tests/i915/gem_close_race.c                 |   4 +-
 tests/i915/gem_concurrent_all.c             |   5 +-
 tests/i915/gem_cs_prefetch.c                |   1 +
 tests/i915/gem_cs_tlb.c                     |   4 +-
 tests/i915/gem_ctx_clone.c                  |   5 +-
 tests/i915/gem_ctx_create.c                 |   4 +-
 tests/i915/gem_ctx_engines.c                |   4 +-
 tests/i915/gem_ctx_exec.c                   |   3 +-
 tests/i915/gem_ctx_freq.c                   |   1 +
 tests/i915/gem_ctx_isolation.c              |   1 +
 tests/i915/gem_ctx_param.c                  |   1 +
 tests/i915/gem_ctx_persistence.c            |   1 +
 tests/i915/gem_ctx_ringsize.c               |   1 +
 tests/i915/gem_ctx_shared.c                 |   4 +-
 tests/i915/gem_ctx_sseu.c                   |   4 +-
 tests/i915/gem_ctx_switch.c                 |   4 +-
 tests/i915/gem_ctx_thrash.c                 |   6 +-
 tests/i915/gem_eio.c                        |   3 +-
 tests/i915/gem_evict_alignment.c            |   3 +-
 tests/i915/gem_evict_everything.c           |   4 +-
 tests/i915/gem_exec_alignment.c             |   3 +-
 tests/i915/gem_exec_async.c                 |   1 +
 tests/i915/gem_exec_await.c                 |   9 +-
 tests/i915/gem_exec_bad_domains.c           |   4 +-
 tests/i915/gem_exec_balancer.c              |   3 +-
 tests/i915/gem_exec_big.c                   |   4 +-
 tests/i915/gem_exec_capture.c               |   1 +
 tests/i915/gem_exec_create.c                |   4 +-
 tests/i915/gem_exec_fence.c                 |  11 +-
 tests/i915/gem_exec_flush.c                 |   1 +
 tests/i915/gem_exec_gttfill.c               |   1 +
 tests/i915/gem_exec_latency.c               |   3 +-
 tests/i915/gem_exec_lut_handle.c            |   4 +-
 tests/i915/gem_exec_nop.c                   |  12 +-
 tests/i915/gem_exec_parallel.c              |   1 +
 tests/i915/gem_exec_params.c                |   8 +-
 tests/i915/gem_exec_reloc.c                 |   1 +
 tests/i915/gem_exec_schedule.c              |   3 +-
 tests/i915/gem_exec_store.c                 |   4 +-
 tests/i915/gem_exec_suspend.c               |   1 +
 tests/i915/gem_exec_whisper.c               |   1 +
 tests/i915/gem_fenced_exec_thrash.c         |   1 +
 tests/i915/gem_gpgpu_fill.c                 |   4 +-
 tests/i915/gem_gtt_hog.c                    |   3 +-
 tests/i915/gem_linear_blits.c               |   3 +-
 tests/i915/gem_media_fill.c                 |   4 +-
 tests/i915/gem_media_vme.c                  |   4 +-
 tests/i915/gem_mmap_gtt.c                   |   1 +
 tests/i915/gem_mmap_offset.c                |   1 +
 tests/i915/gem_non_secure_batch.c           |   6 +-
 tests/i915/gem_partial_pwrite_pread.c       |   3 +-
 tests/i915/gem_pipe_control_store_loop.c    |   4 +-
 tests/i915/gem_ppgtt.c                      |   5 +-
 tests/i915/gem_pread_after_blit.c           |   3 +-
 tests/i915/gem_pwrite_snooped.c             |   4 +-
 tests/i915/gem_read_read_speed.c            |   5 +-
 tests/i915/gem_render_copy.c                |   5 +-
 tests/i915/gem_render_copy_redux.c          |   3 +-
 tests/i915/gem_render_linear_blits.c        |   3 +-
 tests/i915/gem_render_tiled_blits.c         |   3 +-
 tests/i915/gem_request_retire.c             |   3 +-
 tests/i915/gem_reset_stats.c                |   5 +-
 tests/i915/gem_ringfill.c                   |   3 +-
 tests/i915/gem_set_tiling_vs_blt.c          |   4 +-
 tests/i915/gem_shrink.c                     |   1 +
 tests/i915/gem_softpin.c                    |   1 +
 tests/i915/gem_spin_batch.c                 |   1 +
 tests/i915/gem_streaming_writes.c           |   4 +-
 tests/i915/gem_sync.c                       |   1 +
 tests/i915/gem_tiled_blits.c                |   3 +-
 tests/i915/gem_tiled_fence_blits.c          |   1 +
 tests/i915/gem_tiled_partial_pwrite_pread.c |   3 +-
 tests/i915/gem_unfence_active_buffers.c     |   4 +-
 tests/i915/gem_unref_active_buffers.c       |   4 +-
 tests/i915/gem_userptr_blits.c              |   3 +-
 tests/i915/gem_vm_create.c                  |   3 +-
 tests/i915/gem_wait.c                       |   1 +
 tests/i915/gem_workarounds.c                |   5 +-
 tests/i915/gen3_mixed_blits.c               |   5 +-
 tests/i915/gen3_render_linear_blits.c       |   5 +-
 tests/i915/gen3_render_mixed_blits.c        |   5 +-
 tests/i915/gen3_render_tiledx_blits.c       |   5 +-
 tests/i915/gen3_render_tiledy_blits.c       |   3 +-
 tests/i915/gen7_exec_parse.c                |   3 +-
 tests/i915/gen9_exec_parse.c                |   3 +-
 tests/i915/i915_hangman.c                   |   3 +-
 tests/i915/i915_pm_rc6_residency.c          |   1 +
 tests/i915/i915_pm_rpm.c                    |   1 +
 tests/i915/i915_pm_rps.c                    |   1 +
 tests/i915/i915_pm_sseu.c                   |   5 +-
 tests/i915/i915_suspend.c                   |   3 +-
 tests/i915/sysfs_heartbeat_interval.c       |   1 +
 tests/i915/sysfs_preempt_timeout.c          |   4 +-
 tests/i915/sysfs_timeslice_duration.c       |   3 +-
 tests/kms_busy.c                            |   5 +-
 tests/kms_cursor_legacy.c                   |   1 +
 tests/kms_draw_crc.c                        |   1 +
 tests/kms_fence_pin_leak.c                  |   3 +-
 tests/kms_flip_tiling.c                     |   4 +-
 tests/kms_frontbuffer_tracking.c            |   7 +-
 tests/perf.c                                |   3 +-
 tests/perf_pmu.c                            |   3 +-
 tests/prime_busy.c                          |   5 +-
 tests/prime_mmap_coherency.c                |   1 +
 tests/prime_vgem.c                          |   6 +-
 129 files changed, 422 insertions(+), 224 deletions(-)
 create mode 100644 lib/i915/gem.c
 create mode 100644 lib/i915/gem.h

diff --git a/lib/Makefile.sources b/lib/Makefile.sources
index 1e2c88aea..6449574ce 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 d6ee39e0c..85f96ae1c 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 d5f0fc256..c56bfafa5 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 000000000..cabd23768
--- /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 000000000..e5403f09c
--- /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 99f4741cb..a57bf4c58 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 72de0c223..c5adcdc72 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 acd24bcbf..b030ed9fc 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 27af899d4..acbb663e6 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 9e6c5c993..050670785 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 ae0fb9378..d4cc9be6a 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 256c7cbc0..64b62c8c3 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 25d04b3e6..61f93bd8c 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 799d90266..9f1f5c5c5 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 e20604308..f2b845c9c 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 fdb8a0283..0242dc772 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 ded53fd58..e03f3b945 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 73b82edae..f6cf1fa00 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 27a34038c..848e19756 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 57efc77c3..7eb7fa538 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 3d3b90274..65f7c3dd4 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 b3d9ed027..0d036ea22 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 7c1f6410a..0ffffa054 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 0e364514e..4fdc1ad79 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 57e004807..db570e8fd 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 22f429e84..fecb2b22e 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_cs_prefetch.c b/tests/i915/gem_cs_prefetch.c
index 3498aa1ed..f329ba7e4 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 f64e4df2b..3e9d882bd 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 471031d42..b72269bcc 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 2d4772264..f651710aa 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 62f305980..7d6d8e664 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 ad2f9e545..23036a952 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 5d2d3ec31..a34472de5 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 dadab2870..9fdf78bb8 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 b2940abc2..72dcb973d 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 3d52987d1..bd3c819b4 100644
--- a/tests/i915/gem_ctx_persistence.c
+++ b/tests/i915/gem_ctx_persistence.c
@@ -29,6 +29,7 @@
 #include <unistd.h>
 
 #include "drmtest.h" /* gem_quiescent_gpu()! */
+#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 ef321c52a..4a3578325 100644
--- a/tests/i915/gem_ctx_ringsize.c
+++ b/tests/i915/gem_ctx_ringsize.c
@@ -30,6 +30,7 @@
 #include <unistd.h>
 
 #include "drmtest.h" /* gem_quiescent_gpu()! */
+#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 c9d30e431..43ff60ad7 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 3bef11b51..749ce336a 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 5f94dac86..3d34c3560 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 ae38a7abe..dc7259c18 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 1ec609410..a12590670 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 da13fb656..d4a5877aa 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 2580a0b23..5d4d15c4b 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 862799118..17a14bef4 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 70f9d20ce..f4198eed4 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 7817b483c..4c1771e27 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 cd2c8956a..733964f47 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 60a901846..d4944e3f1 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 a58693301..63de42d57 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 bc13d8632..dc721c1ae 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 e3ceb3f5c..d3dd78ffb 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 1baa0a367..20a5d49d9 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 513cde364..7d9fcbfcb 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 235fa6e0e..7a6d7c0fb 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 d2159f317..0b85fd2e9 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 6f227628c..bd69e9417 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 64ddb3db8..357449c5b 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 66fe18534..6d7cb3b8e 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 45581738a..bea857add 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 2a18c3b2c..f6fa55a36 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 0e0056cee..e9e6f5be5 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 677db6f6c..b37d63af3 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 f0c53dafa..8f2a781b5 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 153854d1c..6e8943422 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 db1b15aa7..b577a04f3 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 b2d401d6f..fb1758bd4 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 1ebef7765..1372245bf 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 0c6211c27..cae42d52a 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 c880bae99..3f0fec572 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 20f5ca351..c3af1b12e 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 38b4d02d7..d4f3f7cb8 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 93336a228..23d26075f 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 5f3399146..0bc2c3b5c 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 afd43694a..277a73905 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 e44e9fb53..863a4871d 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 4c7d3ba2d..8c02e4af4 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 e12b5d65b..81454c930 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 14f4c44ae..4a3395241 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 2aab22046..06b66935c 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 220164247..1e1e79b95 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 2388fc24f..a3f77e846 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 666a43cda..55a9e6bef 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 5f49b3fed..bd76066a6 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 7efea0b61..4a1ec1153 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 9c7b66458..e2d2dd8b5 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 4c73f4d9d..a2157bd6f 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 16edaf394..cb1641540 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 e434613eb..c9964ccc0 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 4204323e2..684dcfd4c 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 1142a77c7..e7dd58ec2 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 e83d69deb..bd44e1340 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 b50ad4f2b..6b3c76ec0 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 7fd11e050..36e967859 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 f927c819a..99ec78f9b 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 399c118fd..7de5358b2 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 c1670dd59..1e69c70d1 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 2adf0f1ae..753947947 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 17f4d10f0..05f96e759 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 a6d2dd91b..e8af68f19 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 43b3a658d..7b2b1c2b7 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 2fce445d4..4f043d7dd 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 1a954b65a..10a8cd3e2 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 c2cbc0b88..d88a2c93e 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 8cb7af341..cda175bd5 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 3939c07b8..579205f30 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 f0e6535f5..931e91a39 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 5578340f7..2ba438c99 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 854c59863..8cd82f568 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 13cd62087..2b341c4b2 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 9dc26a819..144bcd028 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 fedef872d..47e74856e 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 68b66c166..943a50986 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 c2dee1185..461c70cc9 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 83a4fa546..15340edc6 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 662f48653..100402854 100644
--- a/tests/i915/sysfs_heartbeat_interval.c
+++ b/tests/i915/sysfs_heartbeat_interval.c
@@ -32,6 +32,7 @@
 #include <unistd.h>
 
 #include "drmtest.h" /* gem_quiescent_gpu()! */
+#include "i915/gem.h"
 #include "i915/gem_engine_topology.h"
 #include "igt_dummyload.h"
 #include "igt_sysfs.h"
diff --git a/tests/i915/sysfs_preempt_timeout.c b/tests/i915/sysfs_preempt_timeout.c
index a7e93a4d9..8b2e48810 100644
--- a/tests/i915/sysfs_preempt_timeout.c
+++ b/tests/i915/sysfs_preempt_timeout.c
@@ -30,14 +30,14 @@
 #include <unistd.h>
 
 #include "drmtest.h" /* gem_quiescent_gpu()! */
+#include "i915/gem.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 b983df43d..47c1c3a2c 100644
--- a/tests/i915/sysfs_timeslice_duration.c
+++ b/tests/i915/sysfs_timeslice_duration.c
@@ -30,13 +30,14 @@
 #include <unistd.h>
 
 #include "drmtest.h" /* gem_quiescent_gpu()! */
+#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 "intel_chipset.h"
 #include "intel_reg.h"
+#include "ioctl_wrappers.h" /* igt_require_gem()! */
 #include "sw_sync.h"
 
 #define ATTR "timeslice_duration_ms"
diff --git a/tests/kms_busy.c b/tests/kms_busy.c
index 7e495fe2c..be4273bc4 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 ba66e1bda..9306e54ba 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 fa7433ab2..70b9b05ff 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 1ac65e8a1..b59efc0a5 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 17cf816de..fb79de153 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 347239225..5d55560d5 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 b1e2a2e64..d4ebae30d 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 5384b5264..e54a0d47e 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 caab95a34..aec76393b 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 32d78ee1a..2a0749577 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 d28ee0fad..38e2026aa 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.");
-- 
2.26.2

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [igt-dev] ✓ Fi.CI.BAT: success for lib/i915: Split igt_require_gem() into i915/ (rev2)
  2020-05-07  8:45 [igt-dev] [PATCH i-g-t] lib/i915: Split igt_require_gem() into i915/ Chris Wilson
@ 2020-05-07  9:28 ` Patchwork
  2020-05-07  9:40 ` [igt-dev] [PATCH i-g-t] lib/i915: Split igt_require_gem() into i915/ Petri Latvala
  2020-05-07 12:42 ` [igt-dev] ✓ Fi.CI.IGT: success for lib/i915: Split igt_require_gem() into i915/ (rev2) Patchwork
  2 siblings, 0 replies; 10+ messages in thread
From: Patchwork @ 2020-05-07  9:28 UTC (permalink / raw)
  To: Chris Wilson; +Cc: igt-dev

== Series Details ==

Series: lib/i915: Split igt_require_gem() into i915/ (rev2)
URL   : https://patchwork.freedesktop.org/series/76950/
State : success

== Summary ==

CI Bug Log - changes from IGT_5638 -> IGTPW_4541
====================================================

Summary
-------

  **SUCCESS**

  No regressions found.

  External URL: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4541/index.html


Changes
-------

  No changes found


Participating hosts (49 -> 42)
------------------------------

  Missing    (7): fi-ilk-m540 fi-hsw-4200u fi-byt-squawks fi-bsw-cyan fi-ctg-p8600 fi-byt-clapper fi-bdw-samus 


Build changes
-------------

  * CI: CI-20190529 -> None
  * IGT: IGT_5638 -> IGTPW_4541

  CI-20190529: 20190529
  CI_DRM_8441: 6c0ee41a7c3201ef2a89800234803a95f65989be @ git://anongit.freedesktop.org/gfx-ci/linux
  IGTPW_4541: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4541/index.html
  IGT_5638: 50868ab3c532a86aa147fb555b69a1078c572b13 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4541/index.html
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [igt-dev] [PATCH i-g-t] lib/i915: Split igt_require_gem() into i915/
  2020-05-07  8:45 [igt-dev] [PATCH i-g-t] lib/i915: Split igt_require_gem() into i915/ Chris Wilson
  2020-05-07  9:28 ` [igt-dev] ✓ Fi.CI.BAT: success for lib/i915: Split igt_require_gem() into i915/ (rev2) Patchwork
@ 2020-05-07  9:40 ` Petri Latvala
  2020-05-07  9:45   ` Chris Wilson
  2020-05-07 12:42 ` [igt-dev] ✓ Fi.CI.IGT: success for lib/i915: Split igt_require_gem() into i915/ (rev2) Patchwork
  2 siblings, 1 reply; 10+ messages in thread
From: Petri Latvala @ 2020-05-07  9:40 UTC (permalink / raw)
  To: Chris Wilson; +Cc: igt-dev

On Thu, May 07, 2020 at 09:45:50AM +0100, Chris Wilson wrote:
> igt_require_gem() is a pecularity of i915/, move it out of the core.
> 
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> ---
>  lib/Makefile.sources                        |   2 +
>  lib/drmtest.c                               |  22 +---
>  lib/drmtest.h                               |   2 -
>  lib/i915/gem.c                              | 117 ++++++++++++++++++++
>  lib/i915/gem.h                              |  33 ++++++
>  lib/i915/gem_ring.c                         |   1 +
>  lib/i915/gem_submission.c                   |  22 +---
>  lib/i915/gem_submission.h                   |   2 -
>  lib/i915/gem_vm.h                           |   1 +
>  lib/igt_debugfs.c                           |   5 +-
>  lib/igt_dummyload.c                         |  11 +-
>  lib/igt_gt.c                                |   3 +-
>  lib/ioctl_wrappers.c                        |  49 --------
>  lib/ioctl_wrappers.h                        |   1 -
>  lib/meson.build                             |   1 +
>  tests/amdgpu/amd_prime.c                    |   7 +-
>  tests/core_hotunplug.c                      |   1 +
>  tests/debugfs_test.c                        |   2 +
>  tests/i915/gem_bad_blit.c                   |   4 +-
>  tests/i915/gem_bad_reloc.c                  |   4 +-
>  tests/i915/gem_blits.c                      |   1 +
>  tests/i915/gem_busy.c                       |   3 +-
>  tests/i915/gem_caching.c                    |   3 +-
>  tests/i915/gem_close.c                      |   1 +
>  tests/i915/gem_close_race.c                 |   4 +-
>  tests/i915/gem_concurrent_all.c             |   5 +-
>  tests/i915/gem_cs_prefetch.c                |   1 +
>  tests/i915/gem_cs_tlb.c                     |   4 +-
>  tests/i915/gem_ctx_clone.c                  |   5 +-
>  tests/i915/gem_ctx_create.c                 |   4 +-
>  tests/i915/gem_ctx_engines.c                |   4 +-
>  tests/i915/gem_ctx_exec.c                   |   3 +-
>  tests/i915/gem_ctx_freq.c                   |   1 +
>  tests/i915/gem_ctx_isolation.c              |   1 +
>  tests/i915/gem_ctx_param.c                  |   1 +
>  tests/i915/gem_ctx_persistence.c            |   1 +
>  tests/i915/gem_ctx_ringsize.c               |   1 +
>  tests/i915/gem_ctx_shared.c                 |   4 +-
>  tests/i915/gem_ctx_sseu.c                   |   4 +-
>  tests/i915/gem_ctx_switch.c                 |   4 +-
>  tests/i915/gem_ctx_thrash.c                 |   6 +-
>  tests/i915/gem_eio.c                        |   3 +-
>  tests/i915/gem_evict_alignment.c            |   3 +-
>  tests/i915/gem_evict_everything.c           |   4 +-
>  tests/i915/gem_exec_alignment.c             |   3 +-
>  tests/i915/gem_exec_async.c                 |   1 +
>  tests/i915/gem_exec_await.c                 |   9 +-
>  tests/i915/gem_exec_bad_domains.c           |   4 +-
>  tests/i915/gem_exec_balancer.c              |   3 +-
>  tests/i915/gem_exec_big.c                   |   4 +-
>  tests/i915/gem_exec_capture.c               |   1 +
>  tests/i915/gem_exec_create.c                |   4 +-
>  tests/i915/gem_exec_fence.c                 |  11 +-
>  tests/i915/gem_exec_flush.c                 |   1 +
>  tests/i915/gem_exec_gttfill.c               |   1 +
>  tests/i915/gem_exec_latency.c               |   3 +-
>  tests/i915/gem_exec_lut_handle.c            |   4 +-
>  tests/i915/gem_exec_nop.c                   |  12 +-
>  tests/i915/gem_exec_parallel.c              |   1 +
>  tests/i915/gem_exec_params.c                |   8 +-
>  tests/i915/gem_exec_reloc.c                 |   1 +
>  tests/i915/gem_exec_schedule.c              |   3 +-
>  tests/i915/gem_exec_store.c                 |   4 +-
>  tests/i915/gem_exec_suspend.c               |   1 +
>  tests/i915/gem_exec_whisper.c               |   1 +
>  tests/i915/gem_fenced_exec_thrash.c         |   1 +
>  tests/i915/gem_gpgpu_fill.c                 |   4 +-
>  tests/i915/gem_gtt_hog.c                    |   3 +-
>  tests/i915/gem_linear_blits.c               |   3 +-
>  tests/i915/gem_media_fill.c                 |   4 +-
>  tests/i915/gem_media_vme.c                  |   4 +-
>  tests/i915/gem_mmap_gtt.c                   |   1 +
>  tests/i915/gem_mmap_offset.c                |   1 +
>  tests/i915/gem_non_secure_batch.c           |   6 +-
>  tests/i915/gem_partial_pwrite_pread.c       |   3 +-
>  tests/i915/gem_pipe_control_store_loop.c    |   4 +-
>  tests/i915/gem_ppgtt.c                      |   5 +-
>  tests/i915/gem_pread_after_blit.c           |   3 +-
>  tests/i915/gem_pwrite_snooped.c             |   4 +-
>  tests/i915/gem_read_read_speed.c            |   5 +-
>  tests/i915/gem_render_copy.c                |   5 +-
>  tests/i915/gem_render_copy_redux.c          |   3 +-
>  tests/i915/gem_render_linear_blits.c        |   3 +-
>  tests/i915/gem_render_tiled_blits.c         |   3 +-
>  tests/i915/gem_request_retire.c             |   3 +-
>  tests/i915/gem_reset_stats.c                |   5 +-
>  tests/i915/gem_ringfill.c                   |   3 +-
>  tests/i915/gem_set_tiling_vs_blt.c          |   4 +-
>  tests/i915/gem_shrink.c                     |   1 +
>  tests/i915/gem_softpin.c                    |   1 +
>  tests/i915/gem_spin_batch.c                 |   1 +
>  tests/i915/gem_streaming_writes.c           |   4 +-
>  tests/i915/gem_sync.c                       |   1 +
>  tests/i915/gem_tiled_blits.c                |   3 +-
>  tests/i915/gem_tiled_fence_blits.c          |   1 +
>  tests/i915/gem_tiled_partial_pwrite_pread.c |   3 +-
>  tests/i915/gem_unfence_active_buffers.c     |   4 +-
>  tests/i915/gem_unref_active_buffers.c       |   4 +-
>  tests/i915/gem_userptr_blits.c              |   3 +-
>  tests/i915/gem_vm_create.c                  |   3 +-
>  tests/i915/gem_wait.c                       |   1 +
>  tests/i915/gem_workarounds.c                |   5 +-
>  tests/i915/gen3_mixed_blits.c               |   5 +-
>  tests/i915/gen3_render_linear_blits.c       |   5 +-
>  tests/i915/gen3_render_mixed_blits.c        |   5 +-
>  tests/i915/gen3_render_tiledx_blits.c       |   5 +-
>  tests/i915/gen3_render_tiledy_blits.c       |   3 +-
>  tests/i915/gen7_exec_parse.c                |   3 +-
>  tests/i915/gen9_exec_parse.c                |   3 +-
>  tests/i915/i915_hangman.c                   |   3 +-
>  tests/i915/i915_pm_rc6_residency.c          |   1 +
>  tests/i915/i915_pm_rpm.c                    |   1 +
>  tests/i915/i915_pm_rps.c                    |   1 +
>  tests/i915/i915_pm_sseu.c                   |   5 +-
>  tests/i915/i915_suspend.c                   |   3 +-
>  tests/i915/sysfs_heartbeat_interval.c       |   1 +
>  tests/i915/sysfs_preempt_timeout.c          |   4 +-
>  tests/i915/sysfs_timeslice_duration.c       |   3 +-
>  tests/kms_busy.c                            |   5 +-
>  tests/kms_cursor_legacy.c                   |   1 +
>  tests/kms_draw_crc.c                        |   1 +
>  tests/kms_fence_pin_leak.c                  |   3 +-
>  tests/kms_flip_tiling.c                     |   4 +-
>  tests/kms_frontbuffer_tracking.c            |   7 +-
>  tests/perf.c                                |   3 +-
>  tests/perf_pmu.c                            |   3 +-
>  tests/prime_busy.c                          |   5 +-
>  tests/prime_mmap_coherency.c                |   1 +
>  tests/prime_vgem.c                          |   6 +-
>  129 files changed, 422 insertions(+), 224 deletions(-)
>  create mode 100644 lib/i915/gem.c
>  create mode 100644 lib/i915/gem.h
> 
> diff --git a/lib/Makefile.sources b/lib/Makefile.sources
> index 1e2c88aea..6449574ce 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 d6ee39e0c..85f96ae1c 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 d5f0fc256..c56bfafa5 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 000000000..cabd23768
> --- /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");


Food for thought (not for this patch): Using igt_abort_f() for this instead?


<snip>

> diff --git a/lib/igt_debugfs.c b/lib/igt_debugfs.c
> index 9e6c5c993..050670785 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);
>  }

No more quiescenting here?


<snip>


> diff --git a/tests/i915/gem_ctx_persistence.c b/tests/i915/gem_ctx_persistence.c
> index 3d52987d1..bd3c819b4 100644
> --- a/tests/i915/gem_ctx_persistence.c
> +++ b/tests/i915/gem_ctx_persistence.c
> @@ -29,6 +29,7 @@
>  #include <unistd.h>
>  
>  #include "drmtest.h" /* gem_quiescent_gpu()! */

This comment appears on multiple tests and is now lying.



-- 
Petri Latvala
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [igt-dev] [PATCH i-g-t] lib/i915: Split igt_require_gem() into i915/
  2020-05-07  9:40 ` [igt-dev] [PATCH i-g-t] lib/i915: Split igt_require_gem() into i915/ Petri Latvala
@ 2020-05-07  9:45   ` Chris Wilson
  2020-05-07  9:53     ` Petri Latvala
  0 siblings, 1 reply; 10+ messages in thread
From: Chris Wilson @ 2020-05-07  9:45 UTC (permalink / raw)
  To: Petri Latvala; +Cc: igt-dev

Quoting Petri Latvala (2020-05-07 10:40:35)
> On Thu, May 07, 2020 at 09:45:50AM +0100, Chris Wilson wrote:
> > +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");
> 
> 
> Food for thought (not for this patch): Using igt_abort_f() for this instead?

Not everything requires gem? But yeah, it's pretty common to have a pile
of skips after toasting the GPU.

> <snip>
> 
> > diff --git a/lib/igt_debugfs.c b/lib/igt_debugfs.c
> > index 9e6c5c993..050670785 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);
> >  }
> 
> No more quiescenting here?

gem_object_count() already was idling and freeing.

> <snip>
> 
> 
> > diff --git a/tests/i915/gem_ctx_persistence.c b/tests/i915/gem_ctx_persistence.c
> > index 3d52987d1..bd3c819b4 100644
> > --- a/tests/i915/gem_ctx_persistence.c
> > +++ b/tests/i915/gem_ctx_persistence.c
> > @@ -29,6 +29,7 @@
> >  #include <unistd.h>
> >  
> >  #include "drmtest.h" /* gem_quiescent_gpu()! */
> 
> This comment appears on multiple tests and is now lying.

Good point, I can stop ranting in a few places :)
-Chris
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [igt-dev] [PATCH i-g-t] lib/i915: Split igt_require_gem() into i915/
  2020-05-07  9:45   ` Chris Wilson
@ 2020-05-07  9:53     ` Petri Latvala
  2020-05-07 10:04       ` Chris Wilson
  0 siblings, 1 reply; 10+ messages in thread
From: Petri Latvala @ 2020-05-07  9:53 UTC (permalink / raw)
  To: Chris Wilson, Martin Peres; +Cc: igt-dev

On Thu, May 07, 2020 at 10:45:19AM +0100, Chris Wilson wrote:
> Quoting Petri Latvala (2020-05-07 10:40:35)
> > On Thu, May 07, 2020 at 09:45:50AM +0100, Chris Wilson wrote:
> > > +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");
> > 
> > 
> > Food for thought (not for this patch): Using igt_abort_f() for this instead?
> 
> Not everything requires gem? But yeah, it's pretty common to have a pile
> of skips after toasting the GPU.

Generally if the GPU is toast there's really no point in testing
further, even if they don't require gem. I'd rather have that in CI
than flip-flopping skips. Validation is a different matter.

Martin can probably give a good opinion on that.

-- 
Petri Latvala
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [igt-dev] [PATCH i-g-t] lib/i915: Split igt_require_gem() into i915/
  2020-05-07  9:53     ` Petri Latvala
@ 2020-05-07 10:04       ` Chris Wilson
  2020-05-07 10:07         ` Petri Latvala
  0 siblings, 1 reply; 10+ messages in thread
From: Chris Wilson @ 2020-05-07 10:04 UTC (permalink / raw)
  To: Martin Peres, Petri Latvala; +Cc: igt-dev

Quoting Petri Latvala (2020-05-07 10:53:34)
> On Thu, May 07, 2020 at 10:45:19AM +0100, Chris Wilson wrote:
> > Quoting Petri Latvala (2020-05-07 10:40:35)
> > > On Thu, May 07, 2020 at 09:45:50AM +0100, Chris Wilson wrote:
> > > > +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");
> > > 
> > > 
> > > Food for thought (not for this patch): Using igt_abort_f() for this instead?
> > 
> > Not everything requires gem? But yeah, it's pretty common to have a pile
> > of skips after toasting the GPU.
> 
> Generally if the GPU is toast there's really no point in testing
> further, even if they don't require gem. I'd rather have that in CI
> than flip-flopping skips. Validation is a different matter.
> 
> Martin can probably give a good opinion on that.

Who gets the blame for igt_abort_f? We want it like igt@runner@aborted
that it says couldn't continue after blah.
-Chris
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [igt-dev] [PATCH i-g-t] lib/i915: Split igt_require_gem() into i915/
  2020-05-07 10:04       ` Chris Wilson
@ 2020-05-07 10:07         ` Petri Latvala
  2020-05-07 10:09           ` Chris Wilson
  0 siblings, 1 reply; 10+ messages in thread
From: Petri Latvala @ 2020-05-07 10:07 UTC (permalink / raw)
  To: Chris Wilson; +Cc: igt-dev

On Thu, May 07, 2020 at 11:04:55AM +0100, Chris Wilson wrote:
> Quoting Petri Latvala (2020-05-07 10:53:34)
> > On Thu, May 07, 2020 at 10:45:19AM +0100, Chris Wilson wrote:
> > > Quoting Petri Latvala (2020-05-07 10:40:35)
> > > > On Thu, May 07, 2020 at 09:45:50AM +0100, Chris Wilson wrote:
> > > > > +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");
> > > > 
> > > > 
> > > > Food for thought (not for this patch): Using igt_abort_f() for this instead?
> > > 
> > > Not everything requires gem? But yeah, it's pretty common to have a pile
> > > of skips after toasting the GPU.
> > 
> > Generally if the GPU is toast there's really no point in testing
> > further, even if they don't require gem. I'd rather have that in CI
> > than flip-flopping skips. Validation is a different matter.
> > 
> > Martin can probably give a good opinion on that.
> 
> Who gets the blame for igt_abort_f? We want it like igt@runner@aborted
> that it says couldn't continue after blah.

The test that called it.

Now, that puts the blame on the test that didn't cause the state, but
so does igt_require.


-- 
Petri Latvala
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [igt-dev] [PATCH i-g-t] lib/i915: Split igt_require_gem() into i915/
  2020-05-07 10:07         ` Petri Latvala
@ 2020-05-07 10:09           ` Chris Wilson
  0 siblings, 0 replies; 10+ messages in thread
From: Chris Wilson @ 2020-05-07 10:09 UTC (permalink / raw)
  To: Petri Latvala; +Cc: igt-dev

Quoting Petri Latvala (2020-05-07 11:07:33)
> On Thu, May 07, 2020 at 11:04:55AM +0100, Chris Wilson wrote:
> > Quoting Petri Latvala (2020-05-07 10:53:34)
> > > On Thu, May 07, 2020 at 10:45:19AM +0100, Chris Wilson wrote:
> > > > Quoting Petri Latvala (2020-05-07 10:40:35)
> > > > > On Thu, May 07, 2020 at 09:45:50AM +0100, Chris Wilson wrote:
> > > > > > +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");
> > > > > 
> > > > > 
> > > > > Food for thought (not for this patch): Using igt_abort_f() for this instead?
> > > > 
> > > > Not everything requires gem? But yeah, it's pretty common to have a pile
> > > > of skips after toasting the GPU.
> > > 
> > > Generally if the GPU is toast there's really no point in testing
> > > further, even if they don't require gem. I'd rather have that in CI
> > > than flip-flopping skips. Validation is a different matter.
> > > 
> > > Martin can probably give a good opinion on that.
> > 
> > Who gets the blame for igt_abort_f? We want it like igt@runner@aborted
> > that it says couldn't continue after blah.
> 
> The test that called it.
> 
> Now, that puts the blame on the test that didn't cause the state, but
> so does igt_require.

igt_require is blameless. Filing bugs for it is just a waste of
everybody's time.
-Chris
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [igt-dev] ✓ Fi.CI.IGT: success for lib/i915: Split igt_require_gem() into i915/ (rev2)
  2020-05-07  8:45 [igt-dev] [PATCH i-g-t] lib/i915: Split igt_require_gem() into i915/ Chris Wilson
  2020-05-07  9:28 ` [igt-dev] ✓ Fi.CI.BAT: success for lib/i915: Split igt_require_gem() into i915/ (rev2) Patchwork
  2020-05-07  9:40 ` [igt-dev] [PATCH i-g-t] lib/i915: Split igt_require_gem() into i915/ Petri Latvala
@ 2020-05-07 12:42 ` Patchwork
  2 siblings, 0 replies; 10+ messages in thread
From: Patchwork @ 2020-05-07 12:42 UTC (permalink / raw)
  To: Chris Wilson; +Cc: igt-dev

== Series Details ==

Series: lib/i915: Split igt_require_gem() into i915/ (rev2)
URL   : https://patchwork.freedesktop.org/series/76950/
State : success

== Summary ==

CI Bug Log - changes from IGT_5638_full -> IGTPW_4541_full
====================================================

Summary
-------

  **SUCCESS**

  No regressions found.

  External URL: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4541/index.html

Possible new issues
-------------------

  Here are the unknown changes that may have been introduced in IGTPW_4541_full:

### IGT changes ###

#### Suppressed ####

  The following results come from untrusted machines, tests, or statuses.
  They do not affect the overall result.

  * {igt@prime_busy@hang-wait@rcs0}:
    - shard-tglb:         [PASS][1] -> [INCOMPLETE][2]
   [1]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5638/shard-tglb7/igt@prime_busy@hang-wait@rcs0.html
   [2]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4541/shard-tglb6/igt@prime_busy@hang-wait@rcs0.html

  
Known issues
------------

  Here are the changes found in IGTPW_4541_full that come from known issues:

### IGT changes ###

#### Issues hit ####

  * igt@gem_ctx_persistence@legacy-engines-mixed-process@render:
    - shard-apl:          [PASS][3] -> [FAIL][4] ([i915#1528])
   [3]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5638/shard-apl4/igt@gem_ctx_persistence@legacy-engines-mixed-process@render.html
   [4]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4541/shard-apl8/igt@gem_ctx_persistence@legacy-engines-mixed-process@render.html

  * igt@kms_cursor_legacy@cursorb-vs-flipb-legacy:
    - shard-hsw:          [PASS][5] -> [INCOMPLETE][6] ([i915#61])
   [5]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5638/shard-hsw2/igt@kms_cursor_legacy@cursorb-vs-flipb-legacy.html
   [6]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4541/shard-hsw7/igt@kms_cursor_legacy@cursorb-vs-flipb-legacy.html

  * igt@kms_pipe_crc_basic@suspend-read-crc-pipe-c:
    - shard-kbl:          [PASS][7] -> [DMESG-WARN][8] ([i915#180]) +1 similar issue
   [7]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5638/shard-kbl6/igt@kms_pipe_crc_basic@suspend-read-crc-pipe-c.html
   [8]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4541/shard-kbl2/igt@kms_pipe_crc_basic@suspend-read-crc-pipe-c.html

  * igt@kms_plane_alpha_blend@pipe-a-coverage-vs-premult-vs-constant:
    - shard-kbl:          [PASS][9] -> [FAIL][10] ([fdo#108145] / [i915#265] / [i915#93] / [i915#95])
   [9]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5638/shard-kbl7/igt@kms_plane_alpha_blend@pipe-a-coverage-vs-premult-vs-constant.html
   [10]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4541/shard-kbl1/igt@kms_plane_alpha_blend@pipe-a-coverage-vs-premult-vs-constant.html
    - shard-apl:          [PASS][11] -> [FAIL][12] ([fdo#108145] / [i915#265] / [i915#95])
   [11]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5638/shard-apl6/igt@kms_plane_alpha_blend@pipe-a-coverage-vs-premult-vs-constant.html
   [12]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4541/shard-apl4/igt@kms_plane_alpha_blend@pipe-a-coverage-vs-premult-vs-constant.html

  * igt@kms_plane_lowres@pipe-a-tiling-x:
    - shard-glk:          [PASS][13] -> [FAIL][14] ([i915#899])
   [13]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5638/shard-glk9/igt@kms_plane_lowres@pipe-a-tiling-x.html
   [14]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4541/shard-glk2/igt@kms_plane_lowres@pipe-a-tiling-x.html

  * igt@kms_psr@no_drrs:
    - shard-iclb:         [PASS][15] -> [FAIL][16] ([i915#173])
   [15]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5638/shard-iclb3/igt@kms_psr@no_drrs.html
   [16]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4541/shard-iclb1/igt@kms_psr@no_drrs.html

  * igt@kms_psr@psr2_sprite_plane_move:
    - shard-iclb:         [PASS][17] -> [SKIP][18] ([fdo#109441]) +1 similar issue
   [17]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5638/shard-iclb2/igt@kms_psr@psr2_sprite_plane_move.html
   [18]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4541/shard-iclb6/igt@kms_psr@psr2_sprite_plane_move.html

  
#### Possible fixes ####

  * {igt@gem_ctx_isolation@preservation-s3@rcs0}:
    - shard-apl:          [DMESG-WARN][19] ([i915#180]) -> [PASS][20] +3 similar issues
   [19]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5638/shard-apl6/igt@gem_ctx_isolation@preservation-s3@rcs0.html
   [20]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4541/shard-apl8/igt@gem_ctx_isolation@preservation-s3@rcs0.html

  * igt@kms_big_fb@linear-32bpp-rotate-0:
    - shard-kbl:          [FAIL][21] ([i915#1119] / [i915#93] / [i915#95]) -> [PASS][22]
   [21]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5638/shard-kbl6/igt@kms_big_fb@linear-32bpp-rotate-0.html
   [22]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4541/shard-kbl6/igt@kms_big_fb@linear-32bpp-rotate-0.html
    - shard-apl:          [FAIL][23] ([i915#1119] / [i915#95]) -> [PASS][24]
   [23]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5638/shard-apl2/igt@kms_big_fb@linear-32bpp-rotate-0.html
   [24]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4541/shard-apl1/igt@kms_big_fb@linear-32bpp-rotate-0.html

  * igt@kms_cursor_crc@pipe-a-cursor-64x64-onscreen:
    - shard-kbl:          [FAIL][25] ([i915#54] / [i915#93] / [i915#95]) -> [PASS][26] +1 similar issue
   [25]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5638/shard-kbl2/igt@kms_cursor_crc@pipe-a-cursor-64x64-onscreen.html
   [26]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4541/shard-kbl4/igt@kms_cursor_crc@pipe-a-cursor-64x64-onscreen.html

  * igt@kms_cursor_legacy@2x-long-flip-vs-cursor-legacy:
    - shard-glk:          [FAIL][27] ([i915#72]) -> [PASS][28]
   [27]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5638/shard-glk8/igt@kms_cursor_legacy@2x-long-flip-vs-cursor-legacy.html
   [28]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4541/shard-glk1/igt@kms_cursor_legacy@2x-long-flip-vs-cursor-legacy.html

  * igt@kms_draw_crc@draw-method-xrgb8888-mmap-cpu-untiled:
    - shard-kbl:          [FAIL][29] ([i915#177] / [i915#52] / [i915#54] / [i915#93] / [i915#95]) -> [PASS][30]
   [29]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5638/shard-kbl1/igt@kms_draw_crc@draw-method-xrgb8888-mmap-cpu-untiled.html
   [30]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4541/shard-kbl7/igt@kms_draw_crc@draw-method-xrgb8888-mmap-cpu-untiled.html
    - shard-apl:          [FAIL][31] ([i915#52] / [i915#54] / [i915#95]) -> [PASS][32]
   [31]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5638/shard-apl6/igt@kms_draw_crc@draw-method-xrgb8888-mmap-cpu-untiled.html
   [32]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4541/shard-apl2/igt@kms_draw_crc@draw-method-xrgb8888-mmap-cpu-untiled.html

  * igt@kms_psr@psr2_primary_mmap_cpu:
    - shard-iclb:         [SKIP][33] ([fdo#109441]) -> [PASS][34] +2 similar issues
   [33]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5638/shard-iclb5/igt@kms_psr@psr2_primary_mmap_cpu.html
   [34]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4541/shard-iclb2/igt@kms_psr@psr2_primary_mmap_cpu.html

  * igt@kms_vblank@pipe-c-ts-continuation-suspend:
    - shard-kbl:          [INCOMPLETE][35] ([i915#155] / [i915#794]) -> [PASS][36]
   [35]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5638/shard-kbl4/igt@kms_vblank@pipe-c-ts-continuation-suspend.html
   [36]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4541/shard-kbl6/igt@kms_vblank@pipe-c-ts-continuation-suspend.html

  * {igt@perf@blocking-parameterized}:
    - shard-iclb:         [FAIL][37] ([i915#1542]) -> [PASS][38]
   [37]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5638/shard-iclb8/igt@perf@blocking-parameterized.html
   [38]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4541/shard-iclb7/igt@perf@blocking-parameterized.html

  
#### Warnings ####

  * igt@i915_pm_rpm@gem-idle:
    - shard-snb:          [INCOMPLETE][39] ([i915#82]) -> [SKIP][40] ([fdo#109271])
   [39]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5638/shard-snb5/igt@i915_pm_rpm@gem-idle.html
   [40]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4541/shard-snb5/igt@i915_pm_rpm@gem-idle.html

  * igt@kms_content_protection@atomic:
    - shard-apl:          [TIMEOUT][41] ([i915#1319]) -> [FAIL][42] ([fdo#110321] / [fdo#110336])
   [41]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5638/shard-apl6/igt@kms_content_protection@atomic.html
   [42]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4541/shard-apl4/igt@kms_content_protection@atomic.html

  * igt@kms_content_protection@atomic-dpms:
    - shard-apl:          [FAIL][43] ([fdo#110321] / [fdo#110336]) -> [TIMEOUT][44] ([i915#1319])
   [43]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5638/shard-apl4/igt@kms_content_protection@atomic-dpms.html
   [44]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4541/shard-apl7/igt@kms_content_protection@atomic-dpms.html

  * igt@kms_content_protection@srm:
    - shard-apl:          [FAIL][45] ([fdo#110321] / [i915#95]) -> [TIMEOUT][46] ([i915#1319])
   [45]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5638/shard-apl1/igt@kms_content_protection@srm.html
   [46]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4541/shard-apl2/igt@kms_content_protection@srm.html

  * igt@kms_plane_alpha_blend@pipe-a-alpha-opaque-fb:
    - shard-apl:          [FAIL][47] ([fdo#108145] / [i915#265] / [i915#95]) -> [FAIL][48] ([fdo#108145] / [i915#265])
   [47]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5638/shard-apl7/igt@kms_plane_alpha_blend@pipe-a-alpha-opaque-fb.html
   [48]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4541/shard-apl1/igt@kms_plane_alpha_blend@pipe-a-alpha-opaque-fb.html
    - shard-kbl:          [FAIL][49] ([fdo#108145] / [i915#265] / [i915#93] / [i915#95]) -> [FAIL][50] ([fdo#108145] / [i915#265])
   [49]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5638/shard-kbl1/igt@kms_plane_alpha_blend@pipe-a-alpha-opaque-fb.html
   [50]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4541/shard-kbl2/igt@kms_plane_alpha_blend@pipe-a-alpha-opaque-fb.html

  * igt@kms_psr2_su@page_flip:
    - shard-iclb:         [SKIP][51] ([fdo#109642] / [fdo#111068]) -> [FAIL][52] ([i915#608])
   [51]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5638/shard-iclb1/igt@kms_psr2_su@page_flip.html
   [52]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4541/shard-iclb2/igt@kms_psr2_su@page_flip.html

  
  {name}: This element is suppressed. This means it is ignored when computing
          the status of the difference (SUCCESS, WARNING, or FAILURE).

  [fdo#108145]: https://bugs.freedesktop.org/show_bug.cgi?id=108145
  [fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
  [fdo#109441]: https://bugs.freedesktop.org/show_bug.cgi?id=109441
  [fdo#109642]: https://bugs.freedesktop.org/show_bug.cgi?id=109642
  [fdo#110321]: https://bugs.freedesktop.org/show_bug.cgi?id=110321
  [fdo#110336]: https://bugs.freedesktop.org/show_bug.cgi?id=110336
  [fdo#111068]: https://bugs.freedesktop.org/show_bug.cgi?id=111068
  [i915#1119]: https://gitlab.freedesktop.org/drm/intel/issues/1119
  [i915#1319]: https://gitlab.freedesktop.org/drm/intel/issues/1319
  [i915#1528]: https://gitlab.freedesktop.org/drm/intel/issues/1528
  [i915#1542]: https://gitlab.freedesktop.org/drm/intel/issues/1542
  [i915#155]: https://gitlab.freedesktop.org/drm/intel/issues/155
  [i915#173]: https://gitlab.freedesktop.org/drm/intel/issues/173
  [i915#177]: https://gitlab.freedesktop.org/drm/intel/issues/177
  [i915#180]: https://gitlab.freedesktop.org/drm/intel/issues/180
  [i915#265]: https://gitlab.freedesktop.org/drm/intel/issues/265
  [i915#52]: https://gitlab.freedesktop.org/drm/intel/issues/52
  [i915#54]: https://gitlab.freedesktop.org/drm/intel/issues/54
  [i915#608]: https://gitlab.freedesktop.org/drm/intel/issues/608
  [i915#61]: https://gitlab.freedesktop.org/drm/intel/issues/61
  [i915#72]: https://gitlab.freedesktop.org/drm/intel/issues/72
  [i915#79]: https://gitlab.freedesktop.org/drm/intel/issues/79
  [i915#794]: https://gitlab.freedesktop.org/drm/intel/issues/794
  [i915#82]: https://gitlab.freedesktop.org/drm/intel/issues/82
  [i915#899]: https://gitlab.freedesktop.org/drm/intel/issues/899
  [i915#93]: https://gitlab.freedesktop.org/drm/intel/issues/93
  [i915#95]: https://gitlab.freedesktop.org/drm/intel/issues/95


Participating hosts (8 -> 8)
------------------------------

  No changes in participating hosts


Build changes
-------------

  * CI: CI-20190529 -> None
  * IGT: IGT_5638 -> IGTPW_4541

  CI-20190529: 20190529
  CI_DRM_8441: 6c0ee41a7c3201ef2a89800234803a95f65989be @ git://anongit.freedesktop.org/gfx-ci/linux
  IGTPW_4541: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4541/index.html
  IGT_5638: 50868ab3c532a86aa147fb555b69a1078c572b13 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4541/index.html
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [igt-dev] [PATCH i-g-t] lib/i915: Split igt_require_gem() into i915/
@ 2020-05-05 11:38 Chris Wilson
  0 siblings, 0 replies; 10+ messages in thread
From: Chris Wilson @ 2020-05-05 11:38 UTC (permalink / raw)
  To: intel-gfx; +Cc: igt-dev, Chris Wilson

igt_require_gem() is a pecularity of i915/, move it out of the core.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
---
 lib/Makefile.sources                        |  2 +
 lib/i915/gem.c                              | 80 +++++++++++++++++++++
 lib/i915/gem.h                              | 30 ++++++++
 lib/i915/gem_vm.h                           |  1 +
 lib/igt_dummyload.c                         | 11 +--
 lib/igt_gt.c                                |  3 +-
 lib/ioctl_wrappers.c                        | 49 -------------
 lib/ioctl_wrappers.h                        |  1 -
 lib/meson.build                             |  1 +
 tests/amdgpu/amd_prime.c                    |  7 +-
 tests/core_hotunplug.c                      |  1 +
 tests/debugfs_test.c                        |  2 +
 tests/i915/gem_bad_blit.c                   |  4 +-
 tests/i915/gem_bad_reloc.c                  |  4 +-
 tests/i915/gem_blits.c                      |  1 +
 tests/i915/gem_busy.c                       |  3 +-
 tests/i915/gem_caching.c                    |  3 +-
 tests/i915/gem_close.c                      |  1 +
 tests/i915/gem_close_race.c                 |  4 +-
 tests/i915/gem_concurrent_all.c             |  5 +-
 tests/i915/gem_cs_prefetch.c                |  1 +
 tests/i915/gem_cs_tlb.c                     |  4 +-
 tests/i915/gem_ctx_clone.c                  |  5 +-
 tests/i915/gem_ctx_create.c                 |  4 +-
 tests/i915/gem_ctx_engines.c                |  4 +-
 tests/i915/gem_ctx_exec.c                   |  3 +-
 tests/i915/gem_ctx_freq.c                   |  1 +
 tests/i915/gem_ctx_isolation.c              |  1 +
 tests/i915/gem_ctx_persistence.c            |  1 +
 tests/i915/gem_ctx_ringsize.c               |  1 +
 tests/i915/gem_ctx_shared.c                 |  4 +-
 tests/i915/gem_ctx_sseu.c                   |  4 +-
 tests/i915/gem_ctx_switch.c                 |  4 +-
 tests/i915/gem_ctx_thrash.c                 |  6 +-
 tests/i915/gem_eio.c                        |  3 +-
 tests/i915/gem_evict_alignment.c            |  3 +-
 tests/i915/gem_evict_everything.c           |  4 +-
 tests/i915/gem_exec_alignment.c             |  3 +-
 tests/i915/gem_exec_async.c                 |  1 +
 tests/i915/gem_exec_await.c                 |  9 +--
 tests/i915/gem_exec_bad_domains.c           |  4 +-
 tests/i915/gem_exec_balancer.c              |  3 +-
 tests/i915/gem_exec_big.c                   |  4 +-
 tests/i915/gem_exec_capture.c               |  1 +
 tests/i915/gem_exec_create.c                |  4 +-
 tests/i915/gem_exec_fence.c                 | 11 +--
 tests/i915/gem_exec_flush.c                 |  1 +
 tests/i915/gem_exec_gttfill.c               |  1 +
 tests/i915/gem_exec_latency.c               |  3 +-
 tests/i915/gem_exec_lut_handle.c            |  4 +-
 tests/i915/gem_exec_nop.c                   | 12 ++--
 tests/i915/gem_exec_parallel.c              |  1 +
 tests/i915/gem_exec_params.c                |  8 +--
 tests/i915/gem_exec_reloc.c                 |  1 +
 tests/i915/gem_exec_schedule.c              |  3 +-
 tests/i915/gem_exec_store.c                 |  4 +-
 tests/i915/gem_exec_suspend.c               |  1 +
 tests/i915/gem_exec_whisper.c               |  1 +
 tests/i915/gem_fenced_exec_thrash.c         |  1 +
 tests/i915/gem_gpgpu_fill.c                 |  4 +-
 tests/i915/gem_gtt_hog.c                    |  3 +-
 tests/i915/gem_linear_blits.c               |  3 +-
 tests/i915/gem_media_fill.c                 |  4 +-
 tests/i915/gem_media_vme.c                  |  4 +-
 tests/i915/gem_partial_pwrite_pread.c       |  3 +-
 tests/i915/gem_pipe_control_store_loop.c    |  4 +-
 tests/i915/gem_ppgtt.c                      |  5 +-
 tests/i915/gem_pread_after_blit.c           |  3 +-
 tests/i915/gem_pwrite_snooped.c             |  4 +-
 tests/i915/gem_read_read_speed.c            |  5 +-
 tests/i915/gem_render_copy.c                |  5 +-
 tests/i915/gem_render_copy_redux.c          |  3 +-
 tests/i915/gem_render_linear_blits.c        |  3 +-
 tests/i915/gem_render_tiled_blits.c         |  3 +-
 tests/i915/gem_request_retire.c             |  3 +-
 tests/i915/gem_ringfill.c                   |  3 +-
 tests/i915/gem_set_tiling_vs_blt.c          |  4 +-
 tests/i915/gem_shrink.c                     |  1 +
 tests/i915/gem_softpin.c                    |  1 +
 tests/i915/gem_spin_batch.c                 |  1 +
 tests/i915/gem_streaming_writes.c           |  4 +-
 tests/i915/gem_sync.c                       |  1 +
 tests/i915/gem_tiled_blits.c                |  3 +-
 tests/i915/gem_tiled_fence_blits.c          |  1 +
 tests/i915/gem_tiled_partial_pwrite_pread.c |  3 +-
 tests/i915/gem_unfence_active_buffers.c     |  4 +-
 tests/i915/gem_unref_active_buffers.c       |  4 +-
 tests/i915/gem_userptr_blits.c              |  3 +-
 tests/i915/gem_vm_create.c                  |  3 +-
 tests/i915/gem_wait.c                       |  1 +
 tests/i915/gem_workarounds.c                |  5 +-
 tests/i915/gen3_mixed_blits.c               |  5 +-
 tests/i915/gen3_render_linear_blits.c       |  5 +-
 tests/i915/gen3_render_mixed_blits.c        |  5 +-
 tests/i915/gen3_render_tiledx_blits.c       |  5 +-
 tests/i915/gen3_render_tiledy_blits.c       |  3 +-
 tests/i915/gen7_exec_parse.c                |  3 +-
 tests/i915/gen9_exec_parse.c                |  3 +-
 tests/i915/i915_hangman.c                   |  3 +-
 tests/i915/i915_pm_rc6_residency.c          |  1 +
 tests/i915/i915_pm_rpm.c                    |  1 +
 tests/i915/i915_pm_rps.c                    |  1 +
 tests/i915/i915_pm_sseu.c                   |  5 +-
 tests/i915/sysfs_heartbeat_interval.c       |  1 +
 tests/i915/sysfs_preempt_timeout.c          |  4 +-
 tests/i915/sysfs_timeslice_duration.c       |  3 +-
 tests/kms_busy.c                            |  5 +-
 tests/kms_cursor_legacy.c                   |  1 +
 tests/kms_draw_crc.c                        |  1 +
 tests/kms_fence_pin_leak.c                  |  3 +-
 tests/kms_flip_tiling.c                     |  4 +-
 tests/kms_frontbuffer_tracking.c            |  7 +-
 tests/perf.c                                |  3 +-
 tests/perf_pmu.c                            |  3 +-
 tests/prime_busy.c                          |  5 +-
 tests/prime_mmap_coherency.c                |  1 +
 tests/prime_vgem.c                          |  6 +-
 117 files changed, 365 insertions(+), 170 deletions(-)
 create mode 100644 lib/i915/gem.c
 create mode 100644 lib/i915/gem.h

diff --git a/lib/Makefile.sources b/lib/Makefile.sources
index 1e2c88aea..6449574ce 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/i915/gem.c b/lib/i915/gem.c
new file mode 100644
index 000000000..ac3fe28f4
--- /dev/null
+++ b/lib/i915/gem.c
@@ -0,0 +1,80 @@
+/*
+ * 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 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");
+}
diff --git a/lib/i915/gem.h b/lib/i915/gem.h
new file mode 100644
index 000000000..a489fed29
--- /dev/null
+++ b/lib/i915/gem.h
@@ -0,0 +1,30 @@
+/*
+ * 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 fd);
+
+#endif /* I915_GEM_H */
diff --git a/lib/i915/gem_vm.h b/lib/i915/gem_vm.h
index 27af899d4..acbb663e6 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_dummyload.c b/lib/igt_dummyload.c
index ae0fb9378..d4cc9be6a 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 256c7cbc0..64b62c8c3 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 25d04b3e6..61f93bd8c 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 799d90266..9f1f5c5c5 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 e20604308..f2b845c9c 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 fdb8a0283..0242dc772 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 ded53fd58..e03f3b945 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 73b82edae..f6cf1fa00 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 27a34038c..848e19756 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 57efc77c3..7eb7fa538 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 3d3b90274..65f7c3dd4 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 b3d9ed027..0d036ea22 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 7c1f6410a..0ffffa054 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 0e364514e..4fdc1ad79 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 57e004807..db570e8fd 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 22f429e84..fecb2b22e 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_cs_prefetch.c b/tests/i915/gem_cs_prefetch.c
index 3498aa1ed..f329ba7e4 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 f64e4df2b..3e9d882bd 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 471031d42..b72269bcc 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 2d4772264..f651710aa 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 62f305980..7d6d8e664 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 ad2f9e545..23036a952 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 5d2d3ec31..a34472de5 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 dadab2870..9fdf78bb8 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_persistence.c b/tests/i915/gem_ctx_persistence.c
index 3d52987d1..bd3c819b4 100644
--- a/tests/i915/gem_ctx_persistence.c
+++ b/tests/i915/gem_ctx_persistence.c
@@ -29,6 +29,7 @@
 #include <unistd.h>
 
 #include "drmtest.h" /* gem_quiescent_gpu()! */
+#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 ef321c52a..4a3578325 100644
--- a/tests/i915/gem_ctx_ringsize.c
+++ b/tests/i915/gem_ctx_ringsize.c
@@ -30,6 +30,7 @@
 #include <unistd.h>
 
 #include "drmtest.h" /* gem_quiescent_gpu()! */
+#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 c9d30e431..43ff60ad7 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 3bef11b51..749ce336a 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 5f94dac86..3d34c3560 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 ae38a7abe..dc7259c18 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 1ec609410..a12590670 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 da13fb656..d4a5877aa 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 2580a0b23..5d4d15c4b 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 862799118..17a14bef4 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 70f9d20ce..f4198eed4 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 7817b483c..4c1771e27 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 cd2c8956a..733964f47 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 60a901846..d4944e3f1 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 a58693301..63de42d57 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 bc13d8632..dc721c1ae 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 e3ceb3f5c..d3dd78ffb 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 9fe7c18b5..17fdaebd5 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 513cde364..7d9fcbfcb 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 235fa6e0e..7a6d7c0fb 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 d2159f317..0b85fd2e9 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 6f227628c..bd69e9417 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 64ddb3db8..357449c5b 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 66fe18534..6d7cb3b8e 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 45581738a..bea857add 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 2a18c3b2c..f6fa55a36 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 7274ffbf3..701729b16 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 677db6f6c..b37d63af3 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 f0c53dafa..8f2a781b5 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 153854d1c..6e8943422 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 db1b15aa7..b577a04f3 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 b2d401d6f..fb1758bd4 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 1ebef7765..1372245bf 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 0c6211c27..cae42d52a 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 c880bae99..3f0fec572 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 20f5ca351..c3af1b12e 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_partial_pwrite_pread.c b/tests/i915/gem_partial_pwrite_pread.c
index afd43694a..277a73905 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 e44e9fb53..863a4871d 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 4c7d3ba2d..8c02e4af4 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 e12b5d65b..81454c930 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 14f4c44ae..4a3395241 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 2aab22046..06b66935c 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 220164247..1e1e79b95 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 2388fc24f..a3f77e846 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 666a43cda..55a9e6bef 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 5f49b3fed..bd76066a6 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 7efea0b61..4a1ec1153 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_ringfill.c b/tests/i915/gem_ringfill.c
index 4c73f4d9d..a2157bd6f 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 16edaf394..cb1641540 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 e434613eb..c9964ccc0 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 4204323e2..684dcfd4c 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 1142a77c7..e7dd58ec2 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 e83d69deb..bd44e1340 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 b50ad4f2b..6b3c76ec0 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 7fd11e050..36e967859 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 f927c819a..99ec78f9b 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 399c118fd..7de5358b2 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 c1670dd59..1e69c70d1 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 2adf0f1ae..753947947 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 17f4d10f0..05f96e759 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 a6d2dd91b..e8af68f19 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 43b3a658d..7b2b1c2b7 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 2fce445d4..4f043d7dd 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 1a954b65a..10a8cd3e2 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 c2cbc0b88..d88a2c93e 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 8cb7af341..cda175bd5 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 3939c07b8..579205f30 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 f0e6535f5..931e91a39 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 5578340f7..2ba438c99 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 854c59863..8cd82f568 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 13cd62087..2b341c4b2 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 9dc26a819..144bcd028 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 fedef872d..47e74856e 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 68b66c166..943a50986 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 c2dee1185..461c70cc9 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/sysfs_heartbeat_interval.c b/tests/i915/sysfs_heartbeat_interval.c
index 662f48653..100402854 100644
--- a/tests/i915/sysfs_heartbeat_interval.c
+++ b/tests/i915/sysfs_heartbeat_interval.c
@@ -32,6 +32,7 @@
 #include <unistd.h>
 
 #include "drmtest.h" /* gem_quiescent_gpu()! */
+#include "i915/gem.h"
 #include "i915/gem_engine_topology.h"
 #include "igt_dummyload.h"
 #include "igt_sysfs.h"
diff --git a/tests/i915/sysfs_preempt_timeout.c b/tests/i915/sysfs_preempt_timeout.c
index a7e93a4d9..8b2e48810 100644
--- a/tests/i915/sysfs_preempt_timeout.c
+++ b/tests/i915/sysfs_preempt_timeout.c
@@ -30,14 +30,14 @@
 #include <unistd.h>
 
 #include "drmtest.h" /* gem_quiescent_gpu()! */
+#include "i915/gem.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 b983df43d..47c1c3a2c 100644
--- a/tests/i915/sysfs_timeslice_duration.c
+++ b/tests/i915/sysfs_timeslice_duration.c
@@ -30,13 +30,14 @@
 #include <unistd.h>
 
 #include "drmtest.h" /* gem_quiescent_gpu()! */
+#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 "intel_chipset.h"
 #include "intel_reg.h"
+#include "ioctl_wrappers.h" /* igt_require_gem()! */
 #include "sw_sync.h"
 
 #define ATTR "timeslice_duration_ms"
diff --git a/tests/kms_busy.c b/tests/kms_busy.c
index 7e495fe2c..be4273bc4 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 ba66e1bda..9306e54ba 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 fa7433ab2..70b9b05ff 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 1ac65e8a1..b59efc0a5 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 17cf816de..fb79de153 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 347239225..5d55560d5 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 b1e2a2e64..d4ebae30d 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 206c8dd87..27cd9b432 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 caab95a34..aec76393b 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 32d78ee1a..2a0749577 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 d28ee0fad..38e2026aa 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.");
-- 
2.26.2

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2020-05-07 12:42 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-07  8:45 [igt-dev] [PATCH i-g-t] lib/i915: Split igt_require_gem() into i915/ Chris Wilson
2020-05-07  9:28 ` [igt-dev] ✓ Fi.CI.BAT: success for lib/i915: Split igt_require_gem() into i915/ (rev2) Patchwork
2020-05-07  9:40 ` [igt-dev] [PATCH i-g-t] lib/i915: Split igt_require_gem() into i915/ Petri Latvala
2020-05-07  9:45   ` Chris Wilson
2020-05-07  9:53     ` Petri Latvala
2020-05-07 10:04       ` Chris Wilson
2020-05-07 10:07         ` Petri Latvala
2020-05-07 10:09           ` Chris Wilson
2020-05-07 12:42 ` [igt-dev] ✓ Fi.CI.IGT: success for lib/i915: Split igt_require_gem() into i915/ (rev2) Patchwork
  -- strict thread matches above, loose matches on Subject: below --
2020-05-05 11:38 [igt-dev] [PATCH i-g-t] lib/i915: Split igt_require_gem() into i915/ Chris Wilson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.