1 From cf2ffdea0839398cb0551762af7f5efb0a6e0fea Mon Sep 17 00:00:00 2001
2 From: Heiner Kallweit <hkallweit1@gmail.com>
3 Date: Tue, 18 Jul 2023 13:11:31 +0200
4 Subject: r8169: revert 2ab19de62d67 ("r8169: remove ASPM restrictions now that ASPM is disabled during NAPI poll")
6 From: Heiner Kallweit <hkallweit1@gmail.com>
8 commit cf2ffdea0839398cb0551762af7f5efb0a6e0fea upstream.
10 There have been reports that on a number of systems this change breaks
11 network connectivity. Therefore effectively revert it. Mainly affected
12 seem to be systems where BIOS denies ASPM access to OS.
13 Due to later changes we can't do a direct revert.
15 Fixes: 2ab19de62d67 ("r8169: remove ASPM restrictions now that ASPM is disabled during NAPI poll")
16 Cc: stable@vger.kernel.org
17 Link: https://lore.kernel.org/netdev/e47bac0d-e802-65e1-b311-6acb26d5cf10@freenet.de/T/
18 Closes: https://bugzilla.kernel.org/show_bug.cgi?id=217596
19 Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
20 Link: https://lore.kernel.org/r/57f13ec0-b216-d5d8-363d-5b05528ec5fb@gmail.com
21 Signed-off-by: Jakub Kicinski <kuba@kernel.org>
22 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
24 drivers/net/ethernet/realtek/r8169_main.c | 27 ++++++++++++++++++++++++++-
25 1 file changed, 26 insertions(+), 1 deletion(-)
27 --- a/drivers/net/ethernet/realtek/r8169_main.c
28 +++ b/drivers/net/ethernet/realtek/r8169_main.c
29 @@ -623,6 +623,7 @@ struct rtl8169_private {
30 int cfg9346_usage_count;
32 unsigned supports_gmii:1;
33 + unsigned aspm_manageable:1;
34 dma_addr_t counters_phys_addr;
35 struct rtl8169_counters *counters;
36 struct rtl8169_tc_offsets tc_offset;
37 @@ -2746,7 +2747,8 @@ static void rtl_hw_aspm_clkreq_enable(st
38 if (tp->mac_version < RTL_GIGA_MAC_VER_32)
42 + /* Don't enable ASPM in the chip if OS can't control ASPM */
43 + if (enable && tp->aspm_manageable) {
44 /* On these chip versions ASPM can even harm
45 * bus communication of other PCI devices.
47 @@ -5156,6 +5158,16 @@ done:
48 rtl_rar_set(tp, mac_addr);
51 +/* register is set if system vendor successfully tested ASPM 1.2 */
52 +static bool rtl_aspm_is_safe(struct rtl8169_private *tp)
54 + if (tp->mac_version >= RTL_GIGA_MAC_VER_61 &&
55 + r8168_mac_ocp_read(tp, 0xc0b2) & 0xf)
61 static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
63 struct rtl8169_private *tp;
64 @@ -5227,6 +5239,19 @@ static int rtl_init_one(struct pci_dev *
66 tp->mac_version = chipset;
68 + /* Disable ASPM L1 as that cause random device stop working
69 + * problems as well as full system hangs for some PCIe devices users.
70 + * Chips from RTL8168h partially have issues with L1.2, but seem
71 + * to work fine with L1 and L1.1.
73 + if (rtl_aspm_is_safe(tp))
75 + else if (tp->mac_version >= RTL_GIGA_MAC_VER_46)
76 + rc = pci_disable_link_state(pdev, PCIE_LINK_STATE_L1_2);
78 + rc = pci_disable_link_state(pdev, PCIE_LINK_STATE_L1);
79 + tp->aspm_manageable = !rc;
81 tp->dash_type = rtl_check_dash(tp);
83 tp->cp_cmd = RTL_R16(tp, CPlusCmd) & CPCMD_MASK;