net: page_pool: factor out releasing DMA from releasing the page
authorJakub Kicinski <kuba@kernel.org>
Fri, 8 Dec 2023 00:52:32 +0000 (16:52 -0800)
committerJakub Kicinski <kuba@kernel.org>
Thu, 14 Dec 2023 05:59:04 +0000 (21:59 -0800)
Releasing the DMA mapping will be useful for other types
of pages, so factor it out. Make sure compiler inlines it,
to avoid any regressions.

Signed-off-by: Mina Almasry <almasrymina@google.com>
Reviewed-by: Shakeel Butt <shakeelb@google.com>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/core/page_pool.c

index c92b757369f2fdfd0238156281cc3723de1299e4..dd5a72533f2b9daed0a5cc44226fffed33c0dbd6 100644 (file)
@@ -548,21 +548,16 @@ s32 page_pool_inflight(const struct page_pool *pool, bool strict)
        return inflight;
 }
 
-/* Disconnects a page (from a page_pool).  API users can have a need
- * to disconnect a page (from a page_pool), to allow it to be used as
- * a regular page (that will eventually be returned to the normal
- * page-allocator via put_page).
- */
-static void page_pool_return_page(struct page_pool *pool, struct page *page)
+static __always_inline
+void __page_pool_release_page_dma(struct page_pool *pool, struct page *page)
 {
        dma_addr_t dma;
-       int count;
 
        if (!(pool->p.flags & PP_FLAG_DMA_MAP))
                /* Always account for inflight pages, even if we didn't
                 * map them
                 */
-               goto skip_dma_unmap;
+               return;
 
        dma = page_pool_get_dma_addr(page);
 
@@ -571,7 +566,19 @@ static void page_pool_return_page(struct page_pool *pool, struct page *page)
                             PAGE_SIZE << pool->p.order, pool->p.dma_dir,
                             DMA_ATTR_SKIP_CPU_SYNC | DMA_ATTR_WEAK_ORDERING);
        page_pool_set_dma_addr(page, 0);
-skip_dma_unmap:
+}
+
+/* Disconnects a page (from a page_pool).  API users can have a need
+ * to disconnect a page (from a page_pool), to allow it to be used as
+ * a regular page (that will eventually be returned to the normal
+ * page-allocator via put_page).
+ */
+void page_pool_return_page(struct page_pool *pool, struct page *page)
+{
+       int count;
+
+       __page_pool_release_page_dma(pool, page);
+
        page_pool_clear_pp_info(page);
 
        /* This may be the last page returned, releasing the pool, so