FreeBSD/sys/dev/drm2/ttm/ttm_page_alloc.c
/**
 * Cut 'count' number of pages from the pool and put them on the return list.
 *
 * @return count of pages still required to fulfill the request.
 */
Cut 'count' number of pages from the pool and put them on the return list.
@return count of pages still required to fulfill the request.
Cut ' count ' number of pages from the pool and put them on the return list . @return count of pages still required to fulfill the request .
static unsigned ttm_page_pool_get_pages(struct ttm_page_pool *pool,
					struct pglist *pages,
					int ttm_flags,
					enum ttm_caching_state cstate,
					unsigned count)
{
	vm_page_t p;
	unsigned i;
	mtx_lock(&pool->lock);
	ttm_page_pool_fill_locked(pool, ttm_flags, cstate, count);
	if (count >= pool->npages) {
		TAILQ_CONCAT(pages, &pool->list, plinks.q);
		count -= pool->npages;
		pool->npages = 0;
		goto out;
	}
	for (i = 0; i < count; i++) {
		p = TAILQ_FIRST(&pool->list);
		TAILQ_REMOVE(&pool->list, p, plinks.q);
		TAILQ_INSERT_TAIL(pages, p, plinks.q);
	}
	pool->npages -= count;
	count = 0;
out:
	mtx_unlock(&pool->lock);
	return count;
}
static unsigned ttm_page_pool_get_pages ( struct ttm_page_pool * pool , struct pglist * pages , int ttm_flags , enum ttm_caching_state cstate , unsigned count ) { vm_page_t p ; unsigned i ; mtx_lock ( & pool -> lock ) ; ttm_page_pool_fill_locked ( pool , ttm_flags , cstate , count ) ; if ( count >= pool -> npages ) { TAILQ_CONCAT ( pages , & pool -> list , plinks . q ) ; count -= pool -> npages ; pool -> npages = 0 ; goto out ; } for ( i = 0 ; i < count ; i ++ ) { p = TAILQ_FIRST ( & pool -> list ) ; TAILQ_REMOVE ( & pool -> list , p , plinks . q ) ; TAILQ_INSERT_TAIL ( pages , p , plinks . q ) ; } pool -> npages -= count ; count = 0 ; out : mtx_unlock ( & pool -> lock ) ; return count ; }
Cut 'count' number of pages from the pool and put them on the return list.
Cut ' count ' number of pages from the pool and put them on the return list .
/* take all pages from the pool */