Skip to content

Commit 0678c15

Browse files
Zhaoyu LiuChristianKoenigAMD
authored andcommitted
drm/ttm: use ttm_resource_unevictable() to replace pin_count and swapped
TTM always uses pin_count and ttm_resource_is_swapped() together to determine whether a BO is unevictable. Now use ttm_resource_unevictable() to replace them. Signed-off-by: Zhaoyu Liu <liuzhaoyu.zackary@bytedance.com> Reviewed-by: Christian König <christian.koenig@amd.com> Link: https://patchwork.freedesktop.org/patch/msgid/20250126093256.GA688734@bytedance Signed-off-by: Christian König <christian.koenig@amd.com>
1 parent 011529f commit 0678c15

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

drivers/gpu/drm/ttm/ttm_resource.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -269,19 +269,24 @@ static bool ttm_resource_is_swapped(struct ttm_resource *res, struct ttm_buffer_
269269
return ttm_tt_is_swapped(bo->ttm);
270270
}
271271

272+
static bool ttm_resource_unevictable(struct ttm_resource *res, struct ttm_buffer_object *bo)
273+
{
274+
return bo->pin_count || ttm_resource_is_swapped(res, bo);
275+
}
276+
272277
/* Add the resource to a bulk move if the BO is configured for it */
273278
void ttm_resource_add_bulk_move(struct ttm_resource *res,
274279
struct ttm_buffer_object *bo)
275280
{
276-
if (bo->bulk_move && !bo->pin_count && !ttm_resource_is_swapped(res, bo))
281+
if (bo->bulk_move && !ttm_resource_unevictable(res, bo))
277282
ttm_lru_bulk_move_add(bo->bulk_move, res);
278283
}
279284

280285
/* Remove the resource from a bulk move if the BO is configured for it */
281286
void ttm_resource_del_bulk_move(struct ttm_resource *res,
282287
struct ttm_buffer_object *bo)
283288
{
284-
if (bo->bulk_move && !bo->pin_count && !ttm_resource_is_swapped(res, bo))
289+
if (bo->bulk_move && !ttm_resource_unevictable(res, bo))
285290
ttm_lru_bulk_move_del(bo->bulk_move, res);
286291
}
287292

@@ -293,10 +298,10 @@ void ttm_resource_move_to_lru_tail(struct ttm_resource *res)
293298

294299
lockdep_assert_held(&bo->bdev->lru_lock);
295300

296-
if (bo->pin_count || ttm_resource_is_swapped(res, bo)) {
301+
if (ttm_resource_unevictable(res, bo)) {
297302
list_move_tail(&res->lru.link, &bdev->unevictable);
298303

299-
} else if (bo->bulk_move) {
304+
} else if (bo->bulk_move) {
300305
struct ttm_lru_bulk_move_pos *pos =
301306
ttm_lru_bulk_move_pos(bo->bulk_move, res);
302307

@@ -335,7 +340,7 @@ void ttm_resource_init(struct ttm_buffer_object *bo,
335340

336341
man = ttm_manager_type(bo->bdev, place->mem_type);
337342
spin_lock(&bo->bdev->lru_lock);
338-
if (bo->pin_count || ttm_resource_is_swapped(res, bo))
343+
if (ttm_resource_unevictable(res, bo))
339344
list_add_tail(&res->lru.link, &bo->bdev->unevictable);
340345
else
341346
list_add_tail(&res->lru.link, &man->lru[bo->priority]);

0 commit comments

Comments
 (0)