drm/ttm: Remove ttm_bo_unreserve_core()
authorFrançois Tigeot <ftigeot@wolfpond.org>
Sat, 3 Nov 2018 14:18:38 +0000 (15:18 +0100)
committerFrançois Tigeot <ftigeot@wolfpond.org>
Sat, 3 Nov 2018 14:23:44 +0000 (15:23 +0100)
* This function was DragonFly-specific and apparently
  isn't even needed anymore

* Sync the changed code with Linux as of ecff665f5e3f1c6909353e00b9420e45ae23d995
  "drm/ttm: make ttm reservation calls behave like reservation calls"

sys/dev/drm/ttm/ttm_bo.c

index 2f825bb..edc29f9 100644 (file)
@@ -361,24 +361,11 @@ int ttm_bo_reserve_slowpath(struct ttm_buffer_object *bo,
 }
 EXPORT_SYMBOL(ttm_bo_reserve_slowpath);
 
-/*
- * Must interlock with event_queue to avoid race against
- * wait_event_common() which can cause wait_event_common()
- * to become stuck.
- */
-static void
-ttm_bo_unreserve_core(struct ttm_buffer_object *bo)
-{
-       lockmgr(&bo->event_queue.lock, LK_EXCLUSIVE);
-       atomic_set(&bo->reserved, 0);
-       lockmgr(&bo->event_queue.lock, LK_RELEASE);
-       wake_up_all(&bo->event_queue);
-}
-
 void ttm_bo_unreserve_ticket_locked(struct ttm_buffer_object *bo, struct ww_acquire_ctx *ticket)
 {
        ttm_bo_add_to_lru(bo);
-       ttm_bo_unreserve_core(bo);
+       atomic_set(&bo->reserved, 0);
+       wake_up_all(&bo->event_queue);
 }
 
 void ttm_bo_unreserve(struct ttm_buffer_object *bo)
@@ -570,7 +557,9 @@ static void ttm_bo_cleanup_memtype_use(struct ttm_buffer_object *bo)
                bo->ttm = NULL;
        }
        ttm_bo_mem_put(bo, &bo->mem);
-       ttm_bo_unreserve_core(bo);
+
+       atomic_set(&bo->reserved, 0);
+       wake_up_all(&bo->event_queue);
 
        /*
         * Since the final reference to this bo may not be dropped by
@@ -612,18 +601,8 @@ static void ttm_bo_cleanup_refs_or_queue(struct ttm_buffer_object *bo)
        lockmgr(&bdev->fence_lock, LK_RELEASE);
 
        if (!ret) {
-
-               /*
-                * Make NO_EVICT bos immediately available to
-                * shrinkers, now that they are queued for
-                * destruction.
-                */
-               if (bo->mem.placement & TTM_PL_FLAG_NO_EVICT) {
-                       bo->mem.placement &= ~TTM_PL_FLAG_NO_EVICT;
-                       ttm_bo_add_to_lru(bo);
-               }
-
-               ttm_bo_unreserve_core(bo);
+               atomic_set(&bo->reserved, 0);
+               wake_up_all(&bo->event_queue);
        }
 
        kref_get(&bo->list_kref);
@@ -674,7 +653,8 @@ static int ttm_bo_cleanup_refs_and_unlock(struct ttm_buffer_object *bo,
                sync_obj = driver->sync_obj_ref(bo->sync_obj);
                lockmgr(&bdev->fence_lock, LK_RELEASE);
 
-               ttm_bo_unreserve_core(bo);
+               atomic_set(&bo->reserved, 0);
+               wake_up_all(&bo->event_queue);
                lockmgr(&glob->lru_lock, LK_RELEASE);
 
                ret = driver->sync_obj_wait(sync_obj, false, interruptible);
@@ -712,7 +692,8 @@ static int ttm_bo_cleanup_refs_and_unlock(struct ttm_buffer_object *bo,
                lockmgr(&bdev->fence_lock, LK_RELEASE);
 
        if (ret || unlikely(list_empty(&bo->ddestroy))) {
-               ttm_bo_unreserve_core(bo);
+               atomic_set(&bo->reserved, 0);
+               wake_up_all(&bo->event_queue);
                lockmgr(&glob->lru_lock, LK_RELEASE);
                return ret;
        }
@@ -1959,7 +1940,8 @@ out:
         * already swapped buffer.
         */
 
-       ttm_bo_unreserve_core(bo);
+       atomic_set(&bo->reserved, 0);
+       wake_up_all(&bo->event_queue);
        kref_put(&bo->list_kref, ttm_bo_release_list);
        return ret;
 }