r8169: enable ASPM L0s state
[linux-2.6-microblaze.git] / drivers / net / ethernet / realtek / r8169_main.c
index 4d8e337..9ea59ef 100644 (file)
@@ -2598,7 +2598,7 @@ static u32 rtl_csi_read(struct rtl8169_private *tp, int addr)
                RTL_R32(tp, CSIDR) : ~0;
 }
 
-static void rtl_csi_access_enable(struct rtl8169_private *tp, u8 val)
+static void rtl_set_aspm_entry_latency(struct rtl8169_private *tp, u8 val)
 {
        struct pci_dev *pdev = tp->pci_dev;
        u32 csi;
@@ -2606,6 +2606,8 @@ static void rtl_csi_access_enable(struct rtl8169_private *tp, u8 val)
        /* According to Realtek the value at config space address 0x070f
         * controls the L0s/L1 entrance latency. We try standard ECAM access
         * first and if it fails fall back to CSI.
+        * bit 0..2: L0: 0 = 1us, 1 = 2us .. 6 = 7us, 7 = 7us (no typo)
+        * bit 3..5: L1: 0 = 1us, 1 = 2us .. 6 = 64us, 7 = 64us
         */
        if (pdev->cfg_size > 0x070f &&
            pci_write_config_byte(pdev, 0x070f, val) == PCIBIOS_SUCCESSFUL)
@@ -2619,7 +2621,8 @@ static void rtl_csi_access_enable(struct rtl8169_private *tp, u8 val)
 
 static void rtl_set_def_aspm_entry_latency(struct rtl8169_private *tp)
 {
-       rtl_csi_access_enable(tp, 0x27);
+       /* L0 7us, L1 16us */
+       rtl_set_aspm_entry_latency(tp, 0x27);
 }
 
 struct ephy_info {
@@ -3502,8 +3505,8 @@ static void rtl_hw_start_8106(struct rtl8169_private *tp)
        RTL_W8(tp, MCU, RTL_R8(tp, MCU) | EN_NDP | EN_OOB_RESET);
        RTL_W8(tp, DLLPR, RTL_R8(tp, DLLPR) & ~PFM_EN);
 
-       /* The default value is 0x13. Change it to 0x2f */
-       rtl_csi_access_enable(tp, 0x2f);
+       /* L0 7us, L1 32us - needed to avoid issues with link-up detection */
+       rtl_set_aspm_entry_latency(tp, 0x2f);
 
        rtl_eri_write(tp, 0x1d0, ERIAR_MASK_0011, 0x0000);
 
@@ -4983,7 +4986,7 @@ static const struct net_device_ops rtl_netdev_ops = {
        .ndo_fix_features       = rtl8169_fix_features,
        .ndo_set_features       = rtl8169_set_features,
        .ndo_set_mac_address    = rtl_set_mac_address,
-       .ndo_do_ioctl           = phy_do_ioctl_running,
+       .ndo_eth_ioctl          = phy_do_ioctl_running,
        .ndo_set_rx_mode        = rtl_set_rx_mode,
 #ifdef CONFIG_NET_POLL_CONTROLLER
        .ndo_poll_controller    = rtl8169_netpoll,
@@ -5278,11 +5281,10 @@ static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
        if (rc)
                return rc;
 
-       /* Disable ASPM completely as that cause random device stop working
+       /* Disable ASPM L1 as that cause random device stop working
         * problems as well as full system hangs for some PCIe devices users.
         */
-       rc = pci_disable_link_state(pdev, PCIE_LINK_STATE_L0S |
-                                         PCIE_LINK_STATE_L1);
+       rc = pci_disable_link_state(pdev, PCIE_LINK_STATE_L1);
        tp->aspm_manageable = !rc;
 
        /* enable device (incl. PCI PM wakeup and hotplug setup) */