Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

r8169: improve MAC EEE handling

Let phydev->enable_tx_lpi control whether MAC enables TX LPI, instead of
enabling it unconditionally. This way TX LPI is disabled if e.g. link
partner doesn't support EEE. This helps to avoid potential issues like
link flaps.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Link: https://patch.msgid.link/91bcb837-3fab-4b4e-b495-038df0932e44@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Heiner Kallweit and committed by
Jakub Kicinski
87ad869f de1e5c93

+36 -37
+36 -37
drivers/net/ethernet/realtek/r8169_main.c
··· 2379 2379 } 2380 2380 } 2381 2381 2382 - static void rtl8168_config_eee_mac(struct rtl8169_private *tp) 2383 - { 2384 - /* Adjust EEE LED frequency */ 2385 - if (tp->mac_version != RTL_GIGA_MAC_VER_38) 2386 - RTL_W8(tp, EEE_LED, RTL_R8(tp, EEE_LED) & ~0x07); 2387 - 2388 - rtl_eri_set_bits(tp, 0x1b0, 0x0003); 2389 - } 2390 - 2391 - static void rtl8125a_config_eee_mac(struct rtl8169_private *tp) 2392 - { 2393 - r8168_mac_ocp_modify(tp, 0xe040, 0, BIT(1) | BIT(0)); 2394 - r8168_mac_ocp_modify(tp, 0xeb62, 0, BIT(2) | BIT(1)); 2395 - } 2396 - 2397 - static void rtl8125b_config_eee_mac(struct rtl8169_private *tp) 2398 - { 2399 - r8168_mac_ocp_modify(tp, 0xe040, 0, BIT(1) | BIT(0)); 2400 - } 2401 - 2402 2382 static void rtl_rar_exgmac_set(struct rtl8169_private *tp, const u8 *addr) 2403 2383 { 2404 2384 rtl_eri_write(tp, 0xe0, ERIAR_MASK_1111, get_unaligned_le32(addr)); ··· 3156 3176 3157 3177 RTL_W8(tp, MCU, RTL_R8(tp, MCU) & ~NOW_IS_OOB); 3158 3178 3159 - rtl8168_config_eee_mac(tp); 3160 - 3161 3179 RTL_W8(tp, DLLPR, RTL_R8(tp, DLLPR) | PFM_EN); 3162 3180 RTL_W32(tp, MISC, RTL_R32(tp, MISC) | PWM_EN); 3163 3181 rtl_mod_config5(tp, Spi_en, 0); ··· 3180 3202 RTL_W8(tp, DLLPR, RTL_R8(tp, DLLPR) | PFM_EN); 3181 3203 RTL_W32(tp, MISC, RTL_R32(tp, MISC) | PWM_EN); 3182 3204 rtl_mod_config5(tp, Spi_en, 0); 3183 - 3184 - rtl8168_config_eee_mac(tp); 3185 3205 } 3186 3206 3187 3207 static void rtl_hw_start_8168f_1(struct rtl8169_private *tp) ··· 3228 3252 3229 3253 rtl_eri_write(tp, 0xc0, ERIAR_MASK_0011, 0x0000); 3230 3254 rtl_eri_write(tp, 0xb8, ERIAR_MASK_0011, 0x0000); 3231 - 3232 - rtl8168_config_eee_mac(tp); 3233 3255 3234 3256 rtl_w0w1_eri(tp, 0x2fc, 0x01, 0x06); 3235 3257 rtl_eri_clear_bits(tp, 0x1b0, BIT(12)); ··· 3369 3395 rtl_eri_write(tp, 0xc0, ERIAR_MASK_0011, 0x0000); 3370 3396 rtl_eri_write(tp, 0xb8, ERIAR_MASK_0011, 0x0000); 3371 3397 3372 - rtl8168_config_eee_mac(tp); 3373 - 3374 3398 RTL_W8(tp, DLLPR, RTL_R8(tp, DLLPR) & ~PFM_EN); 3375 3399 RTL_W8(tp, MISC_1, RTL_R8(tp, MISC_1) & ~PFM_D3COLD_EN); 3376 3400 ··· 3415 3443 3416 3444 rtl_eri_write(tp, 0xc0, ERIAR_MASK_0011, 0x0000); 3417 3445 rtl_eri_write(tp, 0xb8, ERIAR_MASK_0011, 0x0000); 3418 - 3419 - rtl8168_config_eee_mac(tp); 3420 3446 3421 3447 rtl_w0w1_eri(tp, 0x2fc, 0x01, 0x06); 3422 3448 ··· 3470 3500 3471 3501 rtl_eri_write(tp, 0xc0, ERIAR_MASK_0011, 0x0000); 3472 3502 rtl_eri_write(tp, 0xb8, ERIAR_MASK_0011, 0x0000); 3473 - 3474 - rtl8168_config_eee_mac(tp); 3475 3503 3476 3504 RTL_W8(tp, DLLPR, RTL_R8(tp, DLLPR) & ~PFM_EN); 3477 3505 RTL_W8(tp, MISC_1, RTL_R8(tp, MISC_1) & ~PFM_D3COLD_EN); ··· 3710 3742 r8168_mac_ocp_write(tp, 0xe098, 0xc302); 3711 3743 3712 3744 rtl_loop_wait_low(tp, &rtl_mac_ocp_e00e_cond, 1000, 10); 3713 - 3714 - if (tp->mac_version == RTL_GIGA_MAC_VER_61) 3715 - rtl8125a_config_eee_mac(tp); 3716 - else 3717 - rtl8125b_config_eee_mac(tp); 3718 3745 3719 3746 rtl_disable_rxdvgate(tp); 3720 3747 } ··· 4713 4750 return work_done; 4714 4751 } 4715 4752 4753 + static void rtl_enable_tx_lpi(struct rtl8169_private *tp, bool enable) 4754 + { 4755 + if (!rtl_supports_eee(tp)) 4756 + return; 4757 + 4758 + switch (tp->mac_version) { 4759 + case RTL_GIGA_MAC_VER_34 ... RTL_GIGA_MAC_VER_52: 4760 + /* Adjust EEE LED frequency */ 4761 + if (tp->mac_version != RTL_GIGA_MAC_VER_38) 4762 + RTL_W8(tp, EEE_LED, RTL_R8(tp, EEE_LED) & ~0x07); 4763 + if (enable) 4764 + rtl_eri_set_bits(tp, 0x1b0, 0x0003); 4765 + else 4766 + rtl_eri_clear_bits(tp, 0x1b0, 0x0003); 4767 + break; 4768 + case RTL_GIGA_MAC_VER_61: 4769 + if (enable) { 4770 + r8168_mac_ocp_modify(tp, 0xe040, 0, 0x0003); 4771 + r8168_mac_ocp_modify(tp, 0xeb62, 0, 0x0006); 4772 + } else { 4773 + r8168_mac_ocp_modify(tp, 0xe040, 0x0003, 0); 4774 + r8168_mac_ocp_modify(tp, 0xeb62, 0x0006, 0); 4775 + } 4776 + break; 4777 + case RTL_GIGA_MAC_VER_63 ... RTL_GIGA_MAC_VER_LAST: 4778 + if (enable) 4779 + r8168_mac_ocp_modify(tp, 0xe040, 0, 0x0003); 4780 + else 4781 + r8168_mac_ocp_modify(tp, 0xe040, 0x0003, 0); 4782 + break; 4783 + default: 4784 + break; 4785 + } 4786 + } 4787 + 4716 4788 static void r8169_phylink_handler(struct net_device *ndev) 4717 4789 { 4718 4790 struct rtl8169_private *tp = netdev_priv(ndev); ··· 4755 4757 4756 4758 if (netif_carrier_ok(ndev)) { 4757 4759 rtl_link_chg_patch(tp); 4760 + rtl_enable_tx_lpi(tp, tp->phydev->enable_tx_lpi); 4758 4761 pm_request_resume(d); 4759 4762 } else { 4760 4763 pm_runtime_idle(d);