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 | |
parent | c9b73ef6daff75df27d17260a9fc84e68f1b21b4 (diff) |
Fix buffer object creation validation.
BO lock fixes.
-rw-r--r-- | linux-core/drm_bo.c | 7 | ||||
-rw-r--r-- | linux-core/drm_bo_lock.c | 10 |
2 files changed, 9 insertions, 8 deletions
diff --git a/linux-core/drm_bo.c b/linux-core/drm_bo.c index 0853d748..6f287532 100644 --- a/linux-core/drm_bo.c +++ b/linux-core/drm_bo.c @@ -1244,6 +1244,7 @@ static int drm_buffer_object_map(struct drm_file *file_priv, uint32_t handle, mutex_unlock(&bo->mutex); drm_bo_usage_deref_unlocked(&bo); + return ret; } @@ -1541,8 +1542,9 @@ static int drm_bo_prepare_for_validate(struct drm_buffer_object *bo, ftype, no_wait); } - if (ret && ret != -EAGAIN) + if (ret && ret != -EAGAIN) ret = drm_bo_wait(bo, 0, 1, no_wait, 1); + if (ret) return ret; } @@ -1622,6 +1624,7 @@ out: drm_bo_fill_rep_arg(bo, rep); mutex_unlock(&bo->mutex); + return ret; } EXPORT_SYMBOL(drm_bo_do_validate); @@ -1816,7 +1819,7 @@ int drm_buffer_object_create(struct drm_device *dev, } mutex_unlock(&bo->mutex); - ret = drm_bo_do_validate(bo, 0, 0, hint & DRM_BO_HINT_DONT_BLOCK, + ret = drm_bo_do_validate(bo, 0, 0, hint | DRM_BO_HINT_DONT_FENCE, 0, NULL); if (ret) goto out_err_unlocked; 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); |