linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net 1/3] net: mvpp2: fix TSO headers allocation and management
@ 2017-10-23 13:24 Antoine Tenart
  2017-10-23 13:24 ` [PATCH net 2/3] net: mvpp2: do not unmap TSO headers buffers Antoine Tenart
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Antoine Tenart @ 2017-10-23 13:24 UTC (permalink / raw)
  To: davem
  Cc: Yan Markman, andrew, gregory.clement, thomas.petazzoni,
	miquel.raynal, nadavh, linux-kernel, mw, stefanc, netdev,
	Antoine Tenart

From: Yan Markman <ymarkman@marvell.com>

TSO headers are managed with txq index and therefore should be aligned
with the txq size, not with the aggregated txq size.

Fixes: 186cd4d4e414 ("net: mvpp2: software tso support")
Reported-by: Marc Zyngier <marc.zyngier@arm.com>
Signed-off-by: Yan Markman <ymarkman@marvell.com>
Signed-off-by: Antoine Tenart <antoine.tenart@free-electrons.com>
---
 drivers/net/ethernet/marvell/mvpp2.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/marvell/mvpp2.c b/drivers/net/ethernet/marvell/mvpp2.c
index 1a540c88c974..2898ac70b826 100644
--- a/drivers/net/ethernet/marvell/mvpp2.c
+++ b/drivers/net/ethernet/marvell/mvpp2.c
@@ -5609,7 +5609,7 @@ static int mvpp2_txq_init(struct mvpp2_port *port,
 
 		txq_pcpu->tso_headers =
 			dma_alloc_coherent(port->dev->dev.parent,
-					   MVPP2_AGGR_TXQ_SIZE * TSO_HEADER_SIZE,
+					   txq_pcpu->size * TSO_HEADER_SIZE,
 					   &txq_pcpu->tso_headers_dma,
 					   GFP_KERNEL);
 		if (!txq_pcpu->tso_headers)
@@ -5623,7 +5623,7 @@ static int mvpp2_txq_init(struct mvpp2_port *port,
 		kfree(txq_pcpu->buffs);
 
 		dma_free_coherent(port->dev->dev.parent,
-				  MVPP2_AGGR_TXQ_SIZE * MVPP2_DESC_ALIGNED_SIZE,
+				  txq_pcpu->size * TSO_HEADER_SIZE,
 				  txq_pcpu->tso_headers,
 				  txq_pcpu->tso_headers_dma);
 	}
@@ -5647,7 +5647,7 @@ static void mvpp2_txq_deinit(struct mvpp2_port *port,
 		kfree(txq_pcpu->buffs);
 
 		dma_free_coherent(port->dev->dev.parent,
-				  MVPP2_AGGR_TXQ_SIZE * MVPP2_DESC_ALIGNED_SIZE,
+				  txq_pcpu->size * TSO_HEADER_SIZE,
 				  txq_pcpu->tso_headers,
 				  txq_pcpu->tso_headers_dma);
 	}
-- 
2.14.2

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

* [PATCH net 2/3] net: mvpp2: do not unmap TSO headers buffers
  2017-10-23 13:24 [PATCH net 1/3] net: mvpp2: fix TSO headers allocation and management Antoine Tenart
@ 2017-10-23 13:24 ` Antoine Tenart
  2017-10-24  9:34   ` David Miller
  2017-10-23 13:24 ` [PATCH net 3/3] net: mvpp2: do not call txq_done from the Tx path when Tx irqs are used Antoine Tenart
  2017-10-24  9:34 ` [PATCH net 1/3] net: mvpp2: fix TSO headers allocation and management David Miller
  2 siblings, 1 reply; 6+ messages in thread
From: Antoine Tenart @ 2017-10-23 13:24 UTC (permalink / raw)
  To: davem
  Cc: Antoine Tenart, andrew, gregory.clement, thomas.petazzoni,
	miquel.raynal, nadavh, linux-kernel, mw, stefanc, netdev

The TSO header buffers are coming from a per cpu pool and should not
be unmapped as they are reused. The PPv2 driver was unmapping all
descriptors buffers unconditionally. This patch fixes this by checking
the buffers dma addresses before unmapping them, and by not unmapping
those who are located in the TSO header pool.

Fixes: 186cd4d4e414 ("net: mvpp2: software tso support")
Signed-off-by: Antoine Tenart <antoine.tenart@free-electrons.com>
---
 drivers/net/ethernet/marvell/mvpp2.c | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/marvell/mvpp2.c b/drivers/net/ethernet/marvell/mvpp2.c
index 2898ac70b826..037f26dfe31c 100644
--- a/drivers/net/ethernet/marvell/mvpp2.c
+++ b/drivers/net/ethernet/marvell/mvpp2.c
@@ -1167,6 +1167,11 @@ struct mvpp2_bm_pool {
 	u32 port_map;
 };
 
+#define IS_TSO_HEADER(txq_pcpu, addr) \
+	((addr) >= (txq_pcpu)->tso_headers_dma && \
+	 (addr) < (txq_pcpu)->tso_headers_dma + \
+	 (txq_pcpu)->size * TSO_HEADER_SIZE)
+
 /* Queue modes */
 #define MVPP2_QDIST_SINGLE_MODE	0
 #define MVPP2_QDIST_MULTI_MODE	1
@@ -5321,8 +5326,9 @@ static void mvpp2_txq_bufs_free(struct mvpp2_port *port,
 		struct mvpp2_txq_pcpu_buf *tx_buf =
 			txq_pcpu->buffs + txq_pcpu->txq_get_index;
 
-		dma_unmap_single(port->dev->dev.parent, tx_buf->dma,
-				 tx_buf->size, DMA_TO_DEVICE);
+		if (!IS_TSO_HEADER(txq_pcpu, tx_buf->dma))
+			dma_unmap_single(port->dev->dev.parent, tx_buf->dma,
+					 tx_buf->size, DMA_TO_DEVICE);
 		if (tx_buf->skb)
 			dev_kfree_skb_any(tx_buf->skb);
 
@@ -6212,12 +6218,15 @@ static inline void
 tx_desc_unmap_put(struct mvpp2_port *port, struct mvpp2_tx_queue *txq,
 		  struct mvpp2_tx_desc *desc)
 {
+	struct mvpp2_txq_pcpu *txq_pcpu = this_cpu_ptr(txq->pcpu);
+
 	dma_addr_t buf_dma_addr =
 		mvpp2_txdesc_dma_addr_get(port, desc);
 	size_t buf_sz =
 		mvpp2_txdesc_size_get(port, desc);
-	dma_unmap_single(port->dev->dev.parent, buf_dma_addr,
-			 buf_sz, DMA_TO_DEVICE);
+	if (!IS_TSO_HEADER(txq_pcpu, buf_dma_addr))
+		dma_unmap_single(port->dev->dev.parent, buf_dma_addr,
+				 buf_sz, DMA_TO_DEVICE);
 	mvpp2_txq_desc_put(txq);
 }
 
-- 
2.14.2

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

* [PATCH net 3/3] net: mvpp2: do not call txq_done from the Tx path when Tx irqs are used
  2017-10-23 13:24 [PATCH net 1/3] net: mvpp2: fix TSO headers allocation and management Antoine Tenart
  2017-10-23 13:24 ` [PATCH net 2/3] net: mvpp2: do not unmap TSO headers buffers Antoine Tenart
