minigbm: i915: use I915_MMAP_WC in certain cases

The Zero Latency Ink app is scanned out while the buffer is being
updated (by design). The buffer update is racy with the display,
leading to artifacts. Calling clflush on the buffer, even only on
the rectangle specified by gralloc (*lock), makes no difference. As
a result, let's map the buffer as uncached when it's being scanned
out (we do the same thing on ARM). Let's make sure not affect
renderscript buffers, since certain renderscript CTS tests require
caching.

BUG=chromium:762324
TEST=no overlay artifacts while using Zero Latency Ink app
     on Eve.

Change-Id: I6f79dc8e48deee441790f737aba79c7f79ca4cb9
Reviewed-on: https://chromium-review.googlesource.com/665390
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: David Reveman <reveman@chromium.org>
diff --git a/i915.c b/i915.c
index a16050f..3f811d9 100644
--- a/i915.c
+++ b/i915.c
@@ -430,6 +430,9 @@
 		struct drm_i915_gem_mmap gem_map;
 		memset(&gem_map, 0, sizeof(gem_map));
 
+		if ((bo->flags & BO_USE_SCANOUT) && !(bo->flags & BO_USE_RENDERSCRIPT))
+			gem_map.flags = I915_MMAP_WC;
+
 		gem_map.handle = bo->handles[0].u32;
 		gem_map.offset = 0;
 		gem_map.size = bo->total_size;