* [PATCH] acpi-cpufreq: Skip cleanup if initialization didn't occur
@ 2021-06-04 17:05 kyle.meyer
2021-06-07 3:25 ` Viresh Kumar
0 siblings, 1 reply; 5+ messages in thread
From: kyle.meyer @ 2021-06-04 17:05 UTC (permalink / raw)
To: rjw, viresh.kumar, linux-kernel
Cc: linux-pm, linux-acpi, Kyle Meyer, Takashi Iwai
From: Kyle Meyer <kyle.meyer@hpe.com>
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 <tiwai@suse.com>
Signed-off-by: Kyle Meyer <kyle.meyer@hpe.com>
---
drivers/cpufreq/acpi-cpufreq.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c
index 7e7450453714..8d425f14c267 100644
--- a/drivers/cpufreq/acpi-cpufreq.c
+++ b/drivers/cpufreq/acpi-cpufreq.c
@@ -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);
--
2.25.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] acpi-cpufreq: Skip cleanup if initialization didn't occur
2021-06-04 17:05 [PATCH] acpi-cpufreq: Skip cleanup if initialization didn't occur kyle.meyer
@ 2021-06-07 3:25 ` Viresh Kumar
2021-06-07 7:13 ` Takashi Iwai
0 siblings, 1 reply; 5+ messages in thread
From: Viresh Kumar @ 2021-06-07 3:25 UTC (permalink / raw)
To: kyle.meyer; +Cc: rjw, linux-kernel, linux-pm, linux-acpi, Takashi Iwai
On 04-06-21, 12:05, kyle.meyer@hpe.com wrote:
> From: Kyle Meyer <kyle.meyer@hpe.com>
>
> 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 <tiwai@suse.com>
> Signed-off-by: Kyle Meyer <kyle.meyer@hpe.com>
> ---
> drivers/cpufreq/acpi-cpufreq.c | 11 +++++++++++
> 1 file changed, 11 insertions(+)
>
> diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c
> index 7e7450453714..8d425f14c267 100644
> --- a/drivers/cpufreq/acpi-cpufreq.c
> +++ b/drivers/cpufreq/acpi-cpufreq.c
> @@ -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);
Looks like some misunderstanding here, this shouldn't happen. If
initialization didn't occur, then exit shall never be called.
--
viresh
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] acpi-cpufreq: Skip cleanup if initialization didn't occur
2021-06-07 3:25 ` Viresh Kumar
@ 2021-06-07 7:13 ` Takashi Iwai
2021-06-07 7:26 ` Viresh Kumar
0 siblings, 1 reply; 5+ messages in thread
From: Takashi Iwai @ 2021-06-07 7:13 UTC (permalink / raw)
To: Viresh Kumar
Cc: kyle.meyer, rjw, linux-kernel, linux-pm, linux-acpi, Takashi Iwai
On Mon, 07 Jun 2021 05:25:50 +0200,
Viresh Kumar wrote:
>
> On 04-06-21, 12:05, kyle.meyer@hpe.com wrote:
> > From: Kyle Meyer <kyle.meyer@hpe.com>
> >
> > 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 <tiwai@suse.com>
> > Signed-off-by: Kyle Meyer <kyle.meyer@hpe.com>
> > ---
> > drivers/cpufreq/acpi-cpufreq.c | 11 +++++++++++
> > 1 file changed, 11 insertions(+)
> >
> > diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c
> > index 7e7450453714..8d425f14c267 100644
> > --- a/drivers/cpufreq/acpi-cpufreq.c
> > +++ b/drivers/cpufreq/acpi-cpufreq.c
> > @@ -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);
>
> 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.
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.
Takashi
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] acpi-cpufreq: Skip cleanup if initialization didn't occur
2021-06-07 7:13 ` Takashi Iwai
@ 2021-06-07 7:26 ` Viresh Kumar
2021-06-07 11:09 ` Rafael J. Wysocki
0 siblings, 1 reply; 5+ messages in thread
From: Viresh Kumar @ 2021-06-07 7:26 UTC (permalink / raw)
To: Takashi Iwai
Cc: kyle.meyer, rjw, linux-kernel, linux-pm, linux-acpi, Takashi Iwai
On 07-06-21, 09:13, Takashi Iwai wrote:
> 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.
--
viresh
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] acpi-cpufreq: Skip cleanup if initialization didn't occur
2021-06-07 7:26 ` Viresh Kumar
@ 2021-06-07 11:09 ` Rafael J. Wysocki
0 siblings, 0 replies; 5+ messages in thread
From: Rafael J. Wysocki @ 2021-06-07 11:09 UTC (permalink / raw)
To: Viresh Kumar, Kyle Meyer
Cc: Takashi Iwai, Rafael J. Wysocki, Linux Kernel Mailing List,
Linux PM, ACPI Devel Maling List, Takashi Iwai
On Mon, Jun 7, 2021 at 9:26 AM Viresh Kumar <viresh.kumar@linaro.org> wrote:
>
> On 07-06-21, 09:13, Takashi Iwai wrote:
> > 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.
Well, thanks, but that confused me a bit.
Given the above, I'm going to drop the original patch.
Kyle, please reconsider this approach.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-06-07 11:09 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-04 17:05 [PATCH] acpi-cpufreq: Skip cleanup if initialization didn't occur kyle.meyer
2021-06-07 3:25 ` Viresh Kumar
2021-06-07 7:13 ` Takashi Iwai
2021-06-07 7:26 ` Viresh Kumar
2021-06-07 11:09 ` Rafael J. Wysocki
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).