/[packages]/backports/8/kernel/current/SOURCES/net-stmmac-work-around-sporadic-tx-issue-on-link-up.patch
ViewVC logotype

Contents of /backports/8/kernel/current/SOURCES/net-stmmac-work-around-sporadic-tx-issue-on-link-up.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1881590 - (show annotations) (download)
Mon Aug 29 03:49:40 2022 UTC (19 months, 2 weeks ago) by tmb
File size: 3443 byte(s)
- add current -stable queue
- io_uring: fix issue with io_write() not always undoing sb_start_write()
- HID: input: fix uclogic tablets


1 From 0dd4fe03156810ab212427474240ea66e35e49f7 Mon Sep 17 00:00:00 2001
2 From: Sasha Levin <sashal@kernel.org>
3 Date: Wed, 24 Aug 2022 22:34:49 +0200
4 Subject: net: stmmac: work around sporadic tx issue on link-up
5
6 From: Heiner Kallweit <hkallweit1@gmail.com>
7
8 [ Upstream commit a3a57bf07de23fe1ff779e0fdf710aa581c3ff73 ]
9
10 This is a follow-up to the discussion in [0]. It seems to me that
11 at least the IP version used on Amlogic SoC's sometimes has a problem
12 if register MAC_CTRL_REG is written whilst the chip is still processing
13 a previous write. But that's just a guess.
14 Adding a delay between two writes to this register helps, but we can
15 also simply omit the offending second write. This patch uses the second
16 approach and is based on a suggestion from Qi Duan.
17 Benefit of this approach is that we can save few register writes, also
18 on not affected chip versions.
19
20 [0] https://www.spinics.net/lists/netdev/msg831526.html
21
22 Fixes: bfab27a146ed ("stmmac: add the experimental PCI support")
23 Suggested-by: Qi Duan <qi.duan@amlogic.com>
24 Suggested-by: Jerome Brunet <jbrunet@baylibre.com>
25 Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
26 Link: https://lore.kernel.org/r/e99857ce-bd90-5093-ca8c-8cd480b5a0a2@gmail.com
27 Signed-off-by: Jakub Kicinski <kuba@kernel.org>
28 Signed-off-by: Sasha Levin <sashal@kernel.org>
29 ---
30 drivers/net/ethernet/stmicro/stmmac/dwmac_lib.c | 8 ++++++--
31 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 9 +++++----
32 2 files changed, 11 insertions(+), 6 deletions(-)
33
34 diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac_lib.c b/drivers/net/ethernet/stmicro/stmmac/dwmac_lib.c
35 index caa4bfc4c1d62..9b6138b117766 100644
36 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac_lib.c
37 +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac_lib.c
38 @@ -258,14 +258,18 @@ EXPORT_SYMBOL_GPL(stmmac_set_mac_addr);
39 /* Enable disable MAC RX/TX */
40 void stmmac_set_mac(void __iomem *ioaddr, bool enable)
41 {
42 - u32 value = readl(ioaddr + MAC_CTRL_REG);
43 + u32 old_val, value;
44 +
45 + old_val = readl(ioaddr + MAC_CTRL_REG);
46 + value = old_val;
47
48 if (enable)
49 value |= MAC_ENABLE_RX | MAC_ENABLE_TX;
50 else
51 value &= ~(MAC_ENABLE_TX | MAC_ENABLE_RX);
52
53 - writel(value, ioaddr + MAC_CTRL_REG);
54 + if (value != old_val)
55 + writel(value, ioaddr + MAC_CTRL_REG);
56 }
57
58 void stmmac_get_mac_addr(void __iomem *ioaddr, unsigned char *addr,
59 diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
60 index c5f33630e7718..78f11dabca056 100644
61 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
62 +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
63 @@ -983,10 +983,10 @@ static void stmmac_mac_link_up(struct phylink_config *config,
64 bool tx_pause, bool rx_pause)
65 {
66 struct stmmac_priv *priv = netdev_priv(to_net_dev(config->dev));
67 - u32 ctrl;
68 + u32 old_ctrl, ctrl;
69
70 - ctrl = readl(priv->ioaddr + MAC_CTRL_REG);
71 - ctrl &= ~priv->hw->link.speed_mask;
72 + old_ctrl = readl(priv->ioaddr + MAC_CTRL_REG);
73 + ctrl = old_ctrl & ~priv->hw->link.speed_mask;
74
75 if (interface == PHY_INTERFACE_MODE_USXGMII) {
76 switch (speed) {
77 @@ -1061,7 +1061,8 @@ static void stmmac_mac_link_up(struct phylink_config *config,
78 if (tx_pause && rx_pause)
79 stmmac_mac_flow_ctrl(priv, duplex);
80
81 - writel(ctrl, priv->ioaddr + MAC_CTRL_REG);
82 + if (ctrl != old_ctrl)
83 + writel(ctrl, priv->ioaddr + MAC_CTRL_REG);
84
85 stmmac_mac_set(priv, priv->ioaddr, true);
86 if (phy && priv->dma_cap.eee) {
87 --
88 2.35.1
89

  ViewVC Help
Powered by ViewVC 1.1.30