Skip to content

PM / devfreq: Do not change the frequency of a suspended device

Arun Iyengar b4-sent linux-pm lkml 3 versions – New

Get series with b4
b4 am [email protected] change-id 20261112-devfreq-suspend-sync-7ca8fc51550a

Versions newest first

  1. v3 Latest2 patches 0 repliesNew
  2. v21 patch 0 repliesSuperseded
  3. v11 patch 2 repliesSuperseded

Changes in v3 from the cover letter

- Run the pending update instead of restoring first, so resume makes
one transition; the userspace governor without set_freq keeps the
frequency from before suspend (Sashiko)
- Keep the passive governor out of the pending update, which evaluated
it with freq 0 (Sashiko)
- Leave devfreq suspended when suspend or resume fails, instead of the
v2 undo: callers may power the device down regardless. A caller that
ignores a failed resume recovers on its next suspend and resume (Sashiko)
- Add [2] as 1/2: commit message corrected (lima on RK3528 is the
mainline case, not panthor), comment shortened
- Rebase on devfreq-next
- Link to v2: https://patch.msgid.link/[email protected]

Patches in v3 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2PM / devfreq: Resume at the frequency from before suspenddrivers/devfreq/devfreq.c+4 -00 replies
2/2PM / devfreq: Do not change the frequency of a suspended devicedrivers/devfreq/devfreq.c drivers/devfreq/governor_userspace.c include/linux/devfreq.h+75 -200 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v3 yet.

Read the v3 thread

Cover letter [PATCH v3 0/2] PM / devfreq: Do not change the frequency of a suspended device

From the review of a panthor patch [1]: Boris Brezillon pointed out that the devfreq core, not the driver, should stop calling ->target() between devfreq_suspend_device() and devfreq_resume_device().

1/2 is v2 of [2], which 2/2 builds on. The panthor side is [3].

Tested on an Orange Pi 5 (RK3588S), v7.3-based kernel with [3], GPU clock on SCMI_CLK_GPU with a 200 MHz opp-suspend (Jonas Karlman's RFC, not in mainline).
min_freq, max_freq, the userspace governor's set_freq and the cooling state written while the GPU was runtime suspended take effect on resume, with no SError; min_freq also after s2idle and deep suspend. 200 runtime suspend/resume cycles with changing limits. A KUnit test (not posted) covers the passive governor, the single transition on resume, failing suspend and resume, and a resume without a suspend.

Developed with Claude (Anthropic), which wrote the code and the commit messages. I reviewed every change.

[1] https://lore.kernel.org/r/[email protected]
[2] https://lore.kernel.org/r/[email protected]
[3] https://lore.kernel.org/r/[email protected]

---
Changes in v3:
- Run the pending update instead of restoring first, so resume makes
one transition; the userspace governor without set_freq keeps the
frequency from before suspend (Sashiko)
- Keep the passive governor out of the pending update, which evaluated
it with freq 0 (Sashiko)
- Leave devfreq suspended when suspend or resume fails, instead of the
v2 undo: callers may power the device down regardless. A caller that
ignores a failed resume recovers on its next suspend and resume (Sashiko)
- Add [2] as 1/2: commit message corrected (lima on RK3528 is the
mainline case, not panthor), comment shortened
- Rebase on devfreq-next
- Link to v2: https://patch.msgid.link/[email protected]

Changes in v2:
- Keep only the suspend count, now a plain int changed under
devfreq->lock, instead of a separate suspended flag that could
disagree with it when suspend and resume race (Sashiko)
- Resume at the resume frequency clamped to the current limits, then
run the deferred update: the userspace governor without set_freq
stayed at the suspend frequency (Sashiko)
- Don't defer the passive governor's parent updates: exynos-bus
children must follow their parent to its suspend frequency, also at
shutdown (Sashiko)
- Drop pending_freq: the deferred update runs like any update_devfreq()
call. If it fails, resume logs the error and still sends
DEVFREQ_GOV_RESUME (Sashiko)
- Undo a failed devfreq_suspend_device(), as rk3399_dmc and lima abort
without resuming; an unbalanced devfreq_resume_device() is a no-op
(Sashiko)
- Leave polling governors to their next poll after resume; the driver
has just reset their load data (Sashiko)
- Link to v1: https://patch.msgid.link/[email protected]

---
Arun Iyengar (2):
PM / devfreq: Resume at the frequency from before suspend PM / devfreq: Do not change the frequency of a suspended device

 drivers/devfreq/devfreq.c            | 86 +++++++++++++++++++++++++++++-------
 drivers/devfreq/governor_userspace.c |  3 +-
 include/linux/devfreq.h              | 10 ++++-
 3 files changed, 79 insertions(+), 20 deletions(-)

---
base-commit: f9316c13d6f621af4f6f4a6089d3c989ffe899e6
change-id: 20261112-devfreq-suspend-sync-7ca8fc51550a

Best regards,

Signature · 1 line
Arun Iyengar <[email protected]>