linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] net: stmmac: don't set own bit too early for jumbo frames
@ 2019-03-14 19:43 Aaro Koskinen
  2019-03-14 19:43 ` [PATCH 2/2] net: stmmac: fix jumbo frame sending with non-linear skbs Aaro Koskinen
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Aaro Koskinen @ 2019-03-14 19:43 UTC (permalink / raw)
  To: David S. Miller, Giuseppe Cavallaro, Alexandre Torgue,
	Jose Abreu, Thor Thayer, netdev, linux-kernel
  Cc: Aaro Koskinen

From: Aaro Koskinen <aaro.koskinen@nokia.com>

Commit 0e80bdc9a72d ("stmmac: first frame prep at the end of xmit
routine") overlooked jumbo frames when re-ordering the code, and as a
result the own bit was not getting set anymore for the first jumbo frame
descriptor. Commit 487e2e22ab79 ("net: stmmac: Set OWN bit for jumbo
frames") tried to fix this, but now the bit is getting set too early and
the DMA may start while we are still setting up the remaing descriptors.
And with the chain mode the own bit remains still unset.

Fix by setting the own bit at the end of xmit also with jumbo frames.

Fixes: 0e80bdc9a72d ("stmmac: first frame prep at the end of xmit routine")
Fixes: 487e2e22ab79 ("net: stmmac: Set OWN bit for jumbo frames")
Signed-off-by: Aaro Koskinen <aaro.koskinen@nokia.com>
---
 drivers/net/ethernet/stmicro/stmmac/ring_mode.c   |  4 ++--
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 14 ++++++++------
 2 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/ring_mode.c b/drivers/net/ethernet/stmicro/stmmac/ring_mode.c
index d8c5bc412219..bc83ced94e1b 100644
--- a/drivers/net/ethernet/stmicro/stmmac/ring_mode.c
+++ b/drivers/net/ethernet/stmicro/stmmac/ring_mode.c
@@ -59,7 +59,7 @@ static int jumbo_frm(void *p, struct sk_buff *skb, int csum)
 
 		desc->des3 = cpu_to_le32(des2 + BUF_SIZE_4KiB);
 		stmmac_prepare_tx_desc(priv, desc, 1, bmax, csum,
-				STMMAC_RING_MODE, 1, false, skb->len);
+				STMMAC_RING_MODE, 0, false, skb->len);
 		tx_q->tx_skbuff[entry] = NULL;
 		entry = STMMAC_GET_ENTRY(entry, DMA_TX_SIZE);
 
@@ -91,7 +91,7 @@ static int jumbo_frm(void *p, struct sk_buff *skb, int csum)
 		tx_q->tx_skbuff_dma[entry].is_jumbo = true;
 		desc->des3 = cpu_to_le32(des2 + BUF_SIZE_4KiB);
 		stmmac_prepare_tx_desc(priv, desc, 1, nopaged_len, csum,
-				STMMAC_RING_MODE, 1, true, skb->len);
+				STMMAC_RING_MODE, 0, true, skb->len);
 	}
 
 	tx_q->cur_tx = entry;
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 97c5e1aad88f..6a2e1031a62a 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -3216,14 +3216,16 @@ static netdev_tx_t stmmac_xmit(struct sk_buff *skb, struct net_device *dev)
 		stmmac_prepare_tx_desc(priv, first, 1, nopaged_len,
 				csum_insertion, priv->mode, 1, last_segment,
 				skb->len);
-
-		/* The own bit must be the latest setting done when prepare the
-		 * descriptor and then barrier is needed to make sure that
-		 * all is coherent before granting the DMA engine.
-		 */
-		wmb();
+	} else {
+		stmmac_set_tx_owner(priv, first);
 	}
 
+	/* The own bit must be the latest setting done when prepare the
+	 * descriptor and then barrier is needed to make sure that
+	 * all is coherent before granting the DMA engine.
+	 */
+	wmb();
+
 	netdev_tx_sent_queue(netdev_get_tx_queue(dev, queue), skb->len);
 
 	stmmac_enable_dma_transmission(priv, priv->ioaddr);
-- 
2.17.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/2] net: stmmac: fix jumbo frame sending with non-linear skbs
  2019-03-14 19:43 [PATCH 1/2] net: stmmac: don't set own bit too early for jumbo frames Aaro Koskinen
@ 2019-03-14 19:43 ` Aaro Koskinen
  2019-03-15  9:50   ` Jose Abreu
  2019-03-15 18:39   ` David Miller
  2019-03-15  8:45 ` [PATCH 1/2] net: stmmac: don't set own bit too early for jumbo frames Sergei Shtylyov
                   ` (2 subsequent siblings)
  3 siblings, 2 replies; 7+ messages in thread
From: Aaro Koskinen @ 2019-03-14 19:43 UTC (permalink / raw)
  To: David S. Miller, Giuseppe Cavallaro, Alexandre Torgue,
	Jose Abreu, Thor Thayer, netdev, linux-kernel
  Cc: Aaro Koskinen

From: Aaro Koskinen <aaro.koskinen@nokia.com>

When sending non-linear skbs with jumbo frames, we set up the non-paged
data and mark that as a last segment, although the paged fragments are
also prepared. This will stall the TX queue and trigger a watchdog warning
(a simple reproducer is to run an iperf client mode TCP test with a large
MTU - networking fails instantly).

Fix by checking if the skb is non-linear.

Signed-off-by: Aaro Koskinen <aaro.koskinen@nokia.com>
---
 drivers/net/ethernet/stmicro/stmmac/ring_mode.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/ring_mode.c b/drivers/net/ethernet/stmicro/stmmac/ring_mode.c
index bc83ced94e1b..f936166d8910 100644
--- a/drivers/net/ethernet/stmicro/stmmac/ring_mode.c
+++ b/drivers/net/ethernet/stmicro/stmmac/ring_mode.c
@@ -79,7 +79,8 @@ static int jumbo_frm(void *p, struct sk_buff *skb, int csum)
 
 		desc->des3 = cpu_to_le32(des2 + BUF_SIZE_4KiB);
 		stmmac_prepare_tx_desc(priv, desc, 0, len, csum,
-				STMMAC_RING_MODE, 1, true, skb->len);
+				STMMAC_RING_MODE, 1, !skb_is_nonlinear(skb),
+				skb->len);
 	} else {
 		des2 = dma_map_single(priv->device, skb->data,
 				      nopaged_len, DMA_TO_DEVICE);
@@ -91,7 +92,8 @@ static int jumbo_frm(void *p, struct sk_buff *skb, int csum)
 		tx_q->tx_skbuff_dma[entry].is_jumbo = true;
 		desc->des3 = cpu_to_le32(des2 + BUF_SIZE_4KiB);
 		stmmac_prepare_tx_desc(priv, desc, 1, nopaged_len, csum,
-				STMMAC_RING_MODE, 0, true, skb->len);
+				STMMAC_RING_MODE, 0, !skb_is_nonlinear(skb),
+				skb->len);
 	}
 
 	tx_q->cur_tx = entry;
-- 
2.17.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2] net: stmmac: don't set own bit too early for jumbo frames
  2019-03-14 19:43 [PATCH 1/2] net: stmmac: don't set own bit too early for jumbo frames Aaro Koskinen
  2019-03-14 19:43 ` [PATCH 2/2] net: stmmac: fix jumbo frame sending with non-linear skbs Aaro Koskinen
@ 2019-03-15  8:45 ` Sergei Shtylyov
  2019-03-15  9:47 ` Jose Abreu
  2019-03-15 18:39 ` David Miller
  3 siblings, 0 replies; 7+ messages in thread
From: Sergei Shtylyov @ 2019-03-15  8:45 UTC (permalink / raw)
  To: Aaro Koskinen, David S. Miller, Giuseppe Cavallaro,
	Alexandre Torgue, Jose Abreu, Thor Thayer, netdev, linux-kernel
  Cc: Aaro Koskinen

Hello!

On 14.03.2019 22:43, Aaro Koskinen wrote:

