Re: [PATCH net-next v1] page_pool: check for dma_sync_size earlier

From: Yunsheng Lin
Date: Thu Oct 10 2024 - 07:54:03 EST


On 2024/10/10 19:40, Furong Xu wrote:
> Setting dma_sync_size to 0 is not illegal, and several drivers already did.
> We can save a couple of function calls if check for dma_sync_size earlier.
>
> Signed-off-by: Furong Xu <0x1207@xxxxxxxxx>
> ---
> net/core/page_pool.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/net/core/page_pool.c b/net/core/page_pool.c
> index a813d30d2135..fac52ba3f7c4 100644
> --- a/net/core/page_pool.c
> +++ b/net/core/page_pool.c
> @@ -454,7 +454,7 @@ page_pool_dma_sync_for_device(const struct page_pool *pool,
> netmem_ref netmem,
> u32 dma_sync_size)
> {
> - if (pool->dma_sync && dma_dev_need_sync(pool->p.dev))
> + if (dma_sync_size && pool->dma_sync && dma_dev_need_sync(pool->p.dev))
> __page_pool_dma_sync_for_device(pool, netmem, dma_sync_size);

Is there any reason that those drivers not to unset the PP_FLAG_DMA_SYNC_DEV
when calling page_pool_create()?
Does it only need dma sync for some cases and not need dma sync for other
cases? if so, why not do the dma sync in the driver instead?

> }
>