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

Merge branch 'r8169-improve-runtime-pm'

Heiner Kallweit says:

====================
r8169: improve runtime pm

On my system with two network ports I found that runtime PM didn't
suspend the unused port. Therefore I checked runtime pm in this driver
in somewhat more detail and this series improves runtime pm in general
and solves the mentioned issue.

Tested on a system with RTL8168evl (MAC version 34).
====================

Signed-off-by: David S. Miller <davem@davemloft.net>

+17 -27
+17 -27
drivers/net/ethernet/realtek/r8169.c
··· 1675 1675 } 1676 1676 } 1677 1677 1678 - static void __rtl8169_check_link_status(struct net_device *dev, 1679 - struct rtl8169_private *tp, 1680 - void __iomem *ioaddr, bool pm) 1678 + static void rtl8169_check_link_status(struct net_device *dev, 1679 + struct rtl8169_private *tp, 1680 + void __iomem *ioaddr) 1681 1681 { 1682 1682 if (tp->link_ok(ioaddr)) { 1683 1683 rtl_link_chg_patch(tp); 1684 1684 /* This is to cancel a scheduled suspend if there's one. */ 1685 - if (pm) 1686 - pm_request_resume(&tp->pci_dev->dev); 1685 + pm_request_resume(&tp->pci_dev->dev); 1687 1686 netif_carrier_on(dev); 1688 1687 if (net_ratelimit()) 1689 1688 netif_info(tp, ifup, dev, "link up\n"); 1690 1689 } else { 1691 1690 netif_carrier_off(dev); 1692 1691 netif_info(tp, ifdown, dev, "link down\n"); 1693 - if (pm) 1694 - pm_schedule_suspend(&tp->pci_dev->dev, 5000); 1692 + pm_runtime_idle(&tp->pci_dev->dev); 1695 1693 } 1696 - } 1697 - 1698 - static void rtl8169_check_link_status(struct net_device *dev, 1699 - struct rtl8169_private *tp, 1700 - void __iomem *ioaddr) 1701 - { 1702 - __rtl8169_check_link_status(dev, tp, ioaddr, false); 1703 1694 } 1704 1695 1705 1696 #define WAKE_ANY (WAKE_PHY | WAKE_MAGIC | WAKE_UCAST | WAKE_BCAST | WAKE_MCAST) ··· 7737 7746 rtl8169_pcierr_interrupt(dev); 7738 7747 7739 7748 if (status & LinkChg) 7740 - __rtl8169_check_link_status(dev, tp, tp->mmio_addr, true); 7749 + rtl8169_check_link_status(dev, tp, tp->mmio_addr); 7741 7750 7742 7751 rtl_irq_enable_all(tp); 7743 7752 } ··· 7950 7959 rtl_unlock_work(tp); 7951 7960 7952 7961 tp->saved_wolopts = 0; 7953 - pm_runtime_put_noidle(&pdev->dev); 7962 + pm_runtime_put_sync(&pdev->dev); 7954 7963 7955 7964 rtl8169_check_link_status(dev, tp, ioaddr); 7956 7965 out: ··· 8094 8103 struct net_device *dev = pci_get_drvdata(pdev); 8095 8104 struct rtl8169_private *tp = netdev_priv(dev); 8096 8105 8097 - if (!tp->TxDescArray) 8106 + if (!tp->TxDescArray) { 8107 + rtl_pll_power_down(tp); 8098 8108 return 0; 8109 + } 8099 8110 8100 8111 rtl_lock_work(tp); 8101 8112 tp->saved_wolopts = __rtl8169_get_wol(tp); ··· 8139 8146 { 8140 8147 struct pci_dev *pdev = to_pci_dev(device); 8141 8148 struct net_device *dev = pci_get_drvdata(pdev); 8142 - struct rtl8169_private *tp = netdev_priv(dev); 8143 8149 8144 - return tp->TxDescArray ? -EBUSY : 0; 8150 + if (!netif_running(dev) || !netif_carrier_ok(dev)) 8151 + pm_schedule_suspend(device, 10000); 8152 + 8153 + return -EBUSY; 8145 8154 } 8146 8155 8147 8156 static const struct dev_pm_ops rtl8169_pm_ops = { ··· 8190 8195 { 8191 8196 struct net_device *dev = pci_get_drvdata(pdev); 8192 8197 struct rtl8169_private *tp = netdev_priv(dev); 8193 - struct device *d = &pdev->dev; 8194 - 8195 - pm_runtime_get_sync(d); 8196 8198 8197 8199 rtl8169_net_suspend(dev); 8198 8200 ··· 8207 8215 pci_wake_from_d3(pdev, true); 8208 8216 pci_set_power_state(pdev, PCI_D3hot); 8209 8217 } 8210 - 8211 - pm_runtime_put_noidle(d); 8212 8218 } 8213 8219 8214 8220 static void rtl_remove_one(struct pci_dev *pdev) ··· 8691 8701 rtl8168_driver_start(tp); 8692 8702 } 8693 8703 8694 - if (pci_dev_run_wake(pdev)) 8695 - pm_runtime_put_noidle(&pdev->dev); 8696 - 8697 8704 netif_carrier_off(dev); 8705 + 8706 + if (pci_dev_run_wake(pdev)) 8707 + pm_runtime_put_sync(&pdev->dev); 8698 8708 8699 8709 return 0; 8700 8710 }