diff options
| author | Christian König <christian.koenig@amd.com> | 2016-04-06 05:12:07 -0400 |
|---|---|---|
| committer | Alex Deucher <alexander.deucher@amd.com> | 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) | |||
| 164 | void ttm_bo_add_to_lru(struct ttm_buffer_object *bo) | 164 | void ttm_bo_add_to_lru(struct ttm_buffer_object *bo) |
| 165 | { | 165 | { |
| 166 | struct ttm_bo_device *bdev = bo->bdev; | 166 | struct ttm_bo_device *bdev = bo->bdev; |
| 167 | struct ttm_mem_type_manager *man; | ||
| 168 | 167 | ||
| 169 | lockdep_assert_held(&bo->resv->lock.base); | 168 | lockdep_assert_held(&bo->resv->lock.base); |
| 170 | 169 | ||
| @@ -172,12 +171,11 @@ void ttm_bo_add_to_lru(struct ttm_buffer_object *bo) | |||
| 172 | 171 | ||
| 173 | BUG_ON(!list_empty(&bo->lru)); | 172 | BUG_ON(!list_empty(&bo->lru)); |
| 174 | 173 | ||
| 175 | man = &bdev->man[bo->mem.mem_type]; | 174 | list_add(&bo->lru, bdev->driver->lru_tail(bo)); |
| 176 | list_add_tail(&bo->lru, &man->lru); | ||
| 177 | kref_get(&bo->list_kref); | 175 | kref_get(&bo->list_kref); |
| 178 | 176 | ||
| 179 | if (bo->ttm && !(bo->ttm->page_flags & TTM_PAGE_FLAG_SG)) { | 177 | if (bo->ttm && !(bo->ttm->page_flags & TTM_PAGE_FLAG_SG)) { |
| 180 | list_add_tail(&bo->swap, &bo->glob->swap_lru); | 178 | list_add(&bo->swap, bdev->driver->swap_lru_tail(bo)); |
| 181 | kref_get(&bo->list_kref); | 179 | kref_get(&bo->list_kref); |
| 182 | } | 180 | } |
| 183 | } | 181 | } |
| @@ -230,7 +228,6 @@ EXPORT_SYMBOL(ttm_bo_del_sub_from_lru); | |||
| 230 | void ttm_bo_move_to_lru_tail(struct ttm_buffer_object *bo) | 228 | void ttm_bo_move_to_lru_tail(struct ttm_buffer_object *bo) |
| 231 | { | 229 | { |
| 232 | struct ttm_bo_device *bdev = bo->bdev; | 230 | struct ttm_bo_device *bdev = bo->bdev; |
| 233 | struct ttm_mem_type_manager *man; | ||
| 234 | 231 | ||
| 235 | lockdep_assert_held(&bo->resv->lock.base); | 232 | lockdep_assert_held(&bo->resv->lock.base); |
| 236 | 233 | ||
| @@ -242,15 +239,29 @@ void ttm_bo_move_to_lru_tail(struct ttm_buffer_object *bo) | |||
| 242 | list_del_init(&bo->lru); | 239 | list_del_init(&bo->lru); |
| 243 | 240 | ||
| 244 | } else { | 241 | } else { |
| 245 | if (bo->ttm && !(bo->ttm->page_flags & TTM_PAGE_FLAG_SG)) | 242 | if (bo->ttm && !(bo->ttm->page_flags & TTM_PAGE_FLAG_SG)) { |
| 246 | list_move_tail(&bo->swap, &bo->glob->swap_lru); | 243 | list_del(&bo->swap); |
| 244 | list_add(&bo->swap, bdev->driver->swap_lru_tail(bo)); | ||
| 245 | } | ||
| 247 | 246 | ||
| 248 | man = &bdev->man[bo->mem.mem_type]; | 247 | list_del(&bo->lru); |
| 249 | list_move_tail(&bo->lru, &man->lru); | 248 | list_add(&bo->lru, bdev->driver->lru_tail(bo)); |
| 250 | } | 249 | } |
| 251 | } | 250 | } |
| 252 | EXPORT_SYMBOL(ttm_bo_move_to_lru_tail); | 251 | EXPORT_SYMBOL(ttm_bo_move_to_lru_tail); |
| 253 | 252 | ||
| 253 | struct list_head *ttm_bo_default_lru_tail(struct ttm_buffer_object *bo) | ||
| 254 | { | ||
| 255 | return bo->bdev->man[bo->mem.mem_type].lru.prev; | ||
| 256 | } | ||
| 257 | EXPORT_SYMBOL(ttm_bo_default_lru_tail); | ||
| 258 | |||
| 259 | struct list_head *ttm_bo_default_swap_lru_tail(struct ttm_buffer_object *bo) | ||
| 260 | { | ||
| 261 | return bo->glob->swap_lru.prev; | ||
| 262 | } | ||
| 263 | EXPORT_SYMBOL(ttm_bo_default_swap_lru_tail); | ||
| 264 | |||
| 254 | /* | 265 | /* |
| 255 | * Call bo->mutex locked. | 266 | * Call bo->mutex locked. |
| 256 | */ | 267 | */ |
