diff options
Diffstat (limited to 'bsd/drm_lock.h')
-rw-r--r-- | bsd/drm_lock.h | 35 |
1 files changed, 14 insertions, 21 deletions
diff --git a/bsd/drm_lock.h b/bsd/drm_lock.h index 5e9294bc..3bab78ef 100644 --- a/bsd/drm_lock.h +++ b/bsd/drm_lock.h @@ -27,6 +27,8 @@ * Authors: * Rickard E. (Rik) Faith <faith@valinux.com> * Gareth Hughes <gareth@valinux.com> + * + * $FreeBSD: src/sys/dev/drm/drm_lock.h,v 1.2 2003/03/09 02:08:28 anholt Exp $ */ #include "drmP.h" @@ -47,14 +49,12 @@ int DRM(lock_take)(__volatile__ unsigned int *lock, unsigned int context) { unsigned int old, new; - char failed; - 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); + } while (!atomic_cmpset_int(lock, old, new)); + if (_DRM_LOCKING_CONTEXT(old) == context) { if (old & _DRM_LOCK_HELD) { if (context != DRM_KERNEL_CONTEXT) { @@ -77,14 +77,13 @@ int DRM(lock_transfer)(drm_device_t *dev, __volatile__ unsigned int *lock, unsigned int context) { unsigned int old, new; - char failed; - dev->lock.pid = 0; + dev->lock.filp = NULL; do { old = *lock; new = context | _DRM_LOCK_HELD; - _DRM_CAS(lock, old, new, failed); - } while (failed); + } while (!atomic_cmpset_int(lock, old, new)); + return 1; } @@ -92,20 +91,16 @@ int DRM(lock_free)(drm_device_t *dev, __volatile__ unsigned int *lock, unsigned int context) { unsigned int old, new; - pid_t pid = dev->lock.pid; - char failed; - dev->lock.pid = 0; + dev->lock.filp = NULL; do { old = *lock; new = 0; - _DRM_CAS(lock, old, new, failed); - } while (failed); + } while (!atomic_cmpset_int(lock, old, new)); + if (_DRM_LOCK_IS_HELD(old) && _DRM_LOCKING_CONTEXT(old) != context) { - DRM_ERROR("%d freed heavyweight lock held by %d (pid %d)\n", - context, - _DRM_LOCKING_CONTEXT(old), - pid); + DRM_ERROR("%d freed heavyweight lock held by %d\n", + context, _DRM_LOCKING_CONTEXT(old)); return 1; } DRM_WAKEUP_INT((void *)&dev->lock.lock_queue); @@ -224,8 +219,6 @@ int DRM(notifier)(void *priv) { drm_sigdata_t *s = (drm_sigdata_t *)priv; unsigned int old, new; - char failed; - /* Allow signal delivery if lock isn't held */ if (!_DRM_LOCK_IS_HELD(s->lock->lock) @@ -236,8 +229,8 @@ int DRM(notifier)(void *priv) do { old = s->lock->lock; new = old | _DRM_LOCK_CONT; - _DRM_CAS(&s->lock->lock, old, new, failed); - } while (failed); + } while (!atomic_cmpset_int(&s->lock->lock, old, new)); + return 0; } |