diff options
author | Daryll Strauss <daryll@users.sourceforge.net> | 1999-12-07 03:37:16 +0000 |
---|---|---|
committer | Daryll Strauss <daryll@users.sourceforge.net> | 1999-12-07 03:37:16 +0000 |
commit | e1dba5c3a73078dec24f07a6d685435677db94a4 (patch) | |
tree | 85df5e4de1dbbbe434e9359e8849325e68c3a79f /linux/lock.c | |
parent | b6a28bfe98f2c89cfb91079bd3c7b63fb0144eb1 (diff) |
Move Mesa to xc/extras Update to the latest Mesa 3.2 code Fix the Q3Demo
bugs (white railgun and texture mapping) Simplify driver texture
mapping routines Fix device driver for 2.3 kernels Improve performance
Diffstat (limited to 'linux/lock.c')
-rw-r--r-- | linux/lock.c | 34 |
1 files changed, 14 insertions, 20 deletions
diff --git a/linux/lock.c b/linux/lock.c index ab1c0742c..e8c1eff10 100644 --- a/linux/lock.c +++ b/linux/lock.c @@ -1,6 +1,6 @@ /* lock.c -- IOCTLs for locking -*- linux-c -*- * Created: Tue Feb 2 08:37:54 1999 by faith@precisioninsight.com - * Revised: Tue Oct 12 08:51:06 1999 by faith@precisioninsight.com + * Revised: Mon Dec 6 16:04:44 1999 by faith@precisioninsight.com * * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. * All Rights Reserved. @@ -48,17 +48,15 @@ int drm_unblock(struct inode *inode, struct file *filp, unsigned int cmd, int drm_lock_take(__volatile__ unsigned int *lock, unsigned int context) { - unsigned int old; - unsigned int new; - char failed; + unsigned int old, new, prev; DRM_DEBUG("%d attempts\n", context); do { old = *lock; if (old & _DRM_LOCK_HELD) new = old | _DRM_LOCK_CONT; else new = context | _DRM_LOCK_HELD; - _DRM_CAS(lock, old, new, failed); - } while (failed); + prev = cmpxchg(lock, old, new); + } while (prev != old); if (_DRM_LOCKING_CONTEXT(old) == context) { if (old & _DRM_LOCK_HELD) { if (context != DRM_KERNEL_CONTEXT) { @@ -83,16 +81,14 @@ int drm_lock_take(__volatile__ unsigned int *lock, unsigned int context) int drm_lock_transfer(drm_device_t *dev, __volatile__ unsigned int *lock, unsigned int context) { - unsigned int old; - unsigned int new; - char failed; + unsigned int old, new, prev; dev->lock.pid = 0; do { - old = *lock; - new = context | _DRM_LOCK_HELD; - _DRM_CAS(lock, old, new, failed); - } while (failed); + old = *lock; + new = context | _DRM_LOCK_HELD; + prev = cmpxchg(lock, old, new); + } while (prev != old); DRM_DEBUG("%d => %d\n", _DRM_LOCKING_CONTEXT(old), context); return 1; } @@ -100,18 +96,16 @@ int drm_lock_transfer(drm_device_t *dev, int drm_lock_free(drm_device_t *dev, __volatile__ unsigned int *lock, unsigned int context) { - unsigned int old; - unsigned int new; - char failed; + unsigned int old, new, prev; pid_t pid = dev->lock.pid; DRM_DEBUG("%d\n", context); dev->lock.pid = 0; do { - old = *lock; - new = 0; - _DRM_CAS(lock, old, new, failed); - } while (failed); + old = *lock; + new = 0; + prev = cmpxchg(lock, old, new); + } while (prev != old); if (_DRM_LOCK_IS_HELD(old) && _DRM_LOCKING_CONTEXT(old) != context) { DRM_ERROR("%d freed heavyweight lock held by %d (pid %d)\n", context, |