linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Huang Rui <ray.huang@amd.com>
To: "Limonciello, Mario" <Mario.Limonciello@amd.com>
Cc: "Rafael J . Wysocki" <rafael@kernel.org>,
	Viresh Kumar <viresh.kumar@linaro.org>,
	"open list:AMD PSTATE DRIVER" <linux-pm@vger.kernel.org>,
	open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2 2/3] cpufreq: amd-pstate: Allow replacing acpi-cpufreq when loaded
Date: Tue, 29 Mar 2022 13:56:05 +0800	[thread overview]
Message-ID: <YkKfdRGD1jcIx+Im@amd.com> (raw)
In-Reply-To: <20220329015947.565-3-mario.limonciello@amd.com>

On Tue, Mar 29, 2022 at 09:59:46AM +0800, Limonciello, Mario wrote:
> `amd-pstate` can be compiled as a module.  This however can be a
> deficiency because `acpi-cpufreq` will be loaded earlier when compiled
> into the kernel meaning `amd-pstate` doesn't get a chance.
> `acpi-cpufreq` is also unable to be unloaded in this circumstance.
> 
> To better improve the usability of `amd-pstate` when compiled as a module,
> add an optional module parameter that will force it to replace other
> cpufreq drivers at startup.
> 
> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
> ---
> v1->v2:
>  * Update to changes from v1.
>  * Verify the driver being matched is acpi-cpufreq.
>  * Show a message letting users know they can use amd-pstate.
> 
>  drivers/cpufreq/amd-pstate.c | 19 ++++++++++++++++---
>  1 file changed, 16 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
> index 7be38bc6a673..7dc2e344f222 100644
> --- a/drivers/cpufreq/amd-pstate.c
> +++ b/drivers/cpufreq/amd-pstate.c
> @@ -63,6 +63,12 @@ module_param(shared_mem, bool, 0444);
>  MODULE_PARM_DESC(shared_mem,
>  		 "enable amd-pstate on processors with shared memory solution (false = disabled (default), true = enabled)");
>  
> +static bool replace = false;
> +module_param(replace, bool, 0444);
> +MODULE_PARM_DESC(replace,
> +		  "replace acpi-cpufreq driver upon init if necessary");
> +extern void acpi_cpufreq_exit(void);
> +
>  static struct cpufreq_driver amd_pstate_driver;
>  
>  /**
> @@ -643,6 +649,7 @@ static struct cpufreq_driver amd_pstate_driver = {
>  
>  static int __init amd_pstate_init(void)
>  {
> +	const char *current_driver;
>  	int ret;
>  
>  	if (boot_cpu_data.x86_vendor != X86_VENDOR_AMD)
> @@ -653,9 +660,15 @@ static int __init amd_pstate_init(void)
>  		return -ENODEV;
>  	}
>  
> -	/* don't keep reloading if cpufreq_driver exists */
> -	if (cpufreq_get_current_driver())
> -		return -EEXIST;
> +	current_driver = cpufreq_get_current_driver();
> +	if (current_driver) {
> +		if (replace && strcmp(current_driver, "acpi-cpufreq") == 0) {

#ifdef CONFIG_X86_ACPI_CPUFREQ
> +			acpi_cpufreq_exit();
#endif

We need a kernel config checking here, otherwise, it will be built failed
once the acpi-cpufreq not set but amd_pstate is set.

Thanks,
Ray

  reply	other threads:[~2022-03-29  5:56 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-29  1:59 [PATCH v2 0/3] Improve usability for amd-pstate Mario Limonciello
2022-03-29  1:59 ` [PATCH v2 1/3] cpufreq: Export acpu_cpufreq_exit for other drivers to call Mario Limonciello
2022-03-29  5:47   ` Huang Rui
2022-03-29  6:22   ` kernel test robot
2022-03-29  6:32   ` kernel test robot
2022-03-29  1:59 ` [PATCH v2 2/3] cpufreq: amd-pstate: Allow replacing acpi-cpufreq when loaded Mario Limonciello
2022-03-29  5:56   ` Huang Rui [this message]
2022-03-29  1:59 ` [PATCH v2 3/3] cpufreq: amd-pstate: Add a module device table Mario Limonciello
2022-03-29  5:56   ` Huang Rui
2022-03-29  6:02 ` [PATCH v2 0/3] Improve usability for amd-pstate Huang Rui
2022-03-29 20:47   ` Limonciello, Mario
2022-03-30  9:54     ` Huang Rui

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YkKfdRGD1jcIx+Im@amd.com \
    --to=ray.huang@amd.com \
    --cc=Mario.Limonciello@amd.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=rafael@kernel.org \
    --cc=viresh.kumar@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).