mac80211: refresh patches
[openwrt/staging/chunkeey.git] / target / linux / brcm2708 / patches-4.19 / 950-0748-net-bcmgenet-Workaround-for-Pi-4B-network-issue.patch
1 From 82a6bacc6df57c05093bea3f628d4d0b5f7a49a2 Mon Sep 17 00:00:00 2001
2 From: Phil Elwell <phil@raspberrypi.org>
3 Date: Fri, 2 Aug 2019 22:25:27 +0100
4 Subject: [PATCH 748/806] net: bcmgenet: Workaround for Pi 4B network issue
5
6 Some combinations of Pi 4Bs and Ethernet switches don't reliably get a
7 DCHP-assigned IP address, leaving the unit with a self=assigned 169.254
8 address.
9
10 Forcing renegotiation has been found to be an effective workaround, so
11 add an automatic renegotiation after the link comes up for the first
12 time; enable it with genet.force_reneg=y - by default it is disabled.
13
14 See: https://github.com/raspberrypi/linux/issues/3108
15
16 Signed-off-by: Phil Elwell <phil@raspberrypi.org>
17 ---
18 .../net/ethernet/broadcom/genet/bcmgenet.c | 22 +++++++++++++++++++
19 1 file changed, 22 insertions(+)
20
21 --- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c
22 +++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
23 @@ -72,6 +72,10 @@
24 #define GENET_RDMA_REG_OFF (priv->hw_params->rdma_offset + \
25 TOTAL_DESC * DMA_DESC_SIZE)
26
27 +static bool force_reneg = false;
28 +module_param(force_reneg, bool, 0444);
29 +MODULE_PARM_DESC(force_reneg, "Force a renegotiation after the initial link-up");
30 +
31 static inline void bcmgenet_writel(u32 value, void __iomem *offset)
32 {
33 /* MIPS chips strapped for BE will automagically configure the
34 @@ -2612,6 +2616,7 @@ static void bcmgenet_irq_task(struct wor
35 unsigned int status;
36 struct bcmgenet_priv *priv = container_of(
37 work, struct bcmgenet_priv, bcmgenet_irq_work);
38 + static int first_link = 1;
39
40 netif_dbg(priv, intr, priv->dev, "%s\n", __func__);
41
42 @@ -2625,9 +2630,26 @@ static void bcmgenet_irq_task(struct wor
43 phy_init_hw(priv->dev->phydev);
44
45 /* Link UP/DOWN event */
46 - if (status & UMAC_IRQ_LINK_EVENT)
47 + if (status & UMAC_IRQ_LINK_EVENT) {
48 phy_mac_interrupt(priv->dev->phydev);
49
50 + if (priv->dev->phydev->link && first_link) {
51 + first_link = 0;
52 + /*
53 + * HACK: Some Pi4Bs, when paired with some switches,
54 + * come up in a strange state where they are unable to
55 + * transmit, causing them to fail to get an IP address.
56 + * Although the failure mechanism is not yet understood,
57 + * forcing renegotiation at this point has been shown
58 + * to be effective in avoiding the problem.
59 + */
60 + if (force_reneg) {
61 + dev_info(&priv->pdev->dev,
62 + "Forcing renegotiation\n");
63 + genphy_restart_aneg(priv->dev->phydev);
64 + }
65 + }
66 + }
67 }
68
69 /* bcmgenet_isr1: handle Rx and Tx priority queues */