[PATCH 4.2.y-ckt 02/64] mm: add dma_pool_zalloc() call to DMA API

Kamal Mostafa kamal at canonical.com
Thu Feb 4 22:43:45 UTC 2016


4.2.8-ckt4 -stable review patch.  If anyone has any objections, please let me know.

---8<------------------------------------------------------------

From: "Sean O. Stalley" <sean.stalley at intel.com>

commit ad82362b2defd4adad87d8538617b2f51a4bf9c3 upstream.

Add a wrapper function for dma_pool_alloc() to get zeroed memory.

Signed-off-by: Sean O. Stalley <sean.stalley at intel.com>
Cc: Vinod Koul <vinod.koul at intel.com>
Cc: Bjorn Helgaas <bhelgaas at google.com>
Cc: Gilles Muller <Gilles.Muller at lip6.fr>
Cc: Nicolas Palix <nicolas.palix at imag.fr>
Cc: Michal Marek <mmarek at suse.cz>
Cc: Sebastian Andrzej Siewior <bigeasy at linutronix.de>
Cc: Jonathan Corbet <corbet at lwn.net>
Signed-off-by: Andrew Morton <akpm at linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds at linux-foundation.org>
[ kamal: 4.2-stable prereq for
  27bc944 dmaengine: bcm2835-dma: Convert to use DMA pool ]
Signed-off-by: Kamal Mostafa <kamal at canonical.com>
---
 Documentation/DMA-API.txt | 7 +++++++
 include/linux/dmapool.h   | 6 ++++++
 2 files changed, 13 insertions(+)

diff --git a/Documentation/DMA-API.txt b/Documentation/DMA-API.txt
index 7eba542..edccacd 100644
--- a/Documentation/DMA-API.txt
+++ b/Documentation/DMA-API.txt
@@ -104,6 +104,13 @@ crossing restrictions, pass 0 for alloc; passing 4096 says memory allocated
 from this pool must not cross 4KByte boundaries.
 
 
+	void *dma_pool_zalloc(struct dma_pool *pool, gfp_t mem_flags,
+			      dma_addr_t *handle)
+
+Wraps dma_pool_alloc() and also zeroes the returned memory if the
+allocation attempt succeeded.
+
+
 	void *dma_pool_alloc(struct dma_pool *pool, gfp_t gfp_flags,
 			dma_addr_t *dma_handle);
 
diff --git a/include/linux/dmapool.h b/include/linux/dmapool.h
index e1043f7..53ba737 100644
--- a/include/linux/dmapool.h
+++ b/include/linux/dmapool.h
@@ -24,6 +24,12 @@ void dma_pool_destroy(struct dma_pool *pool);
 void *dma_pool_alloc(struct dma_pool *pool, gfp_t mem_flags,
 		     dma_addr_t *handle);
 
+static inline void *dma_pool_zalloc(struct dma_pool *pool, gfp_t mem_flags,
+				    dma_addr_t *handle)
+{
+	return dma_pool_alloc(pool, mem_flags | __GFP_ZERO, handle);
+}
+
 void dma_pool_free(struct dma_pool *pool, void *vaddr, dma_addr_t addr);
 
 /*
-- 
1.9.1





More information about the kernel-team mailing list