Commit a0fe26d0 authored by Tetsuo Handa's avatar Tetsuo Handa Committed by Greg Kroah-Hartman

drm/ttm: Choose a pool to shrink correctly in ttm_dma_pool_shrink_scan().

commit 46c2df68f03a236b30808bba361f10900c88d95e upstream.

We can use "unsigned int" instead of "atomic_t" by updating start_pool
variable under _manager->lock. This patch will make it possible to avoid
skipping when choosing a pool to shrink in round-robin style, after next
patch changes mutex_lock(_manager->lock) to !mutex_trylock(_manager->lork).
Signed-off-by: default avatarTetsuo Handa <>
Signed-off-by: default avatarDave Airlie <>
Signed-off-by: default avatarGreg Kroah-Hartman <>
parent 0f90c9c0
......@@ -1006,9 +1006,9 @@ EXPORT_SYMBOL_GPL(ttm_dma_unpopulate);
static int ttm_dma_pool_mm_shrink(struct shrinker *shrink,
struct shrink_control *sc)
static atomic_t start_pool = ATOMIC_INIT(0);
static unsigned start_pool;
unsigned idx = 0;
unsigned pool_offset = atomic_add_return(1, &start_pool);
unsigned pool_offset;
unsigned shrink_pages = sc->nr_to_scan;
struct device_pools *p;
......@@ -1018,7 +1018,7 @@ static int ttm_dma_pool_mm_shrink(struct shrinker *shrink,
if (!_manager->npools)
goto out;
pool_offset = pool_offset % _manager->npools;
pool_offset = ++start_pool % _manager->npools;
list_for_each_entry(p, &_manager->pools, pools) {
unsigned nr_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