[PATCH 17/48] staging: etnaviv: allow etnaviv_ioctl_gem_info() locking to be interruptible

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Russell King <rmk+kernel@xxxxxxxxxxxxxxxx>

Move the locking out of etnaviv_gem_mmap_offset() into its solitary
caller, and take the mutex using mutex_lock_interruptible().  This
allows etnaviv_ioctl_gem_info() to handle signals while trying to
obtain this lock.

Signed-off-by: Russell King <rmk+kernel@xxxxxxxxxxxxxxxx>
---
 drivers/staging/etnaviv/etnaviv_drv.c | 7 ++++++-
 drivers/staging/etnaviv/etnaviv_gem.c | 7 ++-----
 2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/etnaviv/etnaviv_drv.c b/drivers/staging/etnaviv/etnaviv_drv.c
index 9962318075c5..a87de2e79fee 100644
--- a/drivers/staging/etnaviv/etnaviv_drv.c
+++ b/drivers/staging/etnaviv/etnaviv_drv.c
@@ -447,7 +447,12 @@ static int etnaviv_ioctl_gem_info(struct drm_device *dev, void *data,
 	if (!obj)
 		return -ENOENT;
 
-	ret = etnaviv_gem_mmap_offset(obj, &args->offset);
+	ret = mutex_lock_interruptible(&dev->struct_mutex);
+	if (ret == 0) {
+		ret = etnaviv_gem_mmap_offset(obj, &args->offset);
+
+		mutex_unlock(&dev->struct_mutex);
+	}
 
 	drm_gem_object_unreference_unlocked(obj);
 
diff --git a/drivers/staging/etnaviv/etnaviv_gem.c b/drivers/staging/etnaviv/etnaviv_gem.c
index 38dee80d996c..b1984a4ac0c5 100644
--- a/drivers/staging/etnaviv/etnaviv_gem.c
+++ b/drivers/staging/etnaviv/etnaviv_gem.c
@@ -269,20 +269,17 @@ out:
 	}
 }
 
-/** get mmap offset */
+/* get mmap offset - must be called under struct_mutex */
 int etnaviv_gem_mmap_offset(struct drm_gem_object *obj, uint64_t *offset)
 {
-	struct drm_device *dev = obj->dev;
 	int ret;
 
-	mutex_lock(&dev->struct_mutex);
 	/* Make it mmapable */
 	ret = drm_gem_create_mmap_offset(obj);
 	if (ret)
-		dev_err(dev->dev, "could not allocate mmap offset\n");
+		dev_err(obj->dev->dev, "could not allocate mmap offset\n");
 	else
 		*offset = drm_vma_node_offset_addr(&obj->vma_node);
-	mutex_unlock(&dev->struct_mutex);
 
 	return ret;
 }
-- 
2.5.1

_______________________________________________
dri-devel mailing list
dri-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/dri-devel




[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux