cpufreq: Boost cleanup
cover cpufreq: Boost cleanup
Hi,
This series cleans up a few things related to the boost sysfs attribute used by cpufreq.
[1/3] - Make local function static.
[2/3] - Simplify boost-related code in acpi-cpufreq. [3/3] - Simplify boost-related core code.
Thanks,
Rafael
PATCH 1/3 cpufreq: Make cpufreq_boost_supported() static
From: Rafael J. Wysocki <[email protected]>
cpufreq_boost_supported() is not used outside of cpufreq.c, so make it static.
While at it, refactor it as a one-liner (which it really is).
--- drivers/cpufreq/cpufreq.c | 8 ++------ include/linux/cpufreq.h | 5 ----- 2 files changed, 2 insertions(+), 11 deletions(-)
drivers/cpufreq/cpufreq.c +2 -6
@@ -2330,14 +2330,10 @@ int cpufreq_boost_trigger_state(int statreturn ret; } -int cpufreq_boost_supported (void ) +static bool cpufreq_boost_supported (void ) { -if (likely (cpufreq_driver)) -return cpufreq_driver->boost_supported; - -return 0 ; +return likely (cpufreq_driver) && cpufreq_driver->boost_supported; } -EXPORT_SYMBOL_GPL (cpufreq_boost_supported);static int create_boost_sysfs_file (void ) {
include/linux/cpufreq.h +0 -5
@@ -574,7 +574,6 @@ ssize_t cpufreq_show_cpus(const struct c#ifdef CONFIG_CPU_FREQ int cpufreq_boost_trigger_state (int state); -int cpufreq_boost_supported (void );int cpufreq_boost_enabled (void );int cpufreq_enable_boost_support (void );bool policy_has_boost_freq (struct cpufreq_policy *policy);
@@ -583,10 +582,6 @@ static inline int cpufreq_boost_trigger_ {return 0 ; } -static inline int cpufreq_boost_supported (void ) -{ -return 0 ; -}static inline int cpufreq_boost_enabled (void ) {return 0 ;
Re: [PATCH 1/3] cpufreq: Make cpufreq_boost_supported() static
Quoted 5 lines · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
cpufreq_boost_supported()is not used outside ofcpufreq.c, so make it static.
Quoted 7 lines
While at it, refactor it as a one-liner (which it really is).
Signed-off-by Rafael J. Wysocki <[email protected]>--- drivers/cpufreq/cpufreq.c | 8 ++------ include/linux/cpufreq.h | 5 ----- 2 files changed, 2 insertions(+), 11 deletions(-)
Signature · 1 line
viresh
PATCH 2/3 cpufreq: acpi-cpufreq: Simplify boost-related code
In reply to Rafael J. WysockiFrom: Rafael J. Wysocki <[email protected]>
The store_boost() routine is only used by store_cpb(), so move the code from it directly to that function and rename _store_boost() to set_boost() to make its name reflect the name of the driver callback pointing to it.
--- drivers/cpufreq/acpi-cpufreq.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-)
drivers/cpufreq/acpi-cpufreq.c +8 -13
@@ -135,7 +135,7 @@ static void boost_set_msrs(bool enable,wrmsr_on_cpus (cpumask, msr_addr, msrs); } -static int _store_boost (int val) +static int set_boost (int val) {get_online_cpus ();boost_set_msrs (val, cpu_online_mask);
@@ -158,29 +158,24 @@ static ssize_t show_freqdomain_cpus(strucpufreq_freq_attr_ro (freqdomain_cpus);#ifdef CONFIG_X86_ACPI_CPUFREQ_CPB -static ssize_t store_boost (const char *buf,size_t count) +static ssize_t store_cpb (struct cpufreq_policy *policy,const char *buf, +size_t count) {int ret; -unsigned long val =0 ; +unsigned int val =0 ;if (!acpi_cpufreq_driver.boost_supported)return -EINVAL ; - ret =kstrtoul (buf,10 , &val); -if (ret || (val >1 )) + ret =kstrtouint (buf,10 , &val); +if (ret || val >1 )return -EINVAL ; -_store_boost ((int ) val); +set_boost (val);return count; } -static ssize_t store_cpb (struct cpufreq_policy *policy,const char *buf, -size_t count) -{ -return store_boost (buf, count); -} -static ssize_t show_cpb (struct cpufreq_policy *policy,char *buf) {return sprintf (buf,"%u\n" , acpi_cpufreq_driver.boost_enabled);
@@ -905,7 +900,7 @@ static struct cpufreq_driver acpi_cpufre .resume = acpi_cpufreq_resume, .name = "acpi-cpufreq", .attr = acpi_cpufreq_attr, - .set_boost = _store_boost, + .set_boost = set_boost, };static void __init acpi_cpufreq_boost_init (void )
Re: [PATCH 2/3] cpufreq: acpi-cpufreq: Simplify boost-related code
Quoted 11 lines · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
The
store_boost()routine is only used bystore_cpb(), so move the code from it directly to that function and rename_store_boost()toset_boost()to make its name reflect the name of the driver callback pointing to it.Signed-off-by Rafael J. Wysocki <[email protected]>--- drivers/cpufreq/acpi-cpufreq.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-)
Signature · 1 line
viresh
PATCH 3/3 cpufreq: Simplify core code related to boost support
In reply to Rafael J. WysockiFrom: Rafael J. Wysocki <[email protected]>
Notice that the boost_supported field in struct cpufreq_driver is redundant, because the driver's ->set_boost callback may be left unset if "boost" is not supported. Moreover, the only driver populating the ->set_boost callback is acpi_cpufreq, so make it avoid populating that callback if "boost" is not supported, rework the core to check ->set_boost instead of boost_supported to verify "boost" support and drop boost_supported which isn't used any more.
--- drivers/cpufreq/acpi-cpufreq.c | 5 ++--- drivers/cpufreq/cpufreq.c | 22 +++++++--------------- include/linux/cpufreq.h | 1 - 3 files changed, 9 insertions(+), 19 deletions(-)
drivers/cpufreq/acpi-cpufreq.c +2 -3
@@ -164,7 +164,7 @@ static ssize_t store_cpb(struct cpufreq_int ret;unsigned int val =0 ; -if (!acpi_cpufreq_driver.boost_supported) +if (!acpi_cpufreq_driver.set_boost)return -EINVAL ; ret =kstrtouint (buf,10 , &val);
@@ -900,7 +900,6 @@ static struct cpufreq_driver acpi_cpufre .resume = acpi_cpufreq_resume, .name = "acpi-cpufreq", .attr = acpi_cpufreq_attr, - .set_boost = set_boost, };static void __init acpi_cpufreq_boost_init (void )
@@ -911,7 +910,7 @@ static void __init acpi_cpufreq_boost_inif (!msrs)return ; - acpi_cpufreq_driver.boost_supported = true; + acpi_cpufreq_driver.set_boost = set_boost; acpi_cpufreq_driver.boost_enabled =boost_state (0 );cpu_notifier_register_begin ();
drivers/cpufreq/cpufreq.c +7 -15
@@ -2332,23 +2332,13 @@ int cpufreq_boost_trigger_state(int statstatic bool cpufreq_boost_supported (void ) { -return likely (cpufreq_driver) && cpufreq_driver->boost_supported; +return likely (cpufreq_driver) && cpufreq_driver->set_boost; }static int create_boost_sysfs_file (void ) {int ret; -if (!cpufreq_boost_supported ()) -return 0 ; - -/* -* Check if driver provides function to enable boost - -* if not, use cpufreq_boost_set_sw as default -*/ -if (!cpufreq_driver->set_boost) - cpufreq_driver->set_boost = cpufreq_boost_set_sw; - ret =sysfs_create_file (cpufreq_global_kobject, &boost.attr);if (ret) pr_err("%s: cannot register global BOOST sysfs file\n",
@@ -2371,7 +2361,7 @@ int cpufreq_enable_boost_support(void)if (cpufreq_boost_supported ())return 0 ; - cpufreq_driver->boost_supported = true; + cpufreq_driver->set_boost = cpufreq_boost_set_sw;/* This will get removed on driver unregister */ return create_boost_sysfs_file ();
@@ -2431,9 +2421,11 @@ int cpufreq_register_driver(struct cpufrif (driver_data->setpolicy) driver_data->flags |=CPUFREQ_CONST_LOOPS ; - ret =create_boost_sysfs_file (); -if (ret) - goto err_null_driver; +if (cpufreq_boost_supported ()) { + ret =create_boost_sysfs_file (); +if (ret) + goto err_null_driver; + } ret =subsys_interface_register (&cpufreq_interface);if (ret)
include/linux/cpufreq.h +0 -1
@@ -278,7 +278,6 @@ struct cpufreq_driver {struct freq_attr **attr;/* platform specific boost support code */ -bool boost_supported;bool boost_enabled;int (*set_boost)(int state); };
Re: [PATCH 3/3] cpufreq: Simplify core code related to boost support
Quoted 11 lines · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
Notice that the
boost_supportedfield in structcpufreq_driveris redundant, because the driver's ->set_boost callback may be left unset if "boost" is not supported. Moreover, the only driver populating the ->set_boost callback isacpi_cpufreq, so make it avoid populating that callback if "boost" is not supported, rework the core to check ->set_boost instead ofboost_supportedto verify "boost" support and dropboost_supportedwhich isn't used any more.
Quoted 6 lines
Signed-off-by Rafael J. Wysocki <[email protected]>--- drivers/cpufreq/acpi-cpufreq.c | 5 ++--- drivers/cpufreq/cpufreq.c | 22 +++++++--------------- include/linux/cpufreq.h | 1 - 3 files changed, 9 insertions(+), 19 deletions(-)
Signature · 1 line
viresh