brcm2708: update to latest patches from RPi foundation
[openwrt/staging/stintel.git] / target / linux / brcm2708 / patches-4.19 / 950-0748-net-bcmgenet-Workaround-for-Pi-4B-network-issue.patch
1 From 3695a97f62ba999293cb5f92e29179e8beaa44a8 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/782] 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 @@ -2610,6 +2614,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 @@ -2622,6 +2627,23 @@ static void bcmgenet_irq_task(struct wor
43 if (status & UMAC_IRQ_LINK_EVENT) {
44 priv->dev->phydev->link = !!(status & UMAC_IRQ_LINK_UP);
45 phy_mac_interrupt(priv->dev->phydev);
46 +
47 + if (priv->dev->phydev->link && first_link) {
48 + first_link = 0;
49 + /*
50 + * HACK: Some Pi4Bs, when paired with some switches,
51 + * come up in a strange state where they are unable to
52 + * transmit, causing them to fail to get an IP address.
53 + * Although the failure mechanism is not yet understood,
54 + * forcing renegotiation at this point has been shown
55 + * to be effective in avoiding the problem.
56 + */
57 + if (force_reneg) {
58 + dev_info(&priv->pdev->dev,
59 + "Forcing renegotiation\n");
60 + genphy_restart_aneg(priv->dev->phydev);
61 + }
62 + }
63 }
64 }
65