From nobody Mon Nov 25 09:52:52 2024 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 530F21DA631; Mon, 28 Oct 2024 14:23:08 +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=1730125388; cv=none; b=H2kVzgIAwFN8zLPbf5t+tRKjg0q41QlhUTWfEGRYEK/mAo0R7oXtuXCL6VNLf15HFjFZ5qrWWQPci5tYtKVzZlrmRN93niUS9NQDOoUeX3yBNM33C1tvm5rzJ6wMWsQtH4V0/5p/+9K2c+2XxdqrWGkA9CqE4o5D7F7CP0ppI+U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730125388; c=relaxed/simple; bh=70JpgkYvN9YM24Jz+FtvScOfqAM/jZI33kSB5+f8jrI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=HT2BEox6k6gdv2Z5FMOcFw+agzM/OVEXSPUZSODeCt/Ecr7vfcA7ro+uaPY/4opQGNXdb8QJVq1s2iTlky5AdnEQrBJFk7wCiMshC1WKh/bBQ7ldyg2AKjfS49QqTS1TbWyFFOePNPGLHv88AC7LbMeDq/Wt958oEK37QCPxlRI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=uWoduNTd; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="uWoduNTd" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C4680C4CECD; Mon, 28 Oct 2024 14:23:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1730125388; bh=70JpgkYvN9YM24Jz+FtvScOfqAM/jZI33kSB5+f8jrI=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=uWoduNTdbhD9TXD1VwGSVhid/JfbNZDhhSTtQ+Zs3ioRGg6tvVfDDsO7n6Ybo/UJl NsxIokqQOYhAL4WSF2svmo6fDJ32xwI3BhJ4nntHQH/9m04sMJzuX8t4AytmOrUT6S IxWlHolrSrED7yOnX/7n39zdEROIZr2p1dIlWx7wY+W7sUA86CfxB2bGLD+pOaaf6A banm0ijjslbav+xsnj1utuXglFa/F/XmiZcKG1MexyAYqAZyvIQH0RfdF7NOp1l8JX pN++CrTWodTvybBb9bEtYQ6Taw6kleIsLkJw3qOrLTxSI2wILjGwQQQgLV2ktbpqE8 GOTAT3N1G8tKw== From: Konrad Dybcio Date: Mon, 28 Oct 2024 15:22:57 +0100 Subject: [PATCH 1/3] dt-bindings: arm,psci: Allow S2RAM power_state parameter description 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="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20241028-topic-cpu_suspend_s2ram-v1-1-9fdd9a04b75c@oss.qualcomm.com> References: <20241028-topic-cpu_suspend_s2ram-v1-0-9fdd9a04b75c@oss.qualcomm.com> In-Reply-To: <20241028-topic-cpu_suspend_s2ram-v1-0-9fdd9a04b75c@oss.qualcomm.com> To: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Lorenzo Pieralisi , Mark Rutland Cc: Marijn Suijten , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Bjorn Andersson , Konrad Dybcio X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1730125380; l=1434; i=konrad.dybcio@oss.qualcomm.com; s=20230215; h=from:subject:message-id; bh=qowdcUV0IcXfH3TE+fGW1N5ucMJrGFxOqfTc+GjqJNE=; b=PkrsrLQrYHBH3Z0pNaW3PK242z+Gnl0VhBs6CQJrIOlHjhysAG9+Zc9b2RC7ghkCCjFg5lCTT bin1KT4oKNJA+UZHJeDOPleGn5YYe0DX/fXojY3JnSxnRIA+8yqJTag X-Developer-Key: i=konrad.dybcio@oss.qualcomm.com; a=ed25519; pk=iclgkYvtl2w05SSXO5EjjSYlhFKsJ+5OSZBjOkQuEms= From: Konrad Dybcio Certain firmware implementations (such as the ones found on Qualcomm SoCs between roughly 2015 and 2023) expose an S3-like S2RAM state through the CPU_SUSPEND call, as opposed to exposing PSCIv1.0's optional PSCI_SYSTEM_SUSPEND. This really doesn't work well with the model where we associate all calls to CPU_SUSPEND with cpuidle. Allow specifying a single special CPU_SUSPEND suspend parameter value that is to be treated just like SYSTEM_SUSPEND from the OS's point of view. Signed-off-by: Konrad Dybcio --- Documentation/devicetree/bindings/arm/psci.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Documentation/devicetree/bindings/arm/psci.yaml b/Documentatio= n/devicetree/bindings/arm/psci.yaml index cbb012e217ab80c1ca88e611e7acc06c6d56fad0..a6901878697c8e1ec1cbfed6229= 8ae3bc58f2501 100644 --- a/Documentation/devicetree/bindings/arm/psci.yaml +++ b/Documentation/devicetree/bindings/arm/psci.yaml @@ -98,6 +98,12 @@ properties: [1] Kernel documentation - ARM idle states bindings Documentation/devicetree/bindings/cpu/idle-states.yaml =20 + arm,psci-s2ram-param: + $ref: /schemas/types.yaml#/definitions/uint32 + description: + power_state parameter denoting the S2RAM/S3-like system suspend state + maxItems: 1 + patternProperties: "^power-domain-": $ref: /schemas/power/power-domain.yaml# --=20 2.47.0 From nobody Mon Nov 25 09:52:52 2024 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 A5CB41DE3D6; Mon, 28 Oct 2024 14:23:12 +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=1730125392; cv=none; b=F76Cuw5zO9mXGAUyiGRiGqOR9MEghrNEefYrp+lNmjzDNcdkntvDHc4E+hPM9e4h6oyjg8rHWfmvoDCxSvxKkOZWEem2kolVszUi0clW9MjTWeEmQPIqTd4zpa1FEF0ojX+pwVn9kU2wwskSwZRvaj2frh2T5YQGGP1//ZCso2M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730125392; c=relaxed/simple; bh=INIyxIjyW8dZrymPTrJki0+QEIhN5rfp5OXIveeeXZ0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Wafxqr2prYQ2YB5fuFbbByg3Bbh0mGGAIy99ymhFyRqvDJazhQRdmYjmY+bB3gA1UBYdv3far0IEQWpr1RaPQ0tx6y+WAiAIep78n/6zCxd6bOFNvhmhGsXMZCExCD+rSrbtqIdzxoWWIYAkvzrvUnRZHSQM7K0T8SqxFHEOrpA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=jJ2f9wPs; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="jJ2f9wPs" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B58B3C4CEE8; Mon, 28 Oct 2024 14:23:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1730125392; bh=INIyxIjyW8dZrymPTrJki0+QEIhN5rfp5OXIveeeXZ0=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=jJ2f9wPsfrE+3WverENvTtoDPFfJmQyO1YYV46otysBHoQkrDQ2LSKZfoA5L5qju4 Zc0rx+1EQtCOXtkw1hlSTfDUDTPj8y2xH56BUB18XzAI2BFL/qwAeM/g+yv8YoluYl kL5zNLidcdx7h+lqz/o2Pv6MzLCyHtHwBup4AMq8o0aRA5kfbR6vwI2gpoCb+QuGEJ B7cs2vBEe17JVwULTELVB8YgA2/x/b+efJ6oiUZwp/emdJ09HI/DO49eJ+C1IUDeMD CCeuPSTY1jXexgHkvLvTYKhReHQA0VGzVz1D55YRMUrPaDCMTPQeIF04nBTqfJZktg GPWif56YlStwg== From: Konrad Dybcio Date: Mon, 28 Oct 2024 15:22:58 +0100 Subject: [PATCH 2/3] firmware/psci: Set pm_set_resume/suspend_via_firmware() for SYSTEM_SUSPEND 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="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20241028-topic-cpu_suspend_s2ram-v1-2-9fdd9a04b75c@oss.qualcomm.com> References: <20241028-topic-cpu_suspend_s2ram-v1-0-9fdd9a04b75c@oss.qualcomm.com> In-Reply-To: <20241028-topic-cpu_suspend_s2ram-v1-0-9fdd9a04b75c@oss.qualcomm.com> To: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Lorenzo Pieralisi , Mark Rutland Cc: Marijn Suijten , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Bjorn Andersson , Konrad Dybcio , Sudeep Holla , Konrad Dybcio X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1730125380; l=1306; i=konrad.dybcio@oss.qualcomm.com; s=20230215; h=from:subject:message-id; bh=INIyxIjyW8dZrymPTrJki0+QEIhN5rfp5OXIveeeXZ0=; b=hEJdSTloRMtioiwdZulRfEu6ZrNIJW/pFqzZKFYyiI1neblGkpxAW34SRPduGpLKNGaZLn5Dx 8UHBjCVaPk5Cet6SNHK/H7Pzfc47zOOWQ+8V6z1TwP6LpSXQ8RsXjCU X-Developer-Key: i=konrad.dybcio@oss.qualcomm.com; a=ed25519; pk=iclgkYvtl2w05SSXO5EjjSYlhFKsJ+5OSZBjOkQuEms= Some device drivers are curious to know whether "the firmware" (which is often assumed to be ACPI) takes care of suspending or resuming the platform. Set the flag that reports this behavior if SYSTEM_SUSPEND is implemented. Signed-off-by: Konrad Dybcio Reviewed-by: Sudeep Holla --- drivers/firmware/psci/psci.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c index 2328ca58bba61fdb677ac20a1a7447882cd0cf22..0e622aa5ad58bbe69dfc3a71bce= d597618e73f15 100644 --- a/drivers/firmware/psci/psci.c +++ b/drivers/firmware/psci/psci.c @@ -507,12 +507,22 @@ static int psci_system_suspend(unsigned long unused) =20 static int psci_system_suspend_enter(suspend_state_t state) { + pm_set_resume_via_firmware(); + return cpu_suspend(0, psci_system_suspend); } =20 +static int psci_system_suspend_begin(suspend_state_t state) +{ + pm_set_suspend_via_firmware(); + + return 0; +} + static const struct platform_suspend_ops psci_suspend_ops =3D { .valid =3D suspend_valid_only_mem, .enter =3D psci_system_suspend_enter, + .begin =3D psci_system_suspend_begin, }; =20 static void __init psci_init_system_reset2(void) --=20 2.47.0 From nobody Mon Nov 25 09:52:52 2024 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 6B1D21DE4FF; Mon, 28 Oct 2024 14:23: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=1730125396; cv=none; b=XvJTpYYJndRyf8NsvAz76r/ycgGKtq7JQ0vF9isMCAWg/IswUAMYXjiJ4mVo9sC83FwIO/NaqEr6LM0byfkWl8XGxbzkRuJMmsIKFdb38o+g86YwDvHoLA08MXHDGFSjQ8PdsFV/mZ26zqdlxdKyVipyblTPHBg+rm3LeHyDTwA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730125396; c=relaxed/simple; bh=yl7Mfs856g30vpNRTxQo0XG82uyk/8hEkmCtSRgI5BE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=IfnCXTkfyQkDPbqtVodjM/VTJHuquKW9J5ZD7YJ/NZt7H1k65tqLLcL4CphNM39+mPZUvJLN8hXjEFXv6LW2jOcv31/0Hw/MjDJLop+yh9fVJFBaHYy6iwSRgV4PHl6xq0//l7PvRJJcgEPpcIJGeCb/Z29EygmwUXBz7xg3DIQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Mffzb+IZ; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Mffzb+IZ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D1E12C4CEE7; Mon, 28 Oct 2024 14:23:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1730125396; bh=yl7Mfs856g30vpNRTxQo0XG82uyk/8hEkmCtSRgI5BE=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Mffzb+IZ/0b3uzci/Q0aZsGlREKdAflGhK9yFluzbPp8ILpQeFqZJV4CKWQQGMrgR NyxCydIX83gVfMkZMPYQWFWG2I8ndKIvBI7qiSNo9VgdKlTMA6rtAV6SoX0Uy1OVWj VuKuaH6lnzLvE6T5rC29dD0NgdxQ6alkw++42ZfhGUJn6JdKgNd1ElrcxGpTj8trd0 FkgNAM1zS0vjT3bF9g9RW0AsMWWvKka85fcAK2KFGRgKXtNQVabkyuYNaBEv8Pos5m dx6HuPQnKUUap8JUH07gFuhmBGtiOrvlCDdkZIlGDWWahkxj/BQsprRgdwsrrVGZS7 jHZtTG1POO0Fg== From: Konrad Dybcio Date: Mon, 28 Oct 2024 15:22:59 +0100 Subject: [PATCH 3/3] firmware/psci: Allow specifying an S2RAM state through CPU_SUSPEND 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="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20241028-topic-cpu_suspend_s2ram-v1-3-9fdd9a04b75c@oss.qualcomm.com> References: <20241028-topic-cpu_suspend_s2ram-v1-0-9fdd9a04b75c@oss.qualcomm.com> In-Reply-To: <20241028-topic-cpu_suspend_s2ram-v1-0-9fdd9a04b75c@oss.qualcomm.com> To: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Lorenzo Pieralisi , Mark Rutland Cc: Marijn Suijten , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Bjorn Andersson , Konrad Dybcio X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1730125380; l=3714; i=konrad.dybcio@oss.qualcomm.com; s=20230215; h=from:subject:message-id; bh=Bf2hbCxvBem19Ny5a2acnQioUv9USzkxEe/DauTX7oc=; b=FlN28QeiFZU8O2MvaHh0SMZln2dKNtdGQHi7Hs7jxj9PC3ah05CBwHvJH95lZGaASdtMNjQLk 1fNmg0+xUfyDeRqvE0W40TGGMjzDjMITQEIDQ9a0cduZox0+iTIK7WH X-Developer-Key: i=konrad.dybcio@oss.qualcomm.com; a=ed25519; pk=iclgkYvtl2w05SSXO5EjjSYlhFKsJ+5OSZBjOkQuEms= From: Konrad Dybcio Certain firmware implementations (such as the ones found on Qualcomm SoCs between roughly 2015 and 2023) expose an S3-like S2RAM state through the CPU_SUSPEND call. This works exactly like SYSTEM_SUSPEND. The PSCI spec describes that call as optional (and only introduced in PSCIv1.0), so not all platforms expose it. Marking a DT-described "domain-idle-state" as such isn't currently well accounted for in the PSCI idle topology infrastructure: the cpuidle and genpd framework are deeply intertwined, and trying to separate them would cause more havoc than good. Instead, allow the specifying of a single CPU_SUSPEND sleep param under the /psci node that shall be treated exactly like SYSTEM_SUSPEND from Linux's POV. As a bonus, this way we also don't have to fight with the genpd idle governor to avoid taking the S3-like state into consideration. Signed-off-by: Konrad Dybcio --- drivers/firmware/psci/psci.c | 36 +++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c index 0e622aa5ad58bbe69dfc3a71bced597618e73f15..20ae6a6d59a9f276db75260b6ca= 1a5827e443782 100644 --- a/drivers/firmware/psci/psci.c +++ b/drivers/firmware/psci/psci.c @@ -78,6 +78,7 @@ struct psci_0_1_function_ids get_psci_0_1_function_ids(vo= id) =20 static u32 psci_cpu_suspend_feature; static bool psci_system_reset2_supported; +static u32 psci_s2ram_suspend_param; =20 static inline bool psci_has_ext_power_state(void) { @@ -519,10 +520,10 @@ static int psci_system_suspend_begin(suspend_state_t = state) return 0; } =20 -static const struct platform_suspend_ops psci_suspend_ops =3D { - .valid =3D suspend_valid_only_mem, - .enter =3D psci_system_suspend_enter, - .begin =3D psci_system_suspend_begin, +static const struct platform_suspend_ops psci_system_suspend_ops =3D { + .valid =3D suspend_valid_only_mem, + .enter =3D psci_system_suspend_enter, + .begin =3D psci_system_suspend_begin, }; =20 static void __init psci_init_system_reset2(void) @@ -545,7 +546,7 @@ static void __init psci_init_system_suspend(void) ret =3D psci_features(PSCI_FN_NATIVE(1_0, SYSTEM_SUSPEND)); =20 if (ret !=3D PSCI_RET_NOT_SUPPORTED) - suspend_set_ops(&psci_suspend_ops); + suspend_set_ops(&psci_system_suspend_ops); } =20 static void __init psci_init_cpu_suspend(void) @@ -673,6 +674,17 @@ static int __init psci_probe(void) =20 typedef int (*psci_initcall_t)(const struct device_node *); =20 +static int psci_cpu_suspend_s2ram_enter(suspend_state_t state) +{ + return psci_cpu_suspend_enter(psci_s2ram_suspend_param); +} + +static const struct platform_suspend_ops psci_cpu_suspend_s2ram_ops =3D { + .valid =3D suspend_valid_only_mem, + .enter =3D psci_cpu_suspend_s2ram_enter, + .begin =3D psci_system_suspend_begin, +}; + /* * PSCI init function for PSCI versions >=3D0.2 * @@ -686,6 +698,20 @@ static int __init psci_0_2_init(const struct device_no= de *np) if (err) return err; =20 + /* + * Some firmwares expose S2RAM entry through a custom suspend param. + * + * If found, register a suspend handler instead of registering the + * idle state with cpuidle. + */ + err =3D of_property_read_u32(np, "arm,psci-s2ram-param", &psci_s2ram_susp= end_param); + if (!err) { + suspend_set_ops(&psci_cpu_suspend_s2ram_ops); + } else if (err !=3D -EINVAL) { + pr_err("Couldn't read the S2RAM PSCI suspend param: %d\n", + psci_s2ram_suspend_param); + } + /* * Starting with v0.2, the PSCI specification introduced a call * (PSCI_VERSION) that allows probing the firmware version, so --=20 2.47.0