From 283eaa25594347267df4e6e5eedbb9d17bb3682c Mon Sep 17 00:00:00 2001
From: Dave Airlie <airlied@redhat.com>
Date: Tue, 31 Jul 2007 09:22:45 +1000
Subject: drm: fix fencing refcount error

This extra increase was causing fence leaks on my system, due to create/user add already increasing it twice no need for a 3rd go.
---
 linux-core/drm_fence.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

(limited to 'linux-core')

diff --git a/linux-core/drm_fence.c b/linux-core/drm_fence.c
index c4f7da15..fdb2a4db 100644
--- a/linux-core/drm_fence.c
+++ b/linux-core/drm_fence.c
@@ -597,7 +597,6 @@ int drm_fence_create_ioctl(struct drm_device *dev, void *data, struct drm_file *
 	 * usage > 0. No need to lock dev->struct_mutex;
 	 */
 	
-	atomic_inc(&fence->usage);
 	arg->handle = fence->base.hash.key;
 
 	read_lock_irqsave(&fm->lock, flags);
@@ -830,7 +829,7 @@ int drm_fence_buffers_ioctl(struct drm_device *dev, void *data, struct drm_file
 					DRM_FENCE_FLAG_SHAREABLE);
 	if (ret)
 		return ret;
-	atomic_inc(&fence->usage);
+
 	arg->handle = fence->base.hash.key;
 
 	read_lock_irqsave(&fm->lock, flags);
-- 
cgit v1.2.3


From c395d27a725f170645704bfc0d27b1e935b53c83 Mon Sep 17 00:00:00 2001
From: Dave Airlie <airlied@pegasus.(none)>
Date: Wed, 25 Jul 2007 14:32:15 +1000
Subject: drm/fence: shut up lockdep

---
 linux-core/drm_fence.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

(limited to 'linux-core')

diff --git a/linux-core/drm_fence.c b/linux-core/drm_fence.c
index fdb2a4db..2f16f7ef 100644
--- a/linux-core/drm_fence.c
+++ b/linux-core/drm_fence.c
@@ -520,9 +520,10 @@ void drm_fence_manager_init(struct drm_device * dev)
 	struct drm_fence_class_manager *class;
 	struct drm_fence_driver *fed = dev->driver->fence_driver;
 	int i;
+	unsigned long flags;
 
 	rwlock_init(&fm->lock);
-	write_lock(&fm->lock);
+	write_lock_irqsave(&fm->lock, flags);
 	fm->initialized = 0;
 	if (!fed)
 	    goto out_unlock;
@@ -541,7 +542,7 @@ void drm_fence_manager_init(struct drm_device * dev)
 
 	atomic_set(&fm->count, 0);
  out_unlock:
-	write_unlock(&fm->lock);
+	write_unlock_irqrestore(&fm->lock, flags);
 }
 
 void drm_fence_manager_takedown(struct drm_device * dev)
-- 
cgit v1.2.3


From 7602e4f8a67d777437502672b4f74d9b990535ce Mon Sep 17 00:00:00 2001
From: Dave Airlie <airlied@linux.ie>
Date: Thu, 2 Aug 2007 19:13:45 +1000
Subject: drm: add unlocked ioctl code path - not used yet

---
 linux-core/drmP.h    | 2 ++
 linux-core/drm_drv.c | 8 +++++++-
 2 files changed, 9 insertions(+), 1 deletion(-)

(limited to 'linux-core')

diff --git a/linux-core/drmP.h b/linux-core/drmP.h
index 2b7e0a44..a61efcff 100644
--- a/linux-core/drmP.h
+++ b/linux-core/drmP.h
@@ -911,6 +911,8 @@ extern void drm_exit(struct drm_driver *driver);
 extern void drm_cleanup_pci(struct pci_dev *pdev);
 extern int drm_ioctl(struct inode *inode, struct file *filp,
 		     unsigned int cmd, unsigned long arg);
+extern long drm_unlocked_ioctl(struct file *filp,
+			       unsigned int cmd, unsigned long arg);
 extern long drm_compat_ioctl(struct file *filp,
 			     unsigned int cmd, unsigned long arg);
 
diff --git a/linux-core/drm_drv.c b/linux-core/drm_drv.c
index cc676bda..bb15987e 100644
--- a/linux-core/drm_drv.c
+++ b/linux-core/drm_drv.c
@@ -573,6 +573,12 @@ static int drm_version(struct drm_device *dev, void *data,
  */
 int drm_ioctl(struct inode *inode, struct file *filp,
 	      unsigned int cmd, unsigned long arg)
+{
+	return drm_unlocked_ioctl(filp, cmd, arg);
+}
+EXPORT_SYMBOL(drm_ioctl);
+
+long drm_unlocked_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
 {
 	struct drm_file *file_priv = filp->private_data;
 	struct drm_device *dev = file_priv->head->dev;
@@ -650,7 +656,7 @@ err_i1:
 		DRM_DEBUG("ret = %x\n", retcode);
 	return retcode;
 }
-EXPORT_SYMBOL(drm_ioctl);
+EXPORT_SYMBOL(drm_unlocked_ioctl);
 
 drm_local_map_t *drm_getsarea(struct drm_device *dev)
 {
-- 
cgit v1.2.3