[igt-dev] [PATCH i-g-t 1/2] lib/i915/gem_mman: Add gem_mmap__wc_ext()
Ashutosh Dixit
ashutosh.dixit at intel.com
Fri Jan 31 19:47:00 UTC 2020
Add gem_mmap__wc_ext() for when specifically a WC mapping is required,
whether by using mmap_offset or mmap__wc.
Signed-off-by: Ashutosh Dixit <ashutosh.dixit at intel.com>
---
lib/i915/gem_mman.c | 23 +++++++++++++++++++++++
lib/i915/gem_mman.h | 2 ++
2 files changed, 25 insertions(+)
diff --git a/lib/i915/gem_mman.c b/lib/i915/gem_mman.c
index c034f3173..796ae6ebc 100644
--- a/lib/i915/gem_mman.c
+++ b/lib/i915/gem_mman.c
@@ -338,6 +338,29 @@ void *gem_mmap_offset__wc(int fd, uint32_t handle, uint64_t offset,
return ptr;
}
+
+/**
+ * gem_mmap__wc_ext
+ * @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()
+ *
+ * Used when specifically a WC mapping is needed, whether by using
+ * mmap_offset or mmap__wc
+ */
+void *gem_mmap__wc_ext(int fd, uint32_t handle, uint64_t offset,
+ uint64_t size, unsigned prot)
+{
+ void *ptr = __gem_mmap_offset(fd, handle, offset, size, prot,
+ I915_MMAP_OFFSET_WC);
+ if (!ptr)
+ ptr = __gem_mmap__wc(fd, handle, offset, size, prot);
+
+ return ptr;
+}
+
/**
* __gem_mmap__device_coherent:
* @fd: open i915 drm file descriptor
diff --git a/lib/i915/gem_mman.h b/lib/i915/gem_mman.h
index 2730295ea..b8e0c9dcd 100644
--- a/lib/i915/gem_mman.h
+++ b/lib/i915/gem_mman.h
@@ -37,6 +37,8 @@ bool gem_mmap_offset__has_wc(int fd);
void *gem_mmap__wc(int fd, uint32_t handle, uint64_t offset, uint64_t size, unsigned prot);
void *gem_mmap_offset__wc(int fd, uint32_t handle, uint64_t offset,
uint64_t size, unsigned prot);
+void *gem_mmap__wc_ext(int fd, uint32_t handle, uint64_t offset,
+ uint64_t size, unsigned prot);
void *gem_mmap__device_coherent(int fd, uint32_t handle, uint64_t offset,
uint64_t size, unsigned prot);
void *gem_mmap__cpu_coherent(int fd, uint32_t handle, uint64_t offset,
--
2.25.0
More information about the igt-dev
mailing list