Skip to content

Commit 302c25e

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 <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent d342ba1 commit 302c25e

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
@@ -2956,6 +2956,15 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data)
29562956
goto err_null_driver;
29572957
}
29582958

2959+
/*
2960+
* Mark support for the scheduler's frequency invariance engine for
2961+
* drivers that implement target(), target_index() or fast_switch().
2962+
*/
2963+
if (!cpufreq_driver->setpolicy) {
2964+
static_branch_enable_cpuslocked(&cpufreq_freq_invariance);
2965+
pr_debug("cpufreq: supports frequency invariance\n");
2966+
}
2967+
29592968
ret = subsys_interface_register(&cpufreq_interface);
29602969
if (ret)
29612970
goto err_boost_unreg;
@@ -2977,21 +2986,14 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data)
29772986
hp_online = ret;
29782987
ret = 0;
29792988

2980-
/*
2981-
* Mark support for the scheduler's frequency invariance engine for
2982-
* drivers that implement target(), target_index() or fast_switch().
2983-
*/
2984-
if (!cpufreq_driver->setpolicy) {
2985-
static_branch_enable_cpuslocked(&cpufreq_freq_invariance);
2986-
pr_debug("supports frequency invariance");
2987-
}
2988-
29892989
pr_debug("driver %s up and running\n", driver_data->name);
29902990
goto out;
29912991

29922992
err_if_unreg:
29932993
subsys_interface_unregister(&cpufreq_interface);
29942994
err_boost_unreg:
2995+
if (!cpufreq_driver->setpolicy)
2996+
static_branch_disable_cpuslocked(&cpufreq_freq_invariance);
29952997
remove_boost_sysfs_file();
29962998
err_null_driver:
29972999
write_lock_irqsave(&cpufreq_driver_lock, flags);

0 commit comments

Comments
 (0)