lkml.org 
[lkml]   [2022]   [Dec]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCHv2 10/11] dmapool: don't memset on free twice
Date
From: Keith Busch <kbusch@kernel.org>

If debug is enabled, dmapool will poison the range, so no need to clear
it to 0 immediately before writing over it.

Signed-off-by: Keith Busch <kbusch@kernel.org>
---
mm/dmapool.c | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/mm/dmapool.c b/mm/dmapool.c
index 44622f2bf4641..f5b79c3268856 100644
--- a/mm/dmapool.c
+++ b/mm/dmapool.c
@@ -372,10 +372,10 @@ static struct dma_page *pool_find_page(struct dma_pool *pool, dma_addr_t dma)
return NULL;
}

+#ifdef DMAPOOL_DEBUG
static inline bool pool_page_err(struct dma_pool *pool, struct dma_page *page,
void *vaddr)
{
-#ifdef DMAPOOL_DEBUG
unsigned int chain = page->offset;

if ((dma - page->dma) != offset) {
@@ -394,9 +394,17 @@ static inline bool pool_page_err(struct dma_pool *pool, struct dma_page *page,
return true;
}
memset(vaddr, POOL_POISON_FREED, pool->size);
-#endif
return false;
}
+#else
+static inline bool pool_page_err(struct dma_pool *pool, struct dma_page *page,
+ void *vaddr)
+{
+ if (want_init_on_free())
+ memset(vaddr, 0, pool->size);
+ return false;
+}
+#endif

/**
* dma_pool_free - put block back into dma pool
@@ -423,8 +431,6 @@ void dma_pool_free(struct dma_pool *pool, void *vaddr, dma_addr_t dma)
}

offset = vaddr - page->vaddr;
- if (want_init_on_free())
- memset(vaddr, 0, pool->size);
if (pool_page_err(pool, page, vaddr)) {
spin_unlock_irqrestore(&pool->lock, flags);
return;
--
2.30.2
\
 
 \ /
  Last update: 2022-12-16 21:19    [W:0.888 / U:0.016 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site