Commit cfc9c8ed authored by Lukasz Majewski's avatar Lukasz Majewski Committed by Rafael J. Wysocki

acpi-cpufreq: Adjust the code to use the common boost attribute

Modify acpi-cpufreq's hardware-based boost solution to work with the
common cpufreq boost framework.
Signed-off-by: default avatarLukasz Majewski <l.majewski@samsung.com>
Signed-off-by: default avatarMyungjoo Ham <myungjoo.ham@samsung.com>
Acked-by: default avatarViresh Kumar <viresh.kumar@linaro.org>
[rjw: Subject and changelog]
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent 6f19efc0
...@@ -80,7 +80,6 @@ static struct acpi_processor_performance __percpu *acpi_perf_data; ...@@ -80,7 +80,6 @@ static struct acpi_processor_performance __percpu *acpi_perf_data;
static struct cpufreq_driver acpi_cpufreq_driver; static struct cpufreq_driver acpi_cpufreq_driver;
static unsigned int acpi_pstate_strict; static unsigned int acpi_pstate_strict;
static bool boost_enabled, boost_supported;
static struct msr __percpu *msrs; static struct msr __percpu *msrs;
static bool boost_state(unsigned int cpu) static bool boost_state(unsigned int cpu)
...@@ -133,49 +132,16 @@ static void boost_set_msrs(bool enable, const struct cpumask *cpumask) ...@@ -133,49 +132,16 @@ static void boost_set_msrs(bool enable, const struct cpumask *cpumask)
wrmsr_on_cpus(cpumask, msr_addr, msrs); wrmsr_on_cpus(cpumask, msr_addr, msrs);
} }
static ssize_t _store_boost(const char *buf, size_t count) static int _store_boost(int val)
{ {
int ret;
unsigned long val = 0;
if (!boost_supported)
return -EINVAL;
ret = kstrtoul(buf, 10, &val);
if (ret || (val > 1))
return -EINVAL;
if ((val && boost_enabled) || (!val && !boost_enabled))
return count;
get_online_cpus(); get_online_cpus();
boost_set_msrs(val, cpu_online_mask); boost_set_msrs(val, cpu_online_mask);
put_online_cpus(); put_online_cpus();
boost_enabled = val;
pr_debug("Core Boosting %sabled.\n", val ? "en" : "dis"); pr_debug("Core Boosting %sabled.\n", val ? "en" : "dis");
return count; return 0;
}
static ssize_t store_global_boost(struct kobject *kobj, struct attribute *attr,
const char *buf, size_t count)
{
return _store_boost(buf, count);
}
static ssize_t show_global_boost(struct kobject *kobj,
struct attribute *attr, char *buf)
{
return sprintf(buf, "%u\n", boost_enabled);
} }
static struct global_attr global_boost = __ATTR(boost, 0644,
show_global_boost,
store_global_boost);
static ssize_t show_freqdomain_cpus(struct cpufreq_policy *policy, char *buf) static ssize_t show_freqdomain_cpus(struct cpufreq_policy *policy, char *buf)
{ {
struct acpi_cpufreq_data *data = per_cpu(acfreq_data, policy->cpu); struct acpi_cpufreq_data *data = per_cpu(acfreq_data, policy->cpu);
...@@ -186,15 +152,32 @@ static ssize_t show_freqdomain_cpus(struct cpufreq_policy *policy, char *buf) ...@@ -186,15 +152,32 @@ static ssize_t show_freqdomain_cpus(struct cpufreq_policy *policy, char *buf)
cpufreq_freq_attr_ro(freqdomain_cpus); cpufreq_freq_attr_ro(freqdomain_cpus);
#ifdef CONFIG_X86_ACPI_CPUFREQ_CPB #ifdef CONFIG_X86_ACPI_CPUFREQ_CPB
static ssize_t store_boost(const char *buf, size_t count)
{
int ret;
unsigned long val = 0;
if (!acpi_cpufreq_driver.boost_supported)
return -EINVAL;
ret = kstrtoul(buf, 10, &val);
if (ret || (val > 1))
return -EINVAL;
_store_boost((int) val);
return count;
}
static ssize_t store_cpb(struct cpufreq_policy *policy, const char *buf, static ssize_t store_cpb(struct cpufreq_policy *policy, const char *buf,
size_t count) size_t count)
{ {
return _store_boost(buf, count); return store_boost(buf, count);
} }
static ssize_t show_cpb(struct cpufreq_policy *policy, char *buf) static ssize_t show_cpb(struct cpufreq_policy *policy, char *buf)
{ {
return sprintf(buf, "%u\n", boost_enabled); return sprintf(buf, "%u\n", acpi_cpufreq_driver.boost_enabled);
} }
cpufreq_freq_attr_rw(cpb); cpufreq_freq_attr_rw(cpb);
...@@ -554,7 +537,7 @@ static int boost_notify(struct notifier_block *nb, unsigned long action, ...@@ -554,7 +537,7 @@ static int boost_notify(struct notifier_block *nb, unsigned long action,
switch (action) { switch (action) {
case CPU_UP_PREPARE: case CPU_UP_PREPARE:
case CPU_UP_PREPARE_FROZEN: case CPU_UP_PREPARE_FROZEN:
boost_set_msrs(boost_enabled, cpumask); boost_set_msrs(acpi_cpufreq_driver.boost_enabled, cpumask);
break; break;
case CPU_DOWN_PREPARE: case CPU_DOWN_PREPARE:
...@@ -911,6 +894,7 @@ static struct cpufreq_driver acpi_cpufreq_driver = { ...@@ -911,6 +894,7 @@ static struct cpufreq_driver acpi_cpufreq_driver = {
.resume = acpi_cpufreq_resume, .resume = acpi_cpufreq_resume,
.name = "acpi-cpufreq", .name = "acpi-cpufreq",
.attr = acpi_cpufreq_attr, .attr = acpi_cpufreq_attr,
.set_boost = _store_boost,
}; };
static void __init acpi_cpufreq_boost_init(void) static void __init acpi_cpufreq_boost_init(void)
...@@ -921,33 +905,22 @@ static void __init acpi_cpufreq_boost_init(void) ...@@ -921,33 +905,22 @@ static void __init acpi_cpufreq_boost_init(void)
if (!msrs) if (!msrs)
return; return;
boost_supported = true; acpi_cpufreq_driver.boost_supported = true;
boost_enabled = boost_state(0); acpi_cpufreq_driver.boost_enabled = boost_state(0);
get_online_cpus(); get_online_cpus();
/* Force all MSRs to the same value */ /* Force all MSRs to the same value */
boost_set_msrs(boost_enabled, cpu_online_mask); boost_set_msrs(acpi_cpufreq_driver.boost_enabled,
cpu_online_mask);
register_cpu_notifier(&boost_nb); register_cpu_notifier(&boost_nb);
put_online_cpus(); put_online_cpus();
} else }
global_boost.attr.mode = 0444;
/* We create the boost file in any case, though for systems without
* hardware support it will be read-only and hardwired to return 0.
*/
if (cpufreq_sysfs_create_file(&(global_boost.attr)))
pr_warn(PFX "could not register global boost sysfs file\n");
else
pr_debug("registered global boost sysfs file\n");
} }
static void __exit acpi_cpufreq_boost_exit(void) static void __exit acpi_cpufreq_boost_exit(void)
{ {
cpufreq_sysfs_remove_file(&(global_boost.attr));
if (msrs) { if (msrs) {
unregister_cpu_notifier(&boost_nb); unregister_cpu_notifier(&boost_nb);
...@@ -993,12 +966,11 @@ static int __init acpi_cpufreq_init(void) ...@@ -993,12 +966,11 @@ static int __init acpi_cpufreq_init(void)
*iter = &cpb; *iter = &cpb;
} }
#endif #endif
acpi_cpufreq_boost_init();
ret = cpufreq_register_driver(&acpi_cpufreq_driver); ret = cpufreq_register_driver(&acpi_cpufreq_driver);
if (ret) if (ret)
free_acpi_perf_data(); free_acpi_perf_data();
else
acpi_cpufreq_boost_init();
return ret; return ret;
} }
......
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