Skip to content

Commit 3b71805

Browse files
committed
cpufreq: Make cpufreq_online() call driver->offline() on errors
In the CPU removal path the ->offline() callback provided by the driver is always invoked before ->exit(), but in the cpufreq_online() error path it is not, so ->exit() is expected to somehow know the context in which it has been called and act accordingly. That is less than straightforward, so make cpufreq_online() invoke the driver's ->offline() callback, if present, on errors before ->exit() too. This only potentially affects intel_pstate. Fixes: 91a12e9 ("cpufreq: Allow light-weight tear down and bring up of CPUs") Signed-off-by: Rafael J. Wysocki <[email protected]> Acked-by: Viresh Kumar <[email protected]>
1 parent 6cbab78 commit 3b71805

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

drivers/cpufreq/cpufreq.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1367,9 +1367,14 @@ static int cpufreq_online(unsigned int cpu)
13671367
goto out_free_policy;
13681368
}
13691369

1370+
/*
1371+
* The initialization has succeeded and the policy is online.
1372+
* If there is a problem with its frequency table, take it
1373+
* offline and drop it.
1374+
*/
13701375
ret = cpufreq_table_validate_and_sort(policy);
13711376
if (ret)
1372-
goto out_exit_policy;
1377+
goto out_offline_policy;
13731378

13741379
/* related_cpus should at least include policy->cpus. */
13751380
cpumask_copy(policy->related_cpus, policy->cpus);
@@ -1515,6 +1520,10 @@ static int cpufreq_online(unsigned int cpu)
15151520

15161521
up_write(&policy->rwsem);
15171522

1523+
out_offline_policy:
1524+
if (cpufreq_driver->offline)
1525+
cpufreq_driver->offline(policy);
1526+
15181527
out_exit_policy:
15191528
if (cpufreq_driver->exit)
15201529
cpufreq_driver->exit(policy);

0 commit comments

Comments
 (0)