Thread View: linux.kernel.netdev
1 messages
1 total messages
Started by Brian Norris
Tue, 01 Dec 2026 19:59
[PATCH net-next 2/2] r8169: convert to runtime PM autosuspend and drop runtime_idle
Author: Brian Norris
Date: Tue, 01 Dec 2026 19:59
Date: Tue, 01 Dec 2026 19:59
165 lines
16566 bytes
16566 bytes
With rtl_mac_link_up() and rtl_mac_link_down() holding a runtime PM
reference while the link is up, rtl8169_runtime_idle() no longer needs
to inspect netif_running() or netif_carrier_ok() to decide whether to
suspend.
The remaining job of rtl8169_runtime_idle() is to prevent runtime
suspend when DASH is enabled (which is determined once during probe) and
to enforce a 10-second suspend delay (i.e., reimplementing autosuspend).
Thus, we can replace rtl8169_runtime_idle() with:
1) holding a persistent refcount for tp->dash_enabled and
2) configuring 10-second autosuspend
Note about some subtlety: pm_runtime_put_sync() appears "synchronous",
yet in practice, rtl8169_runtime_idle() would always kick a timer
instead of suspending immediately. This is important, because we want to
avoid rtl8169_runtime_suspend() -> rtnl_lock() in the wrong context. So
we avoid "sync" helpers, and use (async) pm_runtime_put_autosuspend()
instead, in case autosuspend delay is ever configured to 0.
Note that after work present in the linux-pm tree ("PM: runtime: Update
last_busy before calling rpm_suspend() in rpm_idle()" and friends),
there is very little difference between pm_runtime_put() and
pm_runtime_put_autosuspend() for drivers without .runtime_idle(). I
stick with *_autosuspend() for now, as there is still more cleanup to do
before any *_autosuspend() variants can be dropped.
This is a step toward removing .runtime_idle() support from the PM core,
as discussed in a few places, including:
https://lore.kernel.org/all/avXs826ikSctpUnA@google.com/
This conversion was only compile-tested and not tested on hardware.
Signed-off-by: Brian Norris <briannorris@chromium.org>
---
Patch 1 is a 'net' candidate (the regression is in v7.4-rc). Patch 2 may
not be, but it is highly related. I'm not sure how that should be
handled, so I've kept the whole thing as 'net-next'.
drivers/net/ethernet/realtek/r8169_main.c | 41 +++++++++--------------
1 file changed, 16 insertions(+), 25 deletions(-)
diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c
index 79da7b72dfd2..cacb24bd743c 100644
--- a/drivers/net/ethernet/realtek/r8169_main.c
+++ b/drivers/net/ethernet/realtek/r8169_main.c
@@ -1075,7 +1075,7 @@ int rtl8168_led_mod_ctrl(struct rtl8169_private *tp, u16 mask, u16 val)
RTL_W16(tp, LED_CTRL, (RTL_R16(tp, LED_CTRL) & ~mask) | val);
mutex_unlock(&tp->led_lock);
- pm_runtime_put_sync(dev);
+ pm_runtime_put_autosuspend(dev);
return 0;
}
@@ -1091,7 +1091,7 @@ int rtl8168_get_led_mode(struct rtl8169_private *tp)
ret = RTL_R16(tp, LED_CTRL);
- pm_runtime_put_sync(dev);
+ pm_runtime_put_autosuspend(dev);
return ret;
}
@@ -1119,7 +1119,7 @@ int rtl8125_set_led_mode(struct rtl8169_private *tp, int index, u16 mode)
RTL_W16(tp, reg, val | mode);
mutex_unlock(&tp->led_lock);
- pm_runtime_put_sync(dev);
+ pm_runtime_put_autosuspend(dev);
return 0;
}
@@ -1136,7 +1136,7 @@ int rtl8125_get_led_mode(struct rtl8169_private *tp, int index)
ret = RTL_R16(tp, reg);
- pm_runtime_put_sync(dev);
+ pm_runtime_put_autosuspend(dev);
return ret;
}
@@ -5780,7 +5780,7 @@ static int rtl8169_close(struct net_device *dev)
tp->TxDescArray = NULL;
rtl8169_free_rx_desc(tp);
- pm_runtime_put_sync(&pdev->dev);
+ pm_runtime_put_autosuspend(&pdev->dev);
return 0;
}
@@ -5840,7 +5840,7 @@ static int rtl_open(struct net_device *dev)
rtl8169_init_counter_offsets(tp);
netif_start_queue(dev);
out:
- pm_runtime_put_sync(&pdev->dev);
+ pm_runtime_put_autosuspend(&pdev->dev);
return retval;
@@ -5983,23 +5983,9 @@ static int rtl8169_runtime_suspend(struct device *device)
return 0;
}
-static int rtl8169_runtime_idle(struct device *device)
-{
- struct rtl8169_private *tp = dev_get_drvdata(device);
-
- if (tp->dash_enabled)
- return -EBUSY;
-
- if (!netif_running(tp->dev) || !netif_carrier_ok(tp->dev))
- pm_schedule_suspend(device, 10000);
-
- return -EBUSY;
-}
-
static const struct dev_pm_ops rtl8169_pm_ops = {
SYSTEM_SLEEP_PM_OPS(rtl8169_suspend, rtl8169_resume)
- RUNTIME_PM_OPS(rtl8169_runtime_suspend, rtl8169_runtime_resume,
- rtl8169_runtime_idle)
+ RUNTIME_PM_OPS(rtl8169_runtime_suspend, rtl8169_runtime_resume, NULL)
};
static void rtl_shutdown(struct pci_dev *pdev)
@@ -6034,8 +6020,10 @@ static void rtl_remove_one(struct pci_dev *pdev)
{
struct rtl8169_private *tp = pci_get_drvdata(pdev);
- if (pci_dev_run_wake(pdev))
+ if (pci_dev_run_wake(pdev) && !tp->dash_enabled) {
pm_runtime_get_noresume(&pdev->dev);
+ pm_runtime_dont_use_autosuspend(&pdev->dev);
+ }
disable_work_sync(&tp->wk.work);
@@ -6411,7 +6399,7 @@ static void rtl_mac_link_down(struct phylink_config *config, unsigned int mode,
phylink_config);
tp->speed = SPEED_UNKNOWN;
- pm_runtime_put(tp_to_dev(tp));
+ pm_runtime_put_autosuspend(tp_to_dev(tp));
}
static void rtl_mac_link_up(struct phylink_config *config,
@@ -7054,8 +7042,11 @@ static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
if (rtl_is_8116af(tp))
rtl_lowpower_hidden_functions(tp->pci_dev);
- if (pci_dev_run_wake(pdev))
- pm_runtime_put_sync(&pdev->dev);
+ if (pci_dev_run_wake(pdev) && !tp->dash_enabled) {
+ pm_runtime_set_autosuspend_delay(&pdev->dev, 10000);
+ pm_runtime_use_autosuspend(&pdev->dev);
+ pm_runtime_put_autosuspend(&pdev->dev);
+ }
return 0;
--
2.56.1.911.g883d8bcb20-goog
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads