netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jesper Dangaard Brouer <brouer@redhat.com>
To: Denis Kirjanov <kda@linux-powerpc.org>
Cc: brouer@redhat.com, netdev@vger.kernel.org, hawk@kernel.org,
	ilias.apalodimas@linaro.org
Subject: Re: [PATCH net-next] net: page pool: allow to pass zero flags to page_pool_init()
Date: Wed, 25 Mar 2020 16:02:11 +0100	[thread overview]
Message-ID: <20200325160211.1b887ca5@carbon> (raw)
In-Reply-To: <1585145575-14477-1-git-send-email-kda@linux-powerpc.org>

On Wed, 25 Mar 2020 17:12:55 +0300
Denis Kirjanov <kda@linux-powerpc.org> wrote:

> page pool API can be useful for non-DMA cases like
> xen-netfront driver so let's allow to pass zero flags to
> page pool flags.
> 
> Signed-off-by: Denis Kirjanov <kda@linux-powerpc.org>
> ---
>  net/core/page_pool.c | 36 +++++++++++++++++++-----------------
>  1 file changed, 19 insertions(+), 17 deletions(-)

The pool->p.dma_dir is only used when flag PP_FLAG_DMA_MAP is used, so
it looks more simple to do:

$ git diff
diff --git a/net/core/page_pool.c b/net/core/page_pool.c
index 626db912fce4..ef98372facf6 100644
--- a/net/core/page_pool.c
+++ b/net/core/page_pool.c
@@ -43,9 +43,11 @@ static int page_pool_init(struct page_pool *pool,
         * DMA_BIDIRECTIONAL is for allowing page used for DMA sending,
         * which is the XDP_TX use-case.
         */
-       if ((pool->p.dma_dir != DMA_FROM_DEVICE) &&
-           (pool->p.dma_dir != DMA_BIDIRECTIONAL))
-               return -EINVAL;
+       if (pool->p.flags & PP_FLAG_DMA_MAP) {
+               if ((pool->p.dma_dir != DMA_FROM_DEVICE) &&
+                   (pool->p.dma_dir != DMA_BIDIRECTIONAL))
+                       return -EINVAL;
+       }
 


> diff --git a/net/core/page_pool.c b/net/core/page_pool.c
> index 10d2b25..eeeb0d9 100644
> --- a/net/core/page_pool.c
> +++ b/net/core/page_pool.c
> @@ -39,27 +39,29 @@ static int page_pool_init(struct page_pool *pool,
>  	if (ring_qsize > 32768)
>  		return -E2BIG;
>  
> -	/* DMA direction is either DMA_FROM_DEVICE or DMA_BIDIRECTIONAL.
> -	 * DMA_BIDIRECTIONAL is for allowing page used for DMA sending,
> -	 * which is the XDP_TX use-case.
> -	 */
> -	if ((pool->p.dma_dir != DMA_FROM_DEVICE) &&
> -	    (pool->p.dma_dir != DMA_BIDIRECTIONAL))
> -		return -EINVAL;
> -
> -	if (pool->p.flags & PP_FLAG_DMA_SYNC_DEV) {
> -		/* In order to request DMA-sync-for-device the page
> -		 * needs to be mapped
> +	if (pool->p.flags) {
> +		/* DMA direction is either DMA_FROM_DEVICE or DMA_BIDIRECTIONAL.
> +		 * DMA_BIDIRECTIONAL is for allowing page used for DMA sending,
> +		 * which is the XDP_TX use-case.
>  		 */
> -		if (!(pool->p.flags & PP_FLAG_DMA_MAP))
> +		if ((pool->p.dma_dir != DMA_FROM_DEVICE) &&
> +		    (pool->p.dma_dir != DMA_BIDIRECTIONAL))
>  			return -EINVAL;
>  
> -		if (!pool->p.max_len)
> -			return -EINVAL;
> +		if (pool->p.flags & PP_FLAG_DMA_SYNC_DEV) {
> +			/* In order to request DMA-sync-for-device the page
> +			 * needs to be mapped
> +			 */
> +			if (!(pool->p.flags & PP_FLAG_DMA_MAP))
> +				return -EINVAL;
>  
> -		/* pool->p.offset has to be set according to the address
> -		 * offset used by the DMA engine to start copying rx data
> -		 */
> +			if (!pool->p.max_len)
> +				return -EINVAL;
> +
> +			/* pool->p.offset has to be set according to the address
> +			 * offset used by the DMA engine to start copying rx data
> +			 */
> +		}
>  	}
>  
>  	if (ptr_ring_init(&pool->ring, ring_qsize, GFP_KERNEL) < 0)



-- 
Best regards,
  Jesper Dangaard Brouer
  MSc.CS, Principal Kernel Engineer at Red Hat
  LinkedIn: http://www.linkedin.com/in/brouer


  reply	other threads:[~2020-03-25 15:02 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-25 14:12 [PATCH net-next] net: page pool: allow to pass zero flags to page_pool_init() Denis Kirjanov
2020-03-25 15:02 ` Jesper Dangaard Brouer [this message]
2020-03-25 19:16   ` Denis Kirjanov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200325160211.1b887ca5@carbon \
    --to=brouer@redhat.com \
    --cc=hawk@kernel.org \
    --cc=ilias.apalodimas@linaro.org \
    --cc=kda@linux-powerpc.org \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).