Skip to content

Commit 1cad629

Browse files
committed
drm/shmem: add support for per object caching flags.
Add map_cached bool to drm_gem_shmem_object, to request cached mappings on a per-object base. Check the flag before adding writecombine to pgprot bits. Cc: [email protected] Signed-off-by: Gerd Hoffmann <[email protected]> Reviewed-by: Gurchetan Singh <[email protected]> Tested-by: Guillaume Gardet <[email protected]> Link: http://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent d1f3722 commit 1cad629

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

drivers/gpu/drm/drm_gem_shmem_helper.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -254,11 +254,16 @@ static void *drm_gem_shmem_vmap_locked(struct drm_gem_shmem_object *shmem)
254254
if (ret)
255255
goto err_zero_use;
256256

257-
if (obj->import_attach)
257+
if (obj->import_attach) {
258258
shmem->vaddr = dma_buf_vmap(obj->import_attach->dmabuf);
259-
else
259+
} else {
260+
pgprot_t prot = PAGE_KERNEL;
261+
262+
if (!shmem->map_cached)
263+
prot = pgprot_writecombine(prot);
260264
shmem->vaddr = vmap(shmem->pages, obj->size >> PAGE_SHIFT,
261-
VM_MAP, pgprot_writecombine(PAGE_KERNEL));
265+
VM_MAP, prot);
266+
}
262267

263268
if (!shmem->vaddr) {
264269
DRM_DEBUG_KMS("Failed to vmap pages\n");
@@ -540,7 +545,9 @@ int drm_gem_shmem_mmap(struct drm_gem_object *obj, struct vm_area_struct *vma)
540545
}
541546

542547
vma->vm_flags |= VM_MIXEDMAP | VM_DONTEXPAND;
543-
vma->vm_page_prot = pgprot_writecombine(vm_get_page_prot(vma->vm_flags));
548+
vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
549+
if (!shmem->map_cached)
550+
vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot);
544551
vma->vm_page_prot = pgprot_decrypted(vma->vm_page_prot);
545552
vma->vm_ops = &drm_gem_shmem_vm_ops;
546553

include/drm/drm_gem_shmem_helper.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,11 @@ struct drm_gem_shmem_object {
9696
* The address are un-mapped when the count reaches zero.
9797
*/
9898
unsigned int vmap_use_count;
99+
100+
/**
101+
* @map_cached: map object cached (instead of using writecombine).
102+
*/
103+
bool map_cached;
99104
};
100105

101106
#define to_drm_gem_shmem_obj(obj) \

0 commit comments

Comments
 (0)