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

r8169: remove old PHY reset hack

This hack (affecting the non-PCIe models only) was introduced in 2004
to deal with link negotiation failures in 1GBit mode. Based on a
comment in the r8169 vendor driver I assume the issue affects RTL8169sb
in combination with particular 1GBit switch models.

Resetting the PHY every 10s and hoping that one fine day we will make
it to establish the link seems to be very hacky to me. I'd say:
If 1GBit doesn't work reliably in a users environment then the user
should remove 1GBit from the advertised modes, e.g. by using
ethtool -s <if> advertise <10/100 modes>

If the issue affects one chip version only and that with most link
partners, then we could also think of removing 1GBit from the
advertised modes for this chip version in the driver.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Heiner Kallweit and committed by
David S. Miller
335c997d c02462d8

+1 -56
+1 -56
drivers/net/ethernet/realtek/r8169.c
··· 80 80 #define R8169_RX_RING_BYTES (NUM_RX_DESC * sizeof(struct RxDesc)) 81 81 82 82 #define RTL8169_TX_TIMEOUT (6*HZ) 83 - #define RTL8169_PHY_TIMEOUT (10*HZ) 84 83 85 84 /* write/read MMIO register */ 86 85 #define RTL_W8(tp, reg, val8) writeb((val8), tp->mmio_addr + (reg)) ··· 702 703 RTL_FLAG_TASK_ENABLED, 703 704 RTL_FLAG_TASK_SLOW_PENDING, 704 705 RTL_FLAG_TASK_RESET_PENDING, 705 - RTL_FLAG_TASK_PHY_PENDING, 706 706 RTL_FLAG_MAX 707 707 }; 708 708 ··· 729 731 dma_addr_t RxPhyAddr; 730 732 void *Rx_databuff[NUM_RX_DESC]; /* Rx data buffers */ 731 733 struct ring_info tx_skb[NUM_TX_DESC]; /* Tx data buffers */ 732 - struct timer_list timer; 733 734 u16 cp_cmd; 734 735 735 736 u16 event_slow; ··· 1785 1788 static int rtl8169_set_speed(struct net_device *dev, 1786 1789 u8 autoneg, u16 speed, u8 duplex, u32 advertising) 1787 1790 { 1788 - struct rtl8169_private *tp = netdev_priv(dev); 1789 - int ret; 1790 - 1791 - ret = rtl8169_set_speed_xmii(dev, autoneg, speed, duplex, advertising); 1792 - if (ret < 0) 1793 - goto out; 1794 - 1795 - if (netif_running(dev) && (autoneg == AUTONEG_ENABLE) && 1796 - (advertising & ADVERTISED_1000baseT_Full) && 1797 - !pci_is_pcie(tp->pci_dev)) { 1798 - mod_timer(&tp->timer, jiffies + RTL8169_PHY_TIMEOUT); 1799 - } 1800 - out: 1801 - return ret; 1791 + return rtl8169_set_speed_xmii(dev, autoneg, speed, duplex, advertising); 1802 1792 } 1803 1793 1804 1794 static netdev_features_t rtl8169_fix_features(struct net_device *dev, ··· 1871 1887 if (!ethtool_convert_link_mode_to_legacy_u32(&advertising, 1872 1888 cmd->link_modes.advertising)) 1873 1889 return -EINVAL; 1874 - 1875 - del_timer_sync(&tp->timer); 1876 1890 1877 1891 rtl_lock_work(tp); 1878 1892 rc = rtl8169_set_speed(dev, cmd->base.autoneg, cmd->base.speed, ··· 4275 4293 } 4276 4294 } 4277 4295 4278 - static void rtl_phy_work(struct rtl8169_private *tp) 4279 - { 4280 - struct timer_list *timer = &tp->timer; 4281 - unsigned long timeout = RTL8169_PHY_TIMEOUT; 4282 - 4283 - if (rtl8169_xmii_reset_pending(tp)) { 4284 - /* 4285 - * A busy loop could burn quite a few cycles on nowadays CPU. 4286 - * Let's delay the execution of the timer for a few ticks. 4287 - */ 4288 - timeout = HZ/10; 4289 - goto out_mod_timer; 4290 - } 4291 - 4292 - if (rtl8169_xmii_link_ok(tp)) 4293 - return; 4294 - 4295 - netif_dbg(tp, link, tp->dev, "PHY reset until link up\n"); 4296 - 4297 - rtl8169_xmii_reset_enable(tp); 4298 - 4299 - out_mod_timer: 4300 - mod_timer(timer, jiffies + timeout); 4301 - } 4302 - 4303 4296 static void rtl_schedule_task(struct rtl8169_private *tp, enum rtl_flag flag) 4304 4297 { 4305 4298 if (!test_and_set_bit(flag, tp->wk.flags)) 4306 4299 schedule_work(&tp->wk.work); 4307 - } 4308 - 4309 - static void rtl8169_phy_timer(struct timer_list *t) 4310 - { 4311 - struct rtl8169_private *tp = from_timer(tp, t, timer); 4312 - 4313 - rtl_schedule_task(tp, RTL_FLAG_TASK_PHY_PENDING); 4314 4300 } 4315 4301 4316 4302 DECLARE_RTL_COND(rtl_phy_reset_cond) ··· 6859 6909 /* XXX - keep rtl_slow_event_work() as first element. */ 6860 6910 { RTL_FLAG_TASK_SLOW_PENDING, rtl_slow_event_work }, 6861 6911 { RTL_FLAG_TASK_RESET_PENDING, rtl_reset_work }, 6862 - { RTL_FLAG_TASK_PHY_PENDING, rtl_phy_work } 6863 6912 }; 6864 6913 struct rtl8169_private *tp = 6865 6914 container_of(work, struct rtl8169_private, wk.work); ··· 6930 6981 static void rtl8169_down(struct net_device *dev) 6931 6982 { 6932 6983 struct rtl8169_private *tp = netdev_priv(dev); 6933 - 6934 - del_timer_sync(&tp->timer); 6935 6984 6936 6985 napi_disable(&tp->napi); 6937 6986 netif_stop_queue(dev); ··· 7640 7693 tp->hw_start = cfg->hw_start; 7641 7694 tp->event_slow = cfg->event_slow; 7642 7695 tp->coalesce_info = cfg->coalesce_info; 7643 - 7644 - timer_setup(&tp->timer, rtl8169_phy_timer, 0); 7645 7696 7646 7697 tp->rtl_fw = RTL_FIRMWARE_UNKNOWN; 7647 7698