minigbm: i915: Do not use I915_MMAP_WC for camera buffers

Some camera use cases, such as camera output buffers shared between
video encoder and hwcomposer, require CPU access to the buffers (the
ARC++ encoder stack is not zero-copy yet) and having uncached mapping
slows them down significantly, to the point that respective CTS tests
start failing. Fix it by excluding buffers with BO_CAMERA_READ and
BO_CAMERA_WRITE from the WC mapping condition.

BUG=b:117978452
TEST=android.hardware.camera2.cts.RecordingTest#testVideoPreviewSurfaceSharing on Nocturne

Change-Id: Icc3c7104029403fbf64a7fcc8476d52a3f9ea3f0
Reviewed-on: https://chromium-review.googlesource.com/1309914
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Tested-by: Tomasz Figa <tfiga@chromium.org>
Reviewed-by: Tomasz Figa <tfiga@chromium.org>
diff --git a/i915.c b/i915.c
index b343e91..43e72c2 100644
--- a/i915.c
+++ b/i915.c
@@ -473,7 +473,17 @@
 		struct drm_i915_gem_mmap gem_map;
 		memset(&gem_map, 0, sizeof(gem_map));
 
-		if ((bo->use_flags & BO_USE_SCANOUT) && !(bo->use_flags & BO_USE_RENDERSCRIPT))
+		/* TODO(b/118799155): We don't seem to have a good way to
+		 * detect the use cases for which WC mapping is really needed.
+		 * The current heuristic seems overly coarse and may be slowing
+		 * down some other use cases unnecessarily.
+		 *
+		 * For now, care must be taken not to use WC mappings for
+		 * Renderscript and camera use cases, as they're
+		 * performance-sensitive. */
+		if ((bo->use_flags & BO_USE_SCANOUT) &&
+		    !(bo->use_flags &
+		      (BO_USE_RENDERSCRIPT | BO_USE_CAMERA_READ | BO_USE_CAMERA_WRITE)))
 			gem_map.flags = I915_MMAP_WC;
 
 		gem_map.handle = bo->handles[0].u32;