Commit d00f85b2 authored by Rafael J. Wysocki's avatar Rafael J. Wysocki Committed by Jiri Slaby

cpufreq: Clean up after a failing light-weight initialization

commit 72368d12 upstream.

If cpufreq_policy_restore() returns NULL during system resume,
__cpufreq_add_dev() should just fall back to the full initialization
instead of returning an error, because that may actually make things
work.  Moreover, it should not leave stale fallback data behind after
it has failed to restore a previously existing policy.

This change is based on Viresh Kumar's work.

Fixes: 5302c3fb ("cpufreq: Perform light-weight init/teardown during suspend/resume")
Reported-by: default avatarBjørn Mork <bjorn@mork.no>
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: default avatarViresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
parent 83b8aa4c
...@@ -1044,15 +1044,17 @@ static int __cpufreq_add_dev(struct device *dev, struct subsys_interface *sif, ...@@ -1044,15 +1044,17 @@ static int __cpufreq_add_dev(struct device *dev, struct subsys_interface *sif,
read_unlock_irqrestore(&cpufreq_driver_lock, flags); read_unlock_irqrestore(&cpufreq_driver_lock, flags);
#endif #endif
if (frozen) /*
/* Restore the saved policy when doing light-weight init */ * Restore the saved policy when doing light-weight init and fall back
policy = cpufreq_policy_restore(cpu); * to the full init if that fails.
else */
policy = frozen ? cpufreq_policy_restore(cpu) : NULL;
if (!policy) {
frozen = false;
policy = cpufreq_policy_alloc(); policy = cpufreq_policy_alloc();
if (!policy)
if (!policy) goto nomem_out;
goto nomem_out; }
/* /*
* In the resume path, since we restore a saved policy, the assignment * In the resume path, since we restore a saved policy, the assignment
...@@ -1135,8 +1137,11 @@ static int __cpufreq_add_dev(struct device *dev, struct subsys_interface *sif, ...@@ -1135,8 +1137,11 @@ static int __cpufreq_add_dev(struct device *dev, struct subsys_interface *sif,
write_unlock_irqrestore(&cpufreq_driver_lock, flags); write_unlock_irqrestore(&cpufreq_driver_lock, flags);
err_set_policy_cpu: err_set_policy_cpu:
if (frozen) if (frozen) {
/* Do not leave stale fallback data behind. */
per_cpu(cpufreq_cpu_data_fallback, cpu) = NULL;
cpufreq_policy_put_kobj(policy); cpufreq_policy_put_kobj(policy);
}
cpufreq_policy_free(policy); cpufreq_policy_free(policy);
nomem_out: nomem_out:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment