[igt-dev] [PATCH i-g-t 1/2] lib/i915: Split gem_create.c from ioctl_wrappers.c

Chris Wilson chris at chris-wilson.co.uk
Mon Jan 11 11:55:11 UTC 2021


From: Andrzej Turko <andrzej.turko at linux.intel.com>

In preparation for a variation on the exisiting GEM_CREATE API, split
the ioctl from out of the large ioctl_wrappers.c

Signed-off-by: Andrzej Turko <andrzej.turko at linux.intel.com>
Reviewed-by: Chris Wilson <chris at chris-wilson.co.uk>
Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
---
 benchmarks/gem_blt.c                  |  1 +
 benchmarks/gem_busy.c                 |  1 +
 benchmarks/gem_create.c               |  3 +-
 benchmarks/gem_exec_ctx.c             |  3 +-
 benchmarks/gem_exec_fault.c           |  5 +--
 benchmarks/gem_exec_nop.c             |  5 +--
 benchmarks/gem_exec_reloc.c           |  8 +++--
 benchmarks/gem_exec_trace.c           |  5 +--
 benchmarks/gem_latency.c              |  3 +-
 benchmarks/gem_prw.c                  |  3 +-
 benchmarks/gem_set_domain.c           |  3 +-
 benchmarks/gem_syslatency.c           |  1 +
 benchmarks/gem_wsim.c                 |  7 ++--
 benchmarks/prime_lookup.c             |  5 +--
 lib/Makefile.sources                  |  1 +
 lib/i915/gem.h                        |  5 +++
 lib/i915/gem_create.c                 | 48 +++++++++++++++++++++++++++
 lib/i915/gem_mman.c                   |  1 +
 lib/i915/gem_mman.h                   |  4 ---
 lib/igt_draw.c                        |  1 +
 lib/igt_fb.c                          |  3 +-
 lib/intel_batchbuffer.c               |  1 +
 lib/intel_bufops.c                    |  2 ++
 lib/ioctl_wrappers.c                  | 38 +--------------------
 lib/ioctl_wrappers.h                  |  2 --
 lib/meson.build                       |  1 +
 tests/i915/gem_basic.c                |  2 ++
 tests/i915/gem_exec_basic.c           |  2 ++
 tests/i915/gem_fd_exhaustion.c        |  2 ++
 tests/i915/gem_fence_thrash.c         |  1 +
 tests/i915/gem_fence_upload.c         |  2 ++
 tests/i915/gem_flink_race.c           |  1 +
 tests/i915/gem_gtt_cpu_tlb.c          |  2 ++
 tests/i915/gem_gtt_speed.c            |  2 ++
 tests/i915/gem_lut_handle.c           |  2 ++
 tests/i915/gem_madvise.c              |  1 +
 tests/i915/gem_mmap.c                 |  2 ++
 tests/i915/gem_mmap_wc.c              |  2 ++
 tests/i915/gem_pread.c                |  3 +-
 tests/i915/gem_pwrite.c               |  2 +-
 tests/i915/gem_readwrite.c            |  2 ++
 tests/i915/gem_set_tiling_vs_gtt.c    |  2 ++
 tests/i915/gem_set_tiling_vs_pwrite.c |  2 ++
 tests/i915/gem_tiled_pread_basic.c    |  3 +-
 tests/i915/gem_tiled_pread_pwrite.c   |  4 +--
 tests/i915/gem_tiled_swapping.c       |  4 +--
 tests/i915/gem_tiled_wb.c             |  2 ++
 tests/i915/gem_tiled_wc.c             |  2 ++
 tests/i915/gem_tiling_max_stride.c    |  2 ++
 tests/i915/i915_module_load.c         | 13 ++++----
 tests/kms_available_modes_crc.c       |  1 +
 tests/kms_big_fb.c                    |  2 ++
 tests/kms_ccs.c                       |  2 ++
 tests/kms_flip.c                      |  1 +
 tests/kms_getfb.c                     |  3 +-
 tests/prime_mmap.c                    |  5 +--
 tests/prime_mmap_kms.c                |  2 ++
 tests/prime_self_import.c             |  1 +
 tools/intel_reg.c                     |  1 +
 59 files changed, 161 insertions(+), 79 deletions(-)
 create mode 100644 lib/i915/gem_create.c

diff --git a/benchmarks/gem_blt.c b/benchmarks/gem_blt.c
index 5c6d28d36..34b82a87b 100644
--- a/benchmarks/gem_blt.c
+++ b/benchmarks/gem_blt.c
@@ -41,6 +41,7 @@
 #include <time.h>
 
 #include "drm.h"
+#include "i915/gem.h"
 
 #define COPY_BLT_CMD		(2<<29|0x53<<22|0x6)
 #define BLT_WRITE_ALPHA		(1<<21)
diff --git a/benchmarks/gem_busy.c b/benchmarks/gem_busy.c
index 50410150f..69be8c178 100644
--- a/benchmarks/gem_busy.c
+++ b/benchmarks/gem_busy.c
@@ -45,6 +45,7 @@
 #include "intel_chipset.h"
 #include "intel_reg.h"
 #include "igt_stats.h"
