Lines Matching refs:pt
225 static void ttm_pool_type_give(struct ttm_pool_type *pt, struct page *p) in ttm_pool_type_give() argument
227 unsigned int i, num_pages = 1 << pt->order; in ttm_pool_type_give()
236 spin_lock(&pt->lock); in ttm_pool_type_give()
237 list_add(&p->lru, &pt->pages); in ttm_pool_type_give()
238 spin_unlock(&pt->lock); in ttm_pool_type_give()
239 atomic_long_add(1 << pt->order, &allocated_pages); in ttm_pool_type_give()
243 static struct page *ttm_pool_type_take(struct ttm_pool_type *pt) in ttm_pool_type_take() argument
247 spin_lock(&pt->lock); in ttm_pool_type_take()
248 p = list_first_entry_or_null(&pt->pages, typeof(*p), lru); in ttm_pool_type_take()
250 atomic_long_sub(1 << pt->order, &allocated_pages); in ttm_pool_type_take()
253 spin_unlock(&pt->lock); in ttm_pool_type_take()
259 static void ttm_pool_type_init(struct ttm_pool_type *pt, struct ttm_pool *pool, in ttm_pool_type_init() argument
262 pt->pool = pool; in ttm_pool_type_init()
263 pt->caching = caching; in ttm_pool_type_init()
264 pt->order = order; in ttm_pool_type_init()
265 spin_lock_init(&pt->lock); in ttm_pool_type_init()
266 INIT_LIST_HEAD(&pt->pages); in ttm_pool_type_init()
269 list_add_tail(&pt->shrinker_list, &shrinker_list); in ttm_pool_type_init()
274 static void ttm_pool_type_fini(struct ttm_pool_type *pt) in ttm_pool_type_fini() argument
279 list_del(&pt->shrinker_list); in ttm_pool_type_fini()
282 while ((p = ttm_pool_type_take(pt))) in ttm_pool_type_fini()
283 ttm_pool_free_page(pt->pool, pt->caching, pt->order, p); in ttm_pool_type_fini()
323 struct ttm_pool_type *pt; in ttm_pool_shrink() local
329 pt = list_first_entry(&shrinker_list, typeof(*pt), shrinker_list); in ttm_pool_shrink()
330 list_move_tail(&pt->shrinker_list, &shrinker_list); in ttm_pool_shrink()
333 p = ttm_pool_type_take(pt); in ttm_pool_shrink()
335 ttm_pool_free_page(pt->pool, pt->caching, pt->order, p); in ttm_pool_shrink()
336 num_pages = 1 << pt->order; in ttm_pool_shrink()
401 struct ttm_pool_type *pt = NULL; in ttm_pool_free_range() local
408 pt = ttm_pool_select_type(pool, caching, order); in ttm_pool_free_range()
409 if (pt) in ttm_pool_free_range()
410 ttm_pool_type_give(pt, *pages); in ttm_pool_free_range()
459 struct ttm_pool_type *pt; in ttm_pool_alloc() local
462 pt = ttm_pool_select_type(pool, tt->caching, order); in ttm_pool_alloc()
463 p = pt ? ttm_pool_type_take(pt) : NULL; in ttm_pool_alloc()
483 p = ttm_pool_type_take(pt); in ttm_pool_alloc()
577 struct ttm_pool_type *pt; in ttm_pool_init() local
580 pt = ttm_pool_select_type(pool, i, j); in ttm_pool_init()
581 if (pt != &pool->caching[i].orders[j]) in ttm_pool_init()
584 ttm_pool_type_init(pt, pool, i, j); in ttm_pool_init()
616 struct ttm_pool_type *pt; in ttm_pool_fini() local
618 pt = ttm_pool_select_type(pool, i, j); in ttm_pool_fini()
619 if (pt != &pool->caching[i].orders[j]) in ttm_pool_fini()
622 ttm_pool_type_fini(pt); in ttm_pool_fini()
657 static unsigned int ttm_pool_type_count(struct ttm_pool_type *pt) in ttm_pool_type_count() argument
662 spin_lock(&pt->lock); in ttm_pool_type_count()
664 list_for_each_entry(p, &pt->pages, lru) in ttm_pool_type_count()
666 spin_unlock(&pt->lock); in ttm_pool_type_count()
683 static void ttm_pool_debugfs_orders(struct ttm_pool_type *pt, in ttm_pool_debugfs_orders() argument
689 seq_printf(m, " %8u", ttm_pool_type_count(&pt[i])); in ttm_pool_debugfs_orders()