Message ID | 1449274118-15575-2-git-send-email-srinivas.pandruvada@linux.intel.com (mailing list archive) |
---|---|
State | Superseded, archived |
Headers | show |
On 04-12-15, 16:08, Srinivas Pandruvada wrote: > diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h > index 177c768..8259c3c 100644 > --- a/include/linux/cpufreq.h > +++ b/include/linux/cpufreq.h > @@ -76,6 +76,7 @@ struct cpufreq_policy { > unsigned int restore_freq; /* = policy->cur before transition */ > unsigned int suspend_freq; /* freq to set during suspend */ > > + u8 available_policies; Why don't we let the set-policy drivers fill in this field? No callback required then.
On Mon, 2015-12-07 at 15:03 +0530, Viresh Kumar wrote: > On 04-12-15, 16:08, Srinivas Pandruvada wrote: > > diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h > > index 177c768..8259c3c 100644 > > --- a/include/linux/cpufreq.h > > +++ b/include/linux/cpufreq.h > > @@ -76,6 +76,7 @@ struct cpufreq_policy { > > unsigned int restore_freq; /* = policy->cur > > before transition */ > > unsigned int suspend_freq; /* freq to set > > during suspend */ > > > > + u8 available_policies; > Why don't we let the set-policy drivers fill in this field? No > callback required then. > That is fine with me. In next revision I will add that. Thanks, Srinivas -- To unsubscribe from this list: send the line "unsubscribe linux-pm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 8412ce5..6fc6e39d 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -688,7 +688,10 @@ static ssize_t show_scaling_available_governors(struct cpufreq_policy *policy, struct cpufreq_governor *t; if (!has_target()) { - i += sprintf(buf, "performance powersave"); + if (policy->available_policies & CPUFREQ_POLICY_PERFORMANCE) + i += sprintf(buf, "performance "); + if (policy->available_policies & CPUFREQ_POLICY_POWERSAVE) + i += sprintf(&buf[i], "powersave "); goto out; } @@ -963,9 +966,18 @@ static int cpufreq_init_policy(struct cpufreq_policy *policy) { struct cpufreq_governor *gov = NULL; struct cpufreq_policy new_policy; + u8 mask; memcpy(&new_policy, policy, sizeof(*policy)); + if (cpufreq_driver->get_available_policies) { + if (!cpufreq_driver->get_available_policies(&mask)) + policy->available_policies = mask; + } + if (!policy->available_policies) + policy->available_policies = CPUFREQ_POLICY_PERFORMANCE | + CPUFREQ_POLICY_POWERSAVE; + /* Update governor of new_policy to the governor used before hotplug */ gov = find_governor(policy->last_governor); if (gov) diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h index 177c768..8259c3c 100644 --- a/include/linux/cpufreq.h +++ b/include/linux/cpufreq.h @@ -76,6 +76,7 @@ struct cpufreq_policy { unsigned int restore_freq; /* = policy->cur before transition */ unsigned int suspend_freq; /* freq to set during suspend */ + u8 available_policies; unsigned int policy; /* see above */ unsigned int last_policy; /* policy before unplug */ struct cpufreq_governor *governor; /* see below */ @@ -229,6 +230,8 @@ struct cpufreq_driver { int (*init)(struct cpufreq_policy *policy); int (*verify)(struct cpufreq_policy *policy); + /* Get available generic policies */ + int (*get_available_policies)(u8 *mask); /* define one out of two */ int (*setpolicy)(struct cpufreq_policy *policy);
For drivers using cpufreq_driver->setpolicy callback, by default two policies are available (performance and powersave). The client drivers can't change them, even if there is no support for a policy. This change adds a new callback get_available_policies() which provides, a mask of supported policies. If there is no callback then only two polices are supported "performance powersave" matching current implementation. Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> --- drivers/cpufreq/cpufreq.c | 14 +++++++++++++- include/linux/cpufreq.h | 3 +++ 2 files changed, 16 insertions(+), 1 deletion(-)