Commit 444f8ef3 authored by Roger He's avatar Roger He Committed by Alex Deucher

drm/ttm: add page order support in ttm_pages_put

Reviewed-by: default avatarChunming Zhou <david1.zhou@amd.com>
Reviewed-by: default avatarChristian König <christian.koenig@amd.com>
Signed-off-by: default avatarRoger He <Hongbo.He@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 154683dd
...@@ -296,13 +296,23 @@ static struct ttm_page_pool *ttm_get_pool(int flags, bool huge, ...@@ -296,13 +296,23 @@ static struct ttm_page_pool *ttm_get_pool(int flags, bool huge,
} }
/* set memory back to wb and free the pages. */ /* set memory back to wb and free the pages. */
static void ttm_pages_put(struct page *pages[], unsigned npages) static void ttm_pages_put(struct page *pages[], unsigned npages,
unsigned int order)
{ {
unsigned i; unsigned int i, pages_nr = (1 << order);
if (order == 0) {
if (set_pages_array_wb(pages, npages)) if (set_pages_array_wb(pages, npages))
pr_err("Failed to set %d pages to wb!\n", npages); pr_err("Failed to set %d pages to wb!\n", npages);
for (i = 0; i < npages; ++i) }
__free_page(pages[i]);
for (i = 0; i < npages; ++i) {
if (order > 0) {
if (set_pages_wb(pages[i], pages_nr))
pr_err("Failed to set %d pages to wb!\n", pages_nr);
}
__free_pages(pages[i], order);
}
} }
static void ttm_pool_update_free_locked(struct ttm_page_pool *pool, static void ttm_pool_update_free_locked(struct ttm_page_pool *pool,
...@@ -365,7 +375,7 @@ static int ttm_page_pool_free(struct ttm_page_pool *pool, unsigned nr_free, ...@@ -365,7 +375,7 @@ static int ttm_page_pool_free(struct ttm_page_pool *pool, unsigned nr_free,
*/ */
spin_unlock_irqrestore(&pool->lock, irq_flags); spin_unlock_irqrestore(&pool->lock, irq_flags);
ttm_pages_put(pages_to_free, freed_pages); ttm_pages_put(pages_to_free, freed_pages, pool->order);
if (likely(nr_free != FREE_ALL_PAGES)) if (likely(nr_free != FREE_ALL_PAGES))
nr_free -= freed_pages; nr_free -= freed_pages;
...@@ -400,7 +410,7 @@ static int ttm_page_pool_free(struct ttm_page_pool *pool, unsigned nr_free, ...@@ -400,7 +410,7 @@ static int ttm_page_pool_free(struct ttm_page_pool *pool, unsigned nr_free,
spin_unlock_irqrestore(&pool->lock, irq_flags); spin_unlock_irqrestore(&pool->lock, irq_flags);
if (freed_pages) if (freed_pages)
ttm_pages_put(pages_to_free, freed_pages); ttm_pages_put(pages_to_free, freed_pages, pool->order);
out: out:
if (pages_to_free != static_buf) if (pages_to_free != static_buf)
kfree(pages_to_free); kfree(pages_to_free);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment