All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net 0/4] net: mvpp2: set of fixes
@ 2017-11-28 13:19 Antoine Tenart
  2017-11-28 13:19 ` [PATCH net 1/4] net: mvpp2: fix the txq_init error path Antoine Tenart
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Antoine Tenart @ 2017-11-28 13:19 UTC (permalink / raw)
  To: davem
  Cc: Antoine Tenart, gregory.clement, thomas.petazzoni, miquel.raynal,
	nadavh, mw, stefanc, ymarkman, netdev, linux-kernel

Hi all,

This series fixes various issues with the Marvell PPv2 driver. The
patches are sent together to avoid any possible conflict. The series is
based on today's net tree.

Thanks!
Antoine

Antoine Tenart (3):
  net: mvpp2: fix the txq_init error path
  net: mvpp2: cleanup probed ports in the probe error path
  net: mvpp2: check ethtool sets the Tx ring size is to a valid min
    value

Yan Markman (1):
  net: mvpp2: do not disable GMAC padding

 drivers/net/ethernet/marvell/mvpp2.c | 46 +++++++++++++-----------------------
 1 file changed, 17 insertions(+), 29 deletions(-)

-- 
2.14.3

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

* [PATCH net 1/4] net: mvpp2: fix the txq_init error path
  2017-11-28 13:19 [PATCH net 0/4] net: mvpp2: set of fixes Antoine Tenart
@ 2017-11-28 13:19 ` Antoine Tenart
  2017-11-28 13:19 ` [PATCH net 2/4] net: mvpp2: cleanup probed ports in the probe " Antoine Tenart
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Antoine Tenart @ 2017-11-28 13:19 UTC (permalink / raw)
  To: davem
  Cc: Antoine Tenart, gregory.clement, thomas.petazzoni, miquel.raynal,
	nadavh, mw, stefanc, ymarkman, netdev, linux-kernel

When an allocation in the txq_init path fails, the allocated buffers
end-up being freed twice: in the txq_init error path, and in txq_deinit.
This lead to issues as txq_deinit would work on already freed memory
regions:

    kernel BUG at mm/slub.c:3915!
    Internal error: Oops - BUG: 0 [#1] PREEMPT SMP

This patch fixes this by removing the txq_init own error path, as the
txq_deinit function is always called on errors. This was introduced by
TSO as way more buffers are allocated.

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

diff --git a/drivers/net/ethernet/marvell/mvpp2.c b/drivers/net/ethernet/marvell/mvpp2.c
index 6c20e811f973..79f01cd80dd7 100644
--- a/drivers/net/ethernet/marvell/mvpp2.c
+++ b/drivers/net/ethernet/marvell/mvpp2.c
@@ -5805,7 +5805,7 @@ static int mvpp2_txq_init(struct mvpp2_port *port,
 						sizeof(*txq_pcpu->buffs),
 						GFP_KERNEL);
 		if (!txq_pcpu->buffs)
-			goto cleanup;
+			return -ENOMEM;
 
 		txq_pcpu->count = 0;
 		txq_pcpu->reserved_num = 0;
@@ -5821,26 +5821,10 @@ static int mvpp2_txq_init(struct mvpp2_port *port,
 					   &txq_pcpu->tso_headers_dma,
 					   GFP_KERNEL);
 		if (!txq_pcpu->tso_headers)
-			goto cleanup;
+			return -ENOMEM;
 	}
 
 	return 0;
-cleanup:
-	for_each_present_cpu(cpu) {
-		txq_pcpu = per_cpu_ptr(txq->pcpu, cpu);
-		kfree(txq_pcpu->buffs);
-
-		dma_free_coherent(port->dev->dev.parent,
-				  txq_pcpu->size * TSO_HEADER_SIZE,
-				  txq_pcpu->tso_headers,
-				  txq_pcpu->tso_headers_dma);
-	}
-
-	dma_free_coherent(port->dev->dev.parent,
-			  txq->size * MVPP2_DESC_ALIGNED_SIZE,
-			  txq->descs, txq->descs_dma);
-
-	return -ENOMEM;
 }
 
 /* Free allocated TXQ resources */
-- 
2.14.3

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

* [PATCH net 2/4] net: mvpp2: cleanup probed ports in the probe error path
  2017-11-28 13:19 [PATCH net 0/4] net: mvpp2: set of fixes Antoine Tenart
  2017-11-28 13:19 ` [PATCH net 1/4] net: mvpp2: fix the txq_init error path Antoine Tenart
@ 2017-11-28 13:19 ` Antoine Tenart
  2017-11-28 13:19 ` [PATCH net 3/4] net: mvpp2: do not disable GMAC padding Antoine Tenart
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Antoine Tenart @ 2017-11-28 13:19 UTC (permalink / raw)
  To: davem
  Cc: Antoine Tenart, gregory.clement, thomas.petazzoni, miquel.raynal,
	nadavh, mw, stefanc, ymarkman, netdev, linux-kernel

