Skip to content

Commit e930888

Browse files
Jérôme Glisseairlied
authored andcommitted
drm/ttm: improve uncached page deallocation.
Calls to set_memory_wb() incure heavy TLB flush and IPI cost. To minimize those wait until pool grow beyond batch size before draining the pool. Signed-off-by: Jérôme Glisse <[email protected]> Reviewed-by: Mario Kleiner <[email protected]> Reviewed-and-Tested-by: Michel Dänzer <[email protected]> Reviewed-by: Konrad Rzeszutek Wilk <[email protected]> Cc: Thomas Hellstrom <[email protected]> Reviewed-by: Alex Deucher <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
1 parent ef2b731 commit e930888

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

drivers/gpu/drm/ttm/ttm_page_alloc_dma.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -963,13 +963,13 @@ void ttm_dma_unpopulate(struct ttm_dma_tt *ttm_dma, struct device *dev)
963963
} else {
964964
pool->npages_free += count;
965965
list_splice(&ttm_dma->pages_list, &pool->free_list);
966-
if (pool->npages_free > _manager->options.max_size) {
966+
/*
967+
* Wait to have at at least NUM_PAGES_TO_ALLOC number of pages
968+
* to free in order to minimize calls to set_memory_wb().
969+
*/
970+
if (pool->npages_free >= (_manager->options.max_size +
971+
NUM_PAGES_TO_ALLOC))
967972
npages = pool->npages_free - _manager->options.max_size;
968-
/* free at least NUM_PAGES_TO_ALLOC number of pages
969-
* to reduce calls to set_memory_wb */
970-
if (npages < NUM_PAGES_TO_ALLOC)
971-
npages = NUM_PAGES_TO_ALLOC;
972-
}
973973
}
974974
spin_unlock_irqrestore(&pool->lock, irq_flags);
975975

0 commit comments

Comments
 (0)