mbox series

[v3,0/6] Improve usability for amd-pstate

Message ID 20220414164801.1051-1-mario.limonciello@amd.com
Headers show
Series Improve usability for amd-pstate | expand

Message

Mario Limonciello April 14, 2022, 4:47 p.m. UTC
There has recently been some news coverage about `amd-pstate` being in
5.17, but this news also mentioned that it's a bit difficult to use.

You need to either block init calls, or compile the module into the kernel
to force it to take precedence over acpi-cpufreq.

This series aims to improve the usability of amd-pstate so that distros
can compile as a module, but users can still use it (relatively) easily.

A new module parameter is included that will force amd-pstate to take
precedence and a module table to let it load automatically on such
systems.

By default with this series it will replace acpi-cpufreq no matter the
module load order.  If users want to prefer acpi-cpufreq when amd-pstate
is a module they can make a modprobe configuration file.

/etc/modprobe.d/amd-pstate.conf:

options amd-pstate replace=0

Mario Limonciello (6):
  cpufreq: Export acpu_cpufreq_exit for other drivers to call
  cpufreq: amd-pstate: Only show shared memory solution message once
  cpufreq: amd-pstate: Move cpufreq driver check later
  cpufreq: amd-pstate: Allow replacing acpi-cpufreq when loaded
  cpufreq: amd-pstate: Add a module device table
  cpufreq: amd-pstate: Default to replace acpi-cpufreq

 drivers/cpufreq/acpi-cpufreq.c | 10 +++++++--
 drivers/cpufreq/amd-pstate.c   | 39 +++++++++++++++++++++++++++++-----
 include/linux/cpufreq.h        |  3 +++
 3 files changed, 45 insertions(+), 7 deletions(-)

Comments

Huang Rui April 27, 2022, 1:46 p.m. UTC | #1
On Fri, Apr 15, 2022 at 12:47:57AM +0800, Limonciello, Mario wrote:
> A message is emitted to let users know they can enable shared memory,
> but it shows on all CPUs.
> 
> As this parameter is system-wide not CPU specific, it doesn't make
> sense to show 8+ times.  Modify it to print only once.
> 
> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>

Reviewed-by: Huang Rui <ray.huang@amd.com>

> ---
> v2->v3:
>  * New patch
> 
>  drivers/cpufreq/amd-pstate.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
> index 7be38bc6a673..ecd1fd5e5b5a 100644
> --- a/drivers/cpufreq/amd-pstate.c
> +++ b/drivers/cpufreq/amd-pstate.c
> @@ -666,7 +666,7 @@ static int __init amd_pstate_init(void)
>  		static_call_update(amd_pstate_init_perf, cppc_init_perf);
>  		static_call_update(amd_pstate_update_perf, cppc_update_perf);
>  	} else {
> -		pr_info("This processor supports shared memory solution, you can enable it with amd_pstate.shared_mem=1\n");
> +		pr_info_once("A processor on this system supports the shared memory solution, you can enable it with amd_pstate.shared_mem=1\n");
>  		return -ENODEV;
>  	}
>  
> -- 
> 2.34.1
>
Huang Rui April 27, 2022, 2:45 p.m. UTC | #2
On Fri, Apr 15, 2022 at 12:47:58AM +0800, Limonciello, Mario wrote:
> The cpufreq driver check occurs before we verify if the CPU is supported.
> 
> Depending upon module load order, this may mean that users are never
> notified they can enable the shared memory solution.
> 
> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>

Acked-by: Huang Rui <ray.huang@amd.com>

> ---
> v2->v3:
>  * New patch
> 
>  drivers/cpufreq/amd-pstate.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
> index ecd1fd5e5b5a..d323f3e3888c 100644
> --- a/drivers/cpufreq/amd-pstate.c
> +++ b/drivers/cpufreq/amd-pstate.c
> @@ -653,10 +653,6 @@ static int __init amd_pstate_init(void)
>  		return -ENODEV;
>  	}
>  
> -	/* don't keep reloading if cpufreq_driver exists */
> -	if (cpufreq_get_current_driver())
> -		return -EEXIST;
> -
>  	/* capability check */
>  	if (boot_cpu_has(X86_FEATURE_CPPC)) {
>  		pr_debug("AMD CPPC MSR based functionality is supported\n");
> @@ -670,6 +666,10 @@ static int __init amd_pstate_init(void)
>  		return -ENODEV;
>  	}
>  
> +	/* don't keep reloading if cpufreq_driver exists */
> +	if (cpufreq_get_current_driver())
> +		return -EEXIST;
> +
>  	/* enable amd pstate feature */
>  	ret = amd_pstate_enable(true);
>  	if (ret) {
> -- 
> 2.34.1
>