From: Alexandre Courbot <acourbot@nvidia.com>
Date: Mon, 27 Oct 2014 09:49:16 +0000 (+0900)
Subject: drm/nouveau: introduce nv_device_is_cpu_coherent()
X-Git-Tag: firefly_0821_release~176^2~2543^2~2^2~34
X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=c5d7ddf70a8445f711f5ab9ab92bd4f59f993262;p=firefly-linux-kernel-4.4.55.git

drm/nouveau: introduce nv_device_is_cpu_coherent()

Add a function allowing us to know whether a device is CPU-coherent,
i.e. accesses performed by the CPU on GPU-mapped buffers will
be immediately visible on the GPU side and vice-versa.

For now, a device is considered to be coherent if it uses the PCI bus on
a non-ARM architecture.

Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
---

diff --git a/drivers/gpu/drm/nouveau/core/include/core/device.h b/drivers/gpu/drm/nouveau/core/include/core/device.h
index 1d9d893929bb..0d839e1ddaf4 100644
--- a/drivers/gpu/drm/nouveau/core/include/core/device.h
+++ b/drivers/gpu/drm/nouveau/core/include/core/device.h
@@ -158,6 +158,12 @@ nv_device_is_pci(struct nouveau_device *device)
 	return device->pdev != NULL;
 }
 
+static inline bool
+nv_device_is_cpu_coherent(struct nouveau_device *device)
+{
+	return (!IS_ENABLED(CONFIG_ARM) && nv_device_is_pci(device));
+}
+
 static inline struct device *
 nv_device_base(struct nouveau_device *device)
 {