kernel: bump 5.15 to 5.15.100
[openwrt/openwrt.git] / target / linux / bcm27xx / patches-5.15 / 950-0292-net-bcmgenet-Reset-RBUF-on-first-open.patch
1 From 87bb6f0edf9a4a14d9b41bcfe97216f74f730b43 Mon Sep 17 00:00:00 2001
2 From: Phil Elwell <phil@raspberrypi.com>
3 Date: Fri, 25 Sep 2020 15:07:23 +0100
4 Subject: [PATCH] net: bcmgenet: Reset RBUF on first open
5
6 If the RBUF logic is not reset when the kernel starts then there
7 may be some data left over from any network boot loader. If the
8 64-byte packet headers are enabled then this can be fatal.
9
10 Extend bcmgenet_dma_disable to do perform the reset, but not when
11 called from bcmgenet_resume in order to preserve a wake packet.
12
13 N.B. This different handling of resume is just based on a hunch -
14 why else wouldn't one reset the RBUF as well as the TBUF? If this
15 isn't the case then it's easy to change the patch to make the RBUF
16 reset unconditional.
17
18 See: https://github.com/raspberrypi/linux/issues/3850
19
20 Signed-off-by: Phil Elwell <phil@raspberrypi.com>
21 ---
22 drivers/net/ethernet/broadcom/genet/bcmgenet.c | 16 ++++++++++++----
23 1 file changed, 12 insertions(+), 4 deletions(-)
24
25 --- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c
26 +++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
27 @@ -3265,7 +3265,7 @@ static void bcmgenet_get_hw_addr(struct
28 }
29
30 /* Returns a reusable dma control register value */
31 -static u32 bcmgenet_dma_disable(struct bcmgenet_priv *priv)
32 +static u32 bcmgenet_dma_disable(struct bcmgenet_priv *priv, bool flush_rx)
33 {
34 unsigned int i;
35 u32 reg;
36 @@ -3290,6 +3290,14 @@ static u32 bcmgenet_dma_disable(struct b
37 udelay(10);
38 bcmgenet_umac_writel(priv, 0, UMAC_TX_FLUSH);
39
40 + if (flush_rx) {
41 + reg = bcmgenet_rbuf_ctrl_get(priv);
42 + bcmgenet_rbuf_ctrl_set(priv, reg | BIT(0));
43 + udelay(10);
44 + bcmgenet_rbuf_ctrl_set(priv, reg);
45 + udelay(10);
46 + }
47 +
48 return dma_ctrl;
49 }
50
51 @@ -3353,8 +3361,8 @@ static int bcmgenet_open(struct net_devi
52
53 bcmgenet_set_hw_addr(priv, dev->dev_addr);
54
55 - /* Disable RX/TX DMA and flush TX queues */
56 - dma_ctrl = bcmgenet_dma_disable(priv);
57 + /* Disable RX/TX DMA and flush TX and RX queues */
58 + dma_ctrl = bcmgenet_dma_disable(priv, true);
59
60 /* Reinitialize TDMA and RDMA and SW housekeeping */
61 ret = bcmgenet_init_dma(priv);
62 @@ -4212,7 +4220,7 @@ static int bcmgenet_resume(struct device
63 bcmgenet_hfb_create_rxnfc_filter(priv, rule);
64
65 /* Disable RX/TX DMA and flush TX queues */
66 - dma_ctrl = bcmgenet_dma_disable(priv);
67 + dma_ctrl = bcmgenet_dma_disable(priv, false);
68
69 /* Reinitialize TDMA and RDMA and SW housekeeping */
70 ret = bcmgenet_init_dma(priv);