Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /** |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 2 | * \file drm_lock.c |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3 | * IOCTLs for locking |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 4 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5 | * \author Rickard E. (Rik) Faith <faith@valinux.com> |
| 6 | * \author Gareth Hughes <gareth@valinux.com> |
| 7 | */ |
| 8 | |
| 9 | /* |
| 10 | * Created: Tue Feb 2 08:37:54 1999 by faith@valinux.com |
| 11 | * |
| 12 | * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. |
| 13 | * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. |
| 14 | * All Rights Reserved. |
| 15 | * |
| 16 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 17 | * copy of this software and associated documentation files (the "Software"), |
| 18 | * to deal in the Software without restriction, including without limitation |
| 19 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 20 | * and/or sell copies of the Software, and to permit persons to whom the |
| 21 | * Software is furnished to do so, subject to the following conditions: |
| 22 | * |
| 23 | * The above copyright notice and this permission notice (including the next |
| 24 | * paragraph) shall be included in all copies or substantial portions of the |
| 25 | * Software. |
| 26 | * |
| 27 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 28 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 29 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 30 | * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR |
| 31 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
| 32 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
| 33 | * OTHER DEALINGS IN THE SOFTWARE. |
| 34 | */ |
| 35 | |
| 36 | #include "drmP.h" |
| 37 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 38 | static int drm_lock_transfer(drm_device_t * dev, |
Dave Airlie | c94f702 | 2005-07-07 21:03:38 +1000 | [diff] [blame] | 39 | __volatile__ unsigned int *lock, |
| 40 | unsigned int context); |
| 41 | static int drm_notifier(void *priv); |
| 42 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 43 | /** |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | * Lock ioctl. |
| 45 | * |
| 46 | * \param inode device inode. |
| 47 | * \param filp file pointer. |
| 48 | * \param cmd command. |
| 49 | * \param arg user argument, pointing to a drm_lock structure. |
| 50 | * \return zero on success or negative number on failure. |
| 51 | * |
| 52 | * Add the current task to the lock wait queue, and attempt to take to lock. |
| 53 | */ |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 54 | int drm_lock(struct inode *inode, struct file *filp, |
| 55 | unsigned int cmd, unsigned long arg) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 56 | { |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 57 | drm_file_t *priv = filp->private_data; |
| 58 | drm_device_t *dev = priv->head->dev; |
| 59 | DECLARE_WAITQUEUE(entry, current); |
| 60 | drm_lock_t lock; |
| 61 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 62 | |
| 63 | ++priv->lock_count; |
| 64 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 65 | if (copy_from_user(&lock, (drm_lock_t __user *) arg, sizeof(lock))) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 66 | return -EFAULT; |
| 67 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 68 | if (lock.context == DRM_KERNEL_CONTEXT) { |
| 69 | DRM_ERROR("Process %d using kernel context %d\n", |
| 70 | current->pid, lock.context); |
| 71 | return -EINVAL; |
| 72 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 73 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 74 | DRM_DEBUG("%d (pid %d) requests lock (0x%08x), flags = 0x%08x\n", |
| 75 | lock.context, current->pid, |
| 76 | dev->lock.hw_lock->lock, lock.flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 77 | |
| 78 | if (drm_core_check_feature(dev, DRIVER_DMA_QUEUE)) |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 79 | if (lock.context < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 80 | return -EINVAL; |
| 81 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 82 | add_wait_queue(&dev->lock.lock_queue, &entry); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 83 | for (;;) { |
| 84 | __set_current_state(TASK_INTERRUPTIBLE); |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 85 | if (!dev->lock.hw_lock) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 86 | /* Device has been unregistered */ |
| 87 | ret = -EINTR; |
| 88 | break; |
| 89 | } |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 90 | if (drm_lock_take(&dev->lock.hw_lock->lock, lock.context)) { |
| 91 | dev->lock.filp = filp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 92 | dev->lock.lock_time = jiffies; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 93 | atomic_inc(&dev->counts[_DRM_STAT_LOCKS]); |
| 94 | break; /* Got lock */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 95 | } |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 96 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 97 | /* Contention */ |
| 98 | schedule(); |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 99 | if (signal_pending(current)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 100 | ret = -ERESTARTSYS; |
| 101 | break; |
| 102 | } |
| 103 | } |
| 104 | __set_current_state(TASK_RUNNING); |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 105 | remove_wait_queue(&dev->lock.lock_queue, &entry); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 106 | |
Dave Airlie | cf65f16 | 2005-11-24 21:41:14 +1100 | [diff] [blame] | 107 | DRM_DEBUG("%d %s\n", lock.context, ret ? "interrupted" : "has lock"); |
| 108 | if (ret) |
| 109 | return ret; |
Dave Airlie | d985c10 | 2006-01-02 21:32:48 +1100 | [diff] [blame] | 110 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 111 | sigemptyset(&dev->sigmask); |
| 112 | sigaddset(&dev->sigmask, SIGSTOP); |
| 113 | sigaddset(&dev->sigmask, SIGTSTP); |
| 114 | sigaddset(&dev->sigmask, SIGTTIN); |
| 115 | sigaddset(&dev->sigmask, SIGTTOU); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 116 | dev->sigdata.context = lock.context; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 117 | dev->sigdata.lock = dev->lock.hw_lock; |
| 118 | block_all_signals(drm_notifier, &dev->sigdata, &dev->sigmask); |
| 119 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 120 | if (dev->driver->dma_ready && (lock.flags & _DRM_LOCK_READY)) |
| 121 | dev->driver->dma_ready(dev); |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 122 | |
Dave Airlie | d985c10 | 2006-01-02 21:32:48 +1100 | [diff] [blame] | 123 | if (dev->driver->dma_quiescent && (lock.flags & _DRM_LOCK_QUIESCENT)) { |
| 124 | if (dev->driver->dma_quiescent(dev)) { |
Dave Airlie | cf65f16 | 2005-11-24 21:41:14 +1100 | [diff] [blame] | 125 | DRM_DEBUG("%d waiting for DMA quiescent\n", lock.context); |
Dave Airlie | d985c10 | 2006-01-02 21:32:48 +1100 | [diff] [blame] | 126 | return DRM_ERR(EBUSY); |
| 127 | } |
| 128 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 129 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 130 | /* dev->driver->kernel_context_switch isn't used by any of the x86 |
| 131 | * drivers but is used by the Sparc driver. |
| 132 | */ |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 133 | if (dev->driver->kernel_context_switch && |
| 134 | dev->last_context != lock.context) { |
| 135 | dev->driver->kernel_context_switch(dev, dev->last_context, |
| 136 | lock.context); |
| 137 | } |
Dave Airlie | d985c10 | 2006-01-02 21:32:48 +1100 | [diff] [blame] | 138 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 139 | } |
| 140 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 141 | /** |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 142 | * Unlock ioctl. |
| 143 | * |
| 144 | * \param inode device inode. |
| 145 | * \param filp file pointer. |
| 146 | * \param cmd command. |
| 147 | * \param arg user argument, pointing to a drm_lock structure. |
| 148 | * \return zero on success or negative number on failure. |
| 149 | * |
| 150 | * Transfer and free the lock. |
| 151 | */ |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 152 | int drm_unlock(struct inode *inode, struct file *filp, |
| 153 | unsigned int cmd, unsigned long arg) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 154 | { |
| 155 | drm_file_t *priv = filp->private_data; |
| 156 | drm_device_t *dev = priv->head->dev; |
| 157 | drm_lock_t lock; |
Dave Airlie | 5c2df2b | 2006-10-24 11:36:59 -0700 | [diff] [blame^] | 158 | unsigned long irqflags; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 159 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 160 | if (copy_from_user(&lock, (drm_lock_t __user *) arg, sizeof(lock))) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 161 | return -EFAULT; |
| 162 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 163 | if (lock.context == DRM_KERNEL_CONTEXT) { |
| 164 | DRM_ERROR("Process %d using kernel context %d\n", |
| 165 | current->pid, lock.context); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 166 | return -EINVAL; |
| 167 | } |
| 168 | |
=?utf-8?q?Michel_D=C3=A4nzer?= | 2e54a00 | 2006-10-24 23:08:16 +1000 | [diff] [blame] | 169 | spin_lock_irqsave(&dev->tasklet_lock, irqflags); |
| 170 | |
| 171 | if (dev->locked_tasklet_func) { |
| 172 | dev->locked_tasklet_func(dev); |
| 173 | |
| 174 | dev->locked_tasklet_func = NULL; |
| 175 | } |
| 176 | |
| 177 | spin_unlock_irqrestore(&dev->tasklet_lock, irqflags); |
| 178 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 179 | atomic_inc(&dev->counts[_DRM_STAT_UNLOCKS]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 180 | |
| 181 | /* kernel_context_switch isn't used by any of the x86 drm |
| 182 | * modules but is required by the Sparc driver. |
| 183 | */ |
| 184 | if (dev->driver->kernel_context_switch_unlock) |
| 185 | dev->driver->kernel_context_switch_unlock(dev, &lock); |
| 186 | else { |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 187 | drm_lock_transfer(dev, &dev->lock.hw_lock->lock, |
| 188 | DRM_KERNEL_CONTEXT); |
| 189 | |
| 190 | if (drm_lock_free(dev, &dev->lock.hw_lock->lock, |
| 191 | DRM_KERNEL_CONTEXT)) { |
| 192 | DRM_ERROR("\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 193 | } |
| 194 | } |
| 195 | |
| 196 | unblock_all_signals(); |
| 197 | return 0; |
| 198 | } |
| 199 | |
| 200 | /** |
| 201 | * Take the heavyweight lock. |
| 202 | * |
| 203 | * \param lock lock pointer. |
| 204 | * \param context locking context. |
| 205 | * \return one if the lock is held, or zero otherwise. |
| 206 | * |
| 207 | * Attempt to mark the lock as held by the given context, via the \p cmpxchg instruction. |
| 208 | */ |
| 209 | int drm_lock_take(__volatile__ unsigned int *lock, unsigned int context) |
| 210 | { |
| 211 | unsigned int old, new, prev; |
| 212 | |
| 213 | do { |
| 214 | old = *lock; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 215 | if (old & _DRM_LOCK_HELD) |
| 216 | new = old | _DRM_LOCK_CONT; |
| 217 | else |
| 218 | new = context | _DRM_LOCK_HELD; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 219 | prev = cmpxchg(lock, old, new); |
| 220 | } while (prev != old); |
| 221 | if (_DRM_LOCKING_CONTEXT(old) == context) { |
| 222 | if (old & _DRM_LOCK_HELD) { |
| 223 | if (context != DRM_KERNEL_CONTEXT) { |
| 224 | DRM_ERROR("%d holds heavyweight lock\n", |
| 225 | context); |
| 226 | } |
| 227 | return 0; |
| 228 | } |
| 229 | } |
| 230 | if (new == (context | _DRM_LOCK_HELD)) { |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 231 | /* Have lock */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 232 | return 1; |
| 233 | } |
| 234 | return 0; |
| 235 | } |
| 236 | |
| 237 | /** |
| 238 | * This takes a lock forcibly and hands it to context. Should ONLY be used |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 239 | * inside *_unlock to give lock to kernel before calling *_dma_schedule. |
| 240 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 241 | * \param dev DRM device. |
| 242 | * \param lock lock pointer. |
| 243 | * \param context locking context. |
| 244 | * \return always one. |
| 245 | * |
| 246 | * Resets the lock file pointer. |
| 247 | * Marks the lock as held by the given context, via the \p cmpxchg instruction. |
| 248 | */ |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 249 | static int drm_lock_transfer(drm_device_t * dev, |
Dave Airlie | c94f702 | 2005-07-07 21:03:38 +1000 | [diff] [blame] | 250 | __volatile__ unsigned int *lock, |
| 251 | unsigned int context) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 252 | { |
| 253 | unsigned int old, new, prev; |
| 254 | |
| 255 | dev->lock.filp = NULL; |
| 256 | do { |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 257 | old = *lock; |
| 258 | new = context | _DRM_LOCK_HELD; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 259 | prev = cmpxchg(lock, old, new); |
| 260 | } while (prev != old); |
| 261 | return 1; |
| 262 | } |
| 263 | |
| 264 | /** |
| 265 | * Free lock. |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 266 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 267 | * \param dev DRM device. |
| 268 | * \param lock lock. |
| 269 | * \param context context. |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 270 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 271 | * Resets the lock file pointer. |
| 272 | * Marks the lock as not held, via the \p cmpxchg instruction. Wakes any task |
| 273 | * waiting on the lock queue. |
| 274 | */ |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 275 | int drm_lock_free(drm_device_t * dev, |
| 276 | __volatile__ unsigned int *lock, unsigned int context) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 277 | { |
| 278 | unsigned int old, new, prev; |
| 279 | |
| 280 | dev->lock.filp = NULL; |
| 281 | do { |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 282 | old = *lock; |
| 283 | new = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 284 | prev = cmpxchg(lock, old, new); |
| 285 | } while (prev != old); |
| 286 | if (_DRM_LOCK_IS_HELD(old) && _DRM_LOCKING_CONTEXT(old) != context) { |
| 287 | DRM_ERROR("%d freed heavyweight lock held by %d\n", |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 288 | context, _DRM_LOCKING_CONTEXT(old)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 289 | return 1; |
| 290 | } |
| 291 | wake_up_interruptible(&dev->lock.lock_queue); |
| 292 | return 0; |
| 293 | } |
| 294 | |
| 295 | /** |
| 296 | * If we get here, it means that the process has called DRM_IOCTL_LOCK |
| 297 | * without calling DRM_IOCTL_UNLOCK. |
| 298 | * |
| 299 | * If the lock is not held, then let the signal proceed as usual. If the lock |
| 300 | * is held, then set the contended flag and keep the signal blocked. |
| 301 | * |
| 302 | * \param priv pointer to a drm_sigdata structure. |
| 303 | * \return one if the signal should be delivered normally, or zero if the |
| 304 | * signal should be blocked. |
| 305 | */ |
Dave Airlie | c94f702 | 2005-07-07 21:03:38 +1000 | [diff] [blame] | 306 | static int drm_notifier(void *priv) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 307 | { |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 308 | drm_sigdata_t *s = (drm_sigdata_t *) priv; |
| 309 | unsigned int old, new, prev; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 310 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 311 | /* Allow signal delivery if lock isn't held */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 312 | if (!s->lock || !_DRM_LOCK_IS_HELD(s->lock->lock) |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 313 | || _DRM_LOCKING_CONTEXT(s->lock->lock) != s->context) |
| 314 | return 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 315 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 316 | /* Otherwise, set flag to force call to |
| 317 | drmUnlock */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 318 | do { |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 319 | old = s->lock->lock; |
| 320 | new = old | _DRM_LOCK_CONT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 321 | prev = cmpxchg(&s->lock->lock, old, new); |
| 322 | } while (prev != old); |
| 323 | return 0; |
| 324 | } |