From: Lorenzo Pieralisi <lpieralisi@kernel.org>
To: Maulik Shah <quic_mkshah@quicinc.com>
Cc: Mark Rutland <mark.rutland@arm.com>,
andersson@kernel.org, ulf.hansson@linaro.org,
linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, linux-pm@vger.kernel.org,
quic_lsrao@quicinc.com, stable@vger.kernel.org
Subject: Re: [PATCH] firmware/psci: Move psci_init_system_suspend() to late_initcall()
Date: Mon, 19 Feb 2024 18:29:10 +0100 [thread overview]
Message-ID: <ZdOP5oAwZvEhNAsn@lpieralisi> (raw)
In-Reply-To: <20240219-suspend_ops_late_init-v1-1-6330ca9597fa@quicinc.com>
On Mon, Feb 19, 2024 at 03:02:04PM +0530, Maulik Shah wrote:
> psci_init_system_suspend() invokes suspend_set_ops() very early during
> bootup even before kernel command line for mem_sleep_default is setup.
> This leads to kernel command line mem_sleep_default=s2idle not working
> as mem_sleep_current gets changed to deep via suspend_set_ops() and never
> changes back to s2idle.
>
> Move psci_init_system_suspend() to late_initcall() to make sure kernel
> command line mem_sleep_default=s2idle sets up s2idle as default suspend
> mode.
Why can't we fix it the other way around, namely enforce
mem_sleep_current according to the mem_sleep_default command line
even if suspend_set_ops() was already called ?
Just asking, I am not super keen on using initcalls ordering, it
looks fragile to me.
Thanks,
Lorenzo
> Fixes: faf7ec4a92c0 ("drivers: firmware: psci: add system suspend support")
> CC: stable@vger.kernel.org # 5.15+
> Signed-off-by: Maulik Shah <quic_mkshah@quicinc.com>
> ---
> drivers/firmware/psci/psci.c | 13 ++++++++++---
> 1 file changed, 10 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c
> index d9629ff87861..655a2db70a67 100644
> --- a/drivers/firmware/psci/psci.c
> +++ b/drivers/firmware/psci/psci.c
> @@ -523,18 +523,26 @@ static void __init psci_init_system_reset2(void)
> psci_system_reset2_supported = true;
> }
>
> -static void __init psci_init_system_suspend(void)
> +static int __init psci_init_system_suspend(void)
> {
> int ret;
> + u32 ver;
>
> if (!IS_ENABLED(CONFIG_SUSPEND))
> - return;
> + return 0;
> +
> + ver = psci_0_2_get_version();
> + if (PSCI_VERSION_MAJOR(ver) < 1)
> + return 0;
>
> ret = psci_features(PSCI_FN_NATIVE(1_0, SYSTEM_SUSPEND));
>
> if (ret != PSCI_RET_NOT_SUPPORTED)
> suspend_set_ops(&psci_suspend_ops);
> +
> + return ret;
> }
> +late_initcall(psci_init_system_suspend)
>
> static void __init psci_init_cpu_suspend(void)
> {
> @@ -651,7 +659,6 @@ static int __init psci_probe(void)
> if (PSCI_VERSION_MAJOR(ver) >= 1) {
> psci_init_smccc();
> psci_init_cpu_suspend();
> - psci_init_system_suspend();
> psci_init_system_reset2();
> kvm_init_hyp_services();
> }
>
> ---
> base-commit: d37e1e4c52bc60578969f391fb81f947c3e83118
> change-id: 20240219-suspend_ops_late_init-27fb0b15baee
>
> Best regards,
> --
> Maulik Shah <quic_mkshah@quicinc.com>
>
next prev parent reply other threads:[~2024-02-19 17:29 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-19 9:32 [PATCH] firmware/psci: Move psci_init_system_suspend() to late_initcall() Maulik Shah
2024-02-19 17:29 ` Lorenzo Pieralisi [this message]
2024-02-20 5:48 ` Maulik Shah (mkshah)
2024-02-23 9:04 ` Dhruva Gole
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=ZdOP5oAwZvEhNAsn@lpieralisi \
--to=lpieralisi@kernel.org \
--cc=andersson@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=quic_lsrao@quicinc.com \
--cc=quic_mkshah@quicinc.com \
--cc=stable@vger.kernel.org \
--cc=ulf.hansson@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 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).