Skip to content

Commit 5965750

Browse files
cloehlegregkh
authored andcommitted
cpufreq: Initialize cpufreq-based invariance before subsys
[ Upstream commit 8ffe28b ] commit 2a6c727 ("cpufreq: Initialize cpufreq-based frequency-invariance later") postponed the frequency invariance initialization to avoid disabling it in the error case. This isn't locking safe, instead move the initialization up before the subsys interface is registered (which will rebuild the sched_domains) and add the corresponding disable on the error path. Observed lockdep without this patch: [ 0.989686] ====================================================== [ 0.989688] WARNING: possible circular locking dependency detected [ 0.989690] 6.17.0-rc4-cix-build+ #31 Tainted: G S [ 0.989691] ------------------------------------------------------ [ 0.989692] swapper/0/1 is trying to acquire lock: [ 0.989693] ffff800082ada7f8 (sched_energy_mutex){+.+.}-{4:4}, at: rebuild_sched_domains_energy+0x30/0x58 [ 0.989705] but task is already holding lock: [ 0.989706] ffff000088c89bc8 (&policy->rwsem){+.+.}-{4:4}, at: cpufreq_online+0x7f8/0xbe0 [ 0.989713] which lock already depends on the new lock. Fixes: 2a6c727 ("cpufreq: Initialize cpufreq-based frequency-invariance later") Signed-off-by: Christian Loehle <christian.loehle@arm.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 6833714 commit 5965750

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

drivers/cpufreq/cpufreq.c

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2973,6 +2973,15 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data)
29732973
goto err_null_driver;
29742974
}
29752975

2976+
/*
2977+
* Mark support for the scheduler's frequency invariance engine for
2978+
* drivers that implement target(), target_index() or fast_switch().
2979+
*/
2980+
if (!cpufreq_driver->setpolicy) {
2981+
static_branch_enable_cpuslocked(&cpufreq_freq_invariance);
2982+
pr_debug("cpufreq: supports frequency invariance\n");
2983+
}
2984+
29762985
ret = subsys_interface_register(&cpufreq_interface);
29772986
if (ret)
29782987
goto err_boost_unreg;
@@ -2994,21 +3003,14 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data)
29943003
hp_online = ret;
29953004
ret = 0;
29963005

2997-
/*
2998-
* Mark support for the scheduler's frequency invariance engine for
2999-
* drivers that implement target(), target_index() or fast_switch().
3000-
*/
3001-
if (!cpufreq_driver->setpolicy) {
3002-
static_branch_enable_cpuslocked(&cpufreq_freq_invariance);
3003-
pr_debug("supports frequency invariance");
3004-
}
3005-
30063006
pr_debug("driver %s up and running\n", driver_data->name);
30073007
goto out;
30083008

30093009
err_if_unreg:
30103010
subsys_interface_unregister(&cpufreq_interface);
30113011
err_boost_unreg:
3012+
if (!cpufreq_driver->setpolicy)
3013+
static_branch_disable_cpuslocked(&cpufreq_freq_invariance);
30123014
remove_boost_sysfs_file();
30133015
err_null_driver:
30143016
write_lock_irqsave(&cpufreq_driver_lock, flags);

0 commit comments

Comments
 (0)