Skip to content

Commit

Permalink
cpufreq: Call cpufreq_disable_fast_switch() in sugov_exit()
Browse files Browse the repository at this point in the history
Due to differences in the cpufreq core's handling of runtime CPU
offline and nonboot CPUs disabling during system suspend-to-RAM,
fast frequency switching gets disabled after a suspend-to-RAM and
resume cycle on all of the nonboot CPUs.

To prevent that from happening, move the invocation of
cpufreq_disable_fast_switch() from cpufreq_exit_governor() to
sugov_exit(), as the schedutil governor is the only user of fast
frequency switching today anyway.

That simply prevents cpufreq_disable_fast_switch() from being called
without invoking the ->governor callback for the CPUFREQ_GOV_POLICY_EXIT
event (which happens during system suspend now).

Fixes: b7898fd (cpufreq: Support for fast frequency switching)
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
  • Loading branch information
rafaeljw committed Apr 8, 2016
1 parent 9bdcb44 commit 6c9d9c8
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
19 changes: 11 additions & 8 deletions drivers/cpufreq/cpufreq.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,11 @@ static inline bool has_target(void)
static int cpufreq_governor(struct cpufreq_policy *policy, unsigned int event);
static unsigned int __cpufreq_get(struct cpufreq_policy *policy);
static int cpufreq_start_governor(struct cpufreq_policy *policy);
static int cpufreq_exit_governor(struct cpufreq_policy *policy);

static inline int cpufreq_exit_governor(struct cpufreq_policy *policy)
{
return cpufreq_governor(policy, CPUFREQ_GOV_POLICY_EXIT);
}

/**
* Two notifier lists: the "policy" list is involved in the
Expand Down Expand Up @@ -482,7 +486,11 @@ void cpufreq_enable_fast_switch(struct cpufreq_policy *policy)
}
EXPORT_SYMBOL_GPL(cpufreq_enable_fast_switch);

static void cpufreq_disable_fast_switch(struct cpufreq_policy *policy)
/**
* cpufreq_disable_fast_switch - Disable fast frequency switching for policy.
* @policy: cpufreq policy to disable fast frequency switching for.
*/
void cpufreq_disable_fast_switch(struct cpufreq_policy *policy)
{
mutex_lock(&cpufreq_fast_switch_lock);
if (policy->fast_switch_enabled) {
Expand All @@ -492,6 +500,7 @@ static void cpufreq_disable_fast_switch(struct cpufreq_policy *policy)
}
mutex_unlock(&cpufreq_fast_switch_lock);
}
EXPORT_SYMBOL_GPL(cpufreq_disable_fast_switch);

/*********************************************************************
* SYSFS INTERFACE *
Expand Down Expand Up @@ -2060,12 +2069,6 @@ static int cpufreq_start_governor(struct cpufreq_policy *policy)
return ret ? ret : cpufreq_governor(policy, CPUFREQ_GOV_LIMITS);
}

static int cpufreq_exit_governor(struct cpufreq_policy *policy)
{
cpufreq_disable_fast_switch(policy);
return cpufreq_governor(policy, CPUFREQ_GOV_POLICY_EXIT);
}

int cpufreq_register_governor(struct cpufreq_governor *governor)
{
int err;
Expand Down
1 change: 1 addition & 0 deletions include/linux/cpufreq.h
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ int cpufreq_update_policy(unsigned int cpu);
bool have_governor_per_policy(void);
struct kobject *get_governor_parent_kobj(struct cpufreq_policy *policy);
void cpufreq_enable_fast_switch(struct cpufreq_policy *policy);
void cpufreq_disable_fast_switch(struct cpufreq_policy *policy);
#else
static inline unsigned int cpufreq_get(unsigned int cpu)
{
Expand Down
2 changes: 2 additions & 0 deletions kernel/sched/cpufreq_schedutil.c
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,8 @@ static int sugov_exit(struct cpufreq_policy *policy)
struct sugov_tunables *tunables = sg_policy->tunables;
unsigned int count;

cpufreq_disable_fast_switch(policy);

mutex_lock(&global_tunables_lock);

count = gov_attr_set_put(&tunables->attr_set, &sg_policy->tunables_hook);
Expand Down

0 comments on commit 6c9d9c8

Please sign in to comment.