[v2,net-next] net: page pool: allow to pass zero flags to page_pool_init()
diff mbox series

Message ID 1585168528-2445-1-git-send-email-kda@linux-powerpc.org
State Accepted
Delegated to: David Miller
Headers show
Series
  • [v2,net-next] net: page pool: allow to pass zero flags to page_pool_init()
Related show

Commit Message

Denis Kirjanov March 25, 2020, 8:35 p.m. UTC
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.

v2: check DMA direction only if PP_FLAG_DMA_MAP is set

Signed-off-by: Denis Kirjanov <kda@linux-powerpc.org>
---
 net/core/page_pool.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

Comments

Jesper Dangaard Brouer March 25, 2020, 9:32 p.m. UTC | #1
On Wed, 25 Mar 2020 23:35:28 +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.
> 
> v2: check DMA direction only if PP_FLAG_DMA_MAP is set
> 
> Signed-off-by: Denis Kirjanov <kda@linux-powerpc.org>

Acked-by: Jesper Dangaard Brouer <brouer@redhat.com>
David Miller March 30, 2020, 4:50 a.m. UTC | #2
From: Denis Kirjanov <kda@linux-powerpc.org>
Date: Wed, 25 Mar 2020 23:35:28 +0300

> 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.
> 
> v2: check DMA direction only if PP_FLAG_DMA_MAP is set
> 
> Signed-off-by: Denis Kirjanov <kda@linux-powerpc.org>

Applied.

Patch
diff mbox series

diff --git a/net/core/page_pool.c b/net/core/page_pool.c
index a6aefe9..af70331 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;
+	}
 
 	if (pool->p.flags & PP_FLAG_DMA_SYNC_DEV) {
 		/* In order to request DMA-sync-for-device the page