[PATCH v6 09/11] dmapool: cleanup dma_pool_destroy

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxx>
---

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





[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux