From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6C855C48BF8 for ; Mon, 19 Feb 2024 17:29:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=YbxGuHnYd60a2E69ByCElpTFUsI77hG5NbNyCDZ1qFw=; b=wHxUkMBS5Jpyc0 p7bJ4OyEHS/yII9LbivHcrJMO0U2Fl5LyEHEtdZKuh3Mk/IfDjpK0aTP8EByyFfcCOfCgqLL47Sfl +8SA7NZxj4NEYBq0kBNXQ8uU0bAEH3r0NwJRxU3J1uZAqg1xbm0FyM0/nMKHIXjcPZfSLqC7RPFNb 1xVsqHQyVBchxO2j1l2vxLEfViExS/Mh3kR+xv0co/jUDR2/r9MQsHfUElbJi3e6VfdjFWBlNnCaN lSIZf01svFqf15keTXPn7EN1URuRTt9rYrSlHYpGnrUV/dlyF3MexwXBPksj8UKBrlepwtoEpqAlS HV918xmvDJKF9ENoW4HQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rc7SD-0000000BWHe-2J6F; Mon, 19 Feb 2024 17:29:21 +0000 Received: from sin.source.kernel.org ([145.40.73.55]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rc7SB-0000000BWGQ-2ald for linux-arm-kernel@lists.infradead.org; Mon, 19 Feb 2024 17:29:21 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id B18B5CE12F0; Mon, 19 Feb 2024 17:29:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5D434C433F1; Mon, 19 Feb 2024 17:29:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708363756; bh=HDOUgL6Y0nc7IvKBPLbbUpZK2qQlAnpDmaaG/SLeRF0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=GE770cYsLQOhGWHmeW4Wg45pDEMxw26SbCB7J9GSGeTl7xQsE9XqhdyPsSDWl1Zx3 GkLul7ypkIJvVGKOnIDIlmwNi8Q+VnTopWh448gGGS5T4pP9gJuH89xqr118L7d1l+ obyKh8WkVuV6gjlzFMVRklxXAY53JPCpTT8xRRQlccCm2IQW+xOklWfRPJqQsSsPKl jX+pEMjurC+jfEYSlBBVtis0nu2adzeOz5r3PlYClT5iggsaVZ/Iw8rNmvz8fOtJv2 /KGOTaFj8QTc8l5D2mo7mpGYFBC2DwW7mT6IMbPFGcR+H8eiJ7B64HfaZCJtDbhn8w dXFebOuUKJu9A== Date: Mon, 19 Feb 2024 18:29:10 +0100 From: Lorenzo Pieralisi To: Maulik Shah Cc: Mark Rutland , 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() Message-ID: References: <20240219-suspend_ops_late_init-v1-1-6330ca9597fa@quicinc.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20240219-suspend_ops_late_init-v1-1-6330ca9597fa@quicinc.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240219_092920_027043_2A586E32 X-CRM114-Status: GOOD ( 22.86 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 > --- > 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 > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel