The Intel's HW based boost solution needs to cooperate with common cpufreq
boost.

For this reason the sysfs handling code (/sys/devices/system/cpu/cpufreq/boost)
has been moved to a core cpufreq.c code.

The _store_boost() function has been redesigned to be used as low_level_boost
callback.

Signed-off-by: Lukasz Majewski <l.majew...@samsung.com>
Signed-off-by: Myungjoo Ham <myungjoo....@samsung.com>
---
 drivers/cpufreq/acpi-cpufreq.c |   64 ++++++++++++++++------------------------
 1 file changed, 26 insertions(+), 38 deletions(-)

diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c
index 11b8b4b..2c95540 100644
--- a/drivers/cpufreq/acpi-cpufreq.c
+++ b/drivers/cpufreq/acpi-cpufreq.c
@@ -133,20 +133,10 @@ static void boost_set_msrs(bool enable, const struct 
cpumask *cpumask)
        wrmsr_on_cpus(cpumask, msr_addr, msrs);
 }
 
-static ssize_t _store_boost(const char *buf, size_t count)
+static int _store_boost(struct cpufreq_policy *policy, 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;
+               return 0;
 
        get_online_cpus();
 
@@ -157,30 +147,31 @@ static ssize_t _store_boost(const char *buf, size_t count)
        boost_enabled = val;
        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)
+static ssize_t store_boost(const char *buf, size_t count)
 {
-       return _store_boost(buf, count);
-}
+       int ret;
+       unsigned long val = 0;
 
-static ssize_t show_global_boost(struct kobject *kobj,
-                                struct attribute *attr, char *buf)
-{
-       return sprintf(buf, "%u\n", boost_enabled);
-}
+       if (!boost_supported)
+               return -EINVAL;
 
-static struct global_attr global_boost = __ATTR(boost, 0644,
-                                               show_global_boost,
-                                               store_global_boost);
+       ret = kstrtoul(buf, 10, &val);
+       if (ret || (val > 1))
+               return -EINVAL;
+
+       _store_boost(NULL, (int) val);
+
+       return count;
+}
 
 #ifdef CONFIG_X86_ACPI_CPUFREQ_CPB
 static ssize_t store_cpb(struct cpufreq_policy *policy, const char *buf,
                         size_t count)
 {
-       return _store_boost(buf, count);
+       return store_boost(buf, count);
 }
 
 static ssize_t show_cpb(struct cpufreq_policy *policy, char *buf)
@@ -910,6 +901,11 @@ static struct freq_attr *acpi_cpufreq_attr[] = {
        NULL,
 };
 
+static struct cpufreq_boost acpi_boost = {
+       .low_level_boost        = _store_boost,
+       .policies               = LIST_HEAD_INIT(acpi_boost.policies),
+};
+
 static struct cpufreq_driver acpi_cpufreq_driver = {
        .verify         = acpi_cpufreq_verify,
        .target         = acpi_cpufreq_target,
@@ -920,6 +916,9 @@ static struct cpufreq_driver acpi_cpufreq_driver = {
        .name           = "acpi-cpufreq",
        .owner          = THIS_MODULE,
        .attr           = acpi_cpufreq_attr,
+#ifdef CONFIG_CPU_FREQ_BOOST
+       .boost          = &acpi_boost,
+#endif
 };
 
 static void __init acpi_cpufreq_boost_init(void)
@@ -941,22 +940,11 @@ static void __init acpi_cpufreq_boost_init(void)
                register_cpu_notifier(&boost_nb);
 
                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 (sysfs_create_file(cpufreq_global_kobject, &(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)
 {
-       sysfs_remove_file(cpufreq_global_kobject, &(global_boost.attr));
-
        if (msrs) {
                unregister_cpu_notifier(&boost_nb);
 
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to