Skip to content

Commit a92a084

Browse files
hkallweitdavem330
authored andcommitted
r8169: improve runtime pm in general and suspend unused ports
So far rpm doesn't cover cases like unused ports which are never brought up. If they are active at probe time they remain in this state. Included in this patch: - Let the idle notification check whether we can suspend and let it schedule the suspend. This way we don't need to have calls to pm_schedule_suspend in different places. - At the end of rtl_open and rtl_init_one send an idle notification to allow suspending if the link is down. If a cable is plugged in aneg is finished before the suspend timer expires and the suspend request is cancelled. - Change rtl8169_runtime_suspend to power down the chip if the interface is down. Successfully tested on a RTL8168evl (mac version 34). Signed-off-by: Heiner Kallweit <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent ef4d5fc commit a92a084

File tree

1 file changed

+12
-8
lines changed
  • drivers/net/ethernet/realtek

1 file changed

+12
-8
lines changed

drivers/net/ethernet/realtek/r8169.c

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1689,7 +1689,7 @@ static void rtl8169_check_link_status(struct net_device *dev,
16891689
} else {
16901690
netif_carrier_off(dev);
16911691
netif_info(tp, ifdown, dev, "link down\n");
1692-
pm_schedule_suspend(&tp->pci_dev->dev, 10000);
1692+
pm_runtime_idle(&tp->pci_dev->dev);
16931693
}
16941694
}
16951695

@@ -7950,7 +7950,7 @@ static int rtl_open(struct net_device *dev)
79507950
rtl_unlock_work(tp);
79517951

79527952
tp->saved_wolopts = 0;
7953-
pm_runtime_put_noidle(&pdev->dev);
7953+
pm_runtime_put_sync(&pdev->dev);
79547954

79557955
rtl8169_check_link_status(dev, tp, ioaddr);
79567956
out:
@@ -8094,8 +8094,10 @@ static int rtl8169_runtime_suspend(struct device *device)
80948094
struct net_device *dev = pci_get_drvdata(pdev);
80958095
struct rtl8169_private *tp = netdev_priv(dev);
80968096

8097-
if (!tp->TxDescArray)
8097+
if (!tp->TxDescArray) {
8098+
rtl_pll_power_down(tp);
80988099
return 0;
8100+
}
80998101

81008102
rtl_lock_work(tp);
81018103
tp->saved_wolopts = __rtl8169_get_wol(tp);
@@ -8137,9 +8139,11 @@ static int rtl8169_runtime_idle(struct device *device)
81378139
{
81388140
struct pci_dev *pdev = to_pci_dev(device);
81398141
struct net_device *dev = pci_get_drvdata(pdev);
8140-
struct rtl8169_private *tp = netdev_priv(dev);
81418142

8142-
return tp->TxDescArray ? -EBUSY : 0;
8143+
if (!netif_running(dev) || !netif_carrier_ok(dev))
8144+
pm_schedule_suspend(device, 10000);
8145+
8146+
return -EBUSY;
81438147
}
81448148

81458149
static const struct dev_pm_ops rtl8169_pm_ops = {
@@ -8687,11 +8691,11 @@ static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
86878691
rtl8168_driver_start(tp);
86888692
}
86898693

8690-
if (pci_dev_run_wake(pdev))
8691-
pm_runtime_put_noidle(&pdev->dev);
8692-
86938694
netif_carrier_off(dev);
86948695

8696+
if (pci_dev_run_wake(pdev))
8697+
pm_runtime_put_sync(&pdev->dev);
8698+
86958699
return 0;
86968700
}
86978701

0 commit comments

Comments
 (0)