Skip to content

Commit fc5590f

Browse files
LeoBrasmpe
authored andcommitted
powerpc/kernel/iommu: Use largepool as a last resort when !largealloc
As of today, doing iommu_range_alloc() only for !largealloc (npages <= 15) will only be able to use 3/4 of the available pages, given pages on largepool not being available for !largealloc. This could mean some drivers not being able to fully use all the available pages for the DMA window. Add pages on largepool as a last resort for !largealloc, making all pages of the DMA window available. Signed-off-by: Leonardo Bras <[email protected]> Reviewed-by: Alexey Kardashevskiy <[email protected]> Signed-off-by: Michael Ellerman <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 3c0468d commit fc5590f

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

arch/powerpc/kernel/iommu.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,15 @@ static unsigned long iommu_range_alloc(struct device *dev,
296296
pass++;
297297
goto again;
298298

299+
} else if (pass == tbl->nr_pools + 1) {
300+
/* Last resort: try largepool */
301+
spin_unlock(&pool->lock);
302+
pool = &tbl->large_pool;
303+
spin_lock(&pool->lock);
304+
pool->hint = pool->start;
305+
pass++;
306+
goto again;
307+
299308
} else {
300309
/* Give up */
301310
spin_unlock_irqrestore(&(pool->lock), flags);

0 commit comments

Comments
 (0)