Skip to content

Commit

Permalink
cpufreq: interactive: take idle notifications only when active
Browse files Browse the repository at this point in the history
Register an idle notifier only when the governor is active.  Also
short-circuit work of idle end if the governor is not enabled.

Signed-off-by: Sam Leffler <sleffler@chromium.org>
Change-Id: I4cae36dd2e7389540d337d74745ffbaa0131870f
  • Loading branch information
Sam Leffler authored and pershoot committed Aug 2, 2012
1 parent f5f823b commit b9ca9ac
Showing 1 changed file with 25 additions and 21 deletions.
46 changes: 25 additions & 21 deletions drivers/cpufreq/cpufreq_interactive.c
Expand Up @@ -349,6 +349,9 @@ static void cpufreq_interactive_idle_end(void)
struct cpufreq_interactive_cpuinfo *pcpu =
&per_cpu(cpuinfo, smp_processor_id());

if (!pcpu->governor_enabled)
return;

pcpu->idling = 0;
smp_wmb();

Expand Down Expand Up @@ -790,6 +793,26 @@ static struct attribute_group interactive_attr_group = {
.name = "interactive",
};

static int cpufreq_interactive_idle_notifier(struct notifier_block *nb,
unsigned long val,
void *data)
{
switch (val) {
case IDLE_START:
cpufreq_interactive_idle_start();
break;
case IDLE_END:
cpufreq_interactive_idle_end();
break;
}

return 0;
}

static struct notifier_block cpufreq_interactive_idle_nb = {
.notifier_call = cpufreq_interactive_idle_notifier,
};

static int cpufreq_governor_interactive(struct cpufreq_policy *policy,
unsigned int event)
{
Expand Down Expand Up @@ -843,6 +866,7 @@ static int cpufreq_governor_interactive(struct cpufreq_policy *policy,
pr_warn("%s: failed to register input handler\n",
__func__);

idle_notifier_register(&cpufreq_interactive_idle_nb);
break;

case CPUFREQ_GOV_STOP:
Expand All @@ -865,6 +889,7 @@ static int cpufreq_governor_interactive(struct cpufreq_policy *policy,
if (atomic_dec_return(&active_count) > 0)
return 0;

idle_notifier_unregister(&cpufreq_interactive_idle_nb);
input_unregister_handler(&cpufreq_interactive_input_handler);
sysfs_remove_group(cpufreq_global_kobject,
&interactive_attr_group);
Expand All @@ -883,26 +908,6 @@ static int cpufreq_governor_interactive(struct cpufreq_policy *policy,
return 0;
}

static int cpufreq_interactive_idle_notifier(struct notifier_block *nb,
unsigned long val,
void *data)
{
switch (val) {
case IDLE_START:
cpufreq_interactive_idle_start();
break;
case IDLE_END:
cpufreq_interactive_idle_end();
break;
}

return 0;
}

static struct notifier_block cpufreq_interactive_idle_nb = {
.notifier_call = cpufreq_interactive_idle_notifier,
};

static int __init cpufreq_interactive_init(void)
{
unsigned int i;
Expand Down Expand Up @@ -944,7 +949,6 @@ static int __init cpufreq_interactive_init(void)
spin_lock_init(&down_cpumask_lock);
mutex_init(&set_speed_lock);

idle_notifier_register(&cpufreq_interactive_idle_nb);
INIT_WORK(&inputopen.inputopen_work, cpufreq_interactive_input_open);
return cpufreq_register_governor(&cpufreq_gov_interactive);

Expand Down

0 comments on commit b9ca9ac

Please sign in to comment.