Skip to content

Commit 3066bf6

Browse files
pelwellNipaLocal
authored andcommitted
net: bcmgenet: Reset RBUF on first open
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 <[email protected]> Signed-off-by: Maarten Vanraes <[email protected]> Signed-off-by: NipaLocal <nipa@local>
1 parent 3838962 commit 3066bf6

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
@@ -3280,7 +3280,7 @@ static void bcmgenet_get_hw_addr(struct bcmgenet_priv *priv,
32803280
}
32813281

32823282
/* Returns a reusable dma control register value */
3283-
static u32 bcmgenet_dma_disable(struct bcmgenet_priv *priv)
3283+
static u32 bcmgenet_dma_disable(struct bcmgenet_priv *priv, bool flush_rx)
32843284
{
32853285
unsigned int i;
32863286
u32 reg;
@@ -3305,6 +3305,14 @@ static u32 bcmgenet_dma_disable(struct bcmgenet_priv *priv)
33053305
udelay(10);
33063306
bcmgenet_umac_writel(priv, 0, UMAC_TX_FLUSH);
33073307

3308+
if (flush_rx) {
3309+
reg = bcmgenet_rbuf_ctrl_get(priv);
3310+
bcmgenet_rbuf_ctrl_set(priv, reg | BIT(0));
3311+
udelay(10);
3312+
bcmgenet_rbuf_ctrl_set(priv, reg);
3313+
udelay(10);
3314+
}
3315+
33083316
return dma_ctrl;
33093317
}
33103318

@@ -3368,8 +3376,8 @@ static int bcmgenet_open(struct net_device *dev)
33683376

33693377
bcmgenet_set_hw_addr(priv, dev->dev_addr);
33703378

3371-
/* Disable RX/TX DMA and flush TX queues */
3372-
dma_ctrl = bcmgenet_dma_disable(priv);
3379+
/* Disable RX/TX DMA and flush TX and RX queues */
3380+
dma_ctrl = bcmgenet_dma_disable(priv, true);
33733381

33743382
/* Reinitialize TDMA and RDMA and SW housekeeping */
33753383
ret = bcmgenet_init_dma(priv);
@@ -4235,7 +4243,7 @@ static int bcmgenet_resume(struct device *d)
42354243
bcmgenet_hfb_create_rxnfc_filter(priv, rule);
42364244

42374245
/* Disable RX/TX DMA and flush TX queues */
4238-
dma_ctrl = bcmgenet_dma_disable(priv);
4246+
dma_ctrl = bcmgenet_dma_disable(priv, false);
42394247

42404248
/* Reinitialize TDMA and RDMA and SW housekeeping */
42414249
ret = bcmgenet_init_dma(priv);

0 commit comments

Comments
 (0)