Lines Matching refs:alloc

228 static int ttm_pool_apply_caching(struct ttm_pool_alloc_state *alloc)  in ttm_pool_apply_caching()  argument
231 unsigned int num_pages = alloc->pages - alloc->caching_divide; in ttm_pool_apply_caching()
236 switch (alloc->tt_caching) { in ttm_pool_apply_caching()
240 return set_pages_array_wc(alloc->caching_divide, num_pages); in ttm_pool_apply_caching()
242 return set_pages_array_uc(alloc->caching_divide, num_pages); in ttm_pool_apply_caching()
245 alloc->caching_divide = alloc->pages; in ttm_pool_apply_caching()
495 struct ttm_pool_alloc_state *alloc, in ttm_pool_allocated_page_commit() argument
501 *alloc->pages++ = allocated++; in ttm_pool_allocated_page_commit()
503 alloc->remaining_pages -= nr; in ttm_pool_allocated_page_commit()
505 if (!alloc->dma_addr) in ttm_pool_allocated_page_commit()
509 *alloc->dma_addr++ = first_dma; in ttm_pool_allocated_page_commit()
521 struct ttm_pool_alloc_state *alloc) in ttm_pool_restore_commit() argument
525 struct page **first_page = alloc->pages; in ttm_pool_restore_commit()
570 dma_addr_t *dma_addr = alloc->dma_addr ? &restore->first_dma : NULL; in ttm_pool_restore_commit()
580 alloc, nr); in ttm_pool_restore_commit()
581 if (restore->page_caching == alloc->tt_caching || PageHighMem(restore->alloced_page)) in ttm_pool_restore_commit()
582 alloc->caching_divide = alloc->pages; in ttm_pool_restore_commit()
583 restore->snapshot_alloc = *alloc; in ttm_pool_restore_commit()
596 const struct ttm_pool_alloc_state *alloc) in ttm_pool_page_allocated_restore() argument
604 restore->snapshot_alloc = *alloc; in ttm_pool_page_allocated_restore()
616 struct ttm_pool_alloc_state *alloc, in ttm_pool_page_allocated() argument
623 caching_consistent = (page_caching == alloc->tt_caching) || PageHighMem(p); in ttm_pool_page_allocated()
626 r = ttm_pool_apply_caching(alloc); in ttm_pool_page_allocated()
631 if (alloc->dma_addr) { in ttm_pool_page_allocated()
639 first_dma, restore, alloc); in ttm_pool_page_allocated()
641 ttm_pool_allocated_page_commit(p, first_dma, alloc, 1UL << order); in ttm_pool_page_allocated()
644 alloc->caching_divide = alloc->pages; in ttm_pool_page_allocated()
690 struct ttm_pool_alloc_state *alloc) in ttm_pool_alloc_state_init() argument
692 alloc->pages = tt->pages; in ttm_pool_alloc_state_init()
693 alloc->caching_divide = tt->pages; in ttm_pool_alloc_state_init()
694 alloc->dma_addr = tt->dma_address; in ttm_pool_alloc_state_init()
695 alloc->remaining_pages = tt->num_pages; in ttm_pool_alloc_state_init()
696 alloc->tt_caching = tt->caching; in ttm_pool_alloc_state_init()
704 const struct ttm_pool_alloc_state *alloc) in ttm_pool_alloc_find_order() argument
706 return min_t(unsigned int, highest, __fls(alloc->remaining_pages)); in ttm_pool_alloc_find_order()
711 struct ttm_pool_alloc_state *alloc, in __ttm_pool_alloc() argument
722 WARN_ON(!alloc->remaining_pages || ttm_tt_is_populated(tt)); in __ttm_pool_alloc()
723 WARN_ON(alloc->dma_addr && !pool->dev); in __ttm_pool_alloc()
738 for (order = ttm_pool_alloc_find_order(MAX_PAGE_ORDER, alloc); in __ttm_pool_alloc()
739 alloc->remaining_pages; in __ttm_pool_alloc()
740 order = ttm_pool_alloc_find_order(order, alloc)) { in __ttm_pool_alloc()
770 r = ttm_pool_page_allocated(pool, order, p, page_caching, alloc, in __ttm_pool_alloc()
776 r = ttm_pool_restore_commit(restore, tt->backup, ctx, alloc); in __ttm_pool_alloc()
782 r = ttm_pool_apply_caching(alloc); in __ttm_pool_alloc()
798 caching_divide = alloc->caching_divide - tt->pages; in __ttm_pool_alloc()
801 tt->num_pages - alloc->remaining_pages); in __ttm_pool_alloc()
821 struct ttm_pool_alloc_state alloc; in ttm_pool_alloc() local
826 ttm_pool_alloc_state_init(tt, &alloc); in ttm_pool_alloc()
828 return __ttm_pool_alloc(pool, tt, ctx, &alloc, NULL); in ttm_pool_alloc()
849 struct ttm_pool_alloc_state alloc; in ttm_pool_restore_and_alloc() local
857 ttm_pool_alloc_state_init(tt, &alloc); in ttm_pool_restore_and_alloc()
865 restore->snapshot_alloc = alloc; in ttm_pool_restore_and_alloc()
871 alloc = restore->snapshot_alloc; in ttm_pool_restore_and_alloc()
874 ctx, &alloc); in ttm_pool_restore_and_alloc()
879 if (!alloc.remaining_pages) in ttm_pool_restore_and_alloc()
883 return __ttm_pool_alloc(pool, tt, ctx, &alloc, restore); in ttm_pool_restore_and_alloc()