drm/ttm: use a helper for unlocked moves to the lru tail
authorDave Airlie <airlied@redhat.com>
Tue, 4 Aug 2020 02:55:39 +0000 (12:55 +1000)
committerDave Airlie <airlied@redhat.com>
Thu, 6 Aug 2020 02:16:33 +0000 (12:16 +1000)
The pattern was repeated a few times, just make an inline for it.

Reviewed-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Ben Skeggs <bskeggs@redhat.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200804025632.3868079-7-airlied@gmail.com
drivers/gpu/drm/ttm/ttm_bo.c
drivers/gpu/drm/ttm/ttm_bo_vm.c
include/drm/ttm/ttm_bo_driver.h

index 6c02a336a587a2016b91e9a3511484a0d4a9bacc..c5771a43d8ecdfe65541ca5b9b8201077e9630c6 100644 (file)
@@ -1101,9 +1101,7 @@ int ttm_bo_mem_space(struct ttm_buffer_object *bo,
 
 error:
        if (bo->mem.mem_type == TTM_PL_SYSTEM && !list_empty(&bo->lru)) {
-               spin_lock(&ttm_bo_glob.lru_lock);
-               ttm_bo_move_to_lru_tail(bo, NULL);
-               spin_unlock(&ttm_bo_glob.lru_lock);
+               ttm_bo_move_to_lru_tail_unlocked(bo);
        }
 
        return ret;
@@ -1318,9 +1316,7 @@ int ttm_bo_init_reserved(struct ttm_bo_device *bdev,
                return ret;
        }
 
-       spin_lock(&ttm_bo_glob.lru_lock);
-       ttm_bo_move_to_lru_tail(bo, NULL);
-       spin_unlock(&ttm_bo_glob.lru_lock);
+       ttm_bo_move_to_lru_tail_unlocked(bo);
 
        return ret;
 }
index 82b893d4249f5cce851c6f3aa9c26b55d82b653b..1e2820b06c6afe7e1636faea114804cee3e88812 100644 (file)
@@ -306,9 +306,7 @@ vm_fault_t ttm_bo_vm_fault_reserved(struct vm_fault *vmf,
                }
 
                if (bo->moving != moving) {
-                       spin_lock(&ttm_bo_glob.lru_lock);
-                       ttm_bo_move_to_lru_tail(bo, NULL);
-                       spin_unlock(&ttm_bo_glob.lru_lock);
+                       ttm_bo_move_to_lru_tail_unlocked(bo);
                }
                dma_fence_put(moving);
        }
index 44b4d24e73a230ac1d92f94df00c1c9f3280ac1d..049ebf85712fc30de489341d7597069cc833e904 100644 (file)
@@ -669,6 +669,13 @@ static inline int ttm_bo_reserve_slowpath(struct ttm_buffer_object *bo,
        return 0;
 }
 
+static inline void ttm_bo_move_to_lru_tail_unlocked(struct ttm_buffer_object *bo)
+{
+       spin_lock(&ttm_bo_glob.lru_lock);
+       ttm_bo_move_to_lru_tail(bo, NULL);
+       spin_unlock(&ttm_bo_glob.lru_lock);
+}
+
 /**
  * ttm_bo_unreserve
  *
@@ -678,9 +685,7 @@ static inline int ttm_bo_reserve_slowpath(struct ttm_buffer_object *bo,
  */
 static inline void ttm_bo_unreserve(struct ttm_buffer_object *bo)
 {
-       spin_lock(&ttm_bo_glob.lru_lock);
-       ttm_bo_move_to_lru_tail(bo, NULL);
-       spin_unlock(&ttm_bo_glob.lru_lock);
+       ttm_bo_move_to_lru_tail_unlocked(bo);
        dma_resv_unlock(bo->base.resv);
 }