aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/drm/drm_lock.c
diff options
context:
space:
mode:
authorDave Airlie <airlied@starflyer.(none)>2005-11-24 05:41:14 -0500
committerDave Airlie <airlied@linux.ie>2005-11-24 05:41:14 -0500
commitcf65f1623dd005ddfb1cbba20af3423a6c638dbe (patch)
treeaa1a69092764317ff9ac49c25be5e423882b90d6 /drivers/char/drm/drm_lock.c
parent33bc227e4e48ddadcf2eacb381c19df338f0a6c8 (diff)
drm: fix quiescent locking
A fix for a locking bug which is triggered when a client tries to lock with flag DMA_QUIESCENT (typically the X server), but gets interrupted by a signal. The locking IOCTL should then return an error, but if DMA_QUIESCENT succeeds it returns 0, and the client falsely thinks it has the lock. In addition The client waits for DMA_QUISCENT and possibly DMA_READY without having the lock. From: Thomas Hellstrom Signed-off-by: Dave Airlie <airlied@linux.ie>
Diffstat (limited to 'drivers/char/drm/drm_lock.c')
-rw-r--r--drivers/char/drm/drm_lock.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/drivers/char/drm/drm_lock.c b/drivers/char/drm/drm_lock.c
index b276ae8a6633..b48a595d54ec 100644
--- a/drivers/char/drm/drm_lock.c
+++ b/drivers/char/drm/drm_lock.c
@@ -104,6 +104,10 @@ int drm_lock(struct inode *inode, struct file *filp,
104 __set_current_state(TASK_RUNNING); 104 __set_current_state(TASK_RUNNING);
105 remove_wait_queue(&dev->lock.lock_queue, &entry); 105 remove_wait_queue(&dev->lock.lock_queue, &entry);
106 106
107 DRM_DEBUG("%d %s\n", lock.context, ret ? "interrupted" : "has lock");
108 if (ret)
109 return ret;
110
107 sigemptyset(&dev->sigmask); 111 sigemptyset(&dev->sigmask);
108 sigaddset(&dev->sigmask, SIGSTOP); 112 sigaddset(&dev->sigmask, SIGSTOP);
109 sigaddset(&dev->sigmask, SIGTSTP); 113 sigaddset(&dev->sigmask, SIGTSTP);
@@ -116,8 +120,12 @@ int drm_lock(struct inode *inode, struct file *filp,
116 if (dev->driver->dma_ready && (lock.flags & _DRM_LOCK_READY)) 120 if (dev->driver->dma_ready && (lock.flags & _DRM_LOCK_READY))
117 dev->driver->dma_ready(dev); 121 dev->driver->dma_ready(dev);
118 122
119 if (dev->driver->dma_quiescent && (lock.flags & _DRM_LOCK_QUIESCENT)) 123 if (dev->driver->dma_quiescent && (lock.flags & _DRM_LOCK_QUIESCENT)) {
120 return dev->driver->dma_quiescent(dev); 124 if (dev->driver->dma_quiescent(dev)) {
125 DRM_DEBUG("%d waiting for DMA quiescent\n", lock.context);
126 return DRM_ERR(EBUSY);
127 }
128 }
121 129
122 /* dev->driver->kernel_context_switch isn't used by any of the x86 130 /* dev->driver->kernel_context_switch isn't used by any of the x86
123 * drivers but is used by the Sparc driver. 131 * drivers but is used by the Sparc driver.
@@ -128,9 +136,7 @@ int drm_lock(struct inode *inode, struct file *filp,
128 dev->driver->kernel_context_switch(dev, dev->last_context, 136 dev->driver->kernel_context_switch(dev, dev->last_context,
129 lock.context); 137 lock.context);
130 } 138 }
131 DRM_DEBUG("%d %s\n", lock.context, ret ? "interrupted" : "has lock"); 139 return 0;
132
133 return ret;
134} 140}
135 141
136/** 142/**