Commit d315bdbf authored by Thomas Zimmermann's avatar Thomas Zimmermann

drm/gem-shmem: Set vm_ops in static initializer

Initialize default vm_ops in static initialization of the GEM SHMEM funcs,
instead of the mmap code. It's simply better style. GEM helpers will later
set a VMA's vm_ops from the default automatically.

v2:
	* also update the drivers that build upon GEM SHMEM
Signed-off-by: default avatarThomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: default avatarSteven Price <steven.price@arm.com>
Reviewed-by: default avatarChia-I Wu <olvaffe@gmail.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20220209155634.3994-2-tzimmermann@suse.de
parent 593504ba
...@@ -46,6 +46,7 @@ static const struct drm_gem_object_funcs drm_gem_shmem_funcs = { ...@@ -46,6 +46,7 @@ static const struct drm_gem_object_funcs drm_gem_shmem_funcs = {
.vmap = drm_gem_shmem_object_vmap, .vmap = drm_gem_shmem_object_vmap,
.vunmap = drm_gem_shmem_object_vunmap, .vunmap = drm_gem_shmem_object_vunmap,
.mmap = drm_gem_shmem_object_mmap, .mmap = drm_gem_shmem_object_mmap,
.vm_ops = &drm_gem_shmem_vm_ops,
}; };
static struct drm_gem_shmem_object * static struct drm_gem_shmem_object *
...@@ -585,11 +586,12 @@ static void drm_gem_shmem_vm_close(struct vm_area_struct *vma) ...@@ -585,11 +586,12 @@ static void drm_gem_shmem_vm_close(struct vm_area_struct *vma)
drm_gem_vm_close(vma); drm_gem_vm_close(vma);
} }
static const struct vm_operations_struct drm_gem_shmem_vm_ops = { const struct vm_operations_struct drm_gem_shmem_vm_ops = {
.fault = drm_gem_shmem_fault, .fault = drm_gem_shmem_fault,
.open = drm_gem_shmem_vm_open, .open = drm_gem_shmem_vm_open,
.close = drm_gem_shmem_vm_close, .close = drm_gem_shmem_vm_close,
}; };
EXPORT_SYMBOL_GPL(drm_gem_shmem_vm_ops);
/** /**
* drm_gem_shmem_mmap - Memory-map a shmem GEM object * drm_gem_shmem_mmap - Memory-map a shmem GEM object
...@@ -625,7 +627,6 @@ int drm_gem_shmem_mmap(struct drm_gem_shmem_object *shmem, struct vm_area_struct ...@@ -625,7 +627,6 @@ int drm_gem_shmem_mmap(struct drm_gem_shmem_object *shmem, struct vm_area_struct
vma->vm_page_prot = vm_get_page_prot(vma->vm_flags); vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
if (shmem->map_wc) if (shmem->map_wc)
vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot); vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot);
vma->vm_ops = &drm_gem_shmem_vm_ops;
return 0; return 0;
} }
......
...@@ -213,6 +213,7 @@ static const struct drm_gem_object_funcs lima_gem_funcs = { ...@@ -213,6 +213,7 @@ static const struct drm_gem_object_funcs lima_gem_funcs = {
.vmap = lima_gem_vmap, .vmap = lima_gem_vmap,
.vunmap = drm_gem_shmem_object_vunmap, .vunmap = drm_gem_shmem_object_vunmap,
.mmap = lima_gem_mmap, .mmap = lima_gem_mmap,
.vm_ops = &drm_gem_shmem_vm_ops,
}; };
struct drm_gem_object *lima_gem_create_object(struct drm_device *dev, size_t size) struct drm_gem_object *lima_gem_create_object(struct drm_device *dev, size_t size)
......
...@@ -206,6 +206,7 @@ static const struct drm_gem_object_funcs panfrost_gem_funcs = { ...@@ -206,6 +206,7 @@ static const struct drm_gem_object_funcs panfrost_gem_funcs = {
.vmap = drm_gem_shmem_object_vmap, .vmap = drm_gem_shmem_object_vmap,
.vunmap = drm_gem_shmem_object_vunmap, .vunmap = drm_gem_shmem_object_vunmap,
.mmap = drm_gem_shmem_object_mmap, .mmap = drm_gem_shmem_object_mmap,
.vm_ops = &drm_gem_shmem_vm_ops,
}; };
/** /**
......
...@@ -59,6 +59,7 @@ static const struct drm_gem_object_funcs v3d_gem_funcs = { ...@@ -59,6 +59,7 @@ static const struct drm_gem_object_funcs v3d_gem_funcs = {
.vmap = drm_gem_shmem_object_vmap, .vmap = drm_gem_shmem_object_vmap,
.vunmap = drm_gem_shmem_object_vunmap, .vunmap = drm_gem_shmem_object_vunmap,
.mmap = drm_gem_shmem_object_mmap, .mmap = drm_gem_shmem_object_mmap,
.vm_ops = &drm_gem_shmem_vm_ops,
}; };
/* gem_create_object function for allocating a BO struct and doing /* gem_create_object function for allocating a BO struct and doing
......
...@@ -124,6 +124,7 @@ static const struct drm_gem_object_funcs virtio_gpu_shmem_funcs = { ...@@ -124,6 +124,7 @@ static const struct drm_gem_object_funcs virtio_gpu_shmem_funcs = {
.vmap = drm_gem_shmem_object_vmap, .vmap = drm_gem_shmem_object_vmap,
.vunmap = drm_gem_shmem_object_vunmap, .vunmap = drm_gem_shmem_object_vunmap,
.mmap = drm_gem_shmem_object_mmap, .mmap = drm_gem_shmem_object_mmap,
.vm_ops = &drm_gem_shmem_vm_ops,
}; };
bool virtio_gpu_is_shmem(struct virtio_gpu_object *bo) bool virtio_gpu_is_shmem(struct virtio_gpu_object *bo)
......
...@@ -135,6 +135,8 @@ struct sg_table *drm_gem_shmem_get_pages_sgt(struct drm_gem_shmem_object *shmem) ...@@ -135,6 +135,8 @@ struct sg_table *drm_gem_shmem_get_pages_sgt(struct drm_gem_shmem_object *shmem)
void drm_gem_shmem_print_info(const struct drm_gem_shmem_object *shmem, void drm_gem_shmem_print_info(const struct drm_gem_shmem_object *shmem,
struct drm_printer *p, unsigned int indent); struct drm_printer *p, unsigned int indent);
extern const struct vm_operations_struct drm_gem_shmem_vm_ops;
/* /*
* GEM object functions * GEM object functions
*/ */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment