acpi-cpufreq: Skip cleanup if initialization didn't occur
Subsystems (2)
PATCH 1/1 acpi-cpufreq: Skip cleanup if initialization didn't occur
From: Kyle Meyer <[email protected]>
acpi-cpufreq is loaded without performing initialization when a cpufreq driver exists.
If initialization didn't occur then skip cleanup in acpi_cpufreq_exit(). This prevents unnecessary freeing and unregistering when the module is unloaded.
--- drivers/cpufreq/acpi-cpufreq.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
drivers/cpufreq/acpi-cpufreq.c +11 -0
@@ -1042,8 +1042,19 @@ static int __init acpi_cpufreq_init(void) static void __exit acpi_cpufreq_exit(void) { +const char *current_driver; +pr_debug ("%s\n" , __func__); +/* +* If another cpufreq_driver was loaded, preventing acpi-cpufreq from +* registering, there's no need to unregister it. +*/ + current_driver =cpufreq_get_current_driver (); +if (!current_driver || +strncmp (current_driver, acpi_cpufreq_driver.name,strlen (acpi_cpufreq_driver.name))) +return ; +acpi_cpufreq_boost_exit ();cpufreq_unregister_driver (&acpi_cpufreq_driver);
Signature · 1 line
2.25.1
Viresh Kumar
maintainerQuoted 29 lines · On 04-06-21, 12:05, [email protected] wrote:
From: Kyle Meyer <[email protected]>
acpi-cpufreq is loaded without performing initialization when a cpufreq driver exists.
If initialization didn't occur then skip cleanup in
acpi_cpufreq_exit(). This prevents unnecessary freeing and unregistering when the module is unloaded.Reported-by Takashi Iwai <[email protected]>Signed-off-by Kyle Meyer <[email protected]>--- drivers/cpufreq/acpi-cpufreq.c | 11 +++++++++++ 1 file changed, 11 insertions(+)drivers/cpufreq/acpi-cpufreq.c +4
-0@@ -1042,8 +1042,19 @@ static int __init acpi_cpufreq_init(void) static void __exit acpi_cpufreq_exit(void) { +const char *current_driver; +pr_debug ("%s\n" , __func__); +/* +* If another cpufreq_driver was loaded, preventing acpi-cpufreq from
drivers/cpufreq/acpi-cpufreq.c static int __init acpi_cpufreq_init(void) · line 1060
Quoted 10 lines
drivers/cpufreq/acpi-cpufreq.c +7
-0+* registering, there's no need to unregister it. +*/ + current_driver =cpufreq_get_current_driver (); +if (!current_driver || +strncmp (current_driver, acpi_cpufreq_driver.name,strlen (acpi_cpufreq_driver.name))) +return ; +acpi_cpufreq_boost_exit ();cpufreq_unregister_driver (&acpi_cpufreq_driver);
Looks like some misunderstanding here, this shouldn't happen. If initialization didn't occur, then exit shall never be called.
Signature · 1 line
viresh
Quoted 40 lines · Viresh Kumar
Quoted 38 lines · On 04-06-21, 12:05, [email protected] wrote:
From: Kyle Meyer <[email protected]>
acpi-cpufreq is loaded without performing initialization when a cpufreq driver exists.
If initialization didn't occur then skip cleanup in
acpi_cpufreq_exit(). This prevents unnecessary freeing and unregistering when the module is unloaded.Reported-by Takashi Iwai <[email protected]>Signed-off-by Kyle Meyer <[email protected]>--- drivers/cpufreq/acpi-cpufreq.c | 11 +++++++++++ 1 file changed, 11 insertions(+)drivers/cpufreq/acpi-cpufreq.c +11
-0@@ -1042,8 +1042,19 @@ static int __init acpi_cpufreq_init(void) static void __exit acpi_cpufreq_exit(void) { +const char *current_driver; +pr_debug ("%s\n" , __func__); +/* +* If another cpufreq_driver was loaded, preventing acpi-cpufreq from +* registering, there's no need to unregister it. +*/ + current_driver =cpufreq_get_current_driver (); +if (!current_driver || +strncmp (current_driver, acpi_cpufreq_driver.name,strlen (acpi_cpufreq_driver.name))) +return ; +acpi_cpufreq_boost_exit ();
Quoted 4 lines
drivers/cpufreq/acpi-cpufreq.c static int __init acpi_cpufreq_init(void) · line 1060
Quoted 1 line
drivers/cpufreq/acpi-cpufreq.c +0
-0cpufreq_unregister_driver (&acpi_cpufreq_driver);Looks like some misunderstanding here, this shouldn't happen. If initialization didn't occur, then exit shall never be called.
The missing key information is that it's a fix for the recent change for 5.14, i.e.
The change made the module left even if it exits before registering the cpufreq driver object.
Takashi
Viresh Kumar
maintainerQuoted 6 lines · Takashi Iwai
The missing key information is that it's a fix for the recent change for 5.14, i.e.
Fixes c1d6d2fd2f64 ("cpufreq: acpi-cpufreq: Skip initialization if cpufreq driver is present")The change made the module left even if it exits before registering the cpufreq driver object.
The original patch looks buggy to me, I was never able to review it :(
I have replied on the original thread instead.
Signature · 1 line
viresh
Rafael J. Wysocki
maintainerQuoted 6 lines · Viresh Kumar
Quoted 4 lines · Takashi Iwai
The missing key information is that it's a fix for the recent change for 5.14, i.e.
Fixes c1d6d2fd2f64 ("cpufreq: acpi-cpufreq: Skip initialization if cpufreq driver is present")
Quoted 6 lines
Quoted 2 lines
The change made the module left even if it exits before registering the cpufreq driver object.
The original patch looks buggy to me, I was never able to review it :(
I have replied on the original thread instead.
Well, thanks, but that confused me a bit.
Given the above, I'm going to drop the original patch.
Kyle, please reconsider this approach.