mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-28 11:18:45 +07:00
drm/ttm: allocate/free multiple pages in a single call
Totally surprisingly this is more efficient than doing it page by page. Signed-off-by: Christian König <christian.koenig@amd.com> Acked-by: Felix Kuehling <Felix.Kuehling@amd.com> Acked-by: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
This commit is contained in:
parent
a05502e5cf
commit
c6e839a3e2
@ -873,15 +873,14 @@ int ttm_pool_populate(struct ttm_tt *ttm)
|
|||||||
if (ttm->state != tt_unpopulated)
|
if (ttm->state != tt_unpopulated)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
for (i = 0; i < ttm->num_pages; ++i) {
|
ret = ttm_get_pages(ttm->pages, ttm->num_pages, ttm->page_flags,
|
||||||
ret = ttm_get_pages(&ttm->pages[i], 1,
|
|
||||||
ttm->page_flags,
|
|
||||||
ttm->caching_state);
|
ttm->caching_state);
|
||||||
if (ret != 0) {
|
if (unlikely(ret != 0)) {
|
||||||
ttm_pool_unpopulate(ttm);
|
ttm_pool_unpopulate(ttm);
|
||||||
return -ENOMEM;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < ttm->num_pages; ++i) {
|
||||||
ret = ttm_mem_global_alloc_page(mem_glob, ttm->pages[i],
|
ret = ttm_mem_global_alloc_page(mem_glob, ttm->pages[i],
|
||||||
PAGE_SIZE);
|
PAGE_SIZE);
|
||||||
if (unlikely(ret != 0)) {
|
if (unlikely(ret != 0)) {
|
||||||
@ -908,14 +907,14 @@ void ttm_pool_unpopulate(struct ttm_tt *ttm)
|
|||||||
unsigned i;
|
unsigned i;
|
||||||
|
|
||||||
for (i = 0; i < ttm->num_pages; ++i) {
|
for (i = 0; i < ttm->num_pages; ++i) {
|
||||||
if (ttm->pages[i]) {
|
if (!ttm->pages[i])
|
||||||
ttm_mem_global_free_page(ttm->glob->mem_glob,
|
continue;
|
||||||
ttm->pages[i], PAGE_SIZE);
|
|
||||||
ttm_put_pages(&ttm->pages[i], 1,
|
ttm_mem_global_free_page(ttm->glob->mem_glob, ttm->pages[i],
|
||||||
ttm->page_flags,
|
PAGE_SIZE);
|
||||||
|
}
|
||||||
|
ttm_put_pages(ttm->pages, ttm->num_pages, ttm->page_flags,
|
||||||
ttm->caching_state);
|
ttm->caching_state);
|
||||||
}
|
|
||||||
}
|
|
||||||
ttm->state = tt_unpopulated;
|
ttm->state = tt_unpopulated;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(ttm_pool_unpopulate);
|
EXPORT_SYMBOL(ttm_pool_unpopulate);
|
||||||
|
Loading…
Reference in New Issue
Block a user