All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] net: bcmgenet: Reset RBUF on first open
@ 2024-02-23 23:53 Maarten Vanraes
  2024-02-26 17:34 ` Florian Fainelli
  0 siblings, 1 reply; 13+ messages in thread
From: Maarten Vanraes @ 2024-02-23 23:53 UTC (permalink / raw)
  To: Doug Berger, Florian Fainelli
  Cc: netdev, Broadcom internal kernel review list, Phil Elwell,
	Maarten Vanraes

From: Phil Elwell <phil@raspberrypi.com>

If the RBUF logic is not reset when the kernel starts then there
may be some data left over from any network boot loader. If the
64-byte packet headers are enabled then this can be fatal.

Extend bcmgenet_dma_disable to do perform the reset, but not when
called from bcmgenet_resume in order to preserve a wake packet.

N.B. This different handling of resume is just based on a hunch -
why else wouldn't one reset the RBUF as well as the TBUF? If this
isn't the case then it's easy to change the patch to make the RBUF
reset unconditional.

See: https://github.com/raspberrypi/linux/issues/3850

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
Signed-off-by: Maarten Vanraes <maarten@rmail.be>
---
 drivers/net/ethernet/broadcom/genet/bcmgenet.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

This patch fixes a problem on RPI 4B where in ~2/3 cases (if you're using
nfsroot), you fail to boot; or at least the boot takes longer than
30 minutes.

Doing a simple ping revealed that when the ping starts working again
(during the boot process), you have ping timings of ~1000ms, 2000ms or
even 3000ms; while in normal cases it would be around 0.2ms.

diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
index 2d7ae71287b1..58995772cc00 100644
--- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c
+++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
@@ -3282,7 +3282,7 @@ static void bcmgenet_get_hw_addr(struct bcmgenet_priv *priv,
 }
 
 /* Returns a reusable dma control register value */
-static u32 bcmgenet_dma_disable(struct bcmgenet_priv *priv)
+static u32 bcmgenet_dma_disable(struct bcmgenet_priv *priv, bool flush_rx)
 {
 	unsigned int i;
 	u32 reg;
@@ -3307,6 +3307,14 @@ static u32 bcmgenet_dma_disable(struct bcmgenet_priv *priv)
 	udelay(10);
 	bcmgenet_umac_writel(priv, 0, UMAC_TX_FLUSH);
 
+	if (flush_rx) {
+	    reg = bcmgenet_rbuf_ctrl_get(priv);
+	    bcmgenet_rbuf_ctrl_set(priv, reg | BIT(0));
+	    udelay(10);
+	    bcmgenet_rbuf_ctrl_set(priv, reg);
+	    udelay(10);
+	}
+
 	return dma_ctrl;
 }
 
@@ -3370,8 +3378,8 @@ static int bcmgenet_open(struct net_device *dev)
 
 	bcmgenet_set_hw_addr(priv, dev->dev_addr);
 
-	/* Disable RX/TX DMA and flush TX queues */
-	dma_ctrl = bcmgenet_dma_disable(priv);
+	/* Disable RX/TX DMA and flush TX and RX queues */
+	dma_ctrl = bcmgenet_dma_disable(priv, true);
 
 	/* Reinitialize TDMA and RDMA and SW housekeeping */
 	ret = bcmgenet_init_dma(priv);
@@ -4237,7 +4245,7 @@ static int bcmgenet_resume(struct device *d)
 			bcmgenet_hfb_create_rxnfc_filter(priv, rule);
 
 	/* Disable RX/TX DMA and flush TX queues */
-	dma_ctrl = bcmgenet_dma_disable(priv);
+	dma_ctrl = bcmgenet_dma_disable(priv, false);
 
 	/* Reinitialize TDMA and RDMA and SW housekeeping */
 	ret = bcmgenet_init_dma(priv);
-- 
2.41.0


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

end of thread, other threads:[~2024-03-19 21:50 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-23 23:53 [PATCH] net: bcmgenet: Reset RBUF on first open Maarten Vanraes
2024-02-26 17:34 ` Florian Fainelli
2024-02-26 19:14   ` Maarten
2024-02-26 23:13   ` Doug Berger
2024-02-27 12:53     ` Paolo Abeni
2024-03-05 15:13     ` Jakub Kicinski
2024-03-05 20:36       ` Maarten
2024-03-05 21:07         ` Jakub Kicinski
2024-03-06  8:03           ` Maarten
2024-03-16 11:53     ` Maarten
2024-03-19 16:56       ` Florian Fainelli
2024-03-19 21:11         ` Maarten
2024-03-19 21:50           ` Florian Fainelli

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.