iommu/io-pgtable-armv7s: Fix kmem_cache_alloc() flags
Subsystems (2)
Robin Murphy
reviewerPATCH 1/1 iommu/io-pgtable-armv7s: Fix kmem_cache_alloc() flags
Whilst the default SLUB allocator happily just merges the original allocation flags from kmem_cache_create() with those passed through kmem_cache_alloc(), there is a code path in the SLAB allocator which will aggressively BUG_ON() if the cache was created with SLAB_CACHE_DMA but GFP_DMA is not specified for an allocation.
Keep the peace by adding GFP_DMA when allocating a table.
--- drivers/iommu/io-pgtable-arm-v7s.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iommu/io-pgtable-arm-v7s.c +1 -1
@@ -192,7 +192,7 @@ static void *__arm_v7s_alloc_table(int lvl, gfp_t gfp,if (lvl ==1 ) table = (void *)__get_dma_pages (__GFP_ZERO,get_order (size));else if (lvl ==2 ) - table =kmem_cache_zalloc (data->l2_tables, gfp); + table =kmem_cache_zalloc (data->l2_tables, gfp |GFP_DMA );if (table && !selftest_running) { dma =dma_map_single (dev, table, size,DMA_TO_DEVICE );if (dma_mapping_error (dev, dma))
Signature · 1 line
2.7.2.333.g70bd996.dirty
PATCH 1/1 iommu/io-pgtable-armv7s: Fix kmem_cache_alloc() flags
Quoted 5 lines · Robin Murphy
Whilst the default SLUB allocator happily just merges the original allocation flags from
kmem_cache_create()with those passed throughkmem_cache_alloc(), there is a code path in the SLAB allocator which will aggressivelyBUG_ON()if the cache was created withSLAB_CACHE_DMAbutGFP_DMAis not specified for an allocation.
It would be nice to include the backtrace here.
Quoted 13 lines
Keep the peace by adding
GFP_DMAwhen allocating a table.Reported-by Geert Uytterhoeven <[email protected]>Signed-off-by Robin Murphy <[email protected]>--- drivers/iommu/io-pgtable-arm-v7s.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/iommu/io-pgtable-arm-v7s.c +0
-0
drivers/iommu/io-pgtable-arm-v7s.c static void *__arm_v7s_alloc_table(int lvl, gfp_t gfp, · line 198
Quoted 8 lines
drivers/iommu/io-pgtable-arm-v7s.c +1
-1@@ -192,7 +192,7 @@ static void *__arm_v7s_alloc_table(int lvl, gfp_t gfp,if (lvl ==1 ) table = (void *)__get_dma_pages (__GFP_ZERO,get_order (size));else if (lvl ==2 ) - table =kmem_cache_zalloc (data->l2_tables, gfp); + table =kmem_cache_zalloc (data->l2_tables, gfp |GFP_DMA );if (table && !selftest_running) { dma =dma_map_single (dev, table, size,DMA_TO_DEVICE );if (dma_mapping_error (dev, dma))
Will