Skip to content

Commit c3f687d

Browse files
committed
net: page_pool: factor out releasing DMA from releasing the page
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 <[email protected]> Reviewed-by: Shakeel Butt <[email protected]> Reviewed-by: Ilias Apalodimas <[email protected]> Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 0a149ab commit c3f687d

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

net/core/page_pool.c

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -548,21 +548,16 @@ s32 page_pool_inflight(const struct page_pool *pool, bool strict)
548548
return inflight;
549549
}
550550

551-
/* Disconnects a page (from a page_pool). API users can have a need
552-
* to disconnect a page (from a page_pool), to allow it to be used as
553-
* a regular page (that will eventually be returned to the normal
554-
* page-allocator via put_page).
555-
*/
556-
static void page_pool_return_page(struct page_pool *pool, struct page *page)
551+
static __always_inline
552+
void __page_pool_release_page_dma(struct page_pool *pool, struct page *page)
557553
{
558554
dma_addr_t dma;
559-
int count;
560555

561556
if (!(pool->p.flags & PP_FLAG_DMA_MAP))
562557
/* Always account for inflight pages, even if we didn't
563558
* map them
564559
*/
565-
goto skip_dma_unmap;
560+
return;
566561

567562
dma = page_pool_get_dma_addr(page);
568563

@@ -571,7 +566,19 @@ static void page_pool_return_page(struct page_pool *pool, struct page *page)
571566
PAGE_SIZE << pool->p.order, pool->p.dma_dir,
572567
DMA_ATTR_SKIP_CPU_SYNC | DMA_ATTR_WEAK_ORDERING);
573568
page_pool_set_dma_addr(page, 0);
574-
skip_dma_unmap:
569+
}
570+
571+
/* Disconnects a page (from a page_pool). API users can have a need
572+
* to disconnect a page (from a page_pool), to allow it to be used as
573+
* a regular page (that will eventually be returned to the normal
574+
* page-allocator via put_page).
575+
*/
576+
void page_pool_return_page(struct page_pool *pool, struct page *page)
577+
{
578+
int count;
579+
580+
__page_pool_release_page_dma(pool, page);
581+
575582
page_pool_clear_pp_info(page);
576583

577584
/* This may be the last page returned, releasing the pool, so

0 commit comments

Comments
 (0)