Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp1273273rdb; Mon, 19 Feb 2024 09:29:41 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCX6D/qb9JugiIg1WjZjNsb6DuaSgqT9qUdlq88GZUty9xaYqH64nZRXT0s0XHdl/TGAV4z5aW5+qHFBSGBtVnW0KxXAe9PT8OCfJ2cymQ== X-Google-Smtp-Source: AGHT+IF9Ufmc2Jdrs4lqayTMnYuLAymPTy5JX02u3+asV4dY/Yah5IH4Fx2FIfIGDu0mgnCRB/92 X-Received: by 2002:a17:906:2785:b0:a3e:b523:6c8 with SMTP id j5-20020a170906278500b00a3eb52306c8mr1306385ejc.67.1708363781506; Mon, 19 Feb 2024 09:29:41 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708363781; cv=pass; d=google.com; s=arc-20160816; b=FQ2cTEu03XWOJbQ8pMFeNbotYxwP00NgJh2hlRDP74NMQsipKxoqrtXJO8xrsR472J nE+S7LdGyiZCbKKej1AGWv8dei1BkrrjyAZ9HlUddPpuAn1MvT43xy4do3xdD63onAse Jrbr1xfKuloINDbJL8H5tAVFis8r0dlEjMO1rbtEMiVQBie9PDs+EAoSdHYiTBh4+XJf Iyi/2N/ERv9hYRByo3aLLkvR5h1N0BJj6SzdeFEcnPtEDn9nsJHH2cS99+l6xC0sWcZa QYzAZTV3uR6uperCWiAZwJiaBTJfb2J9c0fbHlYYVaQn8jfAgi1T0gV9ynzR6yr9KfO3 MjXg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=q3WgJrNc1pvjrp3RJMNkml2IKlx+aTdhdShCj0KAAJg=; fh=AtTlbxz/XKO1h+CFEtDeSCqI3RM/eWaNdQbf/d6pRCE=; b=XuN6FFbUnvhGQk4OIwvfPTqFlQDc5eiprMjtF2Tf3IRrHoyVig7Re21u/HI5QaZyBX 31+gC2tGpu+9wGcAuDdbMgwAnsnN0hukrqctvLLBKA+nWRjwB66SoRSP8hL7450PESuZ Q8JM8A4AtZzAKuaiRVYKhTIU+E0gydQYDEty5FTEcAMskzQhIJVpjJpO4VlAMYJedInH 32mFvBNEPQtRcaNE1A4NouLwSEvClCNxP6wY5WOQsL6WPq3cjmNlvyu9hLsJ04xtjpi6 zogQZ8g7biGIgH7imo+oQ1G5e5t82lEFBOdGIXF4VZ8Y+0ixju2+ut+Uy0Y7IjVhpyzY ra7Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=GE770cYs; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-71760-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71760-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id bq25-20020a170906d0d900b00a3e52f4dca8si1733098ejb.537.2024.02.19.09.29.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Feb 2024 09:29:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-71760-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=GE770cYs; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-71760-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71760-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 455AB1F22086 for ; Mon, 19 Feb 2024 17:29:41 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6139445BE4; Mon, 19 Feb 2024 17:29:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="GE770cYs" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 66DA425566; Mon, 19 Feb 2024 17:29:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708363756; cv=none; b=cYh3KQkt6BD31rHmATOQSnIfbIju7FT21qR4ryRjN+1NO6qKvtYXkqZEnH+chAZMYoOx1smr+Mryg3oVamwR9iaNmws4nCne4uPKlbPTgW0UOMlqi+bHHc8y3lQDL4tT/6Y5N/ngmOeY1mChGMm3A9JYAk8h/dORuHL/lqwGFHc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708363756; c=relaxed/simple; bh=HDOUgL6Y0nc7IvKBPLbbUpZK2qQlAnpDmaaG/SLeRF0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=L1iPQzRqBxKR8sx11JYoJR7cScv7h4eJC+a3VZDey26upiybbYNXewKyll/ZgEADvpixsQZvCc49BwAUrLs/kS3HM5bngsDb/MFIRS3bD34zVTKfMAYPl8VdDy6WCOmrZhOSMA40GlXlyzAH/0jTWVr+HiZgFrDNAULfnslSvZE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=GE770cYs; arc=none smtp.client-ip=10.30.226.201 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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 > --- > 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 >