[U-Boot] [PATCH 04/10] net: mvpp2x: fix BM configuration overrun issue

stefanc at malvell.com stefanc at malvell.com
Wed Jun 21 08:31:32 UTC 2017


From: Stefan Chulski <stefanc at marvell.com>

Issue:
BM counters were overran by probe that called per Network interface and
caused release of wrong number of buffers during remove procedure.

Fix:
Add CP level flags to call init and remove procedure once per CP.

Change-Id: I7fa24704e1feadb079d7dc3a19a0b92b3b69b238
Signed-off-by: Stefan Chulski <stefanc at marvell.com>
Reviewed-on: http://vgitil04.il.marvell.com:8080/39400
Tested-by: iSoC Platform CI <ykjenk at marvell.com>
Reviewed-by: Igal Liberman <igall at marvell.com>
---
 drivers/net/mvpp2.c | 27 ++++++++++++++++++++++-----
 1 file changed, 22 insertions(+), 5 deletions(-)

diff --git a/drivers/net/mvpp2.c b/drivers/net/mvpp2.c
index 3083111..af3c3ef 100644
--- a/drivers/net/mvpp2.c
+++ b/drivers/net/mvpp2.c
@@ -67,6 +67,12 @@ do {									\
 
 #define NET_SKB_PAD	max(32, MVPP2_CPU_D_CACHE_LINE_SIZE)
 
+#define MV_EMAC_F_REMOVE_BIT	0
+#define MVPP2_F_PROBE_BIT	1
+
+#define MVPP2_F_PROBE		BIT(MV_EMAC_F_REMOVE_BIT)
+#define MVPP2_F_REMOVE		BIT(MVPP2_F_PROBE_BIT)
+
 #define CONFIG_NR_CPUS		1
 #define ETH_HLEN		ETHER_HDR_SIZE	/* Total octets in header */
 
@@ -942,6 +948,9 @@ struct mvpp2 {
 	struct mii_dev *bus;
 
 	int probe_done;
+
+	/* Flags */
+	u64 flags;
 };
 
 struct mvpp2_pcpu_stats {
@@ -5553,11 +5562,14 @@ static int mvpp2_probe(struct udevice *dev)
 		gop_port_init(port);
 	}
 
-	/* Initialize network controller */
-	err = mvpp2_init(dev, priv);
-	if (err < 0) {
-		dev_err(&pdev->dev, "failed to initialize controller\n");
-		return err;
+	if (!(priv->flags & MVPP2_F_PROBE)) {
+		/* Initialize network controller */
+		err = mvpp2_init(dev, priv);
+		if (err < 0) {
+			dev_err(&pdev->dev, "failed to initialize controller\n");
+			return err;
+		}
+		priv->flags |= MVPP2_F_PROBE;
 	}
 
 	err = mvpp2_port_probe(dev, port, dev_of_offset(dev), priv);
@@ -5585,9 +5597,14 @@ static int mvpp2_remove(struct udevice *dev)
 	struct mvpp2 *priv = port->priv;
 	int i;
 
+	if (priv->flags & MVPP2_F_REMOVE)
+		return 0;
+
 	for (i = 0; i < MVPP2_BM_POOLS_NUM; i++)
 		mvpp2_bm_pool_destroy(dev, priv, &priv->bm_pools[i]);
 
+	priv->flags |= MVPP2_F_REMOVE;
+
 	return 0;
 }
 
-- 
1.9.1



More information about the U-Boot mailing list