This patches fixes the probe error path by cleaning up probed ports, to
avoid leaving registered net devices when the driver failed to probe.

Fixes: 3f518509dedc ("ethernet: Add new driver for Marvell Armada 375 network unit")
Signed-off-by: Antoine Tenart <antoine.tenart@free-electrons.com>
---
 drivers/net/ethernet/marvell/mvpp2.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/marvell/mvpp2.c b/drivers/net/ethernet/marvell/mvpp2.c
index 79f01cd80dd7..afae4fe00965 100644
--- a/drivers/net/ethernet/marvell/mvpp2.c
+++ b/drivers/net/ethernet/marvell/mvpp2.c
@@ -8329,7 +8329,7 @@ static int mvpp2_probe(struct platform_device *pdev)
 	for_each_available_child_of_node(dn, port_node) {
 		err = mvpp2_port_probe(pdev, port_node, priv, i);
 		if (err < 0)
-			goto err_mg_clk;
+			goto err_port_probe;
 		i++;
 	}
 
@@ -8345,12 +8345,19 @@ static int mvpp2_probe(struct platform_device *pdev)
 	priv->stats_queue = create_singlethread_workqueue(priv->queue_name);
 	if (!priv->stats_queue) {
 		err = -ENOMEM;
-		goto err_mg_clk;
+		goto err_port_probe;
 	}
 
 	platform_set_drvdata(pdev, priv);
 	return 0;
 
+err_port_probe:
+	i = 0;
+	for_each_available_child_of_node(dn, port_node) {
+		if (priv->port_list[i])
+			mvpp2_port_remove(priv->port_list[i]);
+		i++;
+	}
 err_mg_clk:
 	clk_disable_unprepare(priv->axi_clk);
 	if (priv->hw_version == MVPP22)
-- 
2.14.3

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

* [PATCH net 3/4] net: mvpp2: do not disable GMAC padding
  2017-11-28 13:19 [PATCH net 0/4] net: mvpp2: set of fixes Antoine Tenart
  2017-11-28 13:19 ` [PATCH net 1/4] net: mvpp2: fix the txq_init error path Antoine Tenart
  2017-11-28 13:19 ` [PATCH net 2/4] net: mvpp2: cleanup probed ports in the probe " Antoine Tenart
