[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <11b7e3cd-c929-654c-1f45-1abe9a6f6a98@cybernetics.com>
Date: Tue, 7 Jun 2022 14:45:44 -0400
From: Tony Battersby <tonyb@...ernetics.com>
To: linux-mm@...ck.org, linux-kernel@...r.kernel.org
Cc: iommu@...ts.linux-foundation.org, kernel-team@...com,
Matthew Wilcox <willy@...radead.org>,
Keith Busch <kbusch@...nel.org>,
Andy Shevchenko <andy.shevchenko@...il.com>,
Robin Murphy <robin.murphy@....com>,
Tony Lindgren <tony@...mide.com>
Subject: [PATCH v6 09/11] dmapool: cleanup dma_pool_destroy
pool_free_page() is called only from dma_pool_destroy(), so inline it
and make it less generic since we know that the pool is being destroyed.
Signed-off-by: Tony Battersby <tonyb@...ernetics.com>
---
Changes since v5:
Take the opposite approach and inline pool_free_page() into
dma_pool_destroy() instead of moving the is_page_busy() check into
pool_free_page().
mm/dmapool.c | 33 ++++++++++++++-------------------
1 file changed, 14 insertions(+), 19 deletions(-)
diff --git a/mm/dmapool.c b/mm/dmapool.c
index c7ec38cb4631..4e075feb038f 100644
--- a/mm/dmapool.c
+++ b/mm/dmapool.c
@@ -241,18 +241,6 @@ static inline bool is_page_busy(struct dma_page *page)
return page->in_use != 0;
}
-static void pool_free_page(struct dma_pool *pool, struct dma_page *page)
-{
- dma_addr_t dma = page->dma;
-
-#ifdef DMAPOOL_DEBUG
- memset(page->vaddr, POOL_POISON_FREED, pool->allocation);
-#endif
- dma_free_coherent(pool->dev, pool->allocation, page->vaddr, dma);
- list_del(&page->page_list);
- kfree(page);
-}
-
/**
* dma_pool_destroy - destroys a pool of dma memory blocks.
* @pool: dma pool that will be destroyed
@@ -280,14 +268,22 @@ void dma_pool_destroy(struct dma_pool *pool)
mutex_unlock(&pools_reg_lock);
list_for_each_entry_safe(page, tmp, &pool->page_list, page_list) {
+ void *vaddr = page->vaddr;
+
if (is_page_busy(page)) {
dev_err(pool->dev, "%s %s, %p busy\n", __func__,
- pool->name, page->vaddr);
+ pool->name, vaddr);
/* leak the still-in-use consistent memory */
- list_del(&page->page_list);
- kfree(page);
- } else
- pool_free_page(pool, page);
+ } else {
+#ifdef DMAPOOL_DEBUG
+ memset(vaddr, POOL_POISON_FREED, pool->allocation);
+#endif
+ dma_free_coherent(pool->dev,
+ pool->allocation,
+ vaddr,
+ page->dma);
+ }
+ kfree(page);
}
kfree(pool);
@@ -459,8 +455,7 @@ void dma_pool_free(struct dma_pool *pool, void *vaddr, dma_addr_t dma)
*(int *)vaddr = page->offset;
page->offset = offset;
/*
- * Resist a temptation to do
- * if (!is_page_busy(page)) pool_free_page(pool, page);
+ * Resist a temptation to free unused pages immediately.
* Better have a few empty pages hang around.
*/
spin_unlock_irqrestore(&pool->lock, flags);
--
2.25.1
Powered by blists - more mailing lists