From: Ulf Hansson <ulf.hansson@linaro.org>
To: andersson@kernel.org, Maulik Shah <quic_mkshah@quicinc.com>
Cc: dianders@chromium.org, swboyd@chromium.org, wingers@google.com,
linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-pm@vger.kernel.org, sudeep.holla@arm.com,
jwerner@chromium.org, quic_lsrao@quicinc.com,
quic_rjendra@quicinc.com
Subject: Re: [PATCH v4 2/3] cpuidle: psci: Move enabling OSI mode after power domains creation
Date: Tue, 2 May 2023 16:44:52 +0200 [thread overview]
Message-ID: <CAPDyKFowJheraoMdJSyhdXB_FcT1oeiAwqrF8eGLC3FNVqhzCg@mail.gmail.com> (raw)
In-Reply-To: <20230424110933.3908-3-quic_mkshah@quicinc.com>
On Mon, 24 Apr 2023 at 13:10, Maulik Shah <quic_mkshah@quicinc.com> wrote:
>
> A switch from OSI to PC mode is only possible if all CPUs other than the
> calling one are OFF, either through a call to CPU_OFF or not yet booted.
>
> Currently OSI mode is enabled before power domains are created. In cases
> where CPUidle states are not using hierarchical CPU topology the bail out
> path tries to switch back to PC mode which gets denied by firmware since
> other CPUs are online at this point and creates inconsistent state as
> firmware is in OSI mode and Linux in PC mode.
>
> This change moves enabling OSI mode after power domains are created,
> this would makes sure that hierarchical CPU topology is used before
> switching firmware to OSI mode.
>
> Fixes: 70c179b49870 ("cpuidle: psci: Allow PM domain to be initialized even if no OSI mode")
> Signed-off-by: Maulik Shah <quic_mkshah@quicinc.com>
Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>
Bjorn, can you pick up this series for 6.4-rc[n]? Moreover, I think it
would be a good idea to tag both patch 1 and patch 2 for stable
kernels.
Kind regards
Uffe
> ---
> drivers/cpuidle/cpuidle-psci-domain.c | 39 +++++++++------------------
> 1 file changed, 13 insertions(+), 26 deletions(-)
>
> diff --git a/drivers/cpuidle/cpuidle-psci-domain.c b/drivers/cpuidle/cpuidle-psci-domain.c
> index c2d6d9c3c930..b88af1262f1a 100644
> --- a/drivers/cpuidle/cpuidle-psci-domain.c
> +++ b/drivers/cpuidle/cpuidle-psci-domain.c
> @@ -120,20 +120,6 @@ static void psci_pd_remove(void)
> }
> }
>
> -static bool psci_pd_try_set_osi_mode(void)
> -{
> - int ret;
> -
> - if (!psci_has_osi_support())
> - return false;
> -
> - ret = psci_set_osi_mode(true);
> - if (ret)
> - return false;
> -
> - return true;
> -}
> -
> static void psci_cpuidle_domain_sync_state(struct device *dev)
> {
> /*
> @@ -152,15 +138,12 @@ static int psci_cpuidle_domain_probe(struct platform_device *pdev)
> {
> struct device_node *np = pdev->dev.of_node;
> struct device_node *node;
> - bool use_osi;
> + bool use_osi = psci_has_osi_support();
> int ret = 0, pd_count = 0;
>
> if (!np)
> return -ENODEV;
>
> - /* If OSI mode is supported, let's try to enable it. */
> - use_osi = psci_pd_try_set_osi_mode();
> -
> /*
> * Parse child nodes for the "#power-domain-cells" property and
> * initialize a genpd/genpd-of-provider pair when it's found.
> @@ -170,33 +153,37 @@ static int psci_cpuidle_domain_probe(struct platform_device *pdev)
> continue;
>
> ret = psci_pd_init(node, use_osi);
> - if (ret)
> - goto put_node;
> + if (ret) {
> + of_node_put(node);
> + goto exit;
> + }
>
> pd_count++;
> }
>
> /* Bail out if not using the hierarchical CPU topology. */
> if (!pd_count)
> - goto no_pd;
> + return 0;
>
> /* Link genpd masters/subdomains to model the CPU topology. */
> ret = dt_idle_pd_init_topology(np);
> if (ret)
> goto remove_pd;
>
> + /* let's try to enable OSI. */
> + ret = psci_set_osi_mode(use_osi);
> + if (ret)
> + goto remove_pd;
> +
> pr_info("Initialized CPU PM domain topology using %s mode\n",
> use_osi ? "OSI" : "PC");
> return 0;
>
> -put_node:
> - of_node_put(node);
> remove_pd:
> + dt_idle_pd_remove_topology(np);
> psci_pd_remove();
> +exit:
> pr_err("failed to create CPU PM domains ret=%d\n", ret);
> -no_pd:
> - if (use_osi)
> - psci_set_osi_mode(false);
> return ret;
> }
>
> --
> 2.17.1
>
next prev parent reply other threads:[~2023-05-02 14:45 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-24 11:09 [PATCH v4 0/3] Use PSCI OS initiated mode for sc7280 Maulik Shah
2023-04-24 11:09 ` [PATCH v4 1/3] cpuidle: dt_idle_genpd: Add helper function to remove genpd topology Maulik Shah
2023-04-24 11:09 ` [PATCH v4 2/3] cpuidle: psci: Move enabling OSI mode after power domains creation Maulik Shah
2023-05-02 14:44 ` Ulf Hansson [this message]
2023-04-24 11:09 ` [PATCH v4 3/3] arm64: dts: qcom: sc7280: Add power-domains for cpuidle states Maulik Shah
2023-05-24 9:56 ` [PATCH v4 0/3] Use PSCI OS initiated mode for sc7280 Ulf Hansson
2023-05-25 2:45 ` Bjorn Andersson
2023-05-29 8:58 ` Ulf Hansson
2023-05-29 16:08 ` Bjorn Andersson
2023-05-30 22:11 ` Ulf Hansson
2023-06-12 10:46 ` Ulf Hansson
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=CAPDyKFowJheraoMdJSyhdXB_FcT1oeiAwqrF8eGLC3FNVqhzCg@mail.gmail.com \
--to=ulf.hansson@linaro.org \
--cc=andersson@kernel.org \
--cc=dianders@chromium.org \
--cc=jwerner@chromium.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=quic_lsrao@quicinc.com \
--cc=quic_mkshah@quicinc.com \
--cc=quic_rjendra@quicinc.com \
--cc=sudeep.holla@arm.com \
--cc=swboyd@chromium.org \
--cc=wingers@google.com \
/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 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).