Skip to content

Commit 4cce137

Browse files
author
Thomas Hellström
committed
drm/ttm: Move pinned objects off LRU lists when pinning
The ttm_bo_pin() and ttm_bo_unpin() functions weren't moving their resources off the LRU list to the unevictable list. Make sure that happens so that pinned objects don't accidently linger on the LRU lists, and also make sure to move them back once they are unpinned. v2: - Removing from a bulk move must be done with the pin-count still zero. v3: - ttm_resource_move_to_lru_tail must be done after pinning with a non- NULL resource (Intel CI). v6: - Use a TAB instead of space (checkpatch.pl error). Cc: Christian König <[email protected]> Cc: Matthew Brost <[email protected]> Cc: <[email protected]> Signed-off-by: Thomas Hellström <[email protected]> Reviewed-by: Christian König <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent fc5d966 commit 4cce137

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

drivers/gpu/drm/ttm/ttm_bo.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,8 @@ void ttm_bo_pin(struct ttm_buffer_object *bo)
594594
spin_lock(&bo->bdev->lru_lock);
595595
if (bo->resource)
596596
ttm_resource_del_bulk_move(bo->resource, bo);
597-
++bo->pin_count;
597+
if (!bo->pin_count++ && bo->resource)
598+
ttm_resource_move_to_lru_tail(bo->resource);
598599
spin_unlock(&bo->bdev->lru_lock);
599600
}
600601
EXPORT_SYMBOL(ttm_bo_pin);
@@ -613,9 +614,10 @@ void ttm_bo_unpin(struct ttm_buffer_object *bo)
613614
return;
614615

615616
spin_lock(&bo->bdev->lru_lock);
616-
--bo->pin_count;
617-
if (bo->resource)
617+
if (!--bo->pin_count && bo->resource) {
618618
ttm_resource_add_bulk_move(bo->resource, bo);
619+
ttm_resource_move_to_lru_tail(bo->resource);
620+
}
619621
spin_unlock(&bo->bdev->lru_lock);
620622
}
621623
EXPORT_SYMBOL(ttm_bo_unpin);

0 commit comments

Comments
 (0)