[2/2] drm/ttm: don't write to bo->reserved without holding glob->lru_lock
diff mbox

Message ID 1267468480-3430-2-git-send-email-madman2003@gmail.com
State Rejected
Headers show

Commit Message

Maarten Maathuis March 1, 2010, 6:34 p.m. UTC
None

Patch
diff mbox

diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index f5333d9..2104885 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -476,9 +476,9 @@  static int ttm_bo_cleanup_refs(struct ttm_buffer_object *bo, bool remove_all)
 			drm_mm_put_block(bo->mem.mm_node);
 			bo->mem.mm_node = NULL;
 		}
-		spin_unlock(&glob->lru_lock);
 
 		atomic_set(&bo->reserved, 0);
+		spin_unlock(&glob->lru_lock);
 
 		while (put_count--)
 			kref_put(&bo->list_kref, ttm_bo_ref_bug);
@@ -1707,8 +1707,12 @@  EXPORT_SYMBOL(ttm_bo_wait);
 
 void ttm_bo_unblock_reservation(struct ttm_buffer_object *bo)
 {
+	struct ttm_bo_global *glob = bo->glob;
+
+	spin_lock(&glob->lru_lock);
 	atomic_set(&bo->reserved, 0);
 	wake_up_all(&bo->event_queue);
+	spin_unlock(&glob->lru_lock);
 }
 
 int ttm_bo_block_reservation(struct ttm_buffer_object *bo, bool interruptible,
@@ -1849,8 +1853,10 @@  out:
 	 * already swapped buffer.
 	 */
 
+	spin_lock(&glob->lru_lock);
 	atomic_set(&bo->reserved, 0);
 	wake_up_all(&bo->event_queue);
+	spin_unlock(&glob->lru_lock);
 	kref_put(&bo->list_kref, ttm_bo_release_list);
 	return ret;
 }