* [REGRESSION: [PATCH v2 1/3] cpufreq: Improve suspend-resume synchronization [not found] ` <4796894.LvFx2qVVIh@rafael.j.wysocki> @ 2026-11-18 13:03 ` Borah, Chaitanya Kumar 2026-11-18 15:02 ` Rafael J. Wysocki (Intel) 0 siblings, 1 reply; 3+ messages in thread From: Borah, Chaitanya Kumar @ 2026-11-18 13:03 UTC (permalink / raw) To: Rafael J. Wysocki, Linux PM Cc: Viresh Kumar, Christian Loehle, Doug Smythies, Zak, Srinivas Pandruvada, Mario Limonciello, intel-gfx@lists.freedesktop.org, intel-xe@lists.freedesktop.org, ravitejax.veesam Hello Rafael, On 11/4/2026 1:15 AM, Rafael J. Wysocki wrote: > From: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com> > > The suspend-resume synchronization in the cpufreq core is not perfect > because the global cpufreq_suspended variable is set at the end of > cpufreq_suspend() after stopping governors for all of the active > policies, so the governor .limits() callback may run via > cpufreq_governor_limits() after stopping the governor and before > setting cpufreq_suspended which is questionable. Likewise, the > governor .limits() callback may run between clearing cpufreq_suspended > in cpufreq_resume() and starting the governor. > > Address this by adding a per-policy "suspended" flag that is always > read under the policy rwsem and is updated under it when the governor > is stopped in cpufreq_suspend() and when the governor is restarted in > cpufreq_resume(). > > Also make cpufreq_resume() use the cpus_read_lock guard to reflect > what is done in cpufreq_suspend() and call cpufreq_exit_governor() for > policies that were suspended during a system suspend transition and > are inactive during the subsequent system resume (to avoid leaking an > inactive policy with a stopped governor that has not exited yet). > This seems to be causing regression in our CI [1] (affecting dg1 and dg2). We could not revert the patch cleanly but resetting to its parent heals the issue. <4> [510.751891] ====================================================== <4> [510.751907] WARNING: possible circular locking dependency detected <4> [510.751925] 7.4.0-rc3-CI_DRM_19546-gfb078d17b966+ #1 Tainted: G S U L <4> [510.751946] ------------------------------------------------------ <4> [510.751962] rtcwake/4256 is trying to acquire lock: <4> [510.751977] ffffffff83ce0f40 (intel_pstate_driver_lock){+.+.}-{3:3}, at: set_power_ctl_ee_state+0x1a/0x90 <4> [510.752022] but task is already holding lock: <4> [510.752038] ffffffff83886890 (cpu_hotplug_lock){++++}-{0:0}, at: cpufreq_resume+0x23/0x250 <4> [510.752074] which lock already depends on the new lock. <4> [510.752094] the existing dependency chain (in reverse order) is: <4> [510.752112] -> #1 (cpu_hotplug_lock){++++}-{0:0}: <4> [510.752137] cpus_read_lock+0x3c/0x100 <4> [510.752157] cpufreq_register_driver+0xca/0x380 <4> [510.752175] intel_pstate_register_driver+0x9e/0x1d0 <4> [510.752192] intel_pstate_init+0x3e3/0xb30 <4> [510.752211] do_one_initcall+0x59/0x3d0 <4> [510.752229] kernel_init_freeable+0x3dc/0x6b0 <4> [510.752249] kernel_init+0x20/0x210 <4> [510.752264] ret_from_fork+0x3bf/0x470 <4> [510.752282] ret_from_fork_asm+0x1a/0x30 <4> [510.752299] -> #0 (intel_pstate_driver_lock){+.+.}-{3:3}: <4> [510.752325] __lock_acquire+0x1700/0x29c0 <4> [510.752341] lock_acquire+0xd9/0x2f0 <4> [510.752355] __mutex_lock+0xae/0x1030 <4> [510.752372] mutex_lock_nested+0x1b/0x30 <4> [510.752390] set_power_ctl_ee_state+0x1a/0x90 <4> [510.752409] intel_pstate_resume+0x109/0x110 <4> [510.752428] cpufreq_resume+0x153/0x250 <4> [510.752445] dpm_resume+0x1f1/0x390 <4> [510.752459] dpm_resume_end+0x11/0x30 <4> [510.752474] suspend_devices_and_enter+0x372/0xcb0 <4> [510.752491] pm_suspend+0x372/0x840 <4> [510.752506] state_store+0x6e/0xe0 <4> [510.752523] kobj_attr_store+0x12/0x40 <4> [510.752541] sysfs_kf_write+0x4d/0x80 <4> [510.752559] kernfs_fop_write_iter+0x193/0x240 <4> [510.752576] vfs_write+0x285/0x530 <4> [510.752591] ksys_write+0x6f/0xf0 <4> [510.752606] __x64_sys_write+0x19/0x30 <4> [510.752622] x64_sys_call+0x1285/0x27e0 <4> [510.752637] do_syscall_64+0xec/0x680 <4> [510.752654] entry_SYSCALL_64_after_hwframe+0x76/0x7e Could you please check why the patch causes this regression and provide a fix if necessary? Regards Chaitanya [1] https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_19546/shard-dg1-14/igt@i915_suspend@basic-s2idle-without-i915.html --Bisect Logs-- git bisect start # status: waiting for both good and bad commits # bad: [cfe67bbcfc37474cbb4482d750d4fba34bbc5a24] drm-tip: 2026y-11m-17d-05h-12m-00s UTC integration manifest git bisect bad cfe67bbcfc37474cbb4482d750d4fba34bbc5a24 # status: waiting for good commit(s), bad commit known # good: [39e407b553ec15d4a233b651531ad431ed7542be] drm/sun4i: dw-hdmi: Deinit PHY in bind error path git bisect good 39e407b553ec15d4a233b651531ad431ed7542be # bad: [715f145f6204363a50853eb15719dc860db0bc01] drm/i915/dsb: Realign GOSUB only for QW slots 6 and 7 git bisect bad 715f145f6204363a50853eb15719dc860db0bc01 # bad: [7e1392a42ea288d70a266f6553fe06f57f8647ea] Merge tag 'net-7.4-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net git bisect bad 7e1392a42ea288d70a266f6553fe06f57f8647ea # good: [0359338fd8cf1a2dc001d0cd69c331c17decee88] af_unix: Inherit SO_INQ in unix_stream_connect() git bisect good 0359338fd8cf1a2dc001d0cd69c331c17decee88 # good: [79eb6679ef6a0d5ea68da53a8321fb1dc72299b9] Merge tag 'loongarch-fixes-7.4-1' of git://git.kernel.org/pub/scm/linux/kernel/git/chenhuacai/linux-loongson git bisect good 79eb6679ef6a0d5ea68da53a8321fb1dc72299b9 # bad: [baa6744dc939a927e2c94e5f20aff01ac538aef1] Merge tag 'acpi-7.4-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm git bisect bad baa6744dc939a927e2c94e5f20aff01ac538aef1 # good: [2cca8a6f6ae690755862f5b633125119dcf6bd0c] Merge patch series "ns: fixes identifier fixes" git bisect good 2cca8a6f6ae690755862f5b633125119dcf6bd0c # bad: [df42809bd599109660bd3f95e2e22330c80993df] Merge branches 'pm-cpufreq' and 'pm-runtime' git bisect bad df42809bd599109660bd3f95e2e22330c80993df # bad: [6bc092a0fc4d331a4adbbb664078af149c580834] cpufreq: acpi-cpufreq: fix P-state index mismatch in extract_io() git bisect bad 6bc092a0fc4d331a4adbbb664078af149c580834 # bad: [02e77af824d5be3a94fdd885835a352f90d24c5c] cpufreq: intel_pstate: Clear last written P-state value on suspend git bisect bad 02e77af824d5be3a94fdd885835a352f90d24c5c # bad: [eee2a44e4e2b41c0699919a550d41cc38daa4f42] cpufreq: Improve suspend-resume synchronization git bisect bad eee2a44e4e2b41c0699919a550d41cc38daa4f42 # good: [e6f50e602e373583423654ec000cad8b8d08f7bc] cpufreq: Hold the policy write lock when changing boost state git bisect good e6f50e602e373583423654ec000cad8b8d08f7bc # first bad commit: [eee2a44e4e2b41c0699919a550d41cc38daa4f42] cpufreq: Improve suspend-resume synchronization > Fixes: 8e30444e1530 ("cpufreq: fix cpufreq suspend/resume for intel_pstate") > Fixes: b1b12babe3b7 ("cpufreq: update 'cpufreq_suspended' after stopping governors") > Cc: All applicable <stable@vger.kernel.org> > Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> > --- > > v1 -> v2: > * Retain all of the cpufreq_suspended checks to avoid carrying out > governor operations after suspending cpufreq during system > shutdown and during hibernation resume on systems with SMT (Sashiko) > > * Rearrange cpufreq_resume() to walk all cpufreq policies and call > cpufreq_resume_policy() for all of them > > * Call cpufreq_exit_governor() in cpufreq_resume_policy() for > policies that were suspended during a system suspend transition and > are inactive during the subsequent system resume (Sashiko) > > * Update cpufreq_suspended under cpus_read_lock in cpufreq_resume() > for more symmetry with cpufreq_suspend() > > * Update changelog > > --- > drivers/cpufreq/cpufreq.c | 86 +++++++++++++++++++++++++++++++++------------- > include/linux/cpufreq.h | 3 + > 2 files changed, 66 insertions(+), 23 deletions(-) > > --- a/drivers/cpufreq/cpufreq.c > +++ b/drivers/cpufreq/cpufreq.c > @@ -35,6 +35,9 @@ > static LIST_HEAD(cpufreq_policy_list); > > /* Macros to iterate over CPU policies */ > +#define for_each_policy(__policy) \ > + list_for_each_entry(__policy, &cpufreq_policy_list, policy_list) > + > #define for_each_suitable_policy(__policy, __active) \ > list_for_each_entry(__policy, &cpufreq_policy_list, policy_list) \ > if ((__active) == !policy_is_inactive(__policy)) > @@ -1956,6 +1959,14 @@ int cpufreq_generic_suspend(struct cpufr > } > EXPORT_SYMBOL(cpufreq_generic_suspend); > > +static void cpufreq_suspend_policy(struct cpufreq_policy *policy) > +{ > + guard(cpufreq_policy_write)(policy); > + > + cpufreq_stop_governor(policy); > + policy->suspended = true; > +} > + > /** > * cpufreq_suspend() - Suspend CPUFreq governors. > * > @@ -1978,11 +1989,8 @@ void cpufreq_suspend(void) > pr_debug("%s: Suspending Governors\n", __func__); > > for_each_active_policy(policy) { > - if (has_target()) { > - scoped_guard(cpufreq_policy_write, policy) { > - cpufreq_stop_governor(policy); > - } > - } > + if (has_target()) > + cpufreq_suspend_policy(policy); > > if (cpufreq_driver->suspend && cpufreq_driver->suspend(policy)) > pr_err("%s: Failed to suspend driver: %s\n", __func__, > @@ -1994,6 +2002,32 @@ suspend: > cpus_read_unlock(); > } > > +static void cpufreq_resume_policy(struct cpufreq_policy *policy, bool start) > +{ > + guard(cpufreq_policy_write)(policy); > + > + if (!policy->suspended) > + return; > + > + policy->suspended = false; > + > + if (policy_is_inactive(policy)) { > + /* > + * The policy was active when it was suspended, so its governor > + * is still there. Let the governor go. > + */ > + cpufreq_exit_governor(policy); > + return; > + } > + > + if (!start) > + return; > + > + if (cpufreq_start_governor(policy)) > + pr_err("%s: Failed to start governor for CPU%u's policy\n", > + __func__, policy->cpu); > +} > + > /** > * cpufreq_resume() - Resume CPUFreq governors. > * > @@ -2003,11 +2037,12 @@ suspend: > void cpufreq_resume(void) > { > struct cpufreq_policy *policy; > - int ret; > > if (!cpufreq_driver) > return; > > + guard(cpus_read_lock)(); > + > if (unlikely(!cpufreq_suspended)) > return; > > @@ -2018,19 +2053,18 @@ void cpufreq_resume(void) > > pr_debug("%s: Resuming Governors\n", __func__); > > - for_each_active_policy(policy) { > - if (cpufreq_driver->resume && cpufreq_driver->resume(policy)) { > - pr_err("%s: Failed to resume driver: %s\n", __func__, > - cpufreq_driver->name); > - } else if (has_target()) { > - scoped_guard(cpufreq_policy_write, policy) { > - ret = cpufreq_start_governor(policy); > - } > + for_each_policy(policy) { > + int ret = 0; > > + if (cpufreq_driver->resume && !policy_is_inactive(policy)) { > + ret = cpufreq_driver->resume(policy); > if (ret) > - pr_err("%s: Failed to start governor for CPU%u's policy\n", > - __func__, policy->cpu); > + pr_err("%s: Failed to resume driver: %s\n", __func__, > + cpufreq_driver->name); > } > + > + if (has_target()) > + cpufreq_resume_policy(policy, ret == 0); > } > } > > @@ -2412,12 +2446,17 @@ __weak struct cpufreq_governor *cpufreq_ > return NULL; > } > > +static bool cpufreq_is_suspended(struct cpufreq_policy *policy) > +{ > + return cpufreq_suspended || policy->suspended; > +} > + > static int cpufreq_init_governor(struct cpufreq_policy *policy) > { > int ret; > > - /* Don't start any governor operations if we are entering suspend */ > - if (cpufreq_suspended) > + /* Don't start any governor operations for suspended policies. */ > + if (cpufreq_is_suspended(policy)) > return 0; > /* > * Governor might not be initiated here if ACPI _PPC changed > @@ -2460,7 +2499,7 @@ static int cpufreq_init_governor(struct > > static void cpufreq_exit_governor(struct cpufreq_policy *policy) > { > - if (cpufreq_suspended || !policy->governor) > + if (cpufreq_is_suspended(policy) || !policy->governor) > return; > > pr_debug("%s: for CPU %u\n", __func__, policy->cpu); > @@ -2475,7 +2514,7 @@ int cpufreq_start_governor(struct cpufre > { > int ret; > > - if (cpufreq_suspended) > + if (cpufreq_is_suspended(policy)) > return 0; > > if (!policy->governor) > @@ -2499,7 +2538,7 @@ int cpufreq_start_governor(struct cpufre > > void cpufreq_stop_governor(struct cpufreq_policy *policy) > { > - if (cpufreq_suspended || !policy->governor) > + if (cpufreq_is_suspended(policy) || !policy->governor) > return; > > pr_debug("%s: for CPU %u\n", __func__, policy->cpu); > @@ -2510,7 +2549,7 @@ void cpufreq_stop_governor(struct cpufre > > static void cpufreq_governor_limits(struct cpufreq_policy *policy) > { > - if (cpufreq_suspended || !policy->governor) > + if (cpufreq_is_suspended(policy) || !policy->governor) > return; > > pr_debug("%s: for CPU %u\n", __func__, policy->cpu); > @@ -2747,7 +2786,8 @@ static void cpufreq_policy_refresh(struc > * -> ask driver for current freq and notify governors about a change > */ > if (cpufreq_driver->get && has_target() && > - (cpufreq_suspended || WARN_ON(!cpufreq_verify_current_freq(policy, false)))) > + (cpufreq_is_suspended(policy) || > + WARN_ON(!cpufreq_verify_current_freq(policy, false)))) > return; > > refresh_frequency_limits(policy); > --- a/include/linux/cpufreq.h > +++ b/include/linux/cpufreq.h > @@ -149,6 +149,9 @@ struct cpufreq_policy { > /* Pending policy->min/max update for the driver */ > bool update_limits; > > + /* The policy has been suspended. */ > + bool suspended; > + > /* Cached frequency lookup from cpufreq_driver_resolve_freq. */ > unsigned int cached_target_freq; > unsigned int cached_resolved_idx; ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [REGRESSION: [PATCH v2 1/3] cpufreq: Improve suspend-resume synchronization 2026-11-18 13:03 ` [REGRESSION: [PATCH v2 1/3] cpufreq: Improve suspend-resume synchronization Borah, Chaitanya Kumar @ 2026-11-18 15:02 ` Rafael J. Wysocki (Intel) 2026-11-19 7:24 ` Borah, Chaitanya Kumar 0 siblings, 1 reply; 3+ messages in thread From: Rafael J. Wysocki (Intel) @ 2026-11-18 15:02 UTC (permalink / raw) To: Borah, Chaitanya Kumar Cc: Rafael J. Wysocki, Linux PM, Viresh Kumar, Christian Loehle, Doug Smythies, Zak, Srinivas Pandruvada, Mario Limonciello, intel-gfx@lists.freedesktop.org, intel-xe@lists.freedesktop.org, ravitejax.veesam [-- Attachment #1: Type: text/plain, Size: 16113 bytes --] On Wed, Nov 18, 2026 at 2:05 PM Borah, Chaitanya Kumar <chaitanya.kumar.borah@intel.com> wrote: > > > Hello Rafael, > > On 11/4/2026 1:15 AM, Rafael J. Wysocki wrote: > > From: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com> > > > > The suspend-resume synchronization in the cpufreq core is not perfect > > because the global cpufreq_suspended variable is set at the end of > > cpufreq_suspend() after stopping governors for all of the active > > policies, so the governor .limits() callback may run via > > cpufreq_governor_limits() after stopping the governor and before > > setting cpufreq_suspended which is questionable. Likewise, the > > governor .limits() callback may run between clearing cpufreq_suspended > > in cpufreq_resume() and starting the governor. > > > > Address this by adding a per-policy "suspended" flag that is always > > read under the policy rwsem and is updated under it when the governor > > is stopped in cpufreq_suspend() and when the governor is restarted in > > cpufreq_resume(). > > > > Also make cpufreq_resume() use the cpus_read_lock guard to reflect > > what is done in cpufreq_suspend() and call cpufreq_exit_governor() for > > policies that were suspended during a system suspend transition and > > are inactive during the subsequent system resume (to avoid leaking an > > inactive policy with a stopped governor that has not exited yet). > > > > This seems to be causing regression in our CI [1] (affecting dg1 and > dg2). We could not revert the patch cleanly but resetting to its parent > heals the issue. > > <4> [510.751891] ====================================================== > <4> [510.751907] WARNING: possible circular locking dependency detected > <4> [510.751925] 7.4.0-rc3-CI_DRM_19546-gfb078d17b966+ #1 Tainted: G S > U L > <4> [510.751946] ------------------------------------------------------ > <4> [510.751962] rtcwake/4256 is trying to acquire lock: > <4> [510.751977] ffffffff83ce0f40 > (intel_pstate_driver_lock){+.+.}-{3:3}, at: set_power_ctl_ee_state+0x1a/0x90 > <4> [510.752022] > but task is already holding lock: > <4> [510.752038] ffffffff83886890 (cpu_hotplug_lock){++++}-{0:0}, at: > cpufreq_resume+0x23/0x250 > <4> [510.752074] > which lock already depends on the new lock. > <4> [510.752094] > the existing dependency chain (in reverse order) is: > <4> [510.752112] > -> #1 (cpu_hotplug_lock){++++}-{0:0}: > <4> [510.752137] cpus_read_lock+0x3c/0x100 > <4> [510.752157] cpufreq_register_driver+0xca/0x380 > <4> [510.752175] intel_pstate_register_driver+0x9e/0x1d0 > <4> [510.752192] intel_pstate_init+0x3e3/0xb30 > <4> [510.752211] do_one_initcall+0x59/0x3d0 > <4> [510.752229] kernel_init_freeable+0x3dc/0x6b0 > <4> [510.752249] kernel_init+0x20/0x210 > <4> [510.752264] ret_from_fork+0x3bf/0x470 > <4> [510.752282] ret_from_fork_asm+0x1a/0x30 > <4> [510.752299] > -> #0 (intel_pstate_driver_lock){+.+.}-{3:3}: > <4> [510.752325] __lock_acquire+0x1700/0x29c0 > <4> [510.752341] lock_acquire+0xd9/0x2f0 > <4> [510.752355] __mutex_lock+0xae/0x1030 > <4> [510.752372] mutex_lock_nested+0x1b/0x30 > <4> [510.752390] set_power_ctl_ee_state+0x1a/0x90 > <4> [510.752409] intel_pstate_resume+0x109/0x110 > <4> [510.752428] cpufreq_resume+0x153/0x250 > <4> [510.752445] dpm_resume+0x1f1/0x390 > <4> [510.752459] dpm_resume_end+0x11/0x30 > <4> [510.752474] suspend_devices_and_enter+0x372/0xcb0 > <4> [510.752491] pm_suspend+0x372/0x840 > <4> [510.752506] state_store+0x6e/0xe0 > <4> [510.752523] kobj_attr_store+0x12/0x40 > <4> [510.752541] sysfs_kf_write+0x4d/0x80 > <4> [510.752559] kernfs_fop_write_iter+0x193/0x240 > <4> [510.752576] vfs_write+0x285/0x530 > <4> [510.752591] ksys_write+0x6f/0xf0 > <4> [510.752606] __x64_sys_write+0x19/0x30 > <4> [510.752622] x64_sys_call+0x1285/0x27e0 > <4> [510.752637] do_syscall_64+0xec/0x680 > <4> [510.752654] entry_SYSCALL_64_after_hwframe+0x76/0x7e > > Could you please check why the patch causes this regression and provide > a fix if necessary? That's because set_power_ctl_ee_state() acquires intel_pstate_driver_lock which is held around cpu_hotplug_lock during driver mode changes, so adding cpu_hotplug_lock around intel_pstate_resume(), which calls set_power_ctl_ee_state(), causes lockdep to complain. Note that the deadlock is not real, but set_power_ctl_ee_state() need not use that particular lock either AFAICS. The attached patch should address this. > [1] > https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_19546/shard-dg1-14/igt@i915_suspend@basic-s2idle-without-i915.html > > --Bisect Logs-- > git bisect start > # status: waiting for both good and bad commits > # bad: [cfe67bbcfc37474cbb4482d750d4fba34bbc5a24] drm-tip: > 2026y-11m-17d-05h-12m-00s UTC integration manifest > git bisect bad cfe67bbcfc37474cbb4482d750d4fba34bbc5a24 > # status: waiting for good commit(s), bad commit known > # good: [39e407b553ec15d4a233b651531ad431ed7542be] drm/sun4i: dw-hdmi: > Deinit PHY in bind error path > git bisect good 39e407b553ec15d4a233b651531ad431ed7542be > # bad: [715f145f6204363a50853eb15719dc860db0bc01] drm/i915/dsb: Realign > GOSUB only for QW slots 6 and 7 > git bisect bad 715f145f6204363a50853eb15719dc860db0bc01 > # bad: [7e1392a42ea288d70a266f6553fe06f57f8647ea] Merge tag > 'net-7.4-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net > git bisect bad 7e1392a42ea288d70a266f6553fe06f57f8647ea > # good: [0359338fd8cf1a2dc001d0cd69c331c17decee88] af_unix: Inherit > SO_INQ in unix_stream_connect() > git bisect good 0359338fd8cf1a2dc001d0cd69c331c17decee88 > # good: [79eb6679ef6a0d5ea68da53a8321fb1dc72299b9] Merge tag > 'loongarch-fixes-7.4-1' of > git://git.kernel.org/pub/scm/linux/kernel/git/chenhuacai/linux-loongson > git bisect good 79eb6679ef6a0d5ea68da53a8321fb1dc72299b9 > # bad: [baa6744dc939a927e2c94e5f20aff01ac538aef1] Merge tag > 'acpi-7.4-rc3' of > git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm > git bisect bad baa6744dc939a927e2c94e5f20aff01ac538aef1 > # good: [2cca8a6f6ae690755862f5b633125119dcf6bd0c] Merge patch series > "ns: fixes identifier fixes" > git bisect good 2cca8a6f6ae690755862f5b633125119dcf6bd0c > # bad: [df42809bd599109660bd3f95e2e22330c80993df] Merge branches > 'pm-cpufreq' and 'pm-runtime' > git bisect bad df42809bd599109660bd3f95e2e22330c80993df > # bad: [6bc092a0fc4d331a4adbbb664078af149c580834] cpufreq: acpi-cpufreq: > fix P-state index mismatch in extract_io() > git bisect bad 6bc092a0fc4d331a4adbbb664078af149c580834 > # bad: [02e77af824d5be3a94fdd885835a352f90d24c5c] cpufreq: intel_pstate: > Clear last written P-state value on suspend > git bisect bad 02e77af824d5be3a94fdd885835a352f90d24c5c > # bad: [eee2a44e4e2b41c0699919a550d41cc38daa4f42] cpufreq: Improve > suspend-resume synchronization > git bisect bad eee2a44e4e2b41c0699919a550d41cc38daa4f42 > # good: [e6f50e602e373583423654ec000cad8b8d08f7bc] cpufreq: Hold the > policy write lock when changing boost state > git bisect good e6f50e602e373583423654ec000cad8b8d08f7bc > # first bad commit: [eee2a44e4e2b41c0699919a550d41cc38daa4f42] cpufreq: > Improve suspend-resume synchronization > > > Fixes: 8e30444e1530 ("cpufreq: fix cpufreq suspend/resume for intel_pstate") > > Fixes: b1b12babe3b7 ("cpufreq: update 'cpufreq_suspended' after stopping governors") > > Cc: All applicable <stable@vger.kernel.org> > > Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> > > --- > > > > v1 -> v2: > > * Retain all of the cpufreq_suspended checks to avoid carrying out > > governor operations after suspending cpufreq during system > > shutdown and during hibernation resume on systems with SMT (Sashiko) > > > > * Rearrange cpufreq_resume() to walk all cpufreq policies and call > > cpufreq_resume_policy() for all of them > > > > * Call cpufreq_exit_governor() in cpufreq_resume_policy() for > > policies that were suspended during a system suspend transition and > > are inactive during the subsequent system resume (Sashiko) > > > > * Update cpufreq_suspended under cpus_read_lock in cpufreq_resume() > > for more symmetry with cpufreq_suspend() > > > > * Update changelog > > > > --- > > drivers/cpufreq/cpufreq.c | 86 +++++++++++++++++++++++++++++++++------------- > > include/linux/cpufreq.h | 3 + > > 2 files changed, 66 insertions(+), 23 deletions(-) > > > > --- a/drivers/cpufreq/cpufreq.c > > +++ b/drivers/cpufreq/cpufreq.c > > @@ -35,6 +35,9 @@ > > static LIST_HEAD(cpufreq_policy_list); > > > > /* Macros to iterate over CPU policies */ > > +#define for_each_policy(__policy) \ > > + list_for_each_entry(__policy, &cpufreq_policy_list, policy_list) > > + > > #define for_each_suitable_policy(__policy, __active) \ > > list_for_each_entry(__policy, &cpufreq_policy_list, policy_list) \ > > if ((__active) == !policy_is_inactive(__policy)) > > @@ -1956,6 +1959,14 @@ int cpufreq_generic_suspend(struct cpufr > > } > > EXPORT_SYMBOL(cpufreq_generic_suspend); > > > > +static void cpufreq_suspend_policy(struct cpufreq_policy *policy) > > +{ > > + guard(cpufreq_policy_write)(policy); > > + > > + cpufreq_stop_governor(policy); > > + policy->suspended = true; > > +} > > + > > /** > > * cpufreq_suspend() - Suspend CPUFreq governors. > > * > > @@ -1978,11 +1989,8 @@ void cpufreq_suspend(void) > > pr_debug("%s: Suspending Governors\n", __func__); > > > > for_each_active_policy(policy) { > > - if (has_target()) { > > - scoped_guard(cpufreq_policy_write, policy) { > > - cpufreq_stop_governor(policy); > > - } > > - } > > + if (has_target()) > > + cpufreq_suspend_policy(policy); > > > > if (cpufreq_driver->suspend && cpufreq_driver->suspend(policy)) > > pr_err("%s: Failed to suspend driver: %s\n", __func__, > > @@ -1994,6 +2002,32 @@ suspend: > > cpus_read_unlock(); > > } > > > > +static void cpufreq_resume_policy(struct cpufreq_policy *policy, bool start) > > +{ > > + guard(cpufreq_policy_write)(policy); > > + > > + if (!policy->suspended) > > + return; > > + > > + policy->suspended = false; > > + > > + if (policy_is_inactive(policy)) { > > + /* > > + * The policy was active when it was suspended, so its governor > > + * is still there. Let the governor go. > > + */ > > + cpufreq_exit_governor(policy); > > + return; > > + } > > + > > + if (!start) > > + return; > > + > > + if (cpufreq_start_governor(policy)) > > + pr_err("%s: Failed to start governor for CPU%u's policy\n", > > + __func__, policy->cpu); > > +} > > + > > /** > > * cpufreq_resume() - Resume CPUFreq governors. > > * > > @@ -2003,11 +2037,12 @@ suspend: > > void cpufreq_resume(void) > > { > > struct cpufreq_policy *policy; > > - int ret; > > > > if (!cpufreq_driver) > > return; > > > > + guard(cpus_read_lock)(); > > + > > if (unlikely(!cpufreq_suspended)) > > return; > > > > @@ -2018,19 +2053,18 @@ void cpufreq_resume(void) > > > > pr_debug("%s: Resuming Governors\n", __func__); > > > > - for_each_active_policy(policy) { > > - if (cpufreq_driver->resume && cpufreq_driver->resume(policy)) { > > - pr_err("%s: Failed to resume driver: %s\n", __func__, > > - cpufreq_driver->name); > > - } else if (has_target()) { > > - scoped_guard(cpufreq_policy_write, policy) { > > - ret = cpufreq_start_governor(policy); > > - } > > + for_each_policy(policy) { > > + int ret = 0; > > > > + if (cpufreq_driver->resume && !policy_is_inactive(policy)) { > > + ret = cpufreq_driver->resume(policy); > > if (ret) > > - pr_err("%s: Failed to start governor for CPU%u's policy\n", > > - __func__, policy->cpu); > > + pr_err("%s: Failed to resume driver: %s\n", __func__, > > + cpufreq_driver->name); > > } > > + > > + if (has_target()) > > + cpufreq_resume_policy(policy, ret == 0); > > } > > } > > > > @@ -2412,12 +2446,17 @@ __weak struct cpufreq_governor *cpufreq_ > > return NULL; > > } > > > > +static bool cpufreq_is_suspended(struct cpufreq_policy *policy) > > +{ > > + return cpufreq_suspended || policy->suspended; > > +} > > + > > static int cpufreq_init_governor(struct cpufreq_policy *policy) > > { > > int ret; > > > > - /* Don't start any governor operations if we are entering suspend */ > > - if (cpufreq_suspended) > > + /* Don't start any governor operations for suspended policies. */ > > + if (cpufreq_is_suspended(policy)) > > return 0; > > /* > > * Governor might not be initiated here if ACPI _PPC changed > > @@ -2460,7 +2499,7 @@ static int cpufreq_init_governor(struct > > > > static void cpufreq_exit_governor(struct cpufreq_policy *policy) > > { > > - if (cpufreq_suspended || !policy->governor) > > + if (cpufreq_is_suspended(policy) || !policy->governor) > > return; > > > > pr_debug("%s: for CPU %u\n", __func__, policy->cpu); > > @@ -2475,7 +2514,7 @@ int cpufreq_start_governor(struct cpufre > > { > > int ret; > > > > - if (cpufreq_suspended) > > + if (cpufreq_is_suspended(policy)) > > return 0; > > > > if (!policy->governor) > > @@ -2499,7 +2538,7 @@ int cpufreq_start_governor(struct cpufre > > > > void cpufreq_stop_governor(struct cpufreq_policy *policy) > > { > > - if (cpufreq_suspended || !policy->governor) > > + if (cpufreq_is_suspended(policy) || !policy->governor) > > return; > > > > pr_debug("%s: for CPU %u\n", __func__, policy->cpu); > > @@ -2510,7 +2549,7 @@ void cpufreq_stop_governor(struct cpufre > > > > static void cpufreq_governor_limits(struct cpufreq_policy *policy) > > { > > - if (cpufreq_suspended || !policy->governor) > > + if (cpufreq_is_suspended(policy) || !policy->governor) > > return; > > > > pr_debug("%s: for CPU %u\n", __func__, policy->cpu); > > @@ -2747,7 +2786,8 @@ static void cpufreq_policy_refresh(struc > > * -> ask driver for current freq and notify governors about a change > > */ > > if (cpufreq_driver->get && has_target() && > > - (cpufreq_suspended || WARN_ON(!cpufreq_verify_current_freq(policy, false)))) > > + (cpufreq_is_suspended(policy) || > > + WARN_ON(!cpufreq_verify_current_freq(policy, false)))) > > return; > > > > refresh_frequency_limits(policy); > > --- a/include/linux/cpufreq.h > > +++ b/include/linux/cpufreq.h > > @@ -149,6 +149,9 @@ struct cpufreq_policy { > > /* Pending policy->min/max update for the driver */ > > bool update_limits; > > > > + /* The policy has been suspended. */ > > + bool suspended; > > + > > /* Cached frequency lookup from cpufreq_driver_resolve_freq. */ > > unsigned int cached_target_freq; > > unsigned int cached_resolved_idx; > > [-- Attachment #2: intel_pstate-power-ctl-ee-state.patch --] [-- Type: text/x-patch, Size: 1723 bytes --] --- drivers/cpufreq/intel_pstate.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) --- a/drivers/cpufreq/intel_pstate.c +++ b/drivers/cpufreq/intel_pstate.c @@ -1352,13 +1352,12 @@ static void intel_pstate_hwp_offline(str #define POWER_CTL_DEC_ENABLE 27 static int power_ctl_ee_state; +static DEFINE_MUTEX(power_ctl_ee_state_lock); -static void set_power_ctl_ee_state(bool input) +static void __set_power_ctl_ee_state(bool input) { u64 power_ctl; - guard(mutex)(&intel_pstate_driver_lock); - rdmsrq(MSR_IA32_POWER_CTL, power_ctl); if (input) { power_ctl &= ~BIT(MSR_IA32_POWER_CTL_BIT_EE); @@ -1370,6 +1369,13 @@ static void set_power_ctl_ee_state(bool wrmsrq(MSR_IA32_POWER_CTL, power_ctl); } +static void set_power_ctl_ee_state(bool enable) +{ + guard(mutex)(&power_ctl_ee_state_lock); + + __set_power_ctl_ee_state(enable); +} + static void intel_pstate_hwp_enable(struct cpudata *cpudata); static void intel_pstate_hwp_reenable(struct cpudata *cpu) @@ -1398,11 +1404,13 @@ static int intel_pstate_resume(struct cp pr_debug("CPU %d resuming\n", cpu->cpu); - /* Only restore if the system default is changed */ - if (power_ctl_ee_state == POWER_CTL_EE_ENABLE) - set_power_ctl_ee_state(true); - else if (power_ctl_ee_state == POWER_CTL_EE_DISABLE) - set_power_ctl_ee_state(false); + scoped_guard(mutex, &power_ctl_ee_state_lock) { + /* Only restore if the system default has changed */ + if (power_ctl_ee_state == POWER_CTL_EE_ENABLE) + __set_power_ctl_ee_state(true); + else if (power_ctl_ee_state == POWER_CTL_EE_DISABLE) + __set_power_ctl_ee_state(false); + } if (cpu->suspended && hwp_active) { mutex_lock(&intel_pstate_limits_lock); ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [REGRESSION: [PATCH v2 1/3] cpufreq: Improve suspend-resume synchronization 2026-11-18 15:02 ` Rafael J. Wysocki (Intel) @ 2026-11-19 7:24 ` Borah, Chaitanya Kumar 0 siblings, 0 replies; 3+ messages in thread From: Borah, Chaitanya Kumar @ 2026-11-19 7:24 UTC (permalink / raw) To: Rafael J. Wysocki (Intel) Cc: Linux PM, Viresh Kumar, Christian Loehle, Doug Smythies, Zak, Srinivas Pandruvada, Mario Limonciello, intel-gfx@lists.freedesktop.org, intel-xe@lists.freedesktop.org, ravitejax.veesam On 11/18/2026 8:32 PM, Rafael J. Wysocki (Intel) wrote: > On Wed, Nov 18, 2026 at 2:05 PM Borah, Chaitanya Kumar > <chaitanya.kumar.borah@intel.com> wrote: >> >> >> Hello Rafael, >> >> On 11/4/2026 1:15 AM, Rafael J. Wysocki wrote: >>> From: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com> >>> >>> The suspend-resume synchronization in the cpufreq core is not perfect >>> because the global cpufreq_suspended variable is set at the end of >>> cpufreq_suspend() after stopping governors for all of the active >>> policies, so the governor .limits() callback may run via >>> cpufreq_governor_limits() after stopping the governor and before >>> setting cpufreq_suspended which is questionable. Likewise, the >>> governor .limits() callback may run between clearing cpufreq_suspended >>> in cpufreq_resume() and starting the governor. >>> >>> Address this by adding a per-policy "suspended" flag that is always >>> read under the policy rwsem and is updated under it when the governor >>> is stopped in cpufreq_suspend() and when the governor is restarted in >>> cpufreq_resume(). >>> >>> Also make cpufreq_resume() use the cpus_read_lock guard to reflect >>> what is done in cpufreq_suspend() and call cpufreq_exit_governor() for >>> policies that were suspended during a system suspend transition and >>> are inactive during the subsequent system resume (to avoid leaking an >>> inactive policy with a stopped governor that has not exited yet). >>> >> >> This seems to be causing regression in our CI [1] (affecting dg1 and >> dg2). We could not revert the patch cleanly but resetting to its parent >> heals the issue. >> >> <4> [510.751891] ====================================================== >> <4> [510.751907] WARNING: possible circular locking dependency detected >> <4> [510.751925] 7.4.0-rc3-CI_DRM_19546-gfb078d17b966+ #1 Tainted: G S >> U L >> <4> [510.751946] ------------------------------------------------------ >> <4> [510.751962] rtcwake/4256 is trying to acquire lock: >> <4> [510.751977] ffffffff83ce0f40 >> (intel_pstate_driver_lock){+.+.}-{3:3}, at: set_power_ctl_ee_state+0x1a/0x90 >> <4> [510.752022] >> but task is already holding lock: >> <4> [510.752038] ffffffff83886890 (cpu_hotplug_lock){++++}-{0:0}, at: >> cpufreq_resume+0x23/0x250 >> <4> [510.752074] >> which lock already depends on the new lock. >> <4> [510.752094] >> the existing dependency chain (in reverse order) is: >> <4> [510.752112] >> -> #1 (cpu_hotplug_lock){++++}-{0:0}: >> <4> [510.752137] cpus_read_lock+0x3c/0x100 >> <4> [510.752157] cpufreq_register_driver+0xca/0x380 >> <4> [510.752175] intel_pstate_register_driver+0x9e/0x1d0 >> <4> [510.752192] intel_pstate_init+0x3e3/0xb30 >> <4> [510.752211] do_one_initcall+0x59/0x3d0 >> <4> [510.752229] kernel_init_freeable+0x3dc/0x6b0 >> <4> [510.752249] kernel_init+0x20/0x210 >> <4> [510.752264] ret_from_fork+0x3bf/0x470 >> <4> [510.752282] ret_from_fork_asm+0x1a/0x30 >> <4> [510.752299] >> -> #0 (intel_pstate_driver_lock){+.+.}-{3:3}: >> <4> [510.752325] __lock_acquire+0x1700/0x29c0 >> <4> [510.752341] lock_acquire+0xd9/0x2f0 >> <4> [510.752355] __mutex_lock+0xae/0x1030 >> <4> [510.752372] mutex_lock_nested+0x1b/0x30 >> <4> [510.752390] set_power_ctl_ee_state+0x1a/0x90 >> <4> [510.752409] intel_pstate_resume+0x109/0x110 >> <4> [510.752428] cpufreq_resume+0x153/0x250 >> <4> [510.752445] dpm_resume+0x1f1/0x390 >> <4> [510.752459] dpm_resume_end+0x11/0x30 >> <4> [510.752474] suspend_devices_and_enter+0x372/0xcb0 >> <4> [510.752491] pm_suspend+0x372/0x840 >> <4> [510.752506] state_store+0x6e/0xe0 >> <4> [510.752523] kobj_attr_store+0x12/0x40 >> <4> [510.752541] sysfs_kf_write+0x4d/0x80 >> <4> [510.752559] kernfs_fop_write_iter+0x193/0x240 >> <4> [510.752576] vfs_write+0x285/0x530 >> <4> [510.752591] ksys_write+0x6f/0xf0 >> <4> [510.752606] __x64_sys_write+0x19/0x30 >> <4> [510.752622] x64_sys_call+0x1285/0x27e0 >> <4> [510.752637] do_syscall_64+0xec/0x680 >> <4> [510.752654] entry_SYSCALL_64_after_hwframe+0x76/0x7e >> >> Could you please check why the patch causes this regression and provide >> a fix if necessary? > > That's because set_power_ctl_ee_state() acquires > intel_pstate_driver_lock which is held around cpu_hotplug_lock during > driver mode changes, so adding cpu_hotplug_lock around > intel_pstate_resume(), which calls set_power_ctl_ee_state(), causes > lockdep to complain. Note that the deadlock is not real, but > set_power_ctl_ee_state() need not use that particular lock either > AFAICS. > > The attached patch should address this. This works. Thank you for the patch. I hope you would be floating it soon. == Chaitanya > >> [1] >> https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_19546/shard-dg1-14/igt@i915_suspend@basic-s2idle-without-i915.html >> >> --Bisect Logs-- >> git bisect start >> # status: waiting for both good and bad commits >> # bad: [cfe67bbcfc37474cbb4482d750d4fba34bbc5a24] drm-tip: >> 2026y-11m-17d-05h-12m-00s UTC integration manifest >> git bisect bad cfe67bbcfc37474cbb4482d750d4fba34bbc5a24 >> # status: waiting for good commit(s), bad commit known >> # good: [39e407b553ec15d4a233b651531ad431ed7542be] drm/sun4i: dw-hdmi: >> Deinit PHY in bind error path >> git bisect good 39e407b553ec15d4a233b651531ad431ed7542be >> # bad: [715f145f6204363a50853eb15719dc860db0bc01] drm/i915/dsb: Realign >> GOSUB only for QW slots 6 and 7 >> git bisect bad 715f145f6204363a50853eb15719dc860db0bc01 >> # bad: [7e1392a42ea288d70a266f6553fe06f57f8647ea] Merge tag >> 'net-7.4-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net >> git bisect bad 7e1392a42ea288d70a266f6553fe06f57f8647ea >> # good: [0359338fd8cf1a2dc001d0cd69c331c17decee88] af_unix: Inherit >> SO_INQ in unix_stream_connect() >> git bisect good 0359338fd8cf1a2dc001d0cd69c331c17decee88 >> # good: [79eb6679ef6a0d5ea68da53a8321fb1dc72299b9] Merge tag >> 'loongarch-fixes-7.4-1' of >> git://git.kernel.org/pub/scm/linux/kernel/git/chenhuacai/linux-loongson >> git bisect good 79eb6679ef6a0d5ea68da53a8321fb1dc72299b9 >> # bad: [baa6744dc939a927e2c94e5f20aff01ac538aef1] Merge tag >> 'acpi-7.4-rc3' of >> git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm >> git bisect bad baa6744dc939a927e2c94e5f20aff01ac538aef1 >> # good: [2cca8a6f6ae690755862f5b633125119dcf6bd0c] Merge patch series >> "ns: fixes identifier fixes" >> git bisect good 2cca8a6f6ae690755862f5b633125119dcf6bd0c >> # bad: [df42809bd599109660bd3f95e2e22330c80993df] Merge branches >> 'pm-cpufreq' and 'pm-runtime' >> git bisect bad df42809bd599109660bd3f95e2e22330c80993df >> # bad: [6bc092a0fc4d331a4adbbb664078af149c580834] cpufreq: acpi-cpufreq: >> fix P-state index mismatch in extract_io() >> git bisect bad 6bc092a0fc4d331a4adbbb664078af149c580834 >> # bad: [02e77af824d5be3a94fdd885835a352f90d24c5c] cpufreq: intel_pstate: >> Clear last written P-state value on suspend >> git bisect bad 02e77af824d5be3a94fdd885835a352f90d24c5c >> # bad: [eee2a44e4e2b41c0699919a550d41cc38daa4f42] cpufreq: Improve >> suspend-resume synchronization >> git bisect bad eee2a44e4e2b41c0699919a550d41cc38daa4f42 >> # good: [e6f50e602e373583423654ec000cad8b8d08f7bc] cpufreq: Hold the >> policy write lock when changing boost state >> git bisect good e6f50e602e373583423654ec000cad8b8d08f7bc >> # first bad commit: [eee2a44e4e2b41c0699919a550d41cc38daa4f42] cpufreq: >> Improve suspend-resume synchronization >> >>> Fixes: 8e30444e1530 ("cpufreq: fix cpufreq suspend/resume for intel_pstate") >>> Fixes: b1b12babe3b7 ("cpufreq: update 'cpufreq_suspended' after stopping governors") >>> Cc: All applicable <stable@vger.kernel.org> >>> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> >>> --- >>> >>> v1 -> v2: >>> * Retain all of the cpufreq_suspended checks to avoid carrying out >>> governor operations after suspending cpufreq during system >>> shutdown and during hibernation resume on systems with SMT (Sashiko) >>> >>> * Rearrange cpufreq_resume() to walk all cpufreq policies and call >>> cpufreq_resume_policy() for all of them >>> >>> * Call cpufreq_exit_governor() in cpufreq_resume_policy() for >>> policies that were suspended during a system suspend transition and >>> are inactive during the subsequent system resume (Sashiko) >>> >>> * Update cpufreq_suspended under cpus_read_lock in cpufreq_resume() >>> for more symmetry with cpufreq_suspend() >>> >>> * Update changelog >>> >>> --- >>> drivers/cpufreq/cpufreq.c | 86 +++++++++++++++++++++++++++++++++------------- >>> include/linux/cpufreq.h | 3 + >>> 2 files changed, 66 insertions(+), 23 deletions(-) >>> >>> --- a/drivers/cpufreq/cpufreq.c >>> +++ b/drivers/cpufreq/cpufreq.c >>> @@ -35,6 +35,9 @@ >>> static LIST_HEAD(cpufreq_policy_list); >>> >>> /* Macros to iterate over CPU policies */ >>> +#define for_each_policy(__policy) \ >>> + list_for_each_entry(__policy, &cpufreq_policy_list, policy_list) >>> + >>> #define for_each_suitable_policy(__policy, __active) \ >>> list_for_each_entry(__policy, &cpufreq_policy_list, policy_list) \ >>> if ((__active) == !policy_is_inactive(__policy)) >>> @@ -1956,6 +1959,14 @@ int cpufreq_generic_suspend(struct cpufr >>> } >>> EXPORT_SYMBOL(cpufreq_generic_suspend); >>> >>> +static void cpufreq_suspend_policy(struct cpufreq_policy *policy) >>> +{ >>> + guard(cpufreq_policy_write)(policy); >>> + >>> + cpufreq_stop_governor(policy); >>> + policy->suspended = true; >>> +} >>> + >>> /** >>> * cpufreq_suspend() - Suspend CPUFreq governors. >>> * >>> @@ -1978,11 +1989,8 @@ void cpufreq_suspend(void) >>> pr_debug("%s: Suspending Governors\n", __func__); >>> >>> for_each_active_policy(policy) { >>> - if (has_target()) { >>> - scoped_guard(cpufreq_policy_write, policy) { >>> - cpufreq_stop_governor(policy); >>> - } >>> - } >>> + if (has_target()) >>> + cpufreq_suspend_policy(policy); >>> >>> if (cpufreq_driver->suspend && cpufreq_driver->suspend(policy)) >>> pr_err("%s: Failed to suspend driver: %s\n", __func__, >>> @@ -1994,6 +2002,32 @@ suspend: >>> cpus_read_unlock(); >>> } >>> >>> +static void cpufreq_resume_policy(struct cpufreq_policy *policy, bool start) >>> +{ >>> + guard(cpufreq_policy_write)(policy); >>> + >>> + if (!policy->suspended) >>> + return; >>> + >>> + policy->suspended = false; >>> + >>> + if (policy_is_inactive(policy)) { >>> + /* >>> + * The policy was active when it was suspended, so its governor >>> + * is still there. Let the governor go. >>> + */ >>> + cpufreq_exit_governor(policy); >>> + return; >>> + } >>> + >>> + if (!start) >>> + return; >>> + >>> + if (cpufreq_start_governor(policy)) >>> + pr_err("%s: Failed to start governor for CPU%u's policy\n", >>> + __func__, policy->cpu); >>> +} >>> + >>> /** >>> * cpufreq_resume() - Resume CPUFreq governors. >>> * >>> @@ -2003,11 +2037,12 @@ suspend: >>> void cpufreq_resume(void) >>> { >>> struct cpufreq_policy *policy; >>> - int ret; >>> >>> if (!cpufreq_driver) >>> return; >>> >>> + guard(cpus_read_lock)(); >>> + >>> if (unlikely(!cpufreq_suspended)) >>> return; >>> >>> @@ -2018,19 +2053,18 @@ void cpufreq_resume(void) >>> >>> pr_debug("%s: Resuming Governors\n", __func__); >>> >>> - for_each_active_policy(policy) { >>> - if (cpufreq_driver->resume && cpufreq_driver->resume(policy)) { >>> - pr_err("%s: Failed to resume driver: %s\n", __func__, >>> - cpufreq_driver->name); >>> - } else if (has_target()) { >>> - scoped_guard(cpufreq_policy_write, policy) { >>> - ret = cpufreq_start_governor(policy); >>> - } >>> + for_each_policy(policy) { >>> + int ret = 0; >>> >>> + if (cpufreq_driver->resume && !policy_is_inactive(policy)) { >>> + ret = cpufreq_driver->resume(policy); >>> if (ret) >>> - pr_err("%s: Failed to start governor for CPU%u's policy\n", >>> - __func__, policy->cpu); >>> + pr_err("%s: Failed to resume driver: %s\n", __func__, >>> + cpufreq_driver->name); >>> } >>> + >>> + if (has_target()) >>> + cpufreq_resume_policy(policy, ret == 0); >>> } >>> } >>> >>> @@ -2412,12 +2446,17 @@ __weak struct cpufreq_governor *cpufreq_ >>> return NULL; >>> } >>> >>> +static bool cpufreq_is_suspended(struct cpufreq_policy *policy) >>> +{ >>> + return cpufreq_suspended || policy->suspended; >>> +} >>> + >>> static int cpufreq_init_governor(struct cpufreq_policy *policy) >>> { >>> int ret; >>> >>> - /* Don't start any governor operations if we are entering suspend */ >>> - if (cpufreq_suspended) >>> + /* Don't start any governor operations for suspended policies. */ >>> + if (cpufreq_is_suspended(policy)) >>> return 0; >>> /* >>> * Governor might not be initiated here if ACPI _PPC changed >>> @@ -2460,7 +2499,7 @@ static int cpufreq_init_governor(struct >>> >>> static void cpufreq_exit_governor(struct cpufreq_policy *policy) >>> { >>> - if (cpufreq_suspended || !policy->governor) >>> + if (cpufreq_is_suspended(policy) || !policy->governor) >>> return; >>> >>> pr_debug("%s: for CPU %u\n", __func__, policy->cpu); >>> @@ -2475,7 +2514,7 @@ int cpufreq_start_governor(struct cpufre >>> { >>> int ret; >>> >>> - if (cpufreq_suspended) >>> + if (cpufreq_is_suspended(policy)) >>> return 0; >>> >>> if (!policy->governor) >>> @@ -2499,7 +2538,7 @@ int cpufreq_start_governor(struct cpufre >>> >>> void cpufreq_stop_governor(struct cpufreq_policy *policy) >>> { >>> - if (cpufreq_suspended || !policy->governor) >>> + if (cpufreq_is_suspended(policy) || !policy->governor) >>> return; >>> >>> pr_debug("%s: for CPU %u\n", __func__, policy->cpu); >>> @@ -2510,7 +2549,7 @@ void cpufreq_stop_governor(struct cpufre >>> >>> static void cpufreq_governor_limits(struct cpufreq_policy *policy) >>> { >>> - if (cpufreq_suspended || !policy->governor) >>> + if (cpufreq_is_suspended(policy) || !policy->governor) >>> return; >>> >>> pr_debug("%s: for CPU %u\n", __func__, policy->cpu); >>> @@ -2747,7 +2786,8 @@ static void cpufreq_policy_refresh(struc >>> * -> ask driver for current freq and notify governors about a change >>> */ >>> if (cpufreq_driver->get && has_target() && >>> - (cpufreq_suspended || WARN_ON(!cpufreq_verify_current_freq(policy, false)))) >>> + (cpufreq_is_suspended(policy) || >>> + WARN_ON(!cpufreq_verify_current_freq(policy, false)))) >>> return; >>> >>> refresh_frequency_limits(policy); >>> --- a/include/linux/cpufreq.h >>> +++ b/include/linux/cpufreq.h >>> @@ -149,6 +149,9 @@ struct cpufreq_policy { >>> /* Pending policy->min/max update for the driver */ >>> bool update_limits; >>> >>> + /* The policy has been suspended. */ >>> + bool suspended; >>> + >>> /* Cached frequency lookup from cpufreq_driver_resolve_freq. */ >>> unsigned int cached_target_freq; >>> unsigned int cached_resolved_idx; >> >> ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-11-19 7:25 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <6065833.DvuYhMxLoT@rafael.j.wysocki>
[not found] ` <4796894.LvFx2qVVIh@rafael.j.wysocki>
2026-11-18 13:03 ` [REGRESSION: [PATCH v2 1/3] cpufreq: Improve suspend-resume synchronization Borah, Chaitanya Kumar
2026-11-18 15:02 ` Rafael J. Wysocki (Intel)
2026-11-19 7:24 ` Borah, Chaitanya Kumar
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox