diff mbox series

[v2,3/3] drm/msm/prime: Add mmap_info support

Message ID 20220815211516.3169470-4-robdclark@gmail.com (mailing list archive)
State Not Applicable
Headers show
Series dma-buf: map-info support | expand

Commit Message

Rob Clark Aug. 15, 2022, 9:15 p.m. UTC
From: Rob Clark <robdclark@chromium.org>

Signed-off-by: Rob Clark <robdclark@chromium.org>
---
 drivers/gpu/drm/msm/msm_gem.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
diff mbox series

Patch

diff --git a/drivers/gpu/drm/msm/msm_gem.c b/drivers/gpu/drm/msm/msm_gem.c
index 1dee0d18abbb..1db53545ac40 100644
--- a/drivers/gpu/drm/msm/msm_gem.c
+++ b/drivers/gpu/drm/msm/msm_gem.c
@@ -1048,6 +1048,17 @@  static const struct vm_operations_struct vm_ops = {
 	.close = drm_gem_vm_close,
 };
 
+static enum dma_buf_map_info msm_gem_map_info(struct drm_gem_object *obj)
+{
+	struct msm_gem_object *msm_obj = to_msm_bo(obj);
+
+	switch (msm_obj->flags & MSM_BO_CACHE_MASK) {
+	case MSM_BO_WC:                return DMA_BUF_COHERENT_WC;
+	case MSM_BO_CACHED_COHERENT:   return DMA_BUF_COHERENT_CACHED;
+	default:                       return DMA_BUF_MAP_INCOHERENT;
+	}
+}
+
 static const struct drm_gem_object_funcs msm_gem_object_funcs = {
 	.free = msm_gem_free_object,
 	.pin = msm_gem_prime_pin,
@@ -1057,6 +1068,7 @@  static const struct drm_gem_object_funcs msm_gem_object_funcs = {
 	.vunmap = msm_gem_prime_vunmap,
 	.mmap = msm_gem_object_mmap,
 	.vm_ops = &vm_ops,
+	.map_info = msm_gem_map_info,
 };
 
 static int msm_gem_new_impl(struct drm_device *dev,