Skip to contentSkip to conversation

dma/pool: respect __GFP_NOWARN in dma_alloc_from_pool()

PATCH Superseded Sai Sree Kartheek Adivi 2 participants 2 messages Jan 11 – Jan 12 DMA mapping helpers

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dma/pool: respect __GFP_NOWARN in dma_alloc_from_pool()

Currently, dma_alloc_from_pool() unconditionally warns and dumps a stack trace when an allocation fails.

This prevents callers from using the __GFP_NOWARN flag to suppress error messages, breaking the expectation that this flag will silence allocation failure logs.

Align dma_pool behaviour with other core allocators by checking for __GFP_NOWARN before issuing the warning.

Fixes 9420139f516d ("dma-pool: fix coherent pool allocations for IOMMU mappings")
---
 kernel/dma/pool.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/dma/pool.c +2 -1
index 26392badc36b..40dc2ab9915f 100644
@@ -276,7 +276,8 @@ struct page *dma_alloc_from_pool(struct device *dev, size_t size,
 			return page;
 	}
 
-	WARN(1, "Failed to get suitable pool for %s\n", dev_name(dev));
+	if (!(gfp & __GFP_NOWARN))
+		WARN(1, "Failed to get suitable pool for %s\n", dev_name(dev));
 	return NULL;
 }
 
Signature · 1 line
2.34.1
#1 lore raw
Quoted 21 lines · Sai Sree Kartheek Adivi

Currently, dma_alloc_from_pool() unconditionally warns and dumps a stack trace when an allocation fails.

This prevents callers from using the __GFP_NOWARN flag to suppress error messages, breaking the expectation that this flag will silence allocation failure logs.

Align dma_pool behaviour with other core allocators by checking for __GFP_NOWARN before issuing the warning.

Fixes 9420139f516d ("dma-pool: fix coherent pool allocations for IOMMU mappings")
---
 kernel/dma/pool.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/dma/pool.c +0 -0
index 26392badc36b..40dc2ab9915f 100644

kernel/dma/pool.c struct page *dma_alloc_from_pool(struct device *dev, size_t size, · line 280

Quoted 6 lines
kernel/dma/pool.c +2 -1
@@ -276,7 +276,8 @@ struct page *dma_alloc_from_pool(struct device *dev, size_t size,
 			return page;
 	}
 
-	WARN(1, "Failed to get suitable pool for %s\n", dev_name(dev));
+	if (!(gfp & __GFP_NOWARN))
+		WARN(1, "Failed to get suitable pool for %s\n", dev_name(dev));

WARN(!(gfp & __GFP_NOWARN), "Failed to get suitable pool for %s\n", dev_name(dev));

Thanks

Quoted 7 lines
kernel/dma/pool.c +0 -0
 	return NULL;
 }
 
Signature · 1 line
2.34.1