diff options
author | Eric Anholt <anholt@freebsd.org> | 2003-02-21 23:23:09 +0000 |
---|---|---|
committer | Eric Anholt <anholt@freebsd.org> | 2003-02-21 23:23:09 +0000 |
commit | cfa778af9c70faea8c13e5cb7f80029eee0d074e (patch) | |
tree | 15483e64b6c2b56d3bb0f247df9df2c2602e0404 /bsd/drm_lock.h | |
parent | a64472d18493de575a7636704b45babe7b4b4572 (diff) |
Merge from bsd-4-0-0-branch.bsd-4-0-0-20030221-merge
Diffstat (limited to 'bsd/drm_lock.h')
-rw-r--r-- | bsd/drm_lock.h | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/bsd/drm_lock.h b/bsd/drm_lock.h index 5e9294bc..bb99d9e6 100644 --- a/bsd/drm_lock.h +++ b/bsd/drm_lock.h @@ -47,14 +47,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 +75,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; 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; } @@ -93,14 +90,13 @@ int DRM(lock_free)(drm_device_t *dev, { unsigned int old, new; pid_t pid = dev->lock.pid; - char failed; dev->lock.pid = 0; 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, @@ -224,8 +220,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 +230,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; } |