Skip to content

Commit 1fa9970

Browse files
committed
Merge tag 'pm-6.14-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm
Pull power management fixes from Rafael Wysocki: "These fix a handful of issues in the amd-pstate driver, the airoha cpufreq driver build, a (recently added) possible NULL pointer dereference in the cpufreq code and a possible memory leak in the power capping subsystem: - Fix cpufreq_policy reference counting and prevent max_perf from going above the current limit in amd-pstate, and drop a redundant goto label from it (Dhananjay Ugwekar) - Prevent the per-policy boost_enabled flag in amd-pstate from getting out of sync with the actual state after boot failures (Lifeng Zheng) - Fix a recently added possible NULL pointer dereference in the cpufreq core (Aboorva Devarajan) - Fix a build issue related to CONFIG_OF and COMPILE_TEST dependencies in the airoha cpufreq driver (Arnd Bergmann) - Fix a possible memory leak in the power capping subsystem (Joe Hattori)" * tag 'pm-6.14-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: cpufreq/amd-pstate: Fix cpufreq_policy ref counting cpufreq: prevent NULL dereference in cpufreq_online() cpufreq: airoha: modify CONFIG_OF dependency cpufreq/amd-pstate: Fix max_perf updation with schedutil cpufreq/amd-pstate: Remove the goto label in amd_pstate_update_limits cpufreq/amd-pstate: Fix per-policy boost flag incorrect when fail powercap: call put_device() on an error path in powercap_register_control_type()
2 parents 0aa0282 + 73195be commit 1fa9970

File tree

4 files changed

+15
-14
lines changed

4 files changed

+15
-14
lines changed

drivers/cpufreq/Kconfig.arm

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ config ARM_ALLWINNER_SUN50I_CPUFREQ_NVMEM
1717

1818
config ARM_AIROHA_SOC_CPUFREQ
1919
tristate "Airoha EN7581 SoC CPUFreq support"
20-
depends on (ARCH_AIROHA && OF) || COMPILE_TEST
20+
depends on ARCH_AIROHA || COMPILE_TEST
21+
depends on OF
2122
select PM_OPP
2223
default ARCH_AIROHA
2324
help

drivers/cpufreq/amd-pstate.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -699,7 +699,7 @@ static void amd_pstate_adjust_perf(unsigned int cpu,
699699
if (min_perf < lowest_nonlinear_perf)
700700
min_perf = lowest_nonlinear_perf;
701701

702-
max_perf = cap_perf;
702+
max_perf = cpudata->max_limit_perf;
703703
if (max_perf < min_perf)
704704
max_perf = min_perf;
705705

@@ -747,7 +747,6 @@ static int amd_pstate_set_boost(struct cpufreq_policy *policy, int state)
747747
guard(mutex)(&amd_pstate_driver_lock);
748748

749749
ret = amd_pstate_cpu_boost_update(policy, state);
750-
policy->boost_enabled = !ret ? state : false;
751750
refresh_frequency_limits(policy);
752751

753752
return ret;
@@ -822,25 +821,28 @@ static void amd_pstate_init_prefcore(struct amd_cpudata *cpudata)
822821

823822
static void amd_pstate_update_limits(unsigned int cpu)
824823
{
825-
struct cpufreq_policy *policy = cpufreq_cpu_get(cpu);
824+
struct cpufreq_policy *policy = NULL;
826825
struct amd_cpudata *cpudata;
827826
u32 prev_high = 0, cur_high = 0;
828827
int ret;
829828
bool highest_perf_changed = false;
830829

830+
if (!amd_pstate_prefcore)
831+
return;
832+
833+
policy = cpufreq_cpu_get(cpu);
831834
if (!policy)
832835
return;
833836

834837
cpudata = policy->driver_data;
835838

836-
if (!amd_pstate_prefcore)
837-
return;
838-
839839
guard(mutex)(&amd_pstate_driver_lock);
840840

841841
ret = amd_get_highest_perf(cpu, &cur_high);
842-
if (ret)
843-
goto free_cpufreq_put;
842+
if (ret) {
843+
cpufreq_cpu_put(policy);
844+
return;
845+
}
844846

845847
prev_high = READ_ONCE(cpudata->prefcore_ranking);
846848
highest_perf_changed = (prev_high != cur_high);
@@ -850,8 +852,6 @@ static void amd_pstate_update_limits(unsigned int cpu)
850852
if (cur_high < CPPC_MAX_PERF)
851853
sched_set_itmt_core_prio((int)cur_high, cpu);
852854
}
853-
854-
free_cpufreq_put:
855855
cpufreq_cpu_put(policy);
856856

857857
if (!highest_perf_changed)

drivers/cpufreq/cpufreq.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1571,7 +1571,8 @@ static int cpufreq_online(unsigned int cpu)
15711571
policy->cdev = of_cpufreq_cooling_register(policy);
15721572

15731573
/* Let the per-policy boost flag mirror the cpufreq_driver boost during init */
1574-
if (policy->boost_enabled != cpufreq_boost_enabled()) {
1574+
if (cpufreq_driver->set_boost &&
1575+
policy->boost_enabled != cpufreq_boost_enabled()) {
15751576
policy->boost_enabled = cpufreq_boost_enabled();
15761577
ret = cpufreq_driver->set_boost(policy, policy->boost_enabled);
15771578
if (ret) {

drivers/powercap/powercap_sys.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -627,8 +627,7 @@ struct powercap_control_type *powercap_register_control_type(
627627
dev_set_name(&control_type->dev, "%s", name);
628628
result = device_register(&control_type->dev);
629629
if (result) {
630-
if (control_type->allocated)
631-
kfree(control_type);
630+
put_device(&control_type->dev);
632631
return ERR_PTR(result);
633632
}
634633
idr_init(&control_type->idr);

0 commit comments

Comments
 (0)