diff mbox

[Precise/Quantal] UBUNTU: SAUCE: Allow filtering of cpufreq drivers

Message ID 1335361286-3115-1-git-send-email-tim.gardner@canonical.com
State New
Headers show

Commit Message

Tim Gardner April 25, 2012, 1:41 p.m. UTC
BugLink: http://bugs.launchpad.net/bugs/984288

Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
---
 Documentation/kernel-parameters.txt |    4 ++++
 drivers/cpufreq/cpufreq.c           |   22 +++++++++++++++++++++-
 2 files changed, 25 insertions(+), 1 deletion(-)

Comments

Stefan Bader April 25, 2012, 2:01 p.m. UTC | #1
On 25.04.2012 15:41, Tim Gardner wrote:
> BugLink: http://bugs.launchpad.net/bugs/984288
> 
> Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
> ---
>  Documentation/kernel-parameters.txt |    4 ++++
>  drivers/cpufreq/cpufreq.c           |   22 +++++++++++++++++++++-
>  2 files changed, 25 insertions(+), 1 deletion(-)
> 
> diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
> index cb0532b..57dfe00 100644
> --- a/Documentation/kernel-parameters.txt
> +++ b/Documentation/kernel-parameters.txt
> @@ -570,6 +570,10 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
>  			/proc/<pid>/coredump_filter.
>  			See also Documentation/filesystems/proc.txt.
>  
> +	cpufreq_driver= [X86] Allow only the named cpu frequency scaling driver
> +			to register. Example: cpufreq_driver=powernow-k8
> +			Format: { none | STRING }
> +
>  	cpuidle.off=1	[CPU_IDLE]
>  			disable the cpuidle sub-system
>  
> diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
> index 987a165..fe63d01 100644
> --- a/drivers/cpufreq/cpufreq.c
> +++ b/drivers/cpufreq/cpufreq.c
> @@ -1798,6 +1798,20 @@ static struct notifier_block __refdata cpufreq_cpu_notifier = {
>   *               REGISTER / UNREGISTER CPUFREQ DRIVER                *
>   *********************************************************************/
>  
> +static char cpufreq_driver_name[CPUFREQ_NAME_LEN];
> +
> +static int __init cpufreq_driver_setup(char *str)
> +{
> +	strlcpy(cpufreq_driver_name, str, CPUFREQ_NAME_LEN);
> +	return 1;
> +}
> +
> +/*
> + * Set this name to only allow one specific cpu freq driver, e.g.,
> + * cpufreq_driver=powernow-k8
> + */
> +__setup("cpufreq_driver=", cpufreq_driver_setup);
> +
>  /**
>   * cpufreq_register_driver - register a CPU Frequency driver
>   * @driver_data: A struct cpufreq_driver containing the values#
> @@ -1817,7 +1831,13 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data)
>  	    ((!driver_data->setpolicy) && (!driver_data->target)))
>  		return -EINVAL;
>  
> -	pr_debug("trying to register driver %s\n", driver_data->name);
> +	pr_debug("trying to register driver %s, cpufreq_driver=%s\n",
> +		driver_data->name, cpufreq_driver_name);
> +
> +	if (cpufreq_driver_name[0])
> +		if (!driver_data->name ||
> +			strcmp(cpufreq_driver_name, driver_data->name))
> +				return -EINVAL;
>  
>  	if (driver_data->setpolicy)
>  		driver_data->flags |= CPUFREQ_CONST_LOOPS;

Guess that could work and as long as no value is set there won't be a difference
in behavior.
Herton Ronaldo Krzesinski April 25, 2012, 7:34 p.m. UTC | #2
On Wed, Apr 25, 2012 at 07:41:26AM -0600, Tim Gardner wrote:
> BugLink: http://bugs.launchpad.net/bugs/984288

Ack, it is simple and cpufreq_driver=phc-k8 will now do what they need.

> 
> Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
> ---
>  Documentation/kernel-parameters.txt |    4 ++++
>  drivers/cpufreq/cpufreq.c           |   22 +++++++++++++++++++++-
>  2 files changed, 25 insertions(+), 1 deletion(-)
> 
> diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
> index cb0532b..57dfe00 100644
> --- a/Documentation/kernel-parameters.txt
> +++ b/Documentation/kernel-parameters.txt
> @@ -570,6 +570,10 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
>  			/proc/<pid>/coredump_filter.
>  			See also Documentation/filesystems/proc.txt.
>  
> +	cpufreq_driver= [X86] Allow only the named cpu frequency scaling driver
> +			to register. Example: cpufreq_driver=powernow-k8
> +			Format: { none | STRING }
> +
>  	cpuidle.off=1	[CPU_IDLE]
>  			disable the cpuidle sub-system
>  
> diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
> index 987a165..fe63d01 100644
> --- a/drivers/cpufreq/cpufreq.c
> +++ b/drivers/cpufreq/cpufreq.c
> @@ -1798,6 +1798,20 @@ static struct notifier_block __refdata cpufreq_cpu_notifier = {
>   *               REGISTER / UNREGISTER CPUFREQ DRIVER                *
>   *********************************************************************/
>  
> +static char cpufreq_driver_name[CPUFREQ_NAME_LEN];
> +
> +static int __init cpufreq_driver_setup(char *str)
> +{
> +	strlcpy(cpufreq_driver_name, str, CPUFREQ_NAME_LEN);
> +	return 1;
> +}
> +
> +/*
> + * Set this name to only allow one specific cpu freq driver, e.g.,
> + * cpufreq_driver=powernow-k8
> + */
> +__setup("cpufreq_driver=", cpufreq_driver_setup);
> +
>  /**
>   * cpufreq_register_driver - register a CPU Frequency driver
>   * @driver_data: A struct cpufreq_driver containing the values#
> @@ -1817,7 +1831,13 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data)
>  	    ((!driver_data->setpolicy) && (!driver_data->target)))
>  		return -EINVAL;
>  
> -	pr_debug("trying to register driver %s\n", driver_data->name);
> +	pr_debug("trying to register driver %s, cpufreq_driver=%s\n",
> +		driver_data->name, cpufreq_driver_name);
> +
> +	if (cpufreq_driver_name[0])
> +		if (!driver_data->name ||
> +			strcmp(cpufreq_driver_name, driver_data->name))
> +				return -EINVAL;
>  
>  	if (driver_data->setpolicy)
>  		driver_data->flags |= CPUFREQ_CONST_LOOPS;
> -- 
> 1.7.9.5
> 
> 
> -- 
> kernel-team mailing list
> kernel-team@lists.ubuntu.com
> https://lists.ubuntu.com/mailman/listinfo/kernel-team
>
Tim Gardner April 25, 2012, 8:05 p.m. UTC | #3

diff mbox

Patch

diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
index cb0532b..57dfe00 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -570,6 +570,10 @@  bytes respectively. Such letter suffixes can also be entirely omitted.
 			/proc/<pid>/coredump_filter.
 			See also Documentation/filesystems/proc.txt.
 
+	cpufreq_driver= [X86] Allow only the named cpu frequency scaling driver
+			to register. Example: cpufreq_driver=powernow-k8
+			Format: { none | STRING }
+
 	cpuidle.off=1	[CPU_IDLE]
 			disable the cpuidle sub-system
 
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 987a165..fe63d01 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -1798,6 +1798,20 @@  static struct notifier_block __refdata cpufreq_cpu_notifier = {
  *               REGISTER / UNREGISTER CPUFREQ DRIVER                *
  *********************************************************************/
 
+static char cpufreq_driver_name[CPUFREQ_NAME_LEN];
+
+static int __init cpufreq_driver_setup(char *str)
+{
+	strlcpy(cpufreq_driver_name, str, CPUFREQ_NAME_LEN);
+	return 1;
+}
+
+/*
+ * Set this name to only allow one specific cpu freq driver, e.g.,
+ * cpufreq_driver=powernow-k8
+ */
+__setup("cpufreq_driver=", cpufreq_driver_setup);
+
 /**
  * cpufreq_register_driver - register a CPU Frequency driver
  * @driver_data: A struct cpufreq_driver containing the values#
@@ -1817,7 +1831,13 @@  int cpufreq_register_driver(struct cpufreq_driver *driver_data)
 	    ((!driver_data->setpolicy) && (!driver_data->target)))
 		return -EINVAL;
 
-	pr_debug("trying to register driver %s\n", driver_data->name);
+	pr_debug("trying to register driver %s, cpufreq_driver=%s\n",
+		driver_data->name, cpufreq_driver_name);
+
+	if (cpufreq_driver_name[0])
+		if (!driver_data->name ||
+			strcmp(cpufreq_driver_name, driver_data->name))
+				return -EINVAL;
 
 	if (driver_data->setpolicy)
 		driver_data->flags |= CPUFREQ_CONST_LOOPS;