+#include "i915/gem.h"
 #include "i915/gem_mman.h"
 
 #define ENGINE_FLAGS  (I915_EXEC_RING_MASK | I915_EXEC_BSD_MASK)
diff --git a/benchmarks/gem_create.c b/benchmarks/gem_create.c
index 5dd996c9b..d4e297ed4 100644
--- a/benchmarks/gem_create.c
+++ b/benchmarks/gem_create.c
@@ -39,11 +39,12 @@
 #include <time.h>
 
 #include "drm.h"
-#include "ioctl_wrappers.h"
 #include "drmtest.h"
+#include "i915/gem.h"
 #include "igt_aux.h"
 #include "igt_stats.h"
 #include "intel_reg.h"
+#include "ioctl_wrappers.h"
 
 #define OBJECT_SIZE (1<<23)
 
diff --git a/benchmarks/gem_exec_ctx.c b/benchmarks/gem_exec_ctx.c
index a2e8d93e9..b6f403fbd 100644
--- a/benchmarks/gem_exec_ctx.c
+++ b/benchmarks/gem_exec_ctx.c
@@ -39,11 +39,12 @@
 #include <time.h>
 
 #include "drm.h"
-#include "ioctl_wrappers.h"
 #include "drmtest.h"
+#include "i915/gem.h"
 #include "intel_io.h"
 #include "intel_reg.h"
 #include "igt_stats.h"
+#include "ioctl_wrappers.h"
 
 enum mode { NOP, CREATE, SWITCH, DEFAULT };
 #define SYNC 0x1
diff --git a/benchmarks/gem_exec_fault.c b/benchmarks/gem_exec_fault.c
index 4bd053726..a3a0992cd 100644
--- a/benchmarks/gem_exec_fault.c
+++ b/benchmarks/gem_exec_fault.c
@@ -41,11 +41,12 @@
 #include <time.h>
 
 #include "drm.h"
-#include "ioctl_wrappers.h"
 #include "drmtest.h"
+#include "i915/gem.h"
+#include "igt_stats.h"
 #include "intel_io.h"
 #include "intel_reg.h"
-#include "igt_stats.h"
+#include "ioctl_wrappers.h"
 
 #define ENGINE_FLAGS  (I915_EXEC_RING_MASK | I915_EXEC_BSD_MASK)
 
diff --git a/benchmarks/gem_exec_nop.c b/benchmarks/gem_exec_nop.c
index 0f17d2327..c44d34543 100644
--- a/benchmarks/gem_exec_nop.c
+++ b/benchmarks/gem_exec_nop.c
@@ -39,11 +39,12 @@
 #include <time.h>
 
 #include "drm.h"
-#include "ioctl_wrappers.h"
 #include "drmtest.h"
+#include "i915/gem.h"
+#include "igt_stats.h"
 #include "intel_io.h"
 #include "intel_reg.h"
-#include "igt_stats.h"
+#include "ioctl_wrappers.h"
 
 #define ENGINE_FLAGS  (I915_EXEC_RING_MASK | I915_EXEC_BSD_MASK)
 
diff --git a/benchmarks/gem_exec_reloc.c b/benchmarks/gem_exec_reloc.c
index a0736b517..abaf93452 100644
--- a/benchmarks/gem_exec_reloc.c
+++ b/benchmarks/gem_exec_reloc.c
@@ -35,12 +35,14 @@
 #include <errno.h>
 #include <sys/stat.h>
 #include <sys/time.h>
+
 #include "drm.h"
-#include "intel_reg.h"
-#include "ioctl_wrappers.h"
-#include "igt_debugfs.h"
 #include "drmtest.h"
+#include "i915/gem.h"
 #include "i915/gem_mman.h"
+#include "igt_debugfs.h"
+#include "intel_reg.h"
+#include "ioctl_wrappers.h"
 
 #define SKIP_RELOC 0x1
 #define NO_RELOC 0x2
diff --git a/benchmarks/gem_exec_trace.c b/benchmarks/gem_exec_trace.c
index 2724ee920..e37f6fb7d 100644
--- a/benchmarks/gem_exec_trace.c
+++ b/benchmarks/gem_exec_trace.c
@@ -40,10 +40,11 @@
 #include <assert.h>
 
 #include "drm.h"
-#include "ioctl_wrappers.h"
 #include "drmtest.h"
-#include "intel_io.h"
+#include "i915/gem.h"
 #include "igt_stats.h"
+#include "intel_io.h"
+#include "ioctl_wrappers.h"
 
 enum {
 	ADD_BO = 0,
diff --git a/benchmarks/gem_latency.c b/benchmarks/gem_latency.c
index 774a33d31..9b3d22b76 100644
--- a/benchmarks/gem_latency.c
+++ b/benchmarks/gem_latency.c
@@ -41,8 +41,9 @@
 #include <sys/time.h>
 #include <sys/poll.h>
 #include <sys/resource.h>
-#include "drm.h"
 
+#include "drm.h"
+#include "i915/gem.h"
 #include "igt.h"
 #include "igt_device.h"
 
diff --git a/benchmarks/gem_prw.c b/benchmarks/gem_prw.c
index c2846040e..5d3fda9ae 100644
--- a/benchmarks/gem_prw.c
+++ b/benchmarks/gem_prw.c
@@ -39,10 +39,11 @@
 #include <time.h>
 
 #include "drm.h"
-#include "ioctl_wrappers.h"
 #include "drmtest.h"
+#include "i915/gem.h"
 #include "igt_aux.h"
 #include "igt_stats.h"
+#include "ioctl_wrappers.h"
 
 #define OBJECT_SIZE (1<<23)
 
diff --git a/benchmarks/gem_set_domain.c b/benchmarks/gem_set_domain.c
index afb410dc8..1c9d797c7 100644
--- a/benchmarks/gem_set_domain.c
+++ b/benchmarks/gem_set_domain.c
@@ -39,9 +39,10 @@
 #include <time.h>
 
 #include "drm.h"
-#include "ioctl_wrappers.h"
 #include "drmtest.h"
+#include "i915/gem.h"
 #include "igt_aux.h"
+#include "ioctl_wrappers.h"
 
 static double elapsed(const struct timespec *start,
 		      const struct timespec *end)
diff --git a/benchmarks/gem_syslatency.c b/benchmarks/gem_syslatency.c
index 9e57df3af..c10d4f504 100644
--- a/benchmarks/gem_syslatency.c
+++ b/benchmarks/gem_syslatency.c
@@ -44,6 +44,7 @@
 
 #include <linux/unistd.h>
 
+#include "i915/gem.h"
 #include "i915/gem_ring.h"
 
 #define sigev_notify_thread_id _sigev_un._tid
diff --git a/benchmarks/gem_wsim.c b/benchmarks/gem_wsim.c
index 1c0c591ed..1b66e63eb 100644
--- a/benchmarks/gem_wsim.c
+++ b/benchmarks/gem_wsim.c
@@ -43,21 +43,22 @@
 #include <pthread.h>
 #include <math.h>
 
+#include "drm.h"
+#include "drmtest.h"
 #include "igt_device_scan.h"
 #include "intel_chipset.h"
 #include "intel_reg.h"
-#include "drm.h"
 #include "ioctl_wrappers.h"
-#include "drmtest.h"
 
 #include "intel_io.h"
 #include "igt_aux.h"
 #include "igt_rand.h"
 #include "igt_perf.h"
 #include "sw_sync.h"
-#include "i915/gem_mman.h"
 
+#include "i915/gem.h"
 #include "i915/gem_engine_topology.h"
+#include "i915/gem_mman.h"
 
 enum intel_engine_id {
 	DEFAULT,
diff --git a/benchmarks/prime_lookup.c b/benchmarks/prime_lookup.c
index d6c397299..b1891756d 100644
--- a/benchmarks/prime_lookup.c
+++ b/benchmarks/prime_lookup.c
@@ -37,10 +37,11 @@
 #include <time.h>
 
 #include "drm.h"
-#include "ioctl_wrappers.h"
 #include "drmtest.h"
-#include "intel_io.h"
+#include "i915/gem.h"
 #include "igt_rand.h"
+#include "intel_io.h"
+#include "ioctl_wrappers.h"
 
 #define CLOSE_DEVICE 0x1
 
diff --git a/lib/Makefile.sources b/lib/Makefile.sources
index 7102f95e7..4f6389f8a 100644
--- a/lib/Makefile.sources
+++ b/lib/Makefile.sources
@@ -7,6 +7,7 @@ lib_source_list =	 	\
 	i915/gem.h		\
 	i915/gem_context.c	\
 	i915/gem_context.h	\
+	i915/gem_create.c	\
 	i915/gem_engine_topology.c	\
 	i915/gem_engine_topology.h	\
 	i915/gem_scheduler.c	\
diff --git a/lib/i915/gem.h b/lib/i915/gem.h
index e5403f09c..9178b773c 100644
--- a/lib/i915/gem.h
+++ b/lib/i915/gem.h
@@ -25,9 +25,14 @@
 #ifndef I915_GEM_H
 #define I915_GEM_H
 
+#include <stdint.h>
+
 void igt_require_gem(int i915);
 void gem_quiescent_gpu(int i915);
 
 int gem_reopen_driver(int i915);
 
+int __gem_create(int fd, uint64_t size, uint32_t *handle);
+uint32_t gem_create(int fd, uint64_t size);
+
 #endif /* I915_GEM_H */
diff --git a/lib/i915/gem_create.c b/lib/i915/gem_create.c
new file mode 100644
index 000000000..fa2ca1e37
--- /dev/null
+++ b/lib/i915/gem_create.c
@@ -0,0 +1,48 @@
+// SPDX-License-Identifier: MIT
+/*
+ * Copyright © 2021 Intel Corporation
+ */
+
+#include <errno.h>
+
+#include "gem.h"
+#include "i915_drm.h"
+#include "igt_core.h"
+#include "ioctl_wrappers.h"
+
+int __gem_create(int fd, uint64_t size, uint32_t *handle)
+{
+	struct drm_i915_gem_create create = {
+		.size = size,
+	};
+	int err = 0;
+
+	if (igt_ioctl(fd, DRM_IOCTL_I915_GEM_CREATE, &create) == 0) {
+		*handle = create.handle;
+	} else {
+		err = -errno;
+		igt_assume(err != 0);
+	}
+
+	errno = 0;
+	return err;
+}
+
+/**
+ * gem_create:
+ * @fd: open i915 drm file descriptor
+ * @size: desired size of the buffer
+ *
+ * This wraps the GEM_CREATE ioctl, which allocates a new gem buffer object of
+ * @size.
+ *
+ * Returns: The file-private handle of the created buffer object
+ */
+uint32_t gem_create(int fd, uint64_t size)
+{
+	uint32_t handle;
+
+	igt_assert_eq(__gem_create(fd, size, &handle), 0);
+
+	return handle;
+}
diff --git a/lib/i915/gem_mman.c b/lib/i915/gem_mman.c
index 728f6e963..ab04cbecb 100644
--- a/lib/i915/gem_mman.c
+++ b/lib/i915/gem_mman.c
@@ -31,6 +31,7 @@
 #include "ioctl_wrappers.h"
 #include "intel_chipset.h"
 
+#include "gem.h"
 #include "gem_mman.h"
 
 #ifdef HAVE_VALGRIND
diff --git a/lib/i915/gem_mman.h b/lib/i915/gem_mman.h
index ec2899ffe..4a69b2595 100644
--- a/lib/i915/gem_mman.h
+++ b/lib/i915/gem_mman.h
@@ -42,10 +42,6 @@ void *gem_mmap__device_coherent(int fd, uint32_t handle, uint64_t offset,
 void *gem_mmap__cpu_coherent(int fd, uint32_t handle, uint64_t offset,
 			     uint64_t size, unsigned prot);
 
-#ifndef I915_GEM_DOMAIN_WC
-#define I915_GEM_DOMAIN_WC 0x80
-#endif
-
 bool gem_has_mappable_ggtt(int i915);
 void gem_require_mappable_ggtt(int i915);
 bool gem_has_mmap_offset(int fd);
diff --git a/lib/igt_draw.c b/lib/igt_draw.c
index 353467a2d..949c0d77b 100644
--- a/lib/igt_draw.c
+++ b/lib/igt_draw.c
@@ -34,6 +34,7 @@
 #include "igt_fb.h"
 #include "ioctl_wrappers.h"
 #include "i830_reg.h"
+#include "i915/gem.h"
 #include "i915/gem_mman.h"
 
 #ifndef PAGE_ALIGN
diff --git a/lib/igt_fb.c b/lib/igt_fb.c
index 422a9e061..4b9be47eb 100644
--- a/lib/igt_fb.c
+++ b/lib/igt_fb.c
@@ -33,6 +33,8 @@
 #include <pixman.h>
 
 #include "drmtest.h"
+#include "i915/gem.h"
+#include "i915/gem_mman.h"
 #include "igt_aux.h"
 #include "igt_color_encoding.h"
 #include "igt_fb.h"
@@ -45,7 +47,6 @@
 #include "ioctl_wrappers.h"
 #include "intel_batchbuffer.h"
 #include "intel_chipset.h"
-#include "i915/gem_mman.h"
 #include "intel_bufops.h"
 
 /**
diff --git a/lib/intel_batchbuffer.c b/lib/intel_batchbuffer.c
index ead890d17..8118dc945 100644
--- a/lib/intel_batchbuffer.c
+++ b/lib/intel_batchbuffer.c
@@ -35,6 +35,7 @@
 
 #include "drm.h"
 #include "drmtest.h"
+#include "i915/gem.h"
 #include "intel_batchbuffer.h"
 #include "intel_bufmgr.h"
 #include "intel_bufops.h"
diff --git a/lib/intel_bufops.c b/lib/intel_bufops.c
index a1e9ba556..a50035e40 100644
--- a/lib/intel_bufops.c
+++ b/lib/intel_bufops.c
@@ -24,6 +24,8 @@
 
 #include <sys/ioctl.h>
 #include <cairo.h>
+
+#include "i915/gem.h"
 #include "igt.h"
 #include "igt_x86.h"
 #include "intel_bufops.h"
diff --git a/lib/ioctl_wrappers.c b/lib/ioctl_wrappers.c
index a928f894f..45415621b 100644
--- a/lib/ioctl_wrappers.c
+++ b/lib/ioctl_wrappers.c
@@ -49,6 +49,7 @@
 
 #include "drmtest.h"
 #include "i915_drm.h"
+#include "i915/gem.h"
 #include "intel_batchbuffer.h"
 #include "intel_chipset.h"
 #include "intel_io.h"
@@ -469,43 +470,6 @@ void gem_sync(int fd, uint32_t handle)
 	errno = 0;
 }
 
-int __gem_create(int fd, uint64_t size, uint32_t *handle)
-{
-	struct drm_i915_gem_create create = {
-		.size = size,
-	};
-	int err = 0;
-
-	if (igt_ioctl(fd, DRM_IOCTL_I915_GEM_CREATE, &create) == 0) {
-		*handle = create.handle;
-	} else {
-		err = -errno;
-		igt_assume(err != 0);
-	}
-
-	errno = 0;
-	return err;
-}
-
-/**
- * gem_create:
- * @fd: open i915 drm file descriptor
- * @size: desired size of the buffer
- *
- * This wraps the GEM_CREATE ioctl, which allocates a new gem buffer object of
- * @size.
- *
- * Returns: The file-private handle of the created buffer object
- */
-uint32_t gem_create(int fd, uint64_t size)
-{
-	uint32_t handle;
-
-	igt_assert_eq(__gem_create(fd, size, &handle), 0);
-
-	return handle;
-}
-
 /**
  * __gem_execbuf:
  * @fd: open i915 drm file descriptor
diff --git a/lib/ioctl_wrappers.h b/lib/ioctl_wrappers.h
index 07879ae96..69e198419 100644
--- a/lib/ioctl_wrappers.h
+++ b/lib/ioctl_wrappers.h
@@ -75,8 +75,6 @@ int __gem_set_domain(int fd, uint32_t handle, uint32_t read, uint32_t write);
 void gem_set_domain(int fd, uint32_t handle, uint32_t read, uint32_t write);
 int gem_wait(int fd, uint32_t handle, int64_t *timeout_ns);
 void gem_sync(int fd, uint32_t handle);
-int __gem_create(int fd, uint64_t size, uint32_t *handle);
-uint32_t gem_create(int fd, uint64_t size);
 void gem_execbuf_wr(int fd, struct drm_i915_gem_execbuffer2 *execbuf);
 int __gem_execbuf_wr(int fd, struct drm_i915_gem_execbuffer2 *execbuf);
 void gem_execbuf(int fd, struct drm_i915_gem_execbuffer2 *execbuf);
diff --git a/lib/meson.build b/lib/meson.build
index 3abc42cb3..02ecef53e 100644
--- a/lib/meson.build
+++ b/lib/meson.build
@@ -3,6 +3,7 @@ lib_sources = [
 	'huc_copy.c',
 	'i915/gem.c',
 	'i915/gem_context.c',
+	'i915/gem_create.c',
 	'i915/gem_engine_topology.c',
 	'i915/gem_scheduler.c',
 	'i915/gem_submission.c',
diff --git a/tests/i915/gem_basic.c b/tests/i915/gem_basic.c
index 9f7412f2a..984bdf603 100644
--- a/tests/i915/gem_basic.c
+++ b/tests/i915/gem_basic.c
@@ -35,7 +35,9 @@
 #include <errno.h>
 #include <sys/stat.h>
 #include <sys/ioctl.h>
+
 #include "drm.h"
+#include "i915/gem.h"
 
 static void
 test_bad_close(int fd)
diff --git a/tests/i915/gem_exec_basic.c b/tests/i915/gem_exec_basic.c
index 0d05819ce..31f6a2346 100644
--- a/tests/i915/gem_exec_basic.c
+++ b/tests/i915/gem_exec_basic.c
@@ -23,6 +23,8 @@
 
 #include "igt.h"
 
+#include "i915/gem.h"
+
 IGT_TEST_DESCRIPTION("Basic sanity check of execbuf-ioctl rings.");
 
 static uint32_t batch_create(int fd)
diff --git a/tests/i915/gem_fd_exhaustion.c b/tests/i915/gem_fd_exhaustion.c
index 23602b980..37c84e6c0 100644
--- a/tests/i915/gem_fd_exhaustion.c
+++ b/tests/i915/gem_fd_exhaustion.c
@@ -33,6 +33,8 @@
 #include <fcntl.h>
 #include <limits.h>
 
+#include "i915/gem.h"
+
 igt_simple_main
 {
 	int fd;
diff --git a/tests/i915/gem_fence_thrash.c b/tests/i915/gem_fence_thrash.c
index 97902890a..872dc554d 100644
--- a/tests/i915/gem_fence_thrash.c
+++ b/tests/i915/gem_fence_thrash.c
@@ -40,6 +40,7 @@
 #include <pthread.h>
 #include "drm.h"
 
+#include "i915/gem.h"
 #include "igt.h"
 #include "igt_x86.h"
 
diff --git a/tests/i915/gem_fence_upload.c b/tests/i915/gem_fence_upload.c
index 17580aff8..87ed1edff 100644
--- a/tests/i915/gem_fence_upload.c
+++ b/tests/i915/gem_fence_upload.c
@@ -37,8 +37,10 @@
 #include <errno.h>
 #include <sys/time.h>
 #include <pthread.h>
+
 #include "drm.h"
 #include "i915_drm.h"
+#include "i915/gem.h"
 
 #define OBJECT_SIZE (1024*1024) /* restricted to 1MiB alignment on i915 fences */
 
diff --git a/tests/i915/gem_flink_race.c b/tests/i915/gem_flink_race.c
index 00363c043..58431b36e 100644
--- a/tests/i915/gem_flink_race.c
+++ b/tests/i915/gem_flink_race.c
@@ -32,6 +32,7 @@
 #include <pthread.h>
 #include <errno.h>
 
+#include "i915/gem.h"
 #include "igt.h"
 #include "igt_stats.h"
 
diff --git a/tests/i915/gem_gtt_cpu_tlb.c b/tests/i915/gem_gtt_cpu_tlb.c
index 0af6a1c42..07f8f1a3c 100644
--- a/tests/i915/gem_gtt_cpu_tlb.c
+++ b/tests/i915/gem_gtt_cpu_tlb.c
@@ -40,7 +40,9 @@
 #include <sys/stat.h>
 #include <sys/time.h>
 #include <sys/ioctl.h>
+
 #include "drm.h"
+#include "i915/gem.h"
 
 IGT_TEST_DESCRIPTION("Check whether gtt tlbs for cpu access are correctly"
 		     " invalidated.");
diff --git a/tests/i915/gem_gtt_speed.c b/tests/i915/gem_gtt_speed.c
index f0c1954fa..06fe70f84 100644
--- a/tests/i915/gem_gtt_speed.c
+++ b/tests/i915/gem_gtt_speed.c
@@ -39,7 +39,9 @@
 #include <sys/stat.h>
 #include <sys/ioctl.h>
 #include <sys/time.h>
+
 #include "drm.h"
+#include "i915/gem.h"
 
 #define OBJECT_SIZE 16384
 
diff --git a/tests/i915/gem_lut_handle.c b/tests/i915/gem_lut_handle.c
index d0c58b8b7..f14a9bdaa 100644
--- a/tests/i915/gem_lut_handle.c
+++ b/tests/i915/gem_lut_handle.c
@@ -36,7 +36,9 @@
 #include <errno.h>
 #include <sys/stat.h>
 #include <sys/time.h>
+
 #include "drm.h"
+#include "i915/gem.h"
 
 IGT_TEST_DESCRIPTION("Exercises the basic execbuffer using the handle LUT"
 		     " interface.");
diff --git a/tests/i915/gem_madvise.c b/tests/i915/gem_madvise.c
index 54c9befff..623c8b091 100644
--- a/tests/i915/gem_madvise.c
+++ b/tests/i915/gem_madvise.c
@@ -37,6 +37,7 @@
 #include <signal.h>
 
 #include "drm.h"
+#include "i915/gem.h"
 
 IGT_TEST_DESCRIPTION("Checks that the kernel reports EFAULT when trying to use"
 		     " purged bo.");
diff --git a/tests/i915/gem_mmap.c b/tests/i915/gem_mmap.c
index 60a64c134..7c36571c9 100644
--- a/tests/i915/gem_mmap.c
+++ b/tests/i915/gem_mmap.c
@@ -35,7 +35,9 @@
 #include <errno.h>
 #include <sys/stat.h>
 #include <sys/ioctl.h>
+
 #include "drm.h"
+#include "i915/gem.h"
 
 #define OBJECT_SIZE 16384
 #define PAGE_SIZE 4096
diff --git a/tests/i915/gem_mmap_wc.c b/tests/i915/gem_mmap_wc.c
index cd2c8f83b..4a2192b30 100644
--- a/tests/i915/gem_mmap_wc.c
+++ b/tests/i915/gem_mmap_wc.c
@@ -36,7 +36,9 @@
 #include <errno.h>
 #include <sys/stat.h>
 #include <sys/ioctl.h>
+
 #include "drm.h"
+#include "i915/gem.h"
 
 struct local_i915_gem_mmap_v2 {
 	uint32_t handle;
diff --git a/tests/i915/gem_pread.c b/tests/i915/gem_pread.c
index d4d022f19..0c4ec0d2f 100644
--- a/tests/i915/gem_pread.c
+++ b/tests/i915/gem_pread.c
@@ -41,8 +41,9 @@
 #include <sys/stat.h>
 #include <sys/time.h>
 #include <pthread.h>
-#include "drm.h"
 
+#include "drm.h"
+#include "i915/gem.h"
 #include "igt_vgem.h"
 
 #define MiB(x) ((x) * 1024 * 1024)
diff --git a/tests/i915/gem_pwrite.c b/tests/i915/gem_pwrite.c
index f76d2bc70..98bec5582 100644
--- a/tests/i915/gem_pwrite.c
+++ b/tests/i915/gem_pwrite.c
@@ -42,7 +42,7 @@
 #include <sys/time.h>
 
 #include "drm.h"
-
+#include "i915/gem.h"
 #include "igt.h"
 #include "igt_rand.h"
 #include "igt_vgem.h"
diff --git a/tests/i915/gem_readwrite.c b/tests/i915/gem_readwrite.c
index 6b2977c1c..d675810ef 100644
--- a/tests/i915/gem_readwrite.c
+++ b/tests/i915/gem_readwrite.c
@@ -35,7 +35,9 @@
 #include <errno.h>
 #include <sys/stat.h>
 #include <sys/ioctl.h>
+
 #include "drm.h"
+#include "i915/gem.h"
 
 #define OBJECT_SIZE 16384
 
diff --git a/tests/i915/gem_set_tiling_vs_gtt.c b/tests/i915/gem_set_tiling_vs_gtt.c
index cee9c02ca..f09022c68 100644
--- a/tests/i915/gem_set_tiling_vs_gtt.c
+++ b/tests/i915/gem_set_tiling_vs_gtt.c
@@ -35,7 +35,9 @@
 #include <errno.h>
 #include <sys/stat.h>
 #include <sys/ioctl.h>
+
 #include "drm.h"
+#include "i915/gem.h"
 
 IGT_TEST_DESCRIPTION("Check set_tiling vs gtt mmap coherency.");
 
diff --git a/tests/i915/gem_set_tiling_vs_pwrite.c b/tests/i915/gem_set_tiling_vs_pwrite.c
index 302ea24b6..771dd2e13 100644
--- a/tests/i915/gem_set_tiling_vs_pwrite.c
+++ b/tests/i915/gem_set_tiling_vs_pwrite.c
@@ -35,7 +35,9 @@
 #include <errno.h>
 #include <sys/stat.h>
 #include <sys/ioctl.h>
+
 #include "drm.h"
+#include "i915/gem.h"
 
 IGT_TEST_DESCRIPTION("Check set_tiling vs pwrite coherency.");
 
diff --git a/tests/i915/gem_tiled_pread_basic.c b/tests/i915/gem_tiled_pread_basic.c
index 7cb644104..862714140 100644
--- a/tests/i915/gem_tiled_pread_basic.c
+++ b/tests/i915/gem_tiled_pread_basic.c
@@ -45,8 +45,9 @@
 #include <sys/stat.h>
 #include <sys/time.h>
 #include <sys/ioctl.h>
-#include "drm.h"
 
+#include "drm.h"
+#include "i915/gem.h"
 
 IGT_TEST_DESCRIPTION("Test pread behavior on tiled objects with respect to the"
 		     " reported swizzling value.");
diff --git a/tests/i915/gem_tiled_pread_pwrite.c b/tests/i915/gem_tiled_pread_pwrite.c
index f58048faa..b73fa1262 100644
--- a/tests/i915/gem_tiled_pread_pwrite.c
+++ b/tests/i915/gem_tiled_pread_pwrite.c
@@ -56,8 +56,8 @@
 #include <sys/time.h>
 #include <sys/ioctl.h>
 
-#include <drm.h>
-
+#include "drm.h"
+#include "i915/gem.h"
 
 IGT_TEST_DESCRIPTION("Test swizzling by testing pwrite does the inverse of"
 		     " pread.");
diff --git a/tests/i915/gem_tiled_swapping.c b/tests/i915/gem_tiled_swapping.c
index 9e0540ba9..1bcf2fa48 100644
--- a/tests/i915/gem_tiled_swapping.c
+++ b/tests/i915/gem_tiled_swapping.c
@@ -56,8 +56,8 @@
 #include <sys/ioctl.h>
 #include <pthread.h>
 
-#include <drm.h>
-
+#include "drm.h"
+#include "i915/gem.h"
 
 IGT_TEST_DESCRIPTION("Exercise swizzle code for swapping.");
 
diff --git a/tests/i915/gem_tiled_wb.c b/tests/i915/gem_tiled_wb.c
index aedec4d4b..2ba424e8d 100644
--- a/tests/i915/gem_tiled_wb.c
+++ b/tests/i915/gem_tiled_wb.c
@@ -42,7 +42,9 @@
 #include <sys/stat.h>
 #include <sys/time.h>
 #include <sys/ioctl.h>
+
 #include "drm.h"
+#include "i915/gem.h"
 
 IGT_TEST_DESCRIPTION("This is a test of write-combining mmap's behavior on"
 		     " tiled objects with respect to the reported swizzling"
diff --git a/tests/i915/gem_tiled_wc.c b/tests/i915/gem_tiled_wc.c
index 3213b5d57..898aad40e 100644
--- a/tests/i915/gem_tiled_wc.c
+++ b/tests/i915/gem_tiled_wc.c
@@ -42,7 +42,9 @@
 #include <sys/stat.h>
 #include <sys/time.h>
 #include <sys/ioctl.h>
+
 #include "drm.h"
+#include "i915/gem.h"
 
 #define WIDTH 512
 #define HEIGHT 512
diff --git a/tests/i915/gem_tiling_max_stride.c b/tests/i915/gem_tiling_max_stride.c
index 77f7223ba..4a273441b 100644
--- a/tests/i915/gem_tiling_max_stride.c
+++ b/tests/i915/gem_tiling_max_stride.c
@@ -36,7 +36,9 @@
 #include <limits.h>
 #include <sys/stat.h>
 #include <sys/ioctl.h>
+
 #include "drm.h"
+#include "i915/gem.h"
 
 IGT_TEST_DESCRIPTION("Check that max fence stride works.");
 
diff --git a/tests/i915/i915_module_load.c b/tests/i915/i915_module_load.c
index 189fd48b2..06522ba61 100644
--- a/tests/i915/i915_module_load.c
+++ b/tests/i915/i915_module_load.c
@@ -21,12 +21,6 @@
  * IN THE SOFTWARE.
  */
 #include "igt.h"
-#include "igt_debugfs.h"
-#include "igt_aux.h"
-#include "igt_kmod.h"
-#include "igt_sysfs.h"
-#include "igt_core.h"
-
 #include <dirent.h>
 #include <sys/utsname.h>
 #include <linux/limits.h>
@@ -36,6 +30,13 @@
 #include <sys/ioctl.h>
 #include <fcntl.h>
 
+#include "i915/gem.h"
+#include "igt_debugfs.h"
+#include "igt_aux.h"
+#include "igt_kmod.h"
+#include "igt_sysfs.h"
+#include "igt_core.h"
+
 static void store_all(int fd)
 {
 	const unsigned int gen = intel_gen(intel_get_drm_devid(fd));
diff --git a/tests/kms_available_modes_crc.c b/tests/kms_available_modes_crc.c
index 1c400bbe8..17e0f2379 100644
--- a/tests/kms_available_modes_crc.c
+++ b/tests/kms_available_modes_crc.c
@@ -24,6 +24,7 @@
 
 #include "drm_mode.h"
 #include "drm_fourcc.h"
+#include "i915/gem.h"
 #include "igt.h"
 
 IGT_TEST_DESCRIPTION("CRC test all different plane modes which kernel advertises.");
diff --git a/tests/kms_big_fb.c b/tests/kms_big_fb.c
index 8794ace08..5260176e1 100644
--- a/tests/kms_big_fb.c
+++ b/tests/kms_big_fb.c
@@ -27,6 +27,8 @@
 #include <stdio.h>
 #include <string.h>
 
+#include "i915/gem.h"
+
 IGT_TEST_DESCRIPTION("Test big framebuffers");
 
 typedef struct {
diff --git a/tests/kms_ccs.c b/tests/kms_ccs.c
index e89bddaaa..c0b024744 100644
--- a/tests/kms_ccs.c
+++ b/tests/kms_ccs.c
@@ -24,6 +24,8 @@
 
 #include "igt.h"
 
+#include "i915/gem.h"
+
 #define SDR_PLANE_BASE	3
 
 IGT_TEST_DESCRIPTION("Test render compression (RC), in which the main surface "
diff --git a/tests/kms_flip.c b/tests/kms_flip.c
index 0f0565cf6..e0d009d22 100755
--- a/tests/kms_flip.c
+++ b/tests/kms_flip.c
@@ -42,6 +42,7 @@
 #include <time.h>
 #include <pthread.h>
 
+#include "i915/gem.h"
 #include "igt_stats.h"
 
 #define TEST_DPMS		(1 << 0)
diff --git a/tests/kms_getfb.c b/tests/kms_getfb.c
index c3d3c9307..8c59b8a9e 100644
--- a/tests/kms_getfb.c
+++ b/tests/kms_getfb.c
@@ -37,9 +37,10 @@
 #include <errno.h>
 #include <sys/stat.h>
 #include <sys/ioctl.h>
+
 #include "drm.h"
 #include "drm_fourcc.h"
-
+#include "i915/gem.h"
 #include "igt_device.h"
 
 IGT_TEST_DESCRIPTION("Tests GETFB and GETFB2 ioctls.");
diff --git a/tests/prime_mmap.c b/tests/prime_mmap.c
index 7c43ced85..cdf2d5149 100644
--- a/tests/prime_mmap.c
+++ b/tests/prime_mmap.c
@@ -41,11 +41,12 @@
 #include <pthread.h>
 
 #include "drm.h"
-#include "i915_drm.h"
 #include "drmtest.h"
+#include "i915_drm.h"
+#include "i915/gem.h"
+#include "i915/gem_mman.h"
 #include "igt_debugfs.h"
 #include "ioctl_wrappers.h"
-#include "i915/gem_mman.h"
 
 #define BO_SIZE (16*1024)
 
diff --git a/tests/prime_mmap_kms.c b/tests/prime_mmap_kms.c
index c06d4ab27..6cc1db87e 100644
--- a/tests/prime_mmap_kms.c
+++ b/tests/prime_mmap_kms.c
@@ -32,6 +32,8 @@
 
 #include "igt.h"
 
+#include "i915/gem.h"
+
 IGT_TEST_DESCRIPTION(
    "Efficiently sharing CPU and GPU buffers");
 
diff --git a/tests/prime_self_import.c b/tests/prime_self_import.c
index 45b70e811..4a0a98035 100644
--- a/tests/prime_self_import.c
+++ b/tests/prime_self_import.c
@@ -44,6 +44,7 @@
 #include <pthread.h>
 
 #include "drm.h"
+#include "i915/gem.h"
 
 IGT_TEST_DESCRIPTION("Check whether prime import/export works on the same"
 		     " device... but with different fds.");
diff --git a/tools/intel_reg.c b/tools/intel_reg.c
index 5f1beba4a..da1832be2 100644
--- a/tools/intel_reg.c
+++ b/tools/intel_reg.c
@@ -32,6 +32,7 @@
 #include <sys/types.h>
 #include <unistd.h>
 
+#include "i915/gem.h"
 #include "igt.h"
 #include "igt_gt.h"
 #include "intel_io.h"
-- 
2.30.0



More information about the igt-dev mailing list