cpufreq: interactive: Fix refcount for migration notification
Current implementation of cpufreq_interactive_enable_sched_input()
returns early if use_sched_input is already enabled. This breaks
refcounting for migration notification registration. It could also
result in failure of registering migration notification after
hotplugging the entire cluster and/or suspend/resume.
Change-Id: I079b2c70b182f696cd8a883f5c8e3a37b5c6d21d
Signed-off-by: Junjie Wu <junjiew@codeaurora.org>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
diff --git a/drivers/cpufreq/cpufreq_interactive.c b/drivers/cpufreq/cpufreq_interactive.c
index bcb60ac..bec8059 100644
--- a/drivers/cpufreq/cpufreq_interactive.c
+++ b/drivers/cpufreq/cpufreq_interactive.c
@@ -1167,7 +1167,7 @@
mutex_lock(&sched_lock);
set_window_count++;
- if (set_window_count != 1) {
+ if (set_window_count > 1) {
for_each_possible_cpu(j) {
t = per_cpu(cpuinfo, j).cached_tunables;
if (t && t->use_sched_load) {
@@ -1176,22 +1176,21 @@
break;
}
}
- goto out;
+ } else {
+ rc = set_window_helper(tunables);
+ if (rc) {
+ pr_err("%s: Failed to set sched window\n", __func__);
+ set_window_count--;
+ goto out;
+ }
+ sched_set_io_is_busy(tunables->io_is_busy);
}
- rc = set_window_helper(tunables);
- if (rc) {
- pr_err("%s: Failed to set sched window\n", __func__);
- set_window_count--;
- goto out;
- }
- sched_set_io_is_busy(tunables->io_is_busy);
-
if (!tunables->use_migration_notif)
goto out;
migration_register_count++;
- if (migration_register_count != 1)
+ if (migration_register_count > 1)
goto out;
else
atomic_notifier_chain_register(&load_alert_notifier_head,
@@ -1208,7 +1207,7 @@
if (tunables->use_migration_notif) {
migration_register_count--;
- if (!migration_register_count)
+ if (migration_register_count < 1)
atomic_notifier_chain_unregister(
&load_alert_notifier_head,
&load_notifier_block);