@ 2017-10-23 13:24 ` Antoine Tenart
  2017-10-24  9:34   ` David Miller
  2017-10-24  9:34 ` [PATCH net 1/3] net: mvpp2: fix TSO headers allocation and management David Miller
  2 siblings, 1 reply; 6+ messages in thread
From: Antoine Tenart @ 2017-10-23 13:24 UTC (permalink / raw)
  To: davem
  Cc: Antoine Tenart, andrew, gregory.clement, thomas.petazzoni,
	miquel.raynal, nadavh, linux-kernel, mw, stefanc, netdev

When Tx IRQs are used, txq_bufs_free() can be called from both the Tx
path and from NAPI poll(). This led to CPU stalls as if these two tasks
(Tx and Poll) are scheduled on two CPUs at the same time, DMA unmapping
operations are done on the same txq buffers.

This patch adds a check not to call txq_done() from the Tx path if Tx
interrupts are used as it does not make sense to do so.

Fixes: edc660fa09e2 ("net: mvpp2: replace TX coalescing interrupts with hrtimer")
Signed-off-by: Antoine Tenart <antoine.tenart@free-electrons.com>
---
 drivers/net/ethernet/marvell/mvpp2.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/marvell/mvpp2.c b/drivers/net/ethernet/marvell/mvpp2.c
index 037f26dfe31c..60b4f3d995af 100644
--- a/drivers/net/ethernet/marvell/mvpp2.c
+++ b/drivers/net/ethernet/marvell/mvpp2.c
@@ -6499,7 +6499,7 @@ static int mvpp2_tx(struct sk_buff *skb, struct net_device *dev)
 	}
 
 	/* Finalize TX processing */
-	if (txq_pcpu->count >= txq->done_pkts_coal)
+	if (!port->has_tx_irqs && txq_pcpu->count >= txq->done_pkts_coal)
 		mvpp2_txq_done(port, txq, txq_pcpu);
 
 	/* Set the timer in case not all frags were processed */
-- 
2.14.2

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

* Re: [PATCH net 1/3] net: mvpp2: fix TSO headers allocation and management
  2017-10-23 13:24 [PATCH net 1/3] net: mvpp2: fix TSO headers allocation and management Antoine Tenart
  2017-10-23 13:24 ` [PATCH net 2/3] net: mvpp2: do not unmap TSO headers buffers Antoine Tenart
  2017-10-23 13:24 ` [PATCH net 3/3] net: mvpp2: do not call txq_done from the Tx path when Tx irqs are used Antoine Tenart
@ 2017-10-24  9:34 ` David Miller
  2 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2017-10-24  9:34 UTC (permalink / raw)
  To: antoine.tenart
  Cc: ymarkman, andrew, gregory.clement, thomas.petazzoni,
	miquel.raynal, nadavh, linux-kernel, mw, stefanc, netdev

