linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm/dmapool.c: avoid duplicate memset within dma_pool_alloc
@ 2022-07-14  3:25 Liu Song
  2022-07-17  1:01 ` Andrew Morton
  0 siblings, 1 reply; 4+ messages in thread
From: Liu Song @ 2022-07-14  3:25 UTC (permalink / raw)
  To: akpm; +Cc: linux-mm, linux-kernel

From: Liu Song <liusong@linux.alibaba.com>

In "dma_direct_alloc", the allocated memory is explicitly set to 0.
If use direct alloc, we need to avoid possible duplicate memset in
dma_pool_alloc.

Signed-off-by: Liu Song <liusong@linux.alibaba.com>
---
 mm/dmapool.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/mm/dmapool.c b/mm/dmapool.c
index a7eb5d0..94f4859 100644
--- a/mm/dmapool.c
+++ b/mm/dmapool.c
@@ -21,6 +21,7 @@
 
 #include <linux/device.h>
 #include <linux/dma-mapping.h>
+#include <linux/dma-map-ops.h>
 #include <linux/dmapool.h>
 #include <linux/kernel.h>
 #include <linux/list.h>
@@ -372,7 +373,7 @@ void *dma_pool_alloc(struct dma_pool *pool, gfp_t mem_flags,
 #endif
 	spin_unlock_irqrestore(&pool->lock, flags);
 
-	if (want_init_on_alloc(mem_flags))
+	if (want_init_on_alloc(mem_flags) && get_dma_ops(pool->dev))
 		memset(retval, 0, pool->size);
 
 	return retval;
-- 
1.8.3.1



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-07-18  2:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-14  3:25 [PATCH] mm/dmapool.c: avoid duplicate memset within dma_pool_alloc Liu Song
2022-07-17  1:01 ` Andrew Morton
2022-07-17 16:42   ` liusong
2022-07-18  2:07     ` liusong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox