aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/udl
diff options
context:
space:
mode:
authorHaixia Shi <hshi@chromium.org>2014-11-12 21:33:52 -0500
committerDave Airlie <airlied@redhat.com>2014-11-19 20:41:32 -0500
commit09a58da052111263e31f0050ad775b62166fafba (patch)
tree3e15a161229e32126ee289799ad2168078edcb3d /drivers/gpu/drm/udl
parenta7ca52e108e549669940b11779bb491a931f8c65 (diff)
drm/udl: add cache flags definitions for udl_gem_object
By default set udl_gem_object as cacheable, but set WC flag when attaching dmabuf. In udl_gem_mmap() update cache attributes based on the flags, similar to exynos_drm_gem_mmap(). Signed-off-by: Haixia Shi <hshi@chromium.org> Reviewed-by: Sonny Rao <sonnyrao@chromium.org> Reviewed-by: Olof Johansson <olofj@chromium.org> Reviewed-by: Stéphane Marchesin <marcheu@chromium.org> Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'drivers/gpu/drm/udl')
-rw-r--r--drivers/gpu/drm/udl/udl_drv.h4
-rw-r--r--drivers/gpu/drm/udl/udl_gem.c21
2 files changed, 25 insertions, 0 deletions
diff --git a/drivers/gpu/drm/udl/udl_drv.h b/drivers/gpu/drm/udl/udl_drv.h
index c7490a2489a7..308278086c72 100644
--- a/drivers/gpu/drm/udl/udl_drv.h
+++ b/drivers/gpu/drm/udl/udl_drv.h
@@ -25,6 +25,9 @@
25#define DRIVER_MINOR 0 25#define DRIVER_MINOR 0
26#define DRIVER_PATCHLEVEL 1 26#define DRIVER_PATCHLEVEL 1
27 27
28#define UDL_BO_CACHEABLE (1 << 0)
29#define UDL_BO_WC (1 << 1)
30
28struct udl_device; 31struct udl_device;
29 32
30struct urb_node { 33struct urb_node {
@@ -69,6 +72,7 @@ struct udl_gem_object {
69 struct page **pages; 72 struct page **pages;
70 void *vmapping; 73 void *vmapping;
71 struct sg_table *sg; 74 struct sg_table *sg;
75 unsigned int flags;
72}; 76};
73 77
74#define to_udl_bo(x) container_of(x, struct udl_gem_object, base) 78#define to_udl_bo(x) container_of(x, struct udl_gem_object, base)
diff --git a/drivers/gpu/drm/udl/udl_gem.c b/drivers/gpu/drm/udl/udl_gem.c
index 8044f5fb7c49..e00459d38dcb 100644
--- a/drivers/gpu/drm/udl/udl_gem.c
+++ b/drivers/gpu/drm/udl/udl_gem.c
@@ -25,6 +25,7 @@ struct udl_gem_object *udl_gem_alloc_object(struct drm_device *dev,
25 return NULL; 25 return NULL;
26 } 26 }
27 27
28 obj->flags = UDL_BO_CACHEABLE;
28 return obj; 29 return obj;
29} 30}
30 31
@@ -56,6 +57,23 @@ udl_gem_create(struct drm_file *file,
56 return 0; 57 return 0;
57} 58}
58 59
60static void update_vm_cache_attr(struct udl_gem_object *obj,
61 struct vm_area_struct *vma)
62{
63 DRM_DEBUG_KMS("flags = 0x%x\n", obj->flags);
64
65 /* non-cacheable as default. */
66 if (obj->flags & UDL_BO_CACHEABLE) {
67 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
68 } else if (obj->flags & UDL_BO_WC) {
69 vma->vm_page_prot =
70 pgprot_writecombine(vm_get_page_prot(vma->vm_flags));
71 } else {
72 vma->vm_page_prot =
73 pgprot_noncached(vm_get_page_prot(vma->vm_flags));
74 }
75}
76
59int udl_dumb_create(struct drm_file *file, 77int udl_dumb_create(struct drm_file *file,
60 struct drm_device *dev, 78 struct drm_device *dev,
61 struct drm_mode_create_dumb *args) 79 struct drm_mode_create_dumb *args)
@@ -77,6 +95,8 @@ int udl_drm_gem_mmap(struct file *filp, struct vm_area_struct *vma)
77 vma->vm_flags &= ~VM_PFNMAP; 95 vma->vm_flags &= ~VM_PFNMAP;
78 vma->vm_flags |= VM_MIXEDMAP; 96 vma->vm_flags |= VM_MIXEDMAP;
79 97
98 update_vm_cache_attr(to_udl_bo(vma->vm_private_data), vma);
99
80 return ret; 100 return ret;
81} 101}
82 102
@@ -279,6 +299,7 @@ struct drm_gem_object *udl_gem_prime_import(struct drm_device *dev,
279 } 299 }
280 300
281 uobj->base.import_attach = attach; 301 uobj->base.import_attach = attach;
302 uobj->flags = UDL_BO_WC;
282 303
283 return &uobj->base; 304 return &uobj->base;
284 305