[PATCH i-g-t] lib/i915: Split igt_require_gem() into i915/

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

Signed-off-by: Chris Wilson <chris@xxxxxxxxxxxxxxxxxx>
---
 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@xxxxxxxxxxxx>
  *
  */
-#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@xxxxxxxxx>
  */
 
-#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@xxxxxxxxx>
  */
 
-#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

_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/intel-gfx





[Index of Archives]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux