[igt-dev] [PATCH i-g-t 1/2] lib/i915/gem_mman: Prioritize GTT mappings over WC

Ashutosh Dixit ashutosh.dixit at intel.com
Sat Jan 11 05:36:52 UTC 2020


In order to preserve legacy behavior for devices with a mappable
aperture try a GTT mapping first. Use a WC mapping only for devices
without a mappable aperture.

Signed-off-by: Ashutosh Dixit <ashutosh.dixit at intel.com>
---
 lib/i915/gem_mman.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/lib/i915/gem_mman.c b/lib/i915/gem_mman.c
index c98f02aee..cdebf44a6 100644
--- a/lib/i915/gem_mman.c
+++ b/lib/i915/gem_mman.c
@@ -347,18 +347,19 @@ void *gem_mmap_offset__wc(int fd, uint32_t handle, uint64_t offset,
  * @prot: memory protection bits as used by mmap()
  *
  * Returns: A pointer to a block of linear device memory mapped into the
- * process with WC semantics. When no WC is available try to mmap using GGTT.
+ * process via GTT. When GTT is not available try WC mapping.
  */
 void *__gem_mmap__device_coherent(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);
+	void *ptr = __gem_mmap__gtt(fd, handle, size, prot);
+
 	if (!ptr)
-		ptr = __gem_mmap__wc(fd, handle, offset, size, prot);
+		ptr = __gem_mmap_offset(fd, handle, offset, size, prot,
+					I915_MMAP_OFFSET_WC);
 
 	if (!ptr)
-		ptr = __gem_mmap__gtt(fd, handle, size, prot);
+		ptr = __gem_mmap__wc(fd, handle, offset, size, prot);
 
 	return ptr;
 }
-- 
2.24.1



More information about the igt-dev mailing list