aboutsummaryrefslogtreecommitdiffstats
path: root/mm
diff options
context:
space:
mode:
Diffstat (limited to 'mm')
-rw-r--r--mm/dmapool.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/mm/dmapool.c b/mm/dmapool.c
index 34aaac451a96..b1f0885dda22 100644
--- a/mm/dmapool.c
+++ b/mm/dmapool.c
@@ -37,6 +37,10 @@
37#include <linux/types.h> 37#include <linux/types.h>
38#include <linux/wait.h> 38#include <linux/wait.h>
39 39
40#if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB_DEBUG_ON)
41#define DMAPOOL_DEBUG 1
42#endif
43
40struct dma_pool { /* the pool */ 44struct dma_pool { /* the pool */
41 struct list_head page_list; 45 struct list_head page_list;
42 spinlock_t lock; 46 spinlock_t lock;
@@ -216,7 +220,7 @@ static struct dma_page *pool_alloc_page(struct dma_pool *pool, gfp_t mem_flags)
216 page->vaddr = dma_alloc_coherent(pool->dev, pool->allocation, 220 page->vaddr = dma_alloc_coherent(pool->dev, pool->allocation,
217 &page->dma, mem_flags); 221 &page->dma, mem_flags);
218 if (page->vaddr) { 222 if (page->vaddr) {
219#ifdef CONFIG_DEBUG_SLAB 223#ifdef DMAPOOL_DEBUG
220 memset(page->vaddr, POOL_POISON_FREED, pool->allocation); 224 memset(page->vaddr, POOL_POISON_FREED, pool->allocation);
221#endif 225#endif
222 pool_initialise_page(pool, page); 226 pool_initialise_page(pool, page);
@@ -239,7 +243,7 @@ static void pool_free_page(struct dma_pool *pool, struct dma_page *page)
239{ 243{
240 dma_addr_t dma = page->dma; 244 dma_addr_t dma = page->dma;
241 245
242#ifdef CONFIG_DEBUG_SLAB 246#ifdef DMAPOOL_DEBUG
243 memset(page->vaddr, POOL_POISON_FREED, pool->allocation); 247 memset(page->vaddr, POOL_POISON_FREED, pool->allocation);
244#endif 248#endif
245 dma_free_coherent(pool->dev, pool->allocation, page->vaddr, dma); 249 dma_free_coherent(pool->dev, pool->allocation, page->vaddr, dma);
@@ -336,7 +340,7 @@ void *dma_pool_alloc(struct dma_pool *pool, gfp_t mem_flags,
336 page->offset = *(int *)(page->vaddr + offset); 340 page->offset = *(int *)(page->vaddr + offset);
337 retval = offset + page->vaddr; 341 retval = offset + page->vaddr;
338 *handle = offset + page->dma; 342 *handle = offset + page->dma;
339#ifdef CONFIG_DEBUG_SLAB 343#ifdef DMAPOOL_DEBUG
340 memset(retval, POOL_POISON_ALLOCATED, pool->size); 344 memset(retval, POOL_POISON_ALLOCATED, pool->size);
341#endif 345#endif
342 done: 346 done:
@@ -391,7 +395,7 @@ void dma_pool_free(struct dma_pool *pool, void *vaddr, dma_addr_t dma)
391 } 395 }
392 396
393 offset = vaddr - page->vaddr; 397 offset = vaddr - page->vaddr;
394#ifdef CONFIG_DEBUG_SLAB 398#ifdef DMAPOOL_DEBUG
395 if ((dma - page->dma) != offset) { 399 if ((dma - page->dma) != offset) {
396 if (pool->dev) 400 if (pool->dev)
397 dev_err(pool->dev, 401 dev_err(pool->dev,