Skip to contentSkip to conversation

lib/i915: Move mmap IOCTLs wrappers into separate file

PATCH Superseded Antonio Argenziano 2 participants 4 messages Feb 26, 2019

Subsystems (2)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 lib/i915: Move mmap IOCTLs wrappers into separate file

Move all mmap flavours and support function to separate file in i915 folder. This helps with moving i915 specific functions away from common libraries.

v2:
- Autotools still exists. (Petri)
- Include gem_mman.h directly. (Chris)

---
 benchmarks/gem_busy.c       |   7 +-
 benchmarks/gem_exec_reloc.c |   6 +-
 benchmarks/gem_mmap.c       |   6 +-
 benchmarks/gem_wsim.c       |  11 +-
 lib/Makefile.sources        |   2 +
 lib/i915/gem_mman.c         | 254 ++++++++++++++++++++++++++++++++++++
 lib/i915/gem_mman.h         |  55 ++++++++
 lib/igt.h                   |   1 +
 lib/igt_draw.c              |   1 +
 lib/igt_dummyload.c         |   1 +
 lib/igt_fb.c                |   1 +
 lib/ioctl_wrappers.c        | 213 ------------------------------
 lib/ioctl_wrappers.h        |  22 ----
 lib/meson.build             |   1 +
 tests/i915/gem_exec_reloc.c |   1 -
 tests/i915/gem_stolen.c     |   9 +-
 tests/prime_mmap.c          |   6 +-
 17 files changed, 327 insertions(+), 270 deletions(-)
 create mode 100644 lib/i915/gem_mman.c
 create mode 100644 lib/i915/gem_mman.h
benchmarks/gem_busy.c +1 -6
index ca517a16..bcb8a879 100644
@@ -39,12 +39,7 @@
 #include <sys/time.h>
 #include <time.h>
 
-#include "drm.h"
-#include "ioctl_wrappers.h"
-#include "drmtest.h"
-#include "intel_chipset.h"
-#include "intel_reg.h"
-#include "igt_stats.h"
+#include "igt.h"
 
 #define LOCAL_I915_EXEC_NO_RELOC (1<<11)
 #define LOCAL_I915_EXEC_HANDLE_LUT (1<<12)
benchmarks/gem_exec_reloc.c +2 -4
index f9487d95..5cbb3120 100644
@@ -36,10 +36,8 @@
 #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 "igt.h"
 
 #define LOCAL_I915_EXEC_NO_RELOC (1<<11)
 #define LOCAL_I915_EXEC_HANDLE_LUT (1<<12)
benchmarks/gem_mmap.c +2 -4
index c809e087..7c42e7d3 100644
@@ -39,10 +39,8 @@
 #include <time.h>
 
 #include "drm.h"
-#include "ioctl_wrappers.h"
-#include "drmtest.h"
-#include "igt_aux.h"
-#include "igt_stats.h"
+
+#include "igt.h"
 
 #define OBJECT_SIZE (1<<23)
 
benchmarks/gem_wsim.c +3 -8
index 5a4753d9..379f83a2 100644
@@ -41,19 +41,14 @@
 #include <limits.h>
 #include <pthread.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 "igt.h"
+#include "intel_reg.h"
+
 #include "ewma.h"
 
 #define LOCAL_I915_EXEC_FENCE_IN              (1<<16)
lib/Makefile.sources +2 -0
index 808b9617..774a1a4e 100644
@@ -11,6 +11,8 @@ lib_source_list =	 	\
 	i915/gem_submission.h	\
 	i915/gem_ring.h	\
 	i915/gem_ring.c	\
+	i915/gem_mman.c	\
+	i915/gem_mman.h	\
 	i915_3d.h		\
 	i915_reg.h		\
 	i915_pciids.h		\
lib/i915/gem_mman.c new file +254 -0

254 lines not on this page · raw message

lib/i915/gem_mman.h new file +55 -0

55 lines not on this page · raw message

lib/igt.h +1 -0
index ebf92349..6654a659 100644
@@ -52,5 +52,6 @@
 #include "media_fill.h"
 #include "media_spin.h"
 #include "rendercopy.h"
+#include "i915/gem_mman.h"
 
 #endif /* IGT_H */
lib/igt_draw.c +1 -0
index 4990d4a0..bea86c61 100644
@@ -33,6 +33,7 @@
 #include "igt_fb.h"
 #include "ioctl_wrappers.h"
 #include "i830_reg.h"
+#include "i915/gem_mman.h"
 
 #ifndef PAGE_ALIGN
 #ifndef PAGE_SIZE
lib/igt_dummyload.c +1 -0
index 982906f2..47f6b92b 100644
@@ -39,6 +39,7 @@
 #include "ioctl_wrappers.h"
 #include "sw_sync.h"
 #include "igt_vgem.h"
+#include "i915/gem_mman.h"
 
 /**
  * SECTION:igt_dummyload
lib/igt_fb.c +1 -0
index 462afec2..10a21044 100644
@@ -41,6 +41,7 @@
 #include "ioctl_wrappers.h"
 #include "intel_batchbuffer.h"
 #include "intel_chipset.h"
+#include "i915/gem_mman.h"
 
 /**
  * SECTION:igt_fb
lib/ioctl_wrappers.c +0 -213

219 lines not on this page · raw message

lib/ioctl_wrappers.h +0 -22
index b22b36b0..f0be2608 100644
@@ -84,22 +84,10 @@ int __gem_execbuf_wr(int fd, struct drm_i915_gem_execbuffer2 *execbuf);
 void gem_execbuf(int fd, struct drm_i915_gem_execbuffer2 *execbuf);
 int __gem_execbuf(int fd, struct drm_i915_gem_execbuffer2 *execbuf);
 
-void *gem_mmap__gtt(int fd, uint32_t handle, uint64_t size, unsigned prot);
-void *gem_mmap__cpu(int fd, uint32_t handle, uint64_t offset, uint64_t size, unsigned prot);
-
-bool gem_mmap__has_wc(int fd);
-void *gem_mmap__wc(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
 
-void *__gem_mmap__gtt(int fd, uint32_t handle, uint64_t size, unsigned prot);
-void *__gem_mmap__cpu(int fd, uint32_t handle, uint64_t offset, uint64_t size, unsigned prot);
-void *__gem_mmap__wc(int fd, uint32_t handle, uint64_t offset, uint64_t size, unsigned prot);
-
-int gem_munmap(void *ptr, uint64_t size);
-
 /**
  * gem_require_stolen_support:
  * @fd: open i915 drm file descriptor
@@ -111,16 +99,6 @@ int gem_munmap(void *ptr, uint64_t size);
 			igt_require(gem_create__has_stolen_support(fd) && \
 				    (gem_total_stolen_size(fd) > 0))
 
-/**
- * gem_require_mmap_wc:
- * @fd: open i915 drm file descriptor
- *
- * Feature test macro to query whether direct (i.e. cpu access path, bypassing
- * the gtt) write-combine memory mappings are available. Automatically skips
- * through igt_require() if not.
- */
-#define gem_require_mmap_wc(fd) igt_require(gem_mmap__has_wc(fd))
-
 int gem_madvise(int fd, uint32_t handle, int state);
 
 #define LOCAL_I915_GEM_USERPTR       0x33
