static void ttm_tt_free_alloced_pages(struct ttm_tt *ttm) { int i; struct page *cur_page; struct ttm_backend *be = ttm->be; if (be) be->func->clear(be); (void)ttm_tt_set_caching(ttm, tt_cached); for (i = 0; i < ttm->num_pages; ++i) { cur_page = ttm->pages[i]; ttm->pages[i] = NULL; if (cur_page) { if (page_count(cur_page) != 1) printk(KERN_ERR TTM_PFX "Erroneous page count. " "Leaking pages.\n"); ttm_mem_global_free_page(ttm->glob->mem_glob, cur_page); __free_page(cur_page); } } ttm->state = tt_unpopulated; ttm->first_himem_page = ttm->num_pages; ttm->last_lomem_page = -1; }
int ttm_tt_set_placement_caching(struct ttm_tt *ttm, uint32_t placement) { enum ttm_caching_state state; if (placement & TTM_PL_FLAG_WC) state = tt_wc; else if (placement & TTM_PL_FLAG_UNCACHED) state = tt_uncached; else state = tt_cached; return ttm_tt_set_caching(ttm, state); }
static void ttm_tt_free_alloced_pages(struct ttm_tt *ttm) { int i; struct page *cur_page; struct ttm_backend *be = ttm->be; void *addr; if (be) be->func->clear(be); (void)ttm_tt_set_caching(ttm, tt_cached); for (i = 0; i < ttm->num_pages; ++i) { cur_page = ttm->pages[i]; ttm->pages[i] = NULL; if (cur_page) { if (page_count(cur_page) != 1) printk(KERN_ERR TTM_PFX "Erroneous page count. " "Leaking pages.\n"); ttm_mem_global_free_page(ttm->glob->mem_glob, cur_page); if ((ttm->page_flags & TTM_PAGE_FLAG_DMA32) && xen_pv_domain()) { addr = page_address(cur_page); WARN_ON(!addr); if (addr) dma_free_coherent(NULL, PAGE_SIZE, addr, virt_to_bus(addr)); } else __free_page(cur_page); } } ttm->state = tt_unpopulated; ttm->first_himem_page = ttm->num_pages; ttm->last_lomem_page = -1; }