mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] cpufreq/amd-pstate: Fix amd_pstate mode switch on shared memory systems
@ 2024-10-04 12:23 Dhananjay Ugwekar
  2024-10-07 16:31 ` Mario Limonciello
  0 siblings, 1 reply; 2+ messages in thread
From: Dhananjay Ugwekar @ 2024-10-04 12:23 UTC (permalink / raw)
  To: gautham.shenoy, mario.limonciello, perry.yuan, ray.huang, rafael,
	viresh.kumar
  Cc: linux-pm, linux-kernel, Dhananjay Ugwekar

While switching the driver mode between active and passive, Collaborative
Processor Performance Control (CPPC) is disabled in
amd_pstate_unregister_driver(). But, it is not enabled back while registering
the new driver (passive or active). This leads to the new driver mode not
working correctly, so enable it back in amd_pstate_register_driver().

Fixes: 3ca7bc818d8c ("cpufreq: amd-pstate: Add guided mode control support via sysfs")
Signed-off-by: Dhananjay Ugwekar <Dhananjay.Ugwekar@amd.com>
---
 drivers/cpufreq/amd-pstate.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
index cdc08d2ddd52..4acf5fbeb116 100644
--- a/drivers/cpufreq/amd-pstate.c
+++ b/drivers/cpufreq/amd-pstate.c
@@ -1191,11 +1191,21 @@ static int amd_pstate_register_driver(int mode)
 		return -EINVAL;
 
 	cppc_state = mode;
+
+	ret = amd_pstate_enable(true);
+	if (ret) {
+		pr_err("failed to enable cppc during amd-pstate driver registration, return %d\n",
+		       ret);
+		amd_pstate_driver_cleanup();
+		return ret;
+	}
+
 	ret = cpufreq_register_driver(current_pstate_driver);
 	if (ret) {
 		amd_pstate_driver_cleanup();
 		return ret;
 	}
+
 	return 0;
 }
 
-- 
2.34.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] cpufreq/amd-pstate: Fix amd_pstate mode switch on shared memory systems
  2024-10-04 12:23 [PATCH] cpufreq/amd-pstate: Fix amd_pstate mode switch on shared memory systems Dhananjay Ugwekar
@ 2024-10-07 16:31 ` Mario Limonciello
  0 siblings, 0 replies; 2+ messages in thread
From: Mario Limonciello @ 2024-10-07 16:31 UTC (permalink / raw)
  To: Dhananjay Ugwekar
  Cc: linux-pm, linux-kernel, gautham.shenoy, perry.yuan, ray.huang,
	rafael, viresh.kumar

On 10/4/2024 07:23, Dhananjay Ugwekar wrote:
> While switching the driver mode between active and passive, Collaborative
> Processor Performance Control (CPPC) is disabled in
> amd_pstate_unregister_driver(). But, it is not enabled back while registering
> the new driver (passive or active). This leads to the new driver mode not
> working correctly, so enable it back in amd_pstate_register_driver().
> 
> Fixes: 3ca7bc818d8c ("cpufreq: amd-pstate: Add guided mode control support via sysfs")
> Signed-off-by: Dhananjay Ugwekar <Dhananjay.Ugwekar@amd.com>

Reviewed-by: Mario Limonciello <mario.limonciello@amd.com>

I think as a minimally risky fix to go to 6.12-rcX this makes sense, but 
looking at all this code there is a bit of duplication that exists that 
we should do a more general cleanup for 6.13.

So I'll queue this up in my -fixes branch for 6.12-rcX. but please do 
the bigger cleanup as a follow up that we can land for 6.13.

> ---
>   drivers/cpufreq/amd-pstate.c | 10 ++++++++++
>   1 file changed, 10 insertions(+)
> 
> diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
> index cdc08d2ddd52..4acf5fbeb116 100644
> --- a/drivers/cpufreq/amd-pstate.c
> +++ b/drivers/cpufreq/amd-pstate.c
> @@ -1191,11 +1191,21 @@ static int amd_pstate_register_driver(int mode)
>   		return -EINVAL;
>   
>   	cppc_state = mode;
> +
> +	ret = amd_pstate_enable(true);
> +	if (ret) {
> +		pr_err("failed to enable cppc during amd-pstate driver registration, return %d\n",
> +		       ret);
> +		amd_pstate_driver_cleanup();
> +		return ret;
> +	}
> +
>   	ret = cpufreq_register_driver(current_pstate_driver);
>   	if (ret) {
>   		amd_pstate_driver_cleanup();
>   		return ret;
>   	}
> +
>   	return 0;
>   }
>   


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-10-07 16:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-10-04 12:23 [PATCH] cpufreq/amd-pstate: Fix amd_pstate mode switch on shared memory systems Dhananjay Ugwekar
2024-10-07 16:31 ` Mario Limonciello

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®