From: Antoine Tenart <antoine.tenart@free-electrons.com>
Date: Mon, 23 Oct 2017 15:24:29 +0200

> From: Yan Markman <ymarkman@marvell.com>
> 
> TSO headers are managed with txq index and therefore should be aligned
> with the txq size, not with the aggregated txq size.
> 
> Fixes: 186cd4d4e414 ("net: mvpp2: software tso support")
> Reported-by: Marc Zyngier <marc.zyngier@arm.com>
> Signed-off-by: Yan Markman <ymarkman@marvell.com>
> Signed-off-by: Antoine Tenart <antoine.tenart@free-electrons.com>

Applied.

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

* Re: [PATCH net 2/3] net: mvpp2: do not unmap TSO headers buffers
  2017-10-23 13:24 ` [PATCH net 2/3] net: mvpp2: do not unmap TSO headers buffers Antoine Tenart
@ 2017-10-24  9:34   ` David Miller
  0 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2017-10-24  9:34 UTC (permalink / raw)
  To: antoine.tenart
  Cc: andrew, gregory.clement, thomas.petazzoni, miquel.raynal, nadavh,
	linux-kernel, mw, stefanc, netdev

From: Antoine Tenart <antoine.tenart@free-electrons.com>
Date: Mon, 23 Oct 2017 15:24:30 +0200

> The TSO header buffers are coming from a per cpu pool and should not
> be unmapped as they are reused. The PPv2 driver was unmapping all
> descriptors buffers unconditionally. This patch fixes this by checking
> the buffers dma addresses before unmapping them, and by not unmapping
> those who are located in the TSO header pool.
> 
> Fixes: 186cd4d4e414 ("net: mvpp2: software tso support")
> Signed-off-by: Antoine Tenart <antoine.tenart@free-electrons.com>

Applied.

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

* Re: [PATCH net 3/3] net: mvpp2: do not call txq_done from the Tx path when Tx irqs are used
  2017-10-23 13:24 ` [PATCH net 3/3] net: mvpp2: do not call txq_done from the Tx path when Tx irqs are used Antoine Tenart
@ 2017-10-24  9:34   ` David Miller
  0 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2017-10-24  9:34 UTC (permalink / raw)
  To: antoine.tenart
  Cc: andrew, gregory.clement, thomas.petazzoni, miquel.raynal, nadavh,
	linux-kernel, mw, stefanc, netdev

From: Antoine Tenart <antoine.tenart@free-electrons.com>
Date: Mon, 23 Oct 2017 15:24:31 +0200

> When Tx IRQs are used, txq_bufs_free() can be called from both the Tx
> path and from NAPI poll(). This led to CPU stalls as if these two tasks
> (Tx and Poll) are scheduled on two CPUs at the same time, DMA unmapping
> operations are done on the same txq buffers.
> 
> This patch adds a check not to call txq_done() from the Tx path if Tx
> interrupts are used as it does not make sense to do so.
> 
> Fixes: edc660fa09e2 ("net: mvpp2: replace TX coalescing interrupts with hrtimer")
> Signed-off-by: Antoine Tenart <antoine.tenart@free-electrons.com>

Applied.

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

end of thread, other threads:[~2017-10-24  9:35 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-23 13:24 [PATCH net 1/3] net: mvpp2: fix TSO headers allocation and management Antoine Tenart
2017-10-23 13:24 ` [PATCH net 2/3] net: mvpp2: do not unmap TSO headers buffers Antoine Tenart
2017-10-24  9:34   ` David Miller
2017-10-23 13:24 ` [PATCH net 3/3] net: mvpp2: do not call txq_done from the Tx path when Tx irqs are used Antoine Tenart
2017-10-24  9:34   ` David Miller
2017-10-24  9:34 ` [PATCH net 1/3] net: mvpp2: fix TSO headers allocation and management 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).