Skip to content

Commit 27241c8

Browse files
vireshkrafaeljw
authored andcommitted
cpufreq: Introduce policy_set_boost()
Introduce policy_set_boost() to update boost state of a cpufreq policy. No intentional function change. Reviewed-by: Lifeng Zheng <[email protected]> Signed-off-by: Viresh Kumar <[email protected]> Link: https://patch.msgid.link/1863178ac17340c810519c8593014b8e561797ea.1745511526.git.viresh.kumar@linaro.org Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent c347f31 commit 27241c8

File tree

1 file changed

+26
-23
lines changed

1 file changed

+26
-23
lines changed

drivers/cpufreq/cpufreq.c

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -588,6 +588,22 @@ static ssize_t show_local_boost(struct cpufreq_policy *policy, char *buf)
588588
return sysfs_emit(buf, "%d\n", policy->boost_enabled);
589589
}
590590

591+
static int policy_set_boost(struct cpufreq_policy *policy, bool enable)
592+
{
593+
int ret;
594+
595+
if (policy->boost_enabled == enable)
596+
return 0;
597+
598+
policy->boost_enabled = enable;
599+
600+
ret = cpufreq_driver->set_boost(policy, enable);
601+
if (ret)
602+
policy->boost_enabled = !policy->boost_enabled;
603+
604+
return ret;
605+
}
606+
591607
static ssize_t store_local_boost(struct cpufreq_policy *policy,
592608
const char *buf, size_t count)
593609
{
@@ -603,21 +619,14 @@ static ssize_t store_local_boost(struct cpufreq_policy *policy,
603619
if (!policy->boost_supported)
604620
return -EINVAL;
605621

606-
if (policy->boost_enabled == enable)
607-
return count;
608-
609-
policy->boost_enabled = enable;
610-
611622
cpus_read_lock();
612-
ret = cpufreq_driver->set_boost(policy, enable);
623+
ret = policy_set_boost(policy, enable);
613624
cpus_read_unlock();
614625

615-
if (ret) {
616-
policy->boost_enabled = !policy->boost_enabled;
617-
return ret;
618-
}
626+
if (!ret)
627+
return count;
619628

620-
return count;
629+
return ret;
621630
}
622631

623632
static struct freq_attr local_boost = __ATTR(boost, 0644, show_local_boost, store_local_boost);
@@ -1615,15 +1624,12 @@ static int cpufreq_online(unsigned int cpu)
16151624
policy->cdev = of_cpufreq_cooling_register(policy);
16161625

16171626
/* Let the per-policy boost flag mirror the cpufreq_driver boost during init */
1618-
if (cpufreq_driver->set_boost && policy->boost_supported &&
1619-
policy->boost_enabled != cpufreq_boost_enabled()) {
1620-
policy->boost_enabled = cpufreq_boost_enabled();
1621-
ret = cpufreq_driver->set_boost(policy, policy->boost_enabled);
1627+
if (cpufreq_driver->set_boost && policy->boost_supported) {
1628+
ret = policy_set_boost(policy, cpufreq_boost_enabled());
16221629
if (ret) {
16231630
/* If the set_boost fails, the online operation is not affected */
16241631
pr_info("%s: CPU%d: Cannot %s BOOST\n", __func__, policy->cpu,
1625-
str_enable_disable(policy->boost_enabled));
1626-
policy->boost_enabled = !policy->boost_enabled;
1632+
str_enable_disable(cpufreq_boost_enabled()));
16271633
}
16281634
}
16291635

@@ -2807,15 +2813,12 @@ static int cpufreq_boost_trigger_state(int state)
28072813

28082814
cpus_read_lock();
28092815
for_each_active_policy(policy) {
2810-
if (!policy->boost_supported || policy->boost_enabled == state)
2816+
if (!policy->boost_supported)
28112817
continue;
28122818

2813-
policy->boost_enabled = state;
2814-
ret = cpufreq_driver->set_boost(policy, state);
2815-
if (ret) {
2816-
policy->boost_enabled = !policy->boost_enabled;
2819+
ret = policy_set_boost(policy, state);
2820+
if (ret)
28172821
goto err_reset_state;
2818-
}
28192822
}
28202823
cpus_read_unlock();
28212824

0 commit comments

Comments
 (0)