From: Lucas Stach Date: Fri, 18 Nov 2016 14:15:16 +0000 (+0100) Subject: drm/etnaviv: implement dma-buf mmap X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=5688e57eb50c08922d0ff88bb30fe65b508917a0;p=linux-beck.git drm/etnaviv: implement dma-buf mmap This adds the required boilerplate to allow direct mmap of exported etnaviv BOs. Signed-off-by: Lucas Stach Tested-by: Philipp Zabel --- diff --git a/drivers/gpu/drm/etnaviv/etnaviv_drv.c b/drivers/gpu/drm/etnaviv/etnaviv_drv.c index aa687669e22b..38720adfc62f 100644 --- a/drivers/gpu/drm/etnaviv/etnaviv_drv.c +++ b/drivers/gpu/drm/etnaviv/etnaviv_drv.c @@ -505,6 +505,7 @@ static struct drm_driver etnaviv_drm_driver = { .gem_prime_import_sg_table = etnaviv_gem_prime_import_sg_table, .gem_prime_vmap = etnaviv_gem_prime_vmap, .gem_prime_vunmap = etnaviv_gem_prime_vunmap, + .gem_prime_mmap = etnaviv_gem_prime_mmap, #ifdef CONFIG_DEBUG_FS .debugfs_init = etnaviv_debugfs_init, .debugfs_cleanup = etnaviv_debugfs_cleanup, diff --git a/drivers/gpu/drm/etnaviv/etnaviv_drv.h b/drivers/gpu/drm/etnaviv/etnaviv_drv.h index 65e057639653..c255eda40526 100644 --- a/drivers/gpu/drm/etnaviv/etnaviv_drv.h +++ b/drivers/gpu/drm/etnaviv/etnaviv_drv.h @@ -78,6 +78,8 @@ 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); void *etnaviv_gem_prime_vmap(struct drm_gem_object *obj); void etnaviv_gem_prime_vunmap(struct drm_gem_object *obj, void *vaddr); +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 dma_buf_attachment *attach, struct sg_table *sg); int etnaviv_gem_prime_pin(struct drm_gem_object *obj); diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gem_prime.c b/drivers/gpu/drm/etnaviv/etnaviv_gem_prime.c index b93618c1aa69..7e8fdb1859dd 100644 --- a/drivers/gpu/drm/etnaviv/etnaviv_gem_prime.c +++ b/drivers/gpu/drm/etnaviv/etnaviv_gem_prime.c @@ -39,6 +39,19 @@ void etnaviv_gem_prime_vunmap(struct drm_gem_object *obj, void *vaddr) /* TODO msm_gem_vunmap() */ } +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) { if (!obj->import_attach) {