Commit 81fd23e2 authored by Thomas Zimmermann's avatar Thomas Zimmermann Committed by Lucas Stach

drm/etnaviv: Implement mmap as GEM object function

Moving the driver-specific mmap code into a GEM object function allows
for using DRM helpers for various mmap callbacks.

The respective etnaviv functions are being removed. The file_operations
structure fops is now being created by the helper macro
DEFINE_DRM_GEM_FOPS().
Signed-off-by: default avatarThomas Zimmermann <tzimmermann@suse.de>
Signed-off-by: default avatarLucas Stach <l.stach@pengutronix.de>
parent 432f51e7
...@@ -468,17 +468,7 @@ static const struct drm_ioctl_desc etnaviv_ioctls[] = { ...@@ -468,17 +468,7 @@ static const struct drm_ioctl_desc etnaviv_ioctls[] = {
ETNA_IOCTL(PM_QUERY_SIG, pm_query_sig, DRM_RENDER_ALLOW), ETNA_IOCTL(PM_QUERY_SIG, pm_query_sig, DRM_RENDER_ALLOW),
}; };
static const struct file_operations fops = { DEFINE_DRM_GEM_FOPS(fops);
.owner = THIS_MODULE,
.open = drm_open,
.release = drm_release,
.unlocked_ioctl = drm_ioctl,
.compat_ioctl = drm_compat_ioctl,
.poll = drm_poll,
.read = drm_read,
.llseek = no_llseek,
.mmap = etnaviv_gem_mmap,
};
static const struct drm_driver etnaviv_drm_driver = { static const struct drm_driver etnaviv_drm_driver = {
.driver_features = DRIVER_GEM | DRIVER_RENDER, .driver_features = DRIVER_GEM | DRIVER_RENDER,
...@@ -487,7 +477,7 @@ static const struct drm_driver etnaviv_drm_driver = { ...@@ -487,7 +477,7 @@ static const struct drm_driver etnaviv_drm_driver = {
.prime_handle_to_fd = drm_gem_prime_handle_to_fd, .prime_handle_to_fd = drm_gem_prime_handle_to_fd,
.prime_fd_to_handle = drm_gem_prime_fd_to_handle, .prime_fd_to_handle = drm_gem_prime_fd_to_handle,
.gem_prime_import_sg_table = etnaviv_gem_prime_import_sg_table, .gem_prime_import_sg_table = etnaviv_gem_prime_import_sg_table,
.gem_prime_mmap = etnaviv_gem_prime_mmap, .gem_prime_mmap = drm_gem_prime_mmap,
#ifdef CONFIG_DEBUG_FS #ifdef CONFIG_DEBUG_FS
.debugfs_init = etnaviv_debugfs_init, .debugfs_init = etnaviv_debugfs_init,
#endif #endif
......
...@@ -47,12 +47,9 @@ struct etnaviv_drm_private { ...@@ -47,12 +47,9 @@ struct etnaviv_drm_private {
int etnaviv_ioctl_gem_submit(struct drm_device *dev, void *data, int etnaviv_ioctl_gem_submit(struct drm_device *dev, void *data,
struct drm_file *file); struct drm_file *file);
int etnaviv_gem_mmap(struct file *filp, struct vm_area_struct *vma);
int etnaviv_gem_mmap_offset(struct drm_gem_object *obj, u64 *offset); int etnaviv_gem_mmap_offset(struct drm_gem_object *obj, u64 *offset);
struct sg_table *etnaviv_gem_prime_get_sg_table(struct drm_gem_object *obj); struct sg_table *etnaviv_gem_prime_get_sg_table(struct drm_gem_object *obj);
int etnaviv_gem_prime_vmap(struct drm_gem_object *obj, struct dma_buf_map *map); int etnaviv_gem_prime_vmap(struct drm_gem_object *obj, struct dma_buf_map *map);
int etnaviv_gem_prime_mmap(struct drm_gem_object *obj,
struct vm_area_struct *vma);
struct drm_gem_object *etnaviv_gem_prime_import_sg_table(struct drm_device *dev, struct drm_gem_object *etnaviv_gem_prime_import_sg_table(struct drm_device *dev,
struct dma_buf_attachment *attach, struct sg_table *sg); struct dma_buf_attachment *attach, struct sg_table *sg);
int etnaviv_gem_prime_pin(struct drm_gem_object *obj); int etnaviv_gem_prime_pin(struct drm_gem_object *obj);
......
...@@ -130,8 +130,7 @@ static int etnaviv_gem_mmap_obj(struct etnaviv_gem_object *etnaviv_obj, ...@@ -130,8 +130,7 @@ static int etnaviv_gem_mmap_obj(struct etnaviv_gem_object *etnaviv_obj,
{ {
pgprot_t vm_page_prot; pgprot_t vm_page_prot;
vma->vm_flags &= ~VM_PFNMAP; vma->vm_flags |= VM_IO | VM_MIXEDMAP | VM_DONTEXPAND | VM_DONTDUMP;
vma->vm_flags |= VM_MIXEDMAP;
vm_page_prot = vm_get_page_prot(vma->vm_flags); vm_page_prot = vm_get_page_prot(vma->vm_flags);
...@@ -154,19 +153,11 @@ static int etnaviv_gem_mmap_obj(struct etnaviv_gem_object *etnaviv_obj, ...@@ -154,19 +153,11 @@ static int etnaviv_gem_mmap_obj(struct etnaviv_gem_object *etnaviv_obj,
return 0; return 0;
} }
int etnaviv_gem_mmap(struct file *filp, struct vm_area_struct *vma) static int etnaviv_gem_mmap(struct drm_gem_object *obj, struct vm_area_struct *vma)
{ {
struct etnaviv_gem_object *obj; struct etnaviv_gem_object *etnaviv_obj = to_etnaviv_bo(obj);
int ret;
ret = drm_gem_mmap(filp, vma);
if (ret) {
DBG("mmap failed: %d", ret);
return ret;
}
obj = to_etnaviv_bo(vma->vm_private_data); return etnaviv_obj->ops->mmap(etnaviv_obj, vma);
return obj->ops->mmap(obj, vma);
} }
static vm_fault_t etnaviv_gem_fault(struct vm_fault *vmf) static vm_fault_t etnaviv_gem_fault(struct vm_fault *vmf)
...@@ -567,6 +558,7 @@ static const struct drm_gem_object_funcs etnaviv_gem_object_funcs = { ...@@ -567,6 +558,7 @@ static const struct drm_gem_object_funcs etnaviv_gem_object_funcs = {
.unpin = etnaviv_gem_prime_unpin, .unpin = etnaviv_gem_prime_unpin,
.get_sg_table = etnaviv_gem_prime_get_sg_table, .get_sg_table = etnaviv_gem_prime_get_sg_table,
.vmap = etnaviv_gem_prime_vmap, .vmap = etnaviv_gem_prime_vmap,
.mmap = etnaviv_gem_mmap,
.vm_ops = &vm_ops, .vm_ops = &vm_ops,
}; };
......
...@@ -34,19 +34,6 @@ int etnaviv_gem_prime_vmap(struct drm_gem_object *obj, struct dma_buf_map *map) ...@@ -34,19 +34,6 @@ int etnaviv_gem_prime_vmap(struct drm_gem_object *obj, struct dma_buf_map *map)
return 0; return 0;
} }
int etnaviv_gem_prime_mmap(struct drm_gem_object *obj,
struct vm_area_struct *vma)
{
struct etnaviv_gem_object *etnaviv_obj = to_etnaviv_bo(obj);
int ret;
ret = drm_gem_mmap_obj(obj, obj->size, vma);
if (ret < 0)
return ret;
return etnaviv_obj->ops->mmap(etnaviv_obj, vma);
}
int etnaviv_gem_prime_pin(struct drm_gem_object *obj) int etnaviv_gem_prime_pin(struct drm_gem_object *obj)
{ {
if (!obj->import_attach) { if (!obj->import_attach) {
......
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