igb lets the device be runtime suspended even if it can't signal a
wake-up from D3. Such a device doesn't notice the link coming back, so
the port stays down until it is resumed from user space.
Only schedule a runtime suspend if pci_dev_run_wake() is true. Devices
that can't wake up no longer runtime suspend, even with power/control
set to auto. Checking it when scheduling the suspend, rather than at
probe and remove as e1000e and r8169 do, keeps the runtime PM usage
count balanced if the result changes while the driver is bound.
Tested with the 82576 emulated by QEMU.
Fixes: 749ab2cd1270 ("igb: add basic runtime PM support")
Cc: stab…@vger.kernel.org
Closes: https://bugzilla.ipfire.org/show_bug.cgi?id=13562
Reviewed-by: Janis Edvarts Lacis <jani…@gmail.com>
Signed-off-by: Antonio Quartulli <anto…@mandelbit.com>
---
v7: mention the wake-up condition in two comments (Sashiko)
v6: no changes
v5: check pci_dev_run_wake() when scheduling the suspend rather than
at probe and remove, which keeps the usage count balanced (Sashiko)
v4: no changes
v3: no changes
v2: no code changes; mention the tested hardware
Note: igc has the same issue: igc_probe() also allows runtime PM
regardless of pci_dev_run_wake().
drivers/net/ethernet/intel/igb/igb_main.c | 18 +++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)
diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c
index d7a4b41..6c29152 100644
--- a/drivers/net/ethernet/intel/igb/igb_main.c
+++ b/drivers/net/ethernet/intel/igb/igb_main.c
@@ -5642,6 +5642,15 @@ static void igb_watchdog(struct timer_list *t)
schedule_work(&adapter->watchdog_task);
}
+/* A device that can't wake up wouldn't notice the link coming back while
+ * runtime suspended
+ */
+static void igb_schedule_runtime_suspend(struct igb_adapter *adapter)
+{
+ if (pci_dev_run_wake(adapter->pdev))
+ pm_schedule_suspend(&adapter->pdev->dev, MSEC_PER_SEC * 5);
+}
+
static void igb_watchdog_task(struct work_struct *work)
{
struct igb_adapter *adapter = container_of(work,
@@ -5794,8 +5803,7 @@ no_wait:
return;
}
}
- pm_schedule_suspend(netdev->dev.parent,
- MSEC_PER_SEC * 5);
+ igb_schedule_runtime_suspend(adapter);
/* also check for alternate media here */
} else if (!netif_carrier_ok(netdev) &&
@@ -9594,7 +9602,7 @@ static int __igb_shutdown(struct pci_dev *pdev, bool *enable_wake,
* suspend, and an RTNL holder resuming it meanwhile (e.g. ethtool)
* waits for the suspend to end: waiting for RTNL here would deadlock.
* Only try to take it: -EBUSY keeps the device active, and
- * igb_rpm_retry_task() schedules a new suspend.
+ * igb_rpm_retry_task() schedules a new suspend if it can still wake up.
*/
if (!runtime) {
rtnl_lock();
@@ -9764,13 +9772,13 @@ static int igb_runtime_idle(struct device *dev)
struct igb_adapter *adapter = netdev_priv(netdev);
if (!igb_has_link(adapter))
- pm_schedule_suspend(dev, MSEC_PER_SEC * 5);
+ igb_schedule_runtime_suspend(adapter);
return -EBUSY;
}
/* Resuming and releasing the device runs igb_runtime_idle(), which schedules
- * a new suspend if the link is still down
+ * a new suspend if the link is still down and the device can wake up
*/
static void igb_rpm_retry_task(struct work_struct *work)
{
--
2.56.1