[PATCH 16/48] staging: etnaviv: give etnaviv_gem_mmap_offset() a sane behaviour
Lucas Stach
l.stach at pengutronix.de
Fri Sep 25 04:57:28 PDT 2015
From: Russell King <rmk+kernel at arm.linux.org.uk>
etnaviv_gem_mmap_offset() returned zero if drm_gem_create_mmap_offset()
failed. This is incorrect behaviour as etnaviv_ioctl_gem_info() does
not detect this condition, so it returns success.
Fix this by re-architecting etnaviv_gem_mmap_offset(). Merge
mmap_offset() into this function, and change its prototype to accept a
pointer to the "offset" return value, thereby allowing it to return a
standard negative errno code.
Signed-off-by: Russell King <rmk+kernel at arm.linux.org.uk>
---
drivers/staging/etnaviv/etnaviv_drv.c | 4 ++--
drivers/staging/etnaviv/etnaviv_drv.h | 2 +-
drivers/staging/etnaviv/etnaviv_gem.c | 26 +++++++-------------------
3 files changed, 10 insertions(+), 22 deletions(-)
diff --git a/drivers/staging/etnaviv/etnaviv_drv.c b/drivers/staging/etnaviv/etnaviv_drv.c
index 1071c449f3d4..9962318075c5 100644
--- a/drivers/staging/etnaviv/etnaviv_drv.c
+++ b/drivers/staging/etnaviv/etnaviv_drv.c
@@ -438,7 +438,7 @@ static int etnaviv_ioctl_gem_info(struct drm_device *dev, void *data,
{
struct drm_etnaviv_gem_info *args = data;
struct drm_gem_object *obj;
- int ret = 0;
+ int ret;
if (args->pad)
return -EINVAL;
@@ -447,7 +447,7 @@ static int etnaviv_ioctl_gem_info(struct drm_device *dev, void *data,
if (!obj)
return -ENOENT;
- args->offset = etnaviv_gem_mmap_offset(obj);
+ ret = etnaviv_gem_mmap_offset(obj, &args->offset);
drm_gem_object_unreference_unlocked(obj);
diff --git a/drivers/staging/etnaviv/etnaviv_drv.h b/drivers/staging/etnaviv/etnaviv_drv.h
index 9abb7f8c2dc0..37992342bbf0 100644
--- a/drivers/staging/etnaviv/etnaviv_drv.h
+++ b/drivers/staging/etnaviv/etnaviv_drv.h
@@ -73,7 +73,7 @@ int etnaviv_ioctl_gem_submit(struct drm_device *dev, void *data,
int etnaviv_gem_mmap(struct file *filp, struct vm_area_struct *vma);
int etnaviv_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf);
-uint64_t etnaviv_gem_mmap_offset(struct drm_gem_object *obj);
+int etnaviv_gem_mmap_offset(struct drm_gem_object *obj, uint64_t *offset);
int etnaviv_gem_get_iova_locked(struct etnaviv_gpu *gpu,
struct drm_gem_object *obj, uint32_t *iova);
int etnaviv_gem_get_iova(struct etnaviv_gpu *gpu, struct drm_gem_object *obj,
diff --git a/drivers/staging/etnaviv/etnaviv_gem.c b/drivers/staging/etnaviv/etnaviv_gem.c
index 522e5a6c3612..38dee80d996c 100644
--- a/drivers/staging/etnaviv/etnaviv_gem.c
+++ b/drivers/staging/etnaviv/etnaviv_gem.c
@@ -270,33 +270,21 @@ out:
}
/** get mmap offset */
-static uint64_t mmap_offset(struct drm_gem_object *obj)
+int etnaviv_gem_mmap_offset(struct drm_gem_object *obj, uint64_t *offset)
{
struct drm_device *dev = obj->dev;
int ret;
- WARN_ON(!mutex_is_locked(&dev->struct_mutex));
-
+ mutex_lock(&dev->struct_mutex);
/* Make it mmapable */
ret = drm_gem_create_mmap_offset(obj);
-
- if (ret) {
+ if (ret)
dev_err(dev->dev, "could not allocate mmap offset\n");
- return 0;
- }
-
- return drm_vma_node_offset_addr(&obj->vma_node);
-}
-
-uint64_t etnaviv_gem_mmap_offset(struct drm_gem_object *obj)
-{
- uint64_t offset;
-
- mutex_lock(&obj->dev->struct_mutex);
- offset = mmap_offset(obj);
- mutex_unlock(&obj->dev->struct_mutex);
+ else
+ *offset = drm_vma_node_offset_addr(&obj->vma_node);
+ mutex_unlock(&dev->struct_mutex);
- return offset;
+ return ret;
}
/* should be called under struct_mutex.. although it can be called
--
2.5.1
More information about the dri-devel
mailing list