From: Gautham R Shenoy <ego@linux.vnet.ibm.com>
To: "Oliver O'Halloran" <oohall@gmail.com>
Cc: linuxppc-dev@lists.ozlabs.org,
Vaidyanathan Srinivasan <svaidy@linux.vnet.ibm.com>,
Viresh Kumar <viresh.kumar@linaro.org>,
linux-pm@vger.kernel.org
Subject: Re: [PATCH 2/2] cpufreq/powernv: Fix unsafe notifiers
Date: Tue, 25 Feb 2020 12:15:32 +0530 [thread overview]
Message-ID: <20200225064532.GJ12846@in.ibm.com> (raw)
In-Reply-To: <20200206062622.28235-2-oohall@gmail.com>
On Thu, Feb 06, 2020 at 05:26:22PM +1100, Oliver O'Halloran wrote:
> The PowerNV cpufreq driver registers two notifiers: one to catch throttle
> messages from the OCC and one to bump the CPU frequency back to normal
> before a reboot. Both require the cpufreq driver to be registered in order
> to function since the notifier callbacks use various cpufreq_*() functions.
>
> Right now we register both notifiers before we've initialised the driver.
> This seems to work, but we should head off any protential problems by
> registering the notifiers after the driver is initialised.
>
> Cc: Vaidyanathan Srinivasan <svaidy@linux.vnet.ibm.com>
> Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
Reviewed-by: Gautham R. Shenoy <ego@linux.vnet.ibm.com>
> ---
> drivers/cpufreq/powernv-cpufreq.c | 11 +++++------
> 1 file changed, 5 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/cpufreq/powernv-cpufreq.c b/drivers/cpufreq/powernv-cpufreq.c
> index 1806b1d..03798c4 100644
> --- a/drivers/cpufreq/powernv-cpufreq.c
> +++ b/drivers/cpufreq/powernv-cpufreq.c
> @@ -1114,9 +1114,6 @@ static int __init powernv_cpufreq_init(void)
> if (rc)
> goto out;
>
> - register_reboot_notifier(&powernv_cpufreq_reboot_nb);
> - opal_message_notifier_register(OPAL_MSG_OCC, &powernv_cpufreq_opal_nb);
> -
> if (powernv_pstate_info.wof_enabled)
> powernv_cpufreq_driver.boost_enabled = true;
> else
> @@ -1125,15 +1122,17 @@ static int __init powernv_cpufreq_init(void)
> rc = cpufreq_register_driver(&powernv_cpufreq_driver);
> if (rc) {
> pr_info("Failed to register the cpufreq driver (%d)\n", rc);
> - goto cleanup_notifiers;
> + goto cleanup;
> }
>
> if (powernv_pstate_info.wof_enabled)
> cpufreq_enable_boost_support();
>
> + register_reboot_notifier(&powernv_cpufreq_reboot_nb);
> + opal_message_notifier_register(OPAL_MSG_OCC, &powernv_cpufreq_opal_nb);
> +
> return 0;
> -cleanup_notifiers:
> - unregister_all_notifiers();
> +cleanup:
> clean_chip_info();
> out:
> pr_info("Platform driver disabled. System does not support PState control\n");
> --
> 2.9.5
>
WARNING: multiple messages have this Message-ID (diff)
From: Gautham R Shenoy <ego@linux.vnet.ibm.com>
To: "Oliver O'Halloran" <oohall@gmail.com>
Cc: Viresh Kumar <viresh.kumar@linaro.org>,
Vaidyanathan Srinivasan <svaidy@linux.vnet.ibm.com>,
linuxppc-dev@lists.ozlabs.org, linux-pm@vger.kernel.org
Subject: Re: [PATCH 2/2] cpufreq/powernv: Fix unsafe notifiers
Date: Tue, 25 Feb 2020 12:15:32 +0530 [thread overview]
Message-ID: <20200225064532.GJ12846@in.ibm.com> (raw)
In-Reply-To: <20200206062622.28235-2-oohall@gmail.com>
On Thu, Feb 06, 2020 at 05:26:22PM +1100, Oliver O'Halloran wrote:
> The PowerNV cpufreq driver registers two notifiers: one to catch throttle
> messages from the OCC and one to bump the CPU frequency back to normal
> before a reboot. Both require the cpufreq driver to be registered in order
> to function since the notifier callbacks use various cpufreq_*() functions.
>
> Right now we register both notifiers before we've initialised the driver.
> This seems to work, but we should head off any protential problems by
> registering the notifiers after the driver is initialised.
>
> Cc: Vaidyanathan Srinivasan <svaidy@linux.vnet.ibm.com>
> Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
Reviewed-by: Gautham R. Shenoy <ego@linux.vnet.ibm.com>
> ---
> drivers/cpufreq/powernv-cpufreq.c | 11 +++++------
> 1 file changed, 5 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/cpufreq/powernv-cpufreq.c b/drivers/cpufreq/powernv-cpufreq.c
> index 1806b1d..03798c4 100644
> --- a/drivers/cpufreq/powernv-cpufreq.c
> +++ b/drivers/cpufreq/powernv-cpufreq.c
> @@ -1114,9 +1114,6 @@ static int __init powernv_cpufreq_init(void)
> if (rc)
> goto out;
>
> - register_reboot_notifier(&powernv_cpufreq_reboot_nb);
> - opal_message_notifier_register(OPAL_MSG_OCC, &powernv_cpufreq_opal_nb);
> -
> if (powernv_pstate_info.wof_enabled)
> powernv_cpufreq_driver.boost_enabled = true;
> else
> @@ -1125,15 +1122,17 @@ static int __init powernv_cpufreq_init(void)
> rc = cpufreq_register_driver(&powernv_cpufreq_driver);
> if (rc) {
> pr_info("Failed to register the cpufreq driver (%d)\n", rc);
> - goto cleanup_notifiers;
> + goto cleanup;
> }
>
> if (powernv_pstate_info.wof_enabled)
> cpufreq_enable_boost_support();
>
> + register_reboot_notifier(&powernv_cpufreq_reboot_nb);
> + opal_message_notifier_register(OPAL_MSG_OCC, &powernv_cpufreq_opal_nb);
> +
> return 0;
> -cleanup_notifiers:
> - unregister_all_notifiers();
> +cleanup:
> clean_chip_info();
> out:
> pr_info("Platform driver disabled. System does not support PState control\n");
> --
> 2.9.5
>
next prev parent reply other threads:[~2020-02-25 6:45 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-06 6:26 [PATCH 1/2] cpufreq/powernv: Fix use-after-free Oliver O'Halloran
2020-02-06 6:26 ` [PATCH 2/2] cpufreq/powernv: Fix unsafe notifiers Oliver O'Halloran
2020-02-25 6:45 ` Gautham R Shenoy [this message]
2020-02-25 6:45 ` Gautham R Shenoy
2020-02-25 6:42 ` [PATCH 1/2] cpufreq/powernv: Fix use-after-free Gautham R Shenoy
2020-02-25 6:42 ` Gautham R Shenoy
2020-02-25 7:03 ` Andrew Donnellan
2020-02-27 1:31 ` Michael Ellerman
2020-03-17 13:14 ` Michael Ellerman
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=20200225064532.GJ12846@in.ibm.com \
--to=ego@linux.vnet.ibm.com \
--cc=linux-pm@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=oohall@gmail.com \
--cc=svaidy@linux.vnet.ibm.com \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.