lib/meson.build +1 -0
index dd36f818..0eb5585d 100644
@@ -4,6 +4,7 @@ lib_sources = [
 	'i915/gem_scheduler.c',
 	'i915/gem_submission.c',
 	'i915/gem_ring.c',
+	'i915/gem_mman.c',
 	'igt_color_encoding.c',
 	'igt_debugfs.c',
 	'igt_device.c',
tests/i915/gem_exec_reloc.c +0 -1
index 837f60a6..3f856fa5 100644
@@ -22,7 +22,6 @@
  */
 
 #include "igt.h"
-#include "igt_dummyload.h"
 
 IGT_TEST_DESCRIPTION("Basic sanity check of execbuf-ioctl relocations.");
 
tests/i915/gem_stolen.c +2 -7
index 1d489976..0b6c3cc2 100644
@@ -47,16 +47,11 @@
 
 #include <drm.h>
 
-#include "ioctl_wrappers.h"
-#include "intel_bufmgr.h"
-#include "intel_batchbuffer.h"
-#include "intel_io.h"
-#include "intel_chipset.h"
-#include "igt_aux.h"
-#include "drmtest.h"
 #include "drm.h"
 #include "i915_drm.h"
 
+#include "igt.h"
+
 IGT_TEST_DESCRIPTION("This test verifies the exetended gem_create ioctl,"
 		     " that includes allocation of obj from stolen region");
 #define CLEAR(s) memset(&s, 0, sizeof(s))
tests/prime_mmap.c +1 -5
index 67a6a232..83b9b3dc 100644
@@ -40,11 +40,7 @@
 #include <sys/ioctl.h>
 #include <pthread.h>
 
-#include "drm.h"
-#include "i915_drm.h"
-#include "drmtest.h"
-#include "igt_debugfs.h"
-#include "ioctl_wrappers.h"
+#include "igt.h"
 
 #define BO_SIZE (16*1024)
 
Signature · 6 lines
2.20.1

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
#1 lore raw

Quoting Antonio Argenziano (2019-02-26 17:01:59)

Quoted 37 lines

Move all mmap flavours and support function to separate file in i915 folder. This helps with moving i915 specific functions away from common libraries.

v2:
- Autotools still exists. (Petri)
- Include gem_mman.h directly. (Chris)

---
 benchmarks/gem_busy.c       |   7 +-
 benchmarks/gem_exec_reloc.c |   6 +-
 benchmarks/gem_mmap.c       |   6 +-
 benchmarks/gem_wsim.c       |  11 +-
 lib/Makefile.sources        |   2 +
 lib/i915/gem_mman.c         | 254 ++++++++++++++++++++++++++++++++++++
 lib/i915/gem_mman.h         |  55 ++++++++
 lib/igt.h                   |   1 +
 lib/igt_draw.c              |   1 +
 lib/igt_dummyload.c         |   1 +
 lib/igt_fb.c                |   1 +
 lib/ioctl_wrappers.c        | 213 ------------------------------
 lib/ioctl_wrappers.h        |  22 ----
 lib/meson.build             |   1 +
 tests/i915/gem_exec_reloc.c |   1 -
 tests/i915/gem_stolen.c     |   9 +-
 tests/prime_mmap.c          |   6 +-
 17 files changed, 327 insertions(+), 270 deletions(-)
 create mode 100644 lib/i915/gem_mman.c
 create mode 100644 lib/i915/gem_mman.h
benchmarks/gem_busy.c +0 -0
index ca517a16..bcb8a879 100644

benchmarks/gem_busy.c line 42

Quoted 10 lines
benchmarks/gem_busy.c +1 -6
@@ -39,12 +39,7 @@
 #include <sys/time.h>
 #include <time.h>
 
-#include "drm.h"
-#include "ioctl_wrappers.h"
-#include "drmtest.h"
-#include "intel_chipset.h"
-#include "intel_reg.h"
-#include "igt_stats.h"
+#include "igt.h"

Nope. That should never have happened. Keep dependencies explicit and headers standalone.
-Chris
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev

#2 lore raw
Quoted 41 lines · Chris Wilson

Quoting Antonio Argenziano (2019-02-26 17:01:59)

Quoted 40 lines

Move all mmap flavours and support function to separate file in i915 folder. This helps with moving i915 specific functions away from common libraries.

v2:
- Autotools still exists. (Petri)
- Include gem_mman.h directly. (Chris)

---
  benchmarks/gem_busy.c       |   7 +-
  benchmarks/gem_exec_reloc.c |   6 +-
  benchmarks/gem_mmap.c       |   6 +-
  benchmarks/gem_wsim.c       |  11 +-
  lib/Makefile.sources        |   2 +
  lib/i915/gem_mman.c         | 254 ++++++++++++++++++++++++++++++++++++
  lib/i915/gem_mman.h         |  55 ++++++++
  lib/igt.h                   |   1 +
  lib/igt_draw.c              |   1 +
  lib/igt_dummyload.c         |   1 +
  lib/igt_fb.c                |   1 +
  lib/ioctl_wrappers.c        | 213 ------------------------------
  lib/ioctl_wrappers.h        |  22 ----
  lib/meson.build             |   1 +
  tests/i915/gem_exec_reloc.c |   1 -
  tests/i915/gem_stolen.c     |   9 +-
  tests/prime_mmap.c          |   6 +-
  17 files changed, 327 insertions(+), 270 deletions(-)

create mode 100644 lib/i915/gem_mman.c
create mode 100644 lib/i915/gem_mman.h

benchmarks/gem_busy.c +0 -0
index ca517a16..bcb8a879 100644
@@ -39,12 +39,7 @@
  #include <sys/time.h>
  #include <time.h>
 
Quoted 10 lines

benchmarks/gem_busy.c line 42

Quoted 7 lines
benchmarks/gem_busy.c +1 -6
-#include "drm.h"
-#include "ioctl_wrappers.h"
-#include "drmtest.h"
-#include "intel_chipset.h"
-#include "intel_reg.h"
-#include "igt_stats.h"
+#include "igt.h"

Nope. That should never have happened. Keep dependencies explicit and headers standalone.

Everywhere or just in benchmark/?

Antonio

Quoted 2 lines

-Chris

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev

#3 lore raw

Quoting Antonio Argenziano (2019-02-26 17:13:47)

Quoted 55 lines · Chris Wilson
Quoted 41 lines

Quoting Antonio Argenziano (2019-02-26 17:01:59)

Quoted 40 lines

Move all mmap flavours and support function to separate file in i915 folder. This helps with moving i915 specific functions away from common libraries.

v2:
- Autotools still exists. (Petri)
- Include gem_mman.h directly. (Chris)

---
  benchmarks/gem_busy.c       |   7 +-
  benchmarks/gem_exec_reloc.c |   6 +-
  benchmarks/gem_mmap.c       |   6 +-
  benchmarks/gem_wsim.c       |  11 +-
  lib/Makefile.sources        |   2 +
  lib/i915/gem_mman.c         | 254 ++++++++++++++++++++++++++++++++++++
  lib/i915/gem_mman.h         |  55 ++++++++
  lib/igt.h                   |   1 +
  lib/igt_draw.c              |   1 +
  lib/igt_dummyload.c         |   1 +
  lib/igt_fb.c                |   1 +
  lib/ioctl_wrappers.c        | 213 ------------------------------
  lib/ioctl_wrappers.h        |  22 ----
  lib/meson.build             |   1 +
  tests/i915/gem_exec_reloc.c |   1 -
  tests/i915/gem_stolen.c     |   9 +-
  tests/prime_mmap.c          |   6 +-
  17 files changed, 327 insertions(+), 270 deletions(-)

create mode 100644 lib/i915/gem_mman.c
create mode 100644 lib/i915/gem_mman.h

benchmarks/gem_busy.c +0 -0
index ca517a16..bcb8a879 100644
@@ -39,12 +39,7 @@
  #include <sys/time.h>
  #include <time.h>
 
Quoted 10 lines

benchmarks/gem_busy.c line 42

Quoted 7 lines
benchmarks/gem_busy.c +1 -6
-#include "drm.h"
-#include "ioctl_wrappers.h"
-#include "drmtest.h"
-#include "intel_chipset.h"
-#include "intel_reg.h"
-#include "igt_stats.h"
+#include "igt.h"

Nope. That should never have happened. Keep dependencies explicit and headers standalone.

Quoted 1 line

Everywhere or just in benchmark/?

I'm denying igt.h even exists because I'm too lazy to git rm. So everywhere...
-Chris
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev