summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonathan Marek <jonathan@marek.ca>2021-04-23 15:08:19 -0400
committerRob Clark <robdclark@chromium.org>2021-06-23 07:32:14 -0700
commitaf9b3547079915d682d14ea98018d6fa6edf97ca (patch)
treeda6ab89f161f4149e05ee857df4d548af2f15b6d
parenta5fc7aa901b6818c67cc7e5cef8201fbaab8fa1b (diff)
downloadlinux-af9b3547079915d682d14ea98018d6fa6edf97ca.tar.bz2
drm/msm: use the right pgprot when mapping BOs in the kernel
Use the same logic as the userspace mapping. This fixes msm_rd with cached BOs. Signed-off-by: Jonathan Marek <jonathan@marek.ca> Acked-by: Jordan Crouse <jordan@cosmicpenguin.net> Link: https://lore.kernel.org/r/20210423190833.25319-4-jonathan@marek.ca Signed-off-by: Rob Clark <robdclark@chromium.org>
-rw-r--r--drivers/gpu/drm/msm/msm_gem.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/drivers/gpu/drm/msm/msm_gem.c b/drivers/gpu/drm/msm/msm_gem.c
index badf599799bf..ffe94bd97219 100644
--- a/drivers/gpu/drm/msm/msm_gem.c
+++ b/drivers/gpu/drm/msm/msm_gem.c
@@ -211,6 +211,15 @@ void msm_gem_put_pages(struct drm_gem_object *obj)
msm_gem_unlock(obj);
}
+static pgprot_t msm_gem_pgprot(struct msm_gem_object *msm_obj, pgprot_t prot)
+{
+ if (msm_obj->flags & MSM_BO_WC)
+ return pgprot_writecombine(prot);
+ if (msm_obj->flags & MSM_BO_UNCACHED)
+ return pgprot_noncached(prot);
+ return prot;
+}
+
int msm_gem_mmap_obj(struct drm_gem_object *obj,
struct vm_area_struct *vma)
{
@@ -218,13 +227,7 @@ int msm_gem_mmap_obj(struct drm_gem_object *obj,
vma->vm_flags &= ~VM_PFNMAP;
vma->vm_flags |= VM_MIXEDMAP;
-
- if (msm_obj->flags & MSM_BO_WC)
- vma->vm_page_prot = pgprot_writecombine(vm_get_page_prot(vma->vm_flags));
- else if (msm_obj->flags & MSM_BO_UNCACHED)
- vma->vm_page_prot = pgprot_noncached(vm_get_page_prot(vma->vm_flags));
- else
- vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
+ vma->vm_page_prot = msm_gem_pgprot(msm_obj, vm_get_page_prot(vma->vm_flags));
return 0;
}
@@ -644,7 +647,7 @@ static void *get_vaddr(struct drm_gem_object *obj, unsigned madv)
goto fail;
}
msm_obj->vaddr = vmap(pages, obj->size >> PAGE_SHIFT,
- VM_MAP, pgprot_writecombine(PAGE_KERNEL));
+ VM_MAP, msm_gem_pgprot(msm_obj, PAGE_KERNEL));
if (msm_obj->vaddr == NULL) {
ret = -ENOMEM;
goto fail;