> From: Aaro Koskinen <aaro.koskinen@nokia.com>
> 
> Commit 0e80bdc9a72d ("stmmac: first frame prep at the end of xmit
> routine") overlooked jumbo frames when re-ordering the code, and as a
> result the own bit was not getting set anymore for the first jumbo frame
> descriptor. Commit 487e2e22ab79 ("net: stmmac: Set OWN bit for jumbo
> frames") tried to fix this, but now the bit is getting set too early and
> the DMA may start while we are still setting up the remaing descriptors.

    Remaining?

> And with the chain mode the own bit remains still unset.
> 
> Fix by setting the own bit at the end of xmit also with jumbo frames.
> 
> Fixes: 0e80bdc9a72d ("stmmac: first frame prep at the end of xmit routine")
> Fixes: 487e2e22ab79 ("net: stmmac: Set OWN bit for jumbo frames")
> Signed-off-by: Aaro Koskinen <aaro.koskinen@nokia.com>
[...]

MBR, Sergei

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2] net: stmmac: don't set own bit too early for jumbo frames
  2019-03-14 19:43 [PATCH 1/2] net: stmmac: don't set own bit too early for jumbo frames Aaro Koskinen
  2019-03-14 19:43 ` [PATCH 2/2] net: stmmac: fix jumbo frame sending with non-linear skbs Aaro Koskinen
  2019-03-15  8:45 ` [PATCH 1/2] net: stmmac: don't set own bit too early for jumbo frames Sergei Shtylyov
@ 2019-03-15  9:47 ` Jose Abreu
  2019-03-15 18:39 ` David Miller
  3 siblings, 0 replies; 7+ messages in thread
From: Jose Abreu @ 2019-03-15  9:47 UTC (permalink / raw)
  To: Aaro Koskinen, David S. Miller, Giuseppe Cavallaro,
	Alexandre Torgue, Jose Abreu, Thor Thayer, netdev, linux-kernel
  Cc: Aaro Koskinen

On 3/14/2019 7:43 PM, Aaro Koskinen wrote:
> From: Aaro Koskinen <aaro.koskinen@nokia.com>
> 
> Commit 0e80bdc9a72d ("stmmac: first frame prep at the end of xmit
> routine") overlooked jumbo frames when re-ordering the code, and as a
> result the own bit was not getting set anymore for the first jumbo frame
> descriptor. Commit 487e2e22ab79 ("net: stmmac: Set OWN bit for jumbo
> frames") tried to fix this, but now the bit is getting set too early and
> the DMA may start while we are still setting up the remaing descriptors.
> And with the chain mode the own bit remains still unset.
> 
> Fix by setting the own bit at the end of xmit also with jumbo frames.
> 
> Fixes: 0e80bdc9a72d ("stmmac: first frame prep at the end of xmit routine")
> Fixes: 487e2e22ab79 ("net: stmmac: Set OWN bit for jumbo frames")
> Signed-off-by: Aaro Koskinen <aaro.koskinen@nokia.com>

With Sergei comment fix:

Acked-by: Jose Abreu <joabreu@synopsys.com>

Thanks,
Jose Miguel Abreu

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 2/2] net: stmmac: fix jumbo frame sending with non-linear skbs
  2019-03-14 19:43 ` [PATCH 2/2] net: stmmac: fix jumbo frame sending with non-linear skbs Aaro Koskinen
@ 2019-03-15  9:50   ` Jose Abreu
  2019-03-15 18:39   ` David Miller
  1 sibling, 0 replies; 7+ messages in thread
From: Jose Abreu @ 2019-03-15  9:50 UTC (permalink / raw)
  To: Aaro Koskinen, David S. Miller, Giuseppe Cavallaro,
	Alexandre Torgue, Jose Abreu, Thor Thayer, netdev, linux-kernel
  Cc: Aaro Koskinen

On 3/14/2019 7:43 PM, Aaro Koskinen wrote:
> From: Aaro Koskinen <aaro.koskinen@nokia.com>
> 
> When sending non-linear skbs with jumbo frames, we set up the non-paged
> data and mark that as a last segment, although the paged fragments are
> also prepared. This will stall the TX queue and trigger a watchdog warning
> (a simple reproducer is to run an iperf client mode TCP test with a large
> MTU - networking fails instantly).
> 
> Fix by checking if the skb is non-linear.
> 
> Signed-off-by: Aaro Koskinen <aaro.koskinen@nokia.com>

Acked-by: Jose Abreu <joabreu@synopsys.com>

Thanks,
Jose Miguel Abreu

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2] net: stmmac: don't set own bit too early for jumbo frames
  2019-03-14 19:43 [PATCH 1/2] net: stmmac: don't set own bit too early for jumbo frames Aaro Koskinen
                   ` (2 preceding siblings ...)
  2019-03-15  9:47 ` Jose Abreu
@ 2019-03-15 18:39 ` David Miller
  3 siblings, 0 replies; 7+ messages in thread
From: David Miller @ 2019-03-15 18:39 UTC (permalink / raw)
  To: aaro.koskinen
  Cc: peppe.cavallaro, alexandre.torgue, joabreu, thor.thayer, netdev,
	linux-kernel, aaro.koskinen

From: Aaro Koskinen <aaro.koskinen@iki.fi>
Date: Thu, 14 Mar 2019 21:43:19 +0200

> From: Aaro Koskinen <aaro.koskinen@nokia.com>
> 
> Commit 0e80bdc9a72d ("stmmac: first frame prep at the end of xmit
> routine") overlooked jumbo frames when re-ordering the code, and as a
> result the own bit was not getting set anymore for the first jumbo frame
> descriptor. Commit 487e2e22ab79 ("net: stmmac: Set OWN bit for jumbo
> frames") tried to fix this, but now the bit is getting set too early and
> the DMA may start while we are still setting up the remaing descriptors.
> And with the chain mode the own bit remains still unset.
> 
> Fix by setting the own bit at the end of xmit also with jumbo frames.
> 
> Fixes: 0e80bdc9a72d ("stmmac: first frame prep at the end of xmit routine")
> Fixes: 487e2e22ab79 ("net: stmmac: Set OWN bit for jumbo frames")
> Signed-off-by: Aaro Koskinen <aaro.koskinen@nokia.com>

Applied with the "remaining" typo fixed.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 2/2] net: stmmac: fix jumbo frame sending with non-linear skbs
  2019-03-14 19:43 ` [PATCH 2/2] net: stmmac: fix jumbo frame sending with non-linear skbs Aaro Koskinen
  2019-03-15  9:50   ` Jose Abreu
@ 2019-03-15 18:39   ` David Miller
  1 sibling, 0 replies; 7+ messages in thread
From: David Miller @ 2019-03-15 18:39 UTC (permalink / raw)
  To: aaro.koskinen
  Cc: peppe.cavallaro, alexandre.torgue, joabreu, thor.thayer, netdev,
	linux-kernel, aaro.koskinen

From: Aaro Koskinen <aaro.koskinen@iki.fi>
Date: Thu, 14 Mar 2019 21:43:20 +0200

> From: Aaro Koskinen <aaro.koskinen@nokia.com>
> 
> When sending non-linear skbs with jumbo frames, we set up the non-paged
> data and mark that as a last segment, although the paged fragments are
> also prepared. This will stall the TX queue and trigger a watchdog warning
> (a simple reproducer is to run an iperf client mode TCP test with a large
> MTU - networking fails instantly).
> 
> Fix by checking if the skb is non-linear.
> 
> Signed-off-by: Aaro Koskinen <aaro.koskinen@nokia.com>

Applied.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2019-03-15 18:39 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-14 19:43 [PATCH 1/2] net: stmmac: don't set own bit too early for jumbo frames Aaro Koskinen
2019-03-14 19:43 ` [PATCH 2/2] net: stmmac: fix jumbo frame sending with non-linear skbs Aaro Koskinen
2019-03-15  9:50   ` Jose Abreu
2019-03-15 18:39   ` David Miller
2019-03-15  8:45 ` [PATCH 1/2] net: stmmac: don't set own bit too early for jumbo frames Sergei Shtylyov
2019-03-15  9:47 ` Jose Abreu
2019-03-15 18:39 ` David Miller

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).