* [PATCH] cpufreq: amd-pstate: Don't create attributes when registration fails
@ 2024-06-23 20:09 Mario Limonciello
2024-06-24 3:32 ` Yuan, Perry
2024-06-24 4:40 ` Gautham R.Shenoy
0 siblings, 2 replies; 3+ messages in thread
From: Mario Limonciello @ 2024-06-23 20:09 UTC (permalink / raw)
To: perry.yuan, gautham.shenoy
Cc: linux-pm, linux-kernel, Mario Limonciello, alex.s.cochran,
Peter Jung
If driver registration fails then immediately return the failure
instead of continuing to register attributes.
This fixes issues of falling back from amd-pstate to other drivers
when cpufreq init has failed for any reason.
Reported-by: alex.s.cochran@proton.me
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
Cc: Peter Jung <peterjung1337@gmail.com>
drivers/cpufreq/amd-pstate.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
index 05e80d2f8803..7195dfa98cc5 100644
--- a/drivers/cpufreq/amd-pstate.c
+++ b/drivers/cpufreq/amd-pstate.c
@@ -2030,8 +2030,10 @@ static int __init amd_pstate_init(void)
}
ret = cpufreq_register_driver(current_pstate_driver);
- if (ret)
+ if (ret) {
pr_err("failed to register with return %d\n", ret);
+ goto disable_driver;
+ }
dev_root = bus_get_dev_root(&cpu_subsys);
if (dev_root) {
@@ -2047,6 +2049,8 @@ static int __init amd_pstate_init(void)
global_attr_free:
cpufreq_unregister_driver(current_pstate_driver);
+disable_driver:
+ amd_pstate_enable(false);
return ret;
}
device_initcall(amd_pstate_init);
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* RE: [PATCH] cpufreq: amd-pstate: Don't create attributes when registration fails
2024-06-23 20:09 [PATCH] cpufreq: amd-pstate: Don't create attributes when registration fails Mario Limonciello
@ 2024-06-24 3:32 ` Yuan, Perry
2024-06-24 4:40 ` Gautham R.Shenoy
1 sibling, 0 replies; 3+ messages in thread
From: Yuan, Perry @ 2024-06-24 3:32 UTC (permalink / raw)
To: Limonciello, Mario, Shenoy, Gautham Ranjal
Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
alex.s.cochran@proton.me, Peter Jung
[AMD Official Use Only - AMD Internal Distribution Only]
Hi Mario,
> -----Original Message-----
> From: Limonciello, Mario <Mario.Limonciello@amd.com>
> Sent: Monday, June 24, 2024 4:09 AM
> To: Yuan, Perry <Perry.Yuan@amd.com>; Shenoy, Gautham Ranjal
> <gautham.shenoy@amd.com>
> Cc: linux-pm@vger.kernel.org; linux-kernel@vger.kernel.org; Limonciello,
> Mario <Mario.Limonciello@amd.com>; alex.s.cochran@proton.me; Peter
> Jung <peterjung1337@gmail.com>
> Subject: [PATCH] cpufreq: amd-pstate: Don't create attributes when
> registration fails
>
> If driver registration fails then immediately return the failure instead of
> continuing to register attributes.
>
> This fixes issues of falling back from amd-pstate to other drivers when
> cpufreq init has failed for any reason.
>
> Reported-by: alex.s.cochran@proton.me
> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
> ---
> Cc: Peter Jung <peterjung1337@gmail.com> drivers/cpufreq/amd-pstate.c |
> 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
> index 05e80d2f8803..7195dfa98cc5 100644
> --- a/drivers/cpufreq/amd-pstate.c
> +++ b/drivers/cpufreq/amd-pstate.c
> @@ -2030,8 +2030,10 @@ static int __init amd_pstate_init(void)
> }
>
> ret = cpufreq_register_driver(current_pstate_driver);
> - if (ret)
> + if (ret) {
> pr_err("failed to register with return %d\n", ret);
> + goto disable_driver;
> + }
>
> dev_root = bus_get_dev_root(&cpu_subsys);
> if (dev_root) {
> @@ -2047,6 +2049,8 @@ static int __init amd_pstate_init(void)
>
> global_attr_free:
> cpufreq_unregister_driver(current_pstate_driver);
> +disable_driver:
> + amd_pstate_enable(false);
> return ret;
> }
> device_initcall(amd_pstate_init);
> --
> 2.43.0
In the previous failure behavior, I saw most of time, the driver will fallback to acpi_cpufreq driver when pstate driver failed to load.
I agree to disable it explicitly with this patch.
Reviewed-by: Perry Yuan <Perry.Yuan@amd.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] cpufreq: amd-pstate: Don't create attributes when registration fails
2024-06-23 20:09 [PATCH] cpufreq: amd-pstate: Don't create attributes when registration fails Mario Limonciello
2024-06-24 3:32 ` Yuan, Perry
@ 2024-06-24 4:40 ` Gautham R.Shenoy
1 sibling, 0 replies; 3+ messages in thread
From: Gautham R.Shenoy @ 2024-06-24 4:40 UTC (permalink / raw)
To: Mario Limonciello, perry.yuan
Cc: linux-pm, linux-kernel, Mario Limonciello, alex.s.cochran,
Peter Jung
Mario Limonciello <mario.limonciello@amd.com> writes:
> If driver registration fails then immediately return the failure
> instead of continuing to register attributes.
>
> This fixes issues of falling back from amd-pstate to other drivers
> when cpufreq init has failed for any reason.
>
> Reported-by: alex.s.cochran@proton.me
> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
Thanks for fixing this.
Reviewed-by: Gautham R. Shenoy <gautham.shenoy@amd.com>
> ---
> Cc: Peter Jung <peterjung1337@gmail.com>
> drivers/cpufreq/amd-pstate.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
> index 05e80d2f8803..7195dfa98cc5 100644
> --- a/drivers/cpufreq/amd-pstate.c
> +++ b/drivers/cpufreq/amd-pstate.c
> @@ -2030,8 +2030,10 @@ static int __init amd_pstate_init(void)
> }
>
> ret = cpufreq_register_driver(current_pstate_driver);
> - if (ret)
> + if (ret) {
> pr_err("failed to register with return %d\n", ret);
> + goto disable_driver;
> + }
>
> dev_root = bus_get_dev_root(&cpu_subsys);
> if (dev_root) {
> @@ -2047,6 +2049,8 @@ static int __init amd_pstate_init(void)
>
> global_attr_free:
> cpufreq_unregister_driver(current_pstate_driver);
> +disable_driver:
> + amd_pstate_enable(false);
> return ret;
> }
> device_initcall(amd_pstate_init);
> --
> 2.43.0
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-06-24 4:41 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-23 20:09 [PATCH] cpufreq: amd-pstate: Don't create attributes when registration fails Mario Limonciello
2024-06-24 3:32 ` Yuan, Perry
2024-06-24 4:40 ` Gautham R.Shenoy
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox