diff options
author | Thomas Hellstrom <thomas-at-tungstengraphics-dot-com> | 2008-04-14 12:10:50 +0200 |
---|---|---|
committer | Thomas Hellstrom <thomas-at-tungstengraphics-dot-com> | 2008-04-14 12:14:20 +0200 |
commit | c5955c652302d66719984cb5a218cb590c74ad42 (patch) | |
tree | afa829b80105f435dac0f4d908c75cc00397666e /linux-core/drm_bo_lock.c | |
parent | c9b73ef6daff75df27d17260a9fc84e68f1b21b4 (diff) |
Fix buffer object creation validation.
BO lock fixes.
Diffstat (limited to 'linux-core/drm_bo_lock.c')
-rw-r--r-- | linux-core/drm_bo_lock.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/linux-core/drm_bo_lock.c b/linux-core/drm_bo_lock.c index 32ebfbe2..08b1c6be 100644 --- a/linux-core/drm_bo_lock.c +++ b/linux-core/drm_bo_lock.c @@ -68,9 +68,7 @@ void drm_bo_init_lock(struct drm_bo_lock *lock) void drm_bo_read_unlock(struct drm_bo_lock *lock) { - if (unlikely(atomic_add_negative(-1, &lock->readers))) - BUG(); - if (atomic_read(&lock->readers) == 0) + if (atomic_dec_and_test(&lock->readers)) wake_up_all(&lock->queue); } EXPORT_SYMBOL(drm_bo_read_unlock); @@ -79,7 +77,7 @@ int drm_bo_read_lock(struct drm_bo_lock *lock, int interruptible) { while (unlikely(atomic_read(&lock->write_lock_pending) != 0)) { int ret; - + if (!interruptible) { wait_event(lock->queue, atomic_read(&lock->write_lock_pending) == 0); @@ -93,7 +91,6 @@ int drm_bo_read_lock(struct drm_bo_lock *lock, int interruptible) while (unlikely(!atomic_add_unless(&lock->readers, 1, -1))) { int ret; - if (!interruptible) { wait_event(lock->queue, atomic_read(&lock->readers) != -1); @@ -156,7 +153,8 @@ int drm_bo_write_lock(struct drm_bo_lock *lock, int interruptible, * while holding it. */ - atomic_dec(&lock->write_lock_pending); + if (atomic_dec_and_test(&lock->write_lock_pending)) + wake_up_all(&lock->queue); dev = file_priv->minor->dev; mutex_lock(&dev->struct_mutex); ret = drm_add_user_object(file_priv, &lock->base, 0); |