Skip to content

Commit 4c26cfe

Browse files
pelwellShujathMohd
authored andcommitted
net: bcmgenet: Reset RBUF on first open
[ Upstream commit 0a6380c ] 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: raspberrypi/linux#3850 See: raspberrypi/firmware#1882 Signed-off-by: Phil Elwell <phil@raspberrypi.com> Signed-off-by: Maarten Vanraes <maarten@rmail.be> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Sasha Levin <sashal@kernel.org> (cherry picked from commit 510e7b1) Signed-off-by: Vegard Nossum <vegard.nossum@oracle.com>
1 parent 00f6868 commit 4c26cfe

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

drivers/net/ethernet/broadcom/genet/bcmgenet.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2805,7 +2805,7 @@ static void bcmgenet_set_hw_addr(struct bcmgenet_priv *priv,
28052805
}
28062806

28072807
/* Returns a reusable dma control register value */
2808-
static u32 bcmgenet_dma_disable(struct bcmgenet_priv *priv)
2808+
static u32 bcmgenet_dma_disable(struct bcmgenet_priv *priv, bool flush_rx)
28092809
{
28102810
unsigned int i;
28112811
u32 reg;
@@ -2830,6 +2830,14 @@ static u32 bcmgenet_dma_disable(struct bcmgenet_priv *priv)
28302830
udelay(10);
28312831
bcmgenet_umac_writel(priv, 0, UMAC_TX_FLUSH);
28322832

2833+
if (flush_rx) {
2834+
reg = bcmgenet_rbuf_ctrl_get(priv);
2835+
bcmgenet_rbuf_ctrl_set(priv, reg | BIT(0));
2836+
udelay(10);
2837+
bcmgenet_rbuf_ctrl_set(priv, reg);
2838+
udelay(10);
2839+
}
2840+
28332841
return dma_ctrl;
28342842
}
28352843

@@ -2931,8 +2939,8 @@ static int bcmgenet_open(struct net_device *dev)
29312939

29322940
bcmgenet_set_hw_addr(priv, dev->dev_addr);
29332941

2934-
/* Disable RX/TX DMA and flush TX queues */
2935-
dma_ctrl = bcmgenet_dma_disable(priv);
2942+
/* Disable RX/TX DMA and flush TX and RX queues */
2943+
dma_ctrl = bcmgenet_dma_disable(priv, true);
29362944

29372945
/* Reinitialize TDMA and RDMA and SW housekeeping */
29382946
ret = bcmgenet_init_dma(priv);
@@ -3729,7 +3737,7 @@ static int bcmgenet_resume(struct device *d)
37293737
bcmgenet_power_up(priv, GENET_POWER_WOL_MAGIC);
37303738

37313739
/* Disable RX/TX DMA and flush TX queues */
3732-
dma_ctrl = bcmgenet_dma_disable(priv);
3740+
dma_ctrl = bcmgenet_dma_disable(priv, false);
37333741

37343742
/* Reinitialize TDMA and RDMA and SW housekeeping */
37353743
ret = bcmgenet_init_dma(priv);

0 commit comments

Comments
 (0)