@ 2017-11-28 13:19 ` Antoine Tenart
  2017-11-28 13:19 ` [PATCH net 4/4] net: mvpp2: check ethtool sets the Tx ring size is to a valid min value Antoine Tenart
  2017-11-28 15:18 ` [PATCH net 0/4] net: mvpp2: set of fixes David Miller
  4 siblings, 0 replies; 6+ messages in thread
From: Antoine Tenart @ 2017-11-28 13:19 UTC (permalink / raw)
  To: davem
  Cc: Yan Markman, gregory.clement, thomas.petazzoni, miquel.raynal,
	nadavh, mw, stefanc, netdev, linux-kernel, Antoine Tenart

From: Yan Markman <ymarkman@marvell.com>

Short fragmented packets may never be sent by the hardware when padding
is disabled. This patch stop modifying the GMAC padding bits, to leave
them to their reset value (disabled).

Fixes: 3919357fb0bb ("net: mvpp2: initialize the GMAC when using a port")
Signed-off-by: Yan Markman <ymarkman@marvell.com>
[Antoine: commit message]
Signed-off-by: Antoine Tenart <antoine.tenart@free-electrons.com>
---
 drivers/net/ethernet/marvell/mvpp2.c | 9 ---------
 1 file changed, 9 deletions(-)

diff --git a/drivers/net/ethernet/marvell/mvpp2.c b/drivers/net/ethernet/marvell/mvpp2.c
index afae4fe00965..5be58b04b95e 100644
--- a/drivers/net/ethernet/marvell/mvpp2.c
+++ b/drivers/net/ethernet/marvell/mvpp2.c
@@ -4629,11 +4629,6 @@ static void mvpp2_port_mii_gmac_configure_mode(struct mvpp2_port *port)
 		       MVPP22_CTRL4_QSGMII_BYPASS_ACTIVE;
 		val &= ~MVPP22_CTRL4_EXT_PIN_GMII_SEL;
 		writel(val, port->base + MVPP22_GMAC_CTRL_4_REG);
-
-		val = readl(port->base + MVPP2_GMAC_CTRL_2_REG);
-		val |= MVPP2_GMAC_DISABLE_PADDING;
-		val &= ~MVPP2_GMAC_FLOW_CTRL_MASK;
-		writel(val, port->base + MVPP2_GMAC_CTRL_2_REG);
 	} else if (phy_interface_mode_is_rgmii(port->phy_interface)) {
 		val = readl(port->base + MVPP22_GMAC_CTRL_4_REG);
 		val |= MVPP22_CTRL4_EXT_PIN_GMII_SEL |
@@ -4641,10 +4636,6 @@ static void mvpp2_port_mii_gmac_configure_mode(struct mvpp2_port *port)
 		       MVPP22_CTRL4_QSGMII_BYPASS_ACTIVE;
 		val &= ~MVPP22_CTRL4_DP_CLK_SEL;
 		writel(val, port->base + MVPP22_GMAC_CTRL_4_REG);
-
-		val = readl(port->base + MVPP2_GMAC_CTRL_2_REG);
-		val &= ~MVPP2_GMAC_DISABLE_PADDING;
-		writel(val, port->base + MVPP2_GMAC_CTRL_2_REG);
 	}
 
 	/* The port is connected to a copper PHY */
-- 
2.14.3

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

* [PATCH net 4/4] net: mvpp2: check ethtool sets the Tx ring size is to a valid min value
  2017-11-28 13:19 [PATCH net 0/4] net: mvpp2: set of fixes Antoine Tenart
                   ` (2 preceding siblings ...)
  2017-11-28 13:19 ` [PATCH net 3/4] net: mvpp2: do not disable GMAC padding Antoine Tenart
@ 2017-11-28 13:19 ` Antoine Tenart
  2017-11-28 15:18 ` [PATCH net 0/4] net: mvpp2: set of fixes David Miller
  4 siblings, 0 replies; 6+ messages in thread
From: Antoine Tenart @ 2017-11-28 13:19 UTC (permalink / raw)
  To: davem
  Cc: Antoine Tenart, gregory.clement, thomas.petazzoni, miquel.raynal,
	nadavh, mw, stefanc, ymarkman, netdev, linux-kernel

This patch fixes the Tx ring size checks when using ethtool, by adding
an extra check in the PPv2 check_ringparam_valid helper. The Tx ring
size cannot be set to a value smaller than the minimum number of
descriptors needed for TSO.

Fixes: 1d17db08c056 ("net: mvpp2: limit TSO segments and use stop/wake thresholds")
Suggested-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, 6 insertions(+)

diff --git a/drivers/net/ethernet/marvell/mvpp2.c b/drivers/net/ethernet/marvell/mvpp2.c
index 5be58b04b95e..d83a78be98a2 100644
--- a/drivers/net/ethernet/marvell/mvpp2.c
+++ b/drivers/net/ethernet/marvell/mvpp2.c
@@ -6842,6 +6842,12 @@ static int mvpp2_check_ringparam_valid(struct net_device *dev,
 	else if (!IS_ALIGNED(ring->tx_pending, 32))
 		new_tx_pending = ALIGN(ring->tx_pending, 32);
 
+	/* The Tx ring size cannot be smaller than the minimum number of
+	 * descriptors needed for TSO.
+	 */
+	if (new_tx_pending < MVPP2_MAX_SKB_DESCS)
+		new_tx_pending = ALIGN(MVPP2_MAX_SKB_DESCS, 32);
+
 	if (ring->rx_pending != new_rx_pending) {
 		netdev_info(dev, "illegal Rx ring size value %d, round to %d\n",
 			    ring->rx_pending, new_rx_pending);
-- 
2.14.3

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

* Re: [PATCH net 0/4] net: mvpp2: set of fixes
  2017-11-28 13:19 [PATCH net 0/4] net: mvpp2: set of fixes Antoine Tenart
                   ` (3 preceding siblings ...)
  2017-11-28 13:19 ` [PATCH net 4/4] net: mvpp2: check ethtool sets the Tx ring size is to a valid min value Antoine Tenart
@ 2017-11-28 15:18 ` David Miller
  4 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2017-11-28 15:18 UTC (permalink / raw)
  To: antoine.tenart
  Cc: gregory.clement, thomas.petazzoni, miquel.raynal, nadavh, mw,
	stefanc, ymarkman, netdev, linux-kernel

From: Antoine Tenart <antoine.tenart@free-electrons.com>
Date: Tue, 28 Nov 2017 14:19:47 +0100

> This series fixes various issues with the Marvell PPv2 driver. The
> patches are sent together to avoid any possible conflict. The series is
> based on today's net tree.

Series applied, thank you.

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

end of thread, other threads:[~2017-11-28 15:18 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-28 13:19 [PATCH net 0/4] net: mvpp2: set of fixes Antoine Tenart
2017-11-28 13:19 ` [PATCH net 1/4] net: mvpp2: fix the txq_init error path Antoine Tenart
2017-11-28 13:19 ` [PATCH net 2/4] net: mvpp2: cleanup probed ports in the probe " Antoine Tenart
2017-11-28 13:19 ` [PATCH net 3/4] net: mvpp2: do not disable GMAC padding Antoine Tenart
2017-11-28 13:19 ` [PATCH net 4/4] net: mvpp2: check ethtool sets the Tx ring size is to a valid min value Antoine Tenart
2017-11-28 15:18 ` [PATCH net 0/4] net: mvpp2: set of fixes David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.