* [igt-dev] [PATCH i-g-t v3] lib/i915: Move mmap IOCTLs wrappers into separate file
@ 2019-02-26 17:30 Antonio Argenziano
2019-02-26 17:46 ` Chris Wilson
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Antonio Argenziano @ 2019-02-26 17:30 UTC (permalink / raw)
To: igt-dev; +Cc: Petri Latvala
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)
v3:
- Keep includes explicit. (Chris)
Signed-off-by: Antonio Argenziano <antonio.argenziano@intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Petri Latvala <petri.latvala@intel.com>
---
benchmarks/gem_busy.c | 1 +
benchmarks/gem_exec_reloc.c | 1 +
benchmarks/gem_mmap.c | 1 +
benchmarks/gem_wsim.c | 1 +
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_stolen.c | 1 +
tests/prime_mmap.c | 1 +
16 files changed, 322 insertions(+), 235 deletions(-)
create mode 100644 lib/i915/gem_mman.c
create mode 100644 lib/i915/gem_mman.h
diff --git a/benchmarks/gem_busy.c b/benchmarks/gem_busy.c
index ca517a16..2fb1edf9 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_mman.h"
#define LOCAL_I915_EXEC_NO_RELOC (1<<11)
#define LOCAL_I915_EXEC_HANDLE_LUT (1<<12)
diff --git a/benchmarks/gem_exec_reloc.c b/benchmarks/gem_exec_reloc.c
index f9487d95..c734643c 100644
--- a/benchmarks/gem_exec_reloc.c
+++ b/benchmarks/gem_exec_reloc.c
@@ -40,6 +40,7 @@
#include "ioctl_wrappers.h"
#include "igt_debugfs.h"
#include "drmtest.h"
+#include "i915/gem_mman.h"
#define LOCAL_I915_EXEC_NO_RELOC (1<<11)
#define LOCAL_I915_EXEC_HANDLE_LUT (1<<12)
diff --git a/benchmarks/gem_mmap.c b/benchmarks/gem_mmap.c
index c809e087..d3d4ad31 100644
--- a/benchmarks/gem_mmap.c
+++ b/benchmarks/gem_mmap.c
@@ -43,6 +43,7 @@
#include "drmtest.h"
#include "igt_aux.h"
#include "igt_stats.h"
+#include "i915/gem_mman.h"
#define OBJECT_SIZE (1<<23)
diff --git a/benchmarks/gem_wsim.c b/benchmarks/gem_wsim.c
index 5a4753d9..0a5abc08 100644
--- a/benchmarks/gem_wsim.c
+++ b/benchmarks/gem_wsim.c
@@ -53,6 +53,7 @@
#include "igt_rand.h"
#include "igt_perf.h"
#include "sw_sync.h"
+#include "i915/gem_mman.h"
#include "ewma.h"
diff --git a/lib/Makefile.sources b/lib/Makefile.sources
index 808b9617..774a1a4e 100644
--- a/lib/Makefile.sources
+++ b/lib/Makefile.sources
@@ -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 \
diff --git a/lib/i915/gem_mman.c b/lib/i915/gem_mman.c
new file mode 100644
index 00000000..3cf9a6bb
--- /dev/null
+++ b/lib/i915/gem_mman.c
@@ -0,0 +1,254 @@
+/*
+ * Copyright © 2007, 2011, 2013, 2014, 2019 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 <stdbool.h>
+#include <sys/ioctl.h>
+#include <errno.h>
+
+#include "igt_core.h"
+#include "ioctl_wrappers.h"
+
+#include "gem_mman.h"
+
+#ifdef HAVE_VALGRIND
+#include <valgrind/valgrind.h>
+#include <valgrind/memcheck.h>
+
+#define VG(x) x
+#else
+#define VG(x) do {} while (0)
+#endif
+
+/**
+ * __gem_mmap__gtt:
+ * @fd: open i915 drm file descriptor
+ * @handle: gem buffer object handle
+ * @size: size of the gem buffer
+ * @prot: memory protection bits as used by mmap()
+ *
+ * This functions wraps up procedure to establish a memory mapping through the
+ * GTT.
+ *
+ * Returns: A pointer to the created memory mapping, NULL on failure.
+ */
+void *__gem_mmap__gtt(int fd, uint32_t handle, uint64_t size, unsigned prot)
+{
+ struct drm_i915_gem_mmap_gtt mmap_arg;
+ void *ptr;
+
+ memset(&mmap_arg, 0, sizeof(mmap_arg));
+ mmap_arg.handle = handle;
+ if (igt_ioctl(fd, DRM_IOCTL_I915_GEM_MMAP_GTT, &mmap_arg))
+ return NULL;
+
+ ptr = mmap64(0, size, prot, MAP_SHARED, fd, mmap_arg.offset);
+ if (ptr == MAP_FAILED)
+ ptr = NULL;
+ else
+ errno = 0;
+
+ VG(VALGRIND_MAKE_MEM_DEFINED(ptr, size));
+
+ return ptr;
+}
+
+/**
+ * gem_mmap__gtt:
+ * @fd: open i915 drm file descriptor
+ * @handle: gem buffer object handle
+ * @size: size of the gem buffer
+ * @prot: memory protection bits as used by mmap()
+ *
+ * Like __gem_mmap__gtt() except we assert on failure.
+ *
+ * Returns: A pointer to the created memory mapping
+ */
+void *gem_mmap__gtt(int fd, uint32_t handle, uint64_t size, unsigned prot)
+{
+ void *ptr = __gem_mmap__gtt(fd, handle, size, prot);
+ igt_assert(ptr);
+ return ptr;
+}
+
+int gem_munmap(void *ptr, uint64_t size)
+{
+ int ret = munmap(ptr, size);
+
+ if (ret == 0)
+ VG(VALGRIND_MAKE_MEM_NOACCESS(ptr, size));
+
+ return ret;
+}
+
+bool gem_mmap__has_wc(int fd)
+{
+ static int has_wc = -1;
+
+ if (has_wc == -1) {
+ struct drm_i915_getparam gp;
+ int mmap_version = -1;
+ int gtt_version = -1;
+
+ has_wc = 0;
+
+ memset(&gp, 0, sizeof(gp));
+ gp.param = I915_PARAM_MMAP_GTT_VERSION;
+ gp.value = >t_version;
+ ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp);
+
+ memset(&gp, 0, sizeof(gp));
+ gp.param = I915_PARAM_MMAP_VERSION;
+ gp.value = &mmap_version;
+ ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp);
+
+ /* Do we have the new mmap_ioctl with DOMAIN_WC? */
+ if (mmap_version >= 1 && gtt_version >= 2) {
+ struct drm_i915_gem_mmap arg;
+
+ /* Does this device support wc-mmaps ? */
+ memset(&arg, 0, sizeof(arg));
+ arg.handle = gem_create(fd, 4096);
+ arg.offset = 0;
+ arg.size = 4096;
+ arg.flags = I915_MMAP_WC;
+ has_wc = igt_ioctl(fd, DRM_IOCTL_I915_GEM_MMAP, &arg) == 0;
+ gem_close(fd, arg.handle);
+ }
+ errno = 0;
+ }
+
+ return has_wc > 0;
+}
+
+/**
+ * __gem_mmap:
+ * @fd: open i915 drm file descriptor
+ * @handle: gem buffer object handle
+ * @offset: offset in the gem buffer of the mmap arena
+ * @size: size of the mmap arena
+ * @prot: memory protection bits as used by mmap()
+ * @flags: flags used to determine caching
+ *
+ * This functions wraps up procedure to establish a memory mapping through
+ * direct cpu access, bypassing the gpu (valid for wc == false). For wc == true
+ * it also bypass cpu caches completely and GTT system agent (i.e. there is no
+ * automatic tiling of the mmapping through the fence registers).
+ *
+ * Returns: A pointer to the created memory mapping, NULL on failure.
+ */
+static void
+*__gem_mmap(int fd, uint32_t handle, uint64_t offset, uint64_t size, unsigned int prot, uint64_t flags)
+{
+ struct drm_i915_gem_mmap arg;
+
+ memset(&arg, 0, sizeof(arg));
+ arg.handle = handle;
+ arg.offset = offset;
+ arg.size = size;
+ arg.flags = flags;
+
+ if (igt_ioctl(fd, DRM_IOCTL_I915_GEM_MMAP, &arg))
+ return NULL;
+
+ VG(VALGRIND_MAKE_MEM_DEFINED(from_user_pointer(arg.addr_ptr), arg.size));
+
+ errno = 0;
+ return from_user_pointer(arg.addr_ptr);
+}
+
+/**
+ * __gem_mmap__wc:
+ * @fd: open i915 drm file descriptor
+ * @handle: gem buffer object handle
+ * @offset: offset in the gem buffer of the mmap arena
+ * @size: size of the mmap arena
+ * @prot: memory protection bits as used by mmap()
+ *
+ * This functions wraps up procedure to establish a memory mapping through
+ * direct cpu access, bypassing the gpu and cpu caches completely and also
+ * bypassing the GTT system agent (i.e. there is no automatic tiling of
+ * the mmapping through the fence registers).
+ *
+ * Returns: A pointer to the created memory mapping, NULL on failure.
+ */
+void *__gem_mmap__wc(int fd, uint32_t handle, uint64_t offset, uint64_t size, unsigned prot)
+{
+ return __gem_mmap(fd, handle, offset, size, prot, I915_MMAP_WC);
+}
+
+/**
+ * gem_mmap__wc:
+ * @fd: open i915 drm file descriptor
+ * @handle: gem buffer object handle
+ * @offset: offset in the gem buffer of the mmap arena
+ * @size: size of the mmap arena
+ * @prot: memory protection bits as used by mmap()
+ *
+ * Like __gem_mmap__wc() except we assert on failure.
+ *
+ * Returns: A pointer to the created memory mapping
+ */
+void *gem_mmap__wc(int fd, uint32_t handle, uint64_t offset, uint64_t size, unsigned prot)
+{
+ void *ptr = __gem_mmap__wc(fd, handle, offset, size, prot);
+ igt_assert(ptr);
+ return ptr;
+}
+
+/**
+ * __gem_mmap__cpu:
+ * @fd: open i915 drm file descriptor
+ * @handle: gem buffer object handle
+ * @offset: offset in the gem buffer of the mmap arena
+ * @size: size of the mmap arena
+ * @prot: memory protection bits as used by mmap()
+ *
+ * This functions wraps up procedure to establish a memory mapping through
+ * direct cpu access, bypassing the gpu completely.
+ *
+ * Returns: A pointer to the created memory mapping, NULL on failure.
+ */
+void *__gem_mmap__cpu(int fd, uint32_t handle, uint64_t offset, uint64_t size, unsigned prot)
+{
+ return __gem_mmap(fd, handle, offset, size, prot, 0);
+}
+
+/**
+ * gem_mmap__cpu:
+ * @fd: open i915 drm file descriptor
+ * @handle: gem buffer object handle
+ * @offset: offset in the gem buffer of the mmap arena
+ * @size: size of the mmap arena
+ * @prot: memory protection bits as used by mmap()
+ *
+ * Like __gem_mmap__cpu() except we assert on failure.
+ *
+ * Returns: A pointer to the created memory mapping
+ */
+void *gem_mmap__cpu(int fd, uint32_t handle, uint64_t offset, uint64_t size, unsigned prot)
+{
+ void *ptr = __gem_mmap__cpu(fd, handle, offset, size, prot);
+ igt_assert(ptr);
+ return ptr;
+}
diff --git a/lib/i915/gem_mman.h b/lib/i915/gem_mman.h
new file mode 100644
index 00000000..f7242ed7
--- /dev/null
+++ b/lib/i915/gem_mman.h
@@ -0,0 +1,55 @@
+/*
+ * Copyright © 2007, 2011, 2013, 2014, 2019 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 GEM_MMAN_H
+#define GEM_MMAN_H
+
+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_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))
+
+#endif /* GEM_MMAN_H */
+
diff --git a/lib/igt.h b/lib/igt.h
index ebf92349..6654a659 100644
--- a/lib/igt.h
+++ b/lib/igt.h
@@ -52,5 +52,6 @@
#include "media_fill.h"
#include "media_spin.h"
#include "rendercopy.h"
+#include "i915/gem_mman.h"
#endif /* IGT_H */
diff --git a/lib/igt_draw.c b/lib/igt_draw.c
index 4990d4a0..bea86c61 100644
--- a/lib/igt_draw.c
+++ b/lib/igt_draw.c
@@ -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
diff --git a/lib/igt_dummyload.c b/lib/igt_dummyload.c
index 982906f2..47f6b92b 100644
--- a/lib/igt_dummyload.c
+++ b/lib/igt_dummyload.c
@@ -39,6 +39,7 @@
#include "ioctl_wrappers.h"
#include "sw_sync.h"
#include "igt_vgem.h"
+#include "i915/gem_mman.h"
/**
* SECTION:igt_dummyload
diff --git a/lib/igt_fb.c b/lib/igt_fb.c
index 462afec2..10a21044 100644
--- a/lib/igt_fb.c
+++ b/lib/igt_fb.c
@@ -41,6 +41,7 @@
#include "ioctl_wrappers.h"
#include "intel_batchbuffer.h"
#include "intel_chipset.h"
+#include "i915/gem_mman.h"
/**
* SECTION:igt_fb
diff --git a/lib/ioctl_wrappers.c b/lib/ioctl_wrappers.c
index 404c2fbf..39920f87 100644
--- a/lib/ioctl_wrappers.c
+++ b/lib/ioctl_wrappers.c
@@ -641,219 +641,6 @@ void gem_execbuf_wr(int fd, struct drm_i915_gem_execbuffer2 *execbuf)
igt_assert_eq(__gem_execbuf_wr(fd, execbuf), 0);
}
-/**
- * __gem_mmap__gtt:
- * @fd: open i915 drm file descriptor
- * @handle: gem buffer object handle
- * @size: size of the gem buffer
- * @prot: memory protection bits as used by mmap()
- *
- * This functions wraps up procedure to establish a memory mapping through the
- * GTT.
- *
- * Returns: A pointer to the created memory mapping, NULL on failure.
- */
-void *__gem_mmap__gtt(int fd, uint32_t handle, uint64_t size, unsigned prot)
-{
- struct drm_i915_gem_mmap_gtt mmap_arg;
- void *ptr;
-
- memset(&mmap_arg, 0, sizeof(mmap_arg));
- mmap_arg.handle = handle;
- if (igt_ioctl(fd, DRM_IOCTL_I915_GEM_MMAP_GTT, &mmap_arg))
- return NULL;
-
- ptr = mmap64(0, size, prot, MAP_SHARED, fd, mmap_arg.offset);
- if (ptr == MAP_FAILED)
- ptr = NULL;
- else
- errno = 0;
-
- VG(VALGRIND_MAKE_MEM_DEFINED(ptr, size));
-
- return ptr;
-}
-
-/**
- * gem_mmap__gtt:
- * @fd: open i915 drm file descriptor
- * @handle: gem buffer object handle
- * @size: size of the gem buffer
- * @prot: memory protection bits as used by mmap()
- *
- * Like __gem_mmap__gtt() except we assert on failure.
- *
- * Returns: A pointer to the created memory mapping
- */
-void *gem_mmap__gtt(int fd, uint32_t handle, uint64_t size, unsigned prot)
-{
- void *ptr = __gem_mmap__gtt(fd, handle, size, prot);
- igt_assert(ptr);
- return ptr;
-}
-
-int gem_munmap(void *ptr, uint64_t size)
-{
- int ret = munmap(ptr, size);
-
- if (ret == 0)
- VG(VALGRIND_MAKE_MEM_NOACCESS(ptr, size));
-
- return ret;
-}
-
-bool gem_mmap__has_wc(int fd)
-{
- static int has_wc = -1;
-
- if (has_wc == -1) {
- struct drm_i915_getparam gp;
- int mmap_version = -1;
- int gtt_version = -1;
-
- has_wc = 0;
-
- memset(&gp, 0, sizeof(gp));
- gp.param = I915_PARAM_MMAP_GTT_VERSION;
- gp.value = >t_version;
- ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp);
-
- memset(&gp, 0, sizeof(gp));
- gp.param = I915_PARAM_MMAP_VERSION;
- gp.value = &mmap_version;
- ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp);
-
- /* Do we have the new mmap_ioctl with DOMAIN_WC? */
- if (mmap_version >= 1 && gtt_version >= 2) {
- struct drm_i915_gem_mmap arg;
-
- /* Does this device support wc-mmaps ? */
- memset(&arg, 0, sizeof(arg));
- arg.handle = gem_create(fd, 4096);
- arg.offset = 0;
- arg.size = 4096;
- arg.flags = I915_MMAP_WC;
- has_wc = igt_ioctl(fd, DRM_IOCTL_I915_GEM_MMAP, &arg) == 0;
- gem_close(fd, arg.handle);
- }
- errno = 0;
- }
-
- return has_wc > 0;
-}
-
-/**
- * __gem_mmap:
- * @fd: open i915 drm file descriptor
- * @handle: gem buffer object handle
- * @offset: offset in the gem buffer of the mmap arena
- * @size: size of the mmap arena
- * @prot: memory protection bits as used by mmap()
- * @flags: flags used to determine caching
- *
- * This functions wraps up procedure to establish a memory mapping through
- * direct cpu access, bypassing the gpu (valid for wc == false). For wc == true
- * it also bypass cpu caches completely and GTT system agent (i.e. there is no
- * automatic tiling of the mmapping through the fence registers).
- *
- * Returns: A pointer to the created memory mapping, NULL on failure.
- */
-static void
-*__gem_mmap(int fd, uint32_t handle, uint64_t offset, uint64_t size, unsigned int prot, uint64_t flags)
-{
- struct drm_i915_gem_mmap arg;
-
- memset(&arg, 0, sizeof(arg));
- arg.handle = handle;
- arg.offset = offset;
- arg.size = size;
- arg.flags = flags;
-
- if (igt_ioctl(fd, DRM_IOCTL_I915_GEM_MMAP, &arg))
- return NULL;
-
- VG(VALGRIND_MAKE_MEM_DEFINED(from_user_pointer(arg.addr_ptr), arg.size));
-
- errno = 0;
- return from_user_pointer(arg.addr_ptr);
-}
-
-/**
- * __gem_mmap__wc:
- * @fd: open i915 drm file descriptor
- * @handle: gem buffer object handle
- * @offset: offset in the gem buffer of the mmap arena
- * @size: size of the mmap arena
- * @prot: memory protection bits as used by mmap()
- *
- * This functions wraps up procedure to establish a memory mapping through
- * direct cpu access, bypassing the gpu and cpu caches completely and also
- * bypassing the GTT system agent (i.e. there is no automatic tiling of
- * the mmapping through the fence registers).
- *
- * Returns: A pointer to the created memory mapping, NULL on failure.
- */
-void *__gem_mmap__wc(int fd, uint32_t handle, uint64_t offset, uint64_t size, unsigned prot)
-{
- return __gem_mmap(fd, handle, offset, size, prot, I915_MMAP_WC);
-}
-
-/**
- * gem_mmap__wc:
- * @fd: open i915 drm file descriptor
- * @handle: gem buffer object handle
- * @offset: offset in the gem buffer of the mmap arena
- * @size: size of the mmap arena
- * @prot: memory protection bits as used by mmap()
- *
- * Like __gem_mmap__wc() except we assert on failure.
- *
- * Returns: A pointer to the created memory mapping
- */
-void *gem_mmap__wc(int fd, uint32_t handle, uint64_t offset, uint64_t size, unsigned prot)
-{
- void *ptr = __gem_mmap__wc(fd, handle, offset, size, prot);
- igt_assert(ptr);
- return ptr;
-}
-
-/**
- * __gem_mmap__cpu:
- * @fd: open i915 drm file descriptor
- * @handle: gem buffer object handle
- * @offset: offset in the gem buffer of the mmap arena
- * @size: size of the mmap arena
- * @prot: memory protection bits as used by mmap()
- *
- * This functions wraps up procedure to establish a memory mapping through
- * direct cpu access, bypassing the gpu completely.
- *
- * Returns: A pointer to the created memory mapping, NULL on failure.
- */
-void *__gem_mmap__cpu(int fd, uint32_t handle, uint64_t offset, uint64_t size, unsigned prot)
-{
- return __gem_mmap(fd, handle, offset, size, prot, 0);
-}
-
-/**
- * gem_mmap__cpu:
- * @fd: open i915 drm file descriptor
- * @handle: gem buffer object handle
- * @offset: offset in the gem buffer of the mmap arena
- * @size: size of the mmap arena
- * @prot: memory protection bits as used by mmap()
- *
- * Like __gem_mmap__cpu() except we assert on failure.
- *
- * Returns: A pointer to the created memory mapping
- */
-void *gem_mmap__cpu(int fd, uint32_t handle, uint64_t offset, uint64_t size, unsigned prot)
-{
- void *ptr = __gem_mmap__cpu(fd, handle, offset, size, prot);
- igt_assert(ptr);
- return ptr;
-}
-
/**
* gem_madvise:
* @fd: open i915 drm file descriptor
diff --git a/lib/ioctl_wrappers.h b/lib/ioctl_wrappers.h
index b22b36b0..f0be2608 100644
--- a/lib/ioctl_wrappers.h
+++ b/lib/ioctl_wrappers.h
@@ -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
diff --git a/lib/meson.build b/lib/meson.build
index dd36f818..0eb5585d 100644
--- a/lib/meson.build
+++ b/lib/meson.build
@@ -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',
diff --git a/tests/i915/gem_stolen.c b/tests/i915/gem_stolen.c
index 1d489976..e2c52723 100644
--- a/tests/i915/gem_stolen.c
+++ b/tests/i915/gem_stolen.c
@@ -56,6 +56,7 @@
#include "drmtest.h"
#include "drm.h"
#include "i915_drm.h"
+#include "i915/gem_mman.h"
IGT_TEST_DESCRIPTION("This test verifies the exetended gem_create ioctl,"
" that includes allocation of obj from stolen region");
diff --git a/tests/prime_mmap.c b/tests/prime_mmap.c
index 67a6a232..fc985784 100644
--- a/tests/prime_mmap.c
+++ b/tests/prime_mmap.c
@@ -45,6 +45,7 @@
#include "drmtest.h"
#include "igt_debugfs.h"
#include "ioctl_wrappers.h"
+#include "i915/gem_mman.h"
#define BO_SIZE (16*1024)
--
2.20.1
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [igt-dev] [PATCH i-g-t v3] lib/i915: Move mmap IOCTLs wrappers into separate file
2019-02-26 17:30 [igt-dev] [PATCH i-g-t v3] lib/i915: Move mmap IOCTLs wrappers into separate file Antonio Argenziano
@ 2019-02-26 17:46 ` Chris Wilson
2019-02-26 17:56 ` [igt-dev] ✓ Fi.CI.BAT: success for lib/i915: Move mmap IOCTLs wrappers into separate file (rev2) Patchwork
2019-02-26 21:53 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
2 siblings, 0 replies; 4+ messages in thread
From: Chris Wilson @ 2019-02-26 17:46 UTC (permalink / raw)
To: Antonio Argenziano, igt-dev; +Cc: Petri Latvala
Quoting Antonio Argenziano (2019-02-26 17:30:44)
> 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)
>
> v3:
> - Keep includes explicit. (Chris)
>
> Signed-off-by: Antonio Argenziano <antonio.argenziano@intel.com>
> Cc: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Petri Latvala <petri.latvala@intel.com>
Very disappointing, I found nothing to complain about.
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
-Chris
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
^ permalink raw reply [flat|nested] 4+ messages in thread
* [igt-dev] ✓ Fi.CI.BAT: success for lib/i915: Move mmap IOCTLs wrappers into separate file (rev2)
2019-02-26 17:30 [igt-dev] [PATCH i-g-t v3] lib/i915: Move mmap IOCTLs wrappers into separate file Antonio Argenziano
2019-02-26 17:46 ` Chris Wilson
@ 2019-02-26 17:56 ` Patchwork
2019-02-26 21:53 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
2 siblings, 0 replies; 4+ messages in thread
From: Patchwork @ 2019-02-26 17:56 UTC (permalink / raw)
To: igt-dev
== Series Details ==
Series: lib/i915: Move mmap IOCTLs wrappers into separate file (rev2)
URL : https://patchwork.freedesktop.org/series/57258/
State : success
== Summary ==
CI Bug Log - changes from CI_DRM_5662 -> IGTPW_2526
====================================================
Summary
-------
**SUCCESS**
No regressions found.
External URL: https://patchwork.freedesktop.org/api/1.0/series/57258/revisions/2/
Known issues
------------
Here are the changes found in IGTPW_2526 that come from known issues:
### IGT changes ###
#### Issues hit ####
* igt@gem_exec_basic@readonly-bsd2:
- fi-pnv-d510: NOTRUN -> SKIP [fdo#109271] +76
* igt@kms_busy@basic-flip-c:
- fi-pnv-d510: NOTRUN -> SKIP [fdo#109271] / [fdo#109278]
* igt@kms_chamelium@common-hpd-after-suspend:
- fi-kbl-7567u: PASS -> WARN [fdo#109380]
* igt@kms_pipe_crc_basic@nonblocking-crc-pipe-c:
- fi-kbl-7567u: PASS -> SKIP [fdo#109271] +33
{name}: This element is suppressed. This means it is ignored when computing
the status of the difference (SUCCESS, WARNING, or FAILURE).
[fdo#108840]: https://bugs.freedesktop.org/show_bug.cgi?id=108840
[fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
[fdo#109278]: https://bugs.freedesktop.org/show_bug.cgi?id=109278
[fdo#109380]: https://bugs.freedesktop.org/show_bug.cgi?id=109380
Participating hosts (41 -> 35)
------------------------------
Additional (1): fi-pnv-d510
Missing (7): fi-ilk-m540 fi-hsw-4200u fi-skl-guc fi-bsw-cyan fi-skl-6260u fi-gdg-551 fi-ivb-3520m
Build changes
-------------
* IGT: IGT_4858 -> IGTPW_2526
CI_DRM_5662: 24f469aa60d64befba6eb7f1bcc374b7b199dea3 @ git://anongit.freedesktop.org/gfx-ci/linux
IGTPW_2526: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_2526/
IGT_4858: f308fb6efa8045a6e97340a49758a2d593e3cb60 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_2526/
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
^ permalink raw reply [flat|nested] 4+ messages in thread
* [igt-dev] ✓ Fi.CI.IGT: success for lib/i915: Move mmap IOCTLs wrappers into separate file (rev2)
2019-02-26 17:30 [igt-dev] [PATCH i-g-t v3] lib/i915: Move mmap IOCTLs wrappers into separate file Antonio Argenziano
2019-02-26 17:46 ` Chris Wilson
2019-02-26 17:56 ` [igt-dev] ✓ Fi.CI.BAT: success for lib/i915: Move mmap IOCTLs wrappers into separate file (rev2) Patchwork
@ 2019-02-26 21:53 ` Patchwork
2 siblings, 0 replies; 4+ messages in thread
From: Patchwork @ 2019-02-26 21:53 UTC (permalink / raw)
To: igt-dev
== Series Details ==
Series: lib/i915: Move mmap IOCTLs wrappers into separate file (rev2)
URL : https://patchwork.freedesktop.org/series/57258/
State : success
== Summary ==
CI Bug Log - changes from CI_DRM_5662_full -> IGTPW_2526_full
====================================================
Summary
-------
**SUCCESS**
No regressions found.
External URL: https://patchwork.freedesktop.org/api/1.0/series/57258/revisions/2/
Known issues
------------
Here are the changes found in IGTPW_2526_full that come from known issues:
### IGT changes ###
#### Issues hit ####
* igt@gem_eio@unwedge-stress:
- shard-apl: PASS -> FAIL [fdo#105957]
* igt@gem_softpin@noreloc-s3:
- shard-kbl: PASS -> INCOMPLETE [fdo#103665]
* igt@i915_pm_rpm@basic-rte:
- shard-snb: NOTRUN -> SKIP [fdo#109271] +17
* igt@kms_busy@extended-modeset-hang-newfb-render-c:
- shard-apl: NOTRUN -> DMESG-WARN [fdo#107956]
* igt@kms_busy@extended-modeset-hang-newfb-with-reset-render-b:
- shard-snb: PASS -> DMESG-WARN [fdo#107956]
* igt@kms_busy@extended-modeset-hang-oldfb-with-reset-render-f:
- shard-glk: NOTRUN -> SKIP [fdo#109271] / [fdo#109278]
* igt@kms_ccs@pipe-a-crc-sprite-planes-basic:
- shard-glk: PASS -> FAIL [fdo#108145]
- shard-kbl: PASS -> FAIL [fdo#107725] / [fdo#108145]
* igt@kms_cursor_crc@cursor-256x256-sliding:
- shard-kbl: PASS -> FAIL [fdo#103232] +1
* igt@kms_cursor_crc@cursor-256x85-onscreen:
- shard-apl: PASS -> FAIL [fdo#103232] +3
* igt@kms_cursor_crc@cursor-64x64-suspend:
- shard-apl: PASS -> FAIL [fdo#103191] / [fdo#103232] +1
- shard-kbl: PASS -> FAIL [fdo#103191] / [fdo#103232]
* igt@kms_cursor_crc@cursor-alpha-opaque:
- shard-glk: PASS -> FAIL [fdo#109350]
* igt@kms_cursor_crc@cursor-size-change:
- shard-glk: PASS -> FAIL [fdo#103232]
* igt@kms_cursor_legacy@2x-long-cursor-vs-flip-legacy:
- shard-hsw: PASS -> FAIL [fdo#105767]
* igt@kms_frontbuffer_tracking@fbc-1p-primscrn-spr-indfb-fullscreen:
- shard-apl: PASS -> FAIL [fdo#103167] +2
* igt@kms_frontbuffer_tracking@fbc-1p-rte:
- shard-apl: PASS -> FAIL [fdo#103167] / [fdo#105682]
* igt@kms_frontbuffer_tracking@fbc-2p-primscrn-spr-indfb-onoff:
- shard-glk: PASS -> FAIL [fdo#103167] +5
* igt@kms_frontbuffer_tracking@fbcpsr-2p-scndscrn-shrfb-msflip-blt:
- shard-glk: NOTRUN -> SKIP [fdo#109271] +7
* igt@kms_frontbuffer_tracking@psr-2p-scndscrn-pri-shrfb-draw-mmap-gtt:
- shard-kbl: NOTRUN -> SKIP [fdo#109271] +4
* igt@kms_frontbuffer_tracking@psr-rgb565-draw-render:
- shard-apl: NOTRUN -> SKIP [fdo#109271] +16
* igt@kms_plane@pixel-format-pipe-a-planes-source-clamping:
- shard-apl: PASS -> FAIL [fdo#108948]
* igt@kms_plane@pixel-format-pipe-c-planes-source-clamping:
- shard-glk: PASS -> FAIL [fdo#108948]
* igt@kms_plane@plane-panning-bottom-right-suspend-pipe-b-planes:
- shard-snb: PASS -> FAIL [fdo#103375]
* igt@kms_plane@plane-position-covered-pipe-c-planes:
- shard-apl: PASS -> FAIL [fdo#103166] +4
* igt@kms_plane_alpha_blend@pipe-b-alpha-opaque-fb:
- shard-kbl: NOTRUN -> FAIL [fdo#108145]
* igt@kms_plane_multiple@atomic-pipe-a-tiling-yf:
- shard-kbl: PASS -> FAIL [fdo#103166] +2
* igt@kms_plane_multiple@atomic-pipe-c-tiling-x:
- shard-glk: PASS -> FAIL [fdo#103166] +5
* igt@kms_universal_plane@disable-primary-vs-flip-pipe-d:
- shard-snb: NOTRUN -> SKIP [fdo#109271] / [fdo#109278]
- shard-apl: NOTRUN -> SKIP [fdo#109271] / [fdo#109278]
* igt@kms_vblank@pipe-a-ts-continuation-dpms-suspend:
- shard-snb: PASS -> INCOMPLETE [fdo#105411] +1
* igt@kms_vblank@pipe-c-ts-continuation-modeset-hang:
- shard-apl: PASS -> FAIL [fdo#104894]
#### Possible fixes ####
* igt@kms_busy@extended-pageflip-modeset-hang-oldfb-render-b:
- shard-kbl: DMESG-WARN [fdo#107956] -> PASS
* igt@kms_ccs@pipe-a-crc-sprite-planes-basic:
- shard-apl: FAIL [fdo#106510] / [fdo#108145] -> PASS
* igt@kms_color@pipe-a-degamma:
- shard-apl: FAIL [fdo#104782] / [fdo#108145] -> PASS
- shard-kbl: FAIL [fdo#104782] / [fdo#108145] -> PASS
* igt@kms_color@pipe-c-ctm-max:
- shard-apl: FAIL [fdo#108147] -> PASS
* igt@kms_cursor_crc@cursor-128x128-onscreen:
- shard-kbl: FAIL [fdo#103232] -> PASS +2
- shard-apl: FAIL [fdo#103232] -> PASS +3
* igt@kms_cursor_crc@cursor-128x128-suspend:
- shard-kbl: FAIL [fdo#103191] / [fdo#103232] -> PASS
* igt@kms_frontbuffer_tracking@fbc-1p-primscrn-cur-indfb-draw-mmap-wc:
- shard-kbl: FAIL [fdo#103167] -> PASS
- shard-apl: FAIL [fdo#103167] -> PASS
* igt@kms_frontbuffer_tracking@fbc-2p-primscrn-spr-indfb-draw-mmap-cpu:
- shard-glk: FAIL [fdo#103167] -> PASS +4
* igt@kms_plane@pixel-format-pipe-b-planes-source-clamping:
- shard-glk: FAIL [fdo#108948] -> PASS
* igt@kms_plane_alpha_blend@pipe-a-constant-alpha-max:
- shard-glk: FAIL [fdo#108145] -> PASS
* igt@kms_plane_multiple@atomic-pipe-a-tiling-none:
- shard-kbl: FAIL [fdo#103166] -> PASS
* igt@kms_plane_multiple@atomic-pipe-c-tiling-none:
- shard-glk: FAIL [fdo#103166] -> PASS +1
* igt@kms_plane_multiple@atomic-pipe-c-tiling-y:
- shard-apl: FAIL [fdo#103166] -> PASS +4
* igt@kms_setmode@basic:
- shard-apl: FAIL [fdo#99912] -> PASS
* igt@perf_pmu@rc6:
- shard-kbl: SKIP [fdo#109271] -> PASS
#### Warnings ####
* igt@kms_cursor_crc@cursor-128x128-suspend:
- shard-apl: FAIL [fdo#103191] / [fdo#103232] -> INCOMPLETE [fdo#103927]
[fdo#103166]: https://bugs.freedesktop.org/show_bug.cgi?id=103166
[fdo#103167]: https://bugs.freedesktop.org/show_bug.cgi?id=103167
[fdo#103191]: https://bugs.freedesktop.org/show_bug.cgi?id=103191
[fdo#103232]: https://bugs.freedesktop.org/show_bug.cgi?id=103232
[fdo#103375]: https://bugs.freedesktop.org/show_bug.cgi?id=103375
[fdo#103665]: https://bugs.freedesktop.org/show_bug.cgi?id=103665
[fdo#103927]: https://bugs.freedesktop.org/show_bug.cgi?id=103927
[fdo#104782]: https://bugs.freedesktop.org/show_bug.cgi?id=104782
[fdo#104894]: https://bugs.freedesktop.org/show_bug.cgi?id=104894
[fdo#105411]: https://bugs.freedesktop.org/show_bug.cgi?id=105411
[fdo#105682]: https://bugs.freedesktop.org/show_bug.cgi?id=105682
[fdo#105767]: https://bugs.freedesktop.org/show_bug.cgi?id=105767
[fdo#105957]: https://bugs.freedesktop.org/show_bug.cgi?id=105957
[fdo#106510]: https://bugs.freedesktop.org/show_bug.cgi?id=106510
[fdo#107725]: https://bugs.freedesktop.org/show_bug.cgi?id=107725
[fdo#107956]: https://bugs.freedesktop.org/show_bug.cgi?id=107956
[fdo#108145]: https://bugs.freedesktop.org/show_bug.cgi?id=108145
[fdo#108147]: https://bugs.freedesktop.org/show_bug.cgi?id=108147
[fdo#108948]: https://bugs.freedesktop.org/show_bug.cgi?id=108948
[fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
[fdo#109278]: https://bugs.freedesktop.org/show_bug.cgi?id=109278
[fdo#109350]: https://bugs.freedesktop.org/show_bug.cgi?id=109350
[fdo#99912]: https://bugs.freedesktop.org/show_bug.cgi?id=99912
Participating hosts (6 -> 5)
------------------------------
Missing (1): shard-skl
Build changes
-------------
* IGT: IGT_4858 -> IGTPW_2526
* Piglit: piglit_4509 -> None
CI_DRM_5662: 24f469aa60d64befba6eb7f1bcc374b7b199dea3 @ git://anongit.freedesktop.org/gfx-ci/linux
IGTPW_2526: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_2526/
IGT_4858: f308fb6efa8045a6e97340a49758a2d593e3cb60 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
piglit_4509: fdc5a4ca11124ab8413c7988896eec4c97336694 @ git://anongit.freedesktop.org/piglit
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_2526/
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-02-26 21:53 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-02-26 17:30 [igt-dev] [PATCH i-g-t v3] lib/i915: Move mmap IOCTLs wrappers into separate file Antonio Argenziano
2019-02-26 17:46 ` Chris Wilson
2019-02-26 17:56 ` [igt-dev] ✓ Fi.CI.BAT: success for lib/i915: Move mmap IOCTLs wrappers into separate file (rev2) Patchwork
2019-02-26 21:53 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox