diff options
author | Christian König | 2016-04-06 11:12:07 +0200 |
---|---|---|
committer | Alex Deucher | 2016-05-04 20:21:38 -0400 |
commit | 98c2872ae99bb7c9e8e4369cf48154f41dd6a109 (patch) | |
tree | fdbcd77633df61e070604aa07dcb002cefe0dfd8 /drivers/gpu/drm/ttm | |
parent | c3ea576e0583bb0537cdd66b704e49d380427721 (diff) |
drm/ttm: implement LRU add callbacks v2
This allows fine grained control for the driver where to add a BO into the LRU.
v2: fix typo in comment
Reviewed-by: Sinclair Yeh <syeh@vmware.com>
Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/ttm')
-rw-r--r-- | drivers/gpu/drm/ttm/ttm_bo.c | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c index 309a72ee7fb4..301e2371c34f 100644 --- a/drivers/gpu/drm/ttm/ttm_bo.c +++ b/drivers/gpu/drm/ttm/ttm_bo.c @@ -164,7 +164,6 @@ static void ttm_bo_release_list(struct kref *list_kref) void ttm_bo_add_to_lru(struct ttm_buffer_object *bo) { struct ttm_bo_device *bdev = bo->bdev; - struct ttm_mem_type_manager *man; lockdep_assert_held(&bo->resv->lock.base); @@ -172,12 +171,11 @@ void ttm_bo_add_to_lru(struct ttm_buffer_object *bo) BUG_ON(!list_empty(&bo->lru)); - man = &bdev->man[bo->mem.mem_type]; - list_add_tail(&bo->lru, &man->lru); + list_add(&bo->lru, bdev->driver->lru_tail(bo)); kref_get(&bo->list_kref); if (bo->ttm && !(bo->ttm->page_flags & TTM_PAGE_FLAG_SG)) { - list_add_tail(&bo->swap, &bo->glob->swap_lru); + list_add(&bo->swap, bdev->driver->swap_lru_tail(bo)); kref_get(&bo->list_kref); } } @@ -230,7 +228,6 @@ EXPORT_SYMBOL(ttm_bo_del_sub_from_lru); void ttm_bo_move_to_lru_tail(struct ttm_buffer_object *bo) { struct ttm_bo_device *bdev = bo->bdev; - struct ttm_mem_type_manager *man; lockdep_assert_held(&bo->resv->lock.base); @@ -242,15 +239,29 @@ void ttm_bo_move_to_lru_tail(struct ttm_buffer_object *bo) list_del_init(&bo->lru); } else { - if (bo->ttm && !(bo->ttm->page_flags & TTM_PAGE_FLAG_SG)) - list_move_tail(&bo->swap, &bo->glob->swap_lru); + if (bo->ttm && !(bo->ttm->page_flags & TTM_PAGE_FLAG_SG)) { + list_del(&bo->swap); + list_add(&bo->swap, bdev->driver->swap_lru_tail(bo)); + } - man = &bdev->man[bo->mem.mem_type]; - list_move_tail(&bo->lru, &man->lru); + list_del(&bo->lru); + list_add(&bo->lru, bdev->driver->lru_tail(bo)); } } EXPORT_SYMBOL(ttm_bo_move_to_lru_tail); +struct list_head *ttm_bo_default_lru_tail(struct ttm_buffer_object *bo) +{ + return bo->bdev->man[bo->mem.mem_type].lru.prev; +} +EXPORT_SYMBOL(ttm_bo_default_lru_tail); + +struct list_head *ttm_bo_default_swap_lru_tail(struct ttm_buffer_object *bo) +{ + return bo->glob->swap_lru.prev; +} +EXPORT_SYMBOL(ttm_bo_default_swap_lru_tail); + /* * Call bo->mutex locked. */ |