From: Shivendra Pratap <shivendra.pratap@oss.qualcomm.com>
To: Lorenzo Pieralisi <lpieralisi@kernel.org>
Cc: Arnd Bergmann <arnd@arndb.de>,
Bjorn Andersson <andersson@kernel.org>,
Sebastian Reichel <sre@kernel.org>, Rob Herring <robh@kernel.org>,
Souvik Chakravarty <Souvik.Chakravarty@arm.com>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Andy Yan <andy.yan@rock-chips.com>,
Matthias Brugger <matthias.bgg@gmail.com>,
Mark Rutland <mark.rutland@arm.com>,
Conor Dooley <conor+dt@kernel.org>,
Konrad Dybcio <konradybcio@kernel.org>,
John Stultz <john.stultz@linaro.org>,
Moritz Fischer <moritz.fischer@ettus.com>,
Bartosz Golaszewski <brgl@kernel.org>,
Sudeep Holla <sudeep.holla@kernel.org>,
Florian Fainelli <florian.fainelli@broadcom.com>,
Krzysztof Kozlowski <krzk@kernel.org>,
Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>,
Mukesh Ojha <mukesh.ojha@oss.qualcomm.com>,
Andre Draszik <andre.draszik@linaro.org>,
Kathiravan Thirumoorthy
<kathiravan.thirumoorthy@oss.qualcomm.com>,
linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org,
Srinivas Kandagatla <srini@kernel.org>
Subject: Re: [PATCH v20 04/10] firmware: psci: Introduce command-based reset in psci_sys_reset
Date: Tue, 31 Mar 2026 23:08:49 +0530 [thread overview]
Message-ID: <96079c7d-647f-4843-b847-b1e50e3c7ad3@oss.qualcomm.com> (raw)
In-Reply-To: <acaPCJnX6lb9lxPy@lpieralisi>
On 27-03-2026 19:37, Lorenzo Pieralisi wrote:
> On Wed, Mar 04, 2026 at 11:33:04PM +0530, Shivendra Pratap wrote:
>> PSCI currently supports only COLD reset and ARCH WARM reset based on the
>> Linux reboot_mode variable. The PSCI specification now includes
>> SYSTEM_RESET2 for vendor-specific resets, but there's no mechanism to
>> issue these through psci_sys_reset.
>>
>> Add a command-based reset mechanism that allows external drivers to set
>> the psci reset command via a new psci_set_reset_cmd() function.
>>
>> The psci command-based reset is disabled by default and the
>> psci_sys_reset follows its original flow until a psci_reset command is
>> set. In kernel panic path, psci_reset command is ignored.
>
> If it is function calls you should add parenthesis (eg psci_sys_reset ->
> psci_sys_reset()).
>
> You must explain why the kernel panic path requires separate handling
> here AND in the code - think about looking at this years down the line
> and figure out why kernel panics are special here.
Ack.
>
>> Signed-off-by: Shivendra Pratap <shivendra.pratap@oss.qualcomm.com>
>> ---
>> drivers/firmware/psci/psci.c | 45 ++++++++++++++++++++++++++++++++++++++++++--
>> include/linux/psci.h | 2 ++
>> 2 files changed, 45 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c
>> index 38ca190d4a22d6e7e0f06420e8478a2b0ec2fe6f..ae6f7a0aead913d740070080d4b2a3da15b29485 100644
>> --- a/drivers/firmware/psci/psci.c
>> +++ b/drivers/firmware/psci/psci.c
>> @@ -51,6 +51,15 @@ static int resident_cpu = -1;
>> struct psci_operations psci_ops;
>> static enum arm_smccc_conduit psci_conduit = SMCCC_CONDUIT_NONE;
>>
>> +struct psci_sys_reset_params {
>> + u32 system_reset;
>> + u32 reset_type;
>> + u32 cookie;
>> + bool cmd;
>> +};
>> +
>> +static struct psci_sys_reset_params psci_reset;
>> +
>> bool psci_tos_resident_on(int cpu)
>> {
>> return cpu == resident_cpu;
>> @@ -80,6 +89,28 @@ static u32 psci_cpu_suspend_feature;
>> static bool psci_system_reset2_supported;
>> static bool psci_system_off2_hibernate_supported;
>>
>> +/**
>> + * psci_set_reset_cmd - Sets the psci_reset_cmd for command-based
>> + * reset which will be used in psci_sys_reset call.
>> + *
>> + * @cmd_sys_rst2: Set to true for SYSTEM_RESET2 based resets.
>> + * @cmd_reset_type: Set the reset_type argument for psci_sys_reset.
>> + * @cmd_cookie: Set the cookie argument for psci_sys_reset.
>> + */
>> +void psci_set_reset_cmd(bool cmd_sys_rst2, u32 cmd_reset_type, u32 cmd_cookie)
>> +{
>
> I don't think cmd_sys_rst2 is needed, as a replied in a different thread.
Need bit more clarification. The issue is that at some point we need to
decide - sys_rst2 or the reboot_mode based reset. Are you suggesting
that this check should be in psci driver instead of a pre-check in
psci_reboot_mode driver?
>
>> + if (cmd_sys_rst2 && psci_system_reset2_supported) {
>> + psci_reset.system_reset = PSCI_FN_NATIVE(1_1, SYSTEM_RESET2);
>> + psci_reset.reset_type = cmd_reset_type;
>> + psci_reset.cookie = cmd_cookie;
>> + } else {
>> + psci_reset.system_reset = PSCI_0_2_FN_SYSTEM_RESET;
>> + psci_reset.reset_type = 0;
>> + psci_reset.cookie = 0;
>> + }
>> + psci_reset.cmd = true;
>> +}
>> +
>> static inline bool psci_has_ext_power_state(void)
>> {
>> return psci_cpu_suspend_feature &
>> @@ -309,14 +340,24 @@ static int get_set_conduit_method(const struct device_node *np)
>> static int psci_sys_reset(struct notifier_block *nb, unsigned long action,
>> void *data)
>> {
>> - if ((reboot_mode == REBOOT_WARM || reboot_mode == REBOOT_SOFT) &&
>> - psci_system_reset2_supported) {
>> + if (((reboot_mode == REBOOT_WARM || reboot_mode == REBOOT_SOFT) &&
>> + psci_system_reset2_supported) && (panic_in_progress() || !psci_reset.cmd)) {
>> /*
>> * reset_type[31] = 0 (architectural)
>> * reset_type[30:0] = 0 (SYSTEM_WARM_RESET)
>> * cookie = 0 (ignored by the implementation)
>> */
>> invoke_psci_fn(PSCI_FN_NATIVE(1_1, SYSTEM_RESET2), 0, 0, 0);
>> + } else if (!panic_in_progress() && psci_reset.cmd) {
>> + /*
>> + * Commands are being set in psci_set_reset_cmd
>> + * This issues, SYSTEM_RESET2 arch warm reset or
>> + * SYSTEM_RESET2 vendor-specific reset or
>> + * a SYSTEM_RESET cold reset in accordance with
>> + * the reboot-mode command.
>> + */
>> + invoke_psci_fn(psci_reset.system_reset, psci_reset.reset_type,
>> + psci_reset.cookie, 0);
>> } else {
>> invoke_psci_fn(PSCI_0_2_FN_SYSTEM_RESET, 0, 0, 0);
>
> This is very hard to parse. IMO, what you should do is:
>
> - Split this into two different paths: reboot_mode vs psci_reset.cmd == true.
> - Document very clearly why a panic needs separate handling.
>
> Something like:
>
> if (psci_reset.cmd)
> handle_reset_cmd();
> else
> handle_reboot_mode();
>
> I don't think we are far from converging but I want to be able to maintain
> this code going forward.
Ack. Will restructure it as suggested.
thanks,
Shivendra
next prev parent reply other threads:[~2026-03-31 17:39 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-04 18:03 [PATCH v20 00/10] Implement PSCI reboot mode driver for PSCI resets Shivendra Pratap
2026-03-04 18:03 ` [PATCH v20 01/10] power: reset: reboot-mode: Remove devres based allocations Shivendra Pratap
2026-03-05 10:05 ` Bartosz Golaszewski
2026-03-11 9:21 ` Sebastian Reichel
2026-03-12 8:54 ` Shivendra Pratap
2026-04-01 15:19 ` Krzysztof Kozlowski
2026-04-02 6:15 ` Shivendra Pratap
2026-03-04 18:03 ` [PATCH v20 02/10] power: reset: reboot-mode: Add support for 64 bit magic Shivendra Pratap
2026-03-11 9:22 ` Sebastian Reichel
2026-03-04 18:03 ` [PATCH v20 03/10] power: reset: reboot-mode: Add support for predefined reboot modes Shivendra Pratap
2026-03-11 9:22 ` Sebastian Reichel
2026-03-04 18:03 ` [PATCH v20 04/10] firmware: psci: Introduce command-based reset in psci_sys_reset Shivendra Pratap
2026-03-27 14:07 ` Lorenzo Pieralisi
2026-03-31 17:38 ` Shivendra Pratap [this message]
2026-03-04 18:03 ` [PATCH v20 05/10] dt-bindings: arm: Document reboot mode magic Shivendra Pratap
2026-03-04 18:03 ` [PATCH v20 06/10] power: reset: Add psci-reboot-mode driver Shivendra Pratap
2026-03-05 10:02 ` Bartosz Golaszewski
2026-03-05 17:06 ` Shivendra Pratap
2026-03-06 13:32 ` Bartosz Golaszewski
2026-03-27 14:08 ` Lorenzo Pieralisi
2026-03-27 14:09 ` Bartosz Golaszewski
2026-03-27 13:55 ` Lorenzo Pieralisi
2026-03-27 13:59 ` Bartosz Golaszewski
2026-03-31 18:00 ` Shivendra Pratap
2026-04-01 14:37 ` Lorenzo Pieralisi
2026-04-01 14:56 ` Arnd Bergmann
2026-04-02 18:38 ` Shivendra Pratap
2026-04-02 18:35 ` Shivendra Pratap
2026-04-03 15:50 ` Lorenzo Pieralisi
2026-04-03 17:45 ` Shivendra Pratap
2026-03-27 14:14 ` Lorenzo Pieralisi
2026-03-31 17:40 ` Shivendra Pratap
2026-03-04 18:03 ` [PATCH v20 07/10] arm64: dts: qcom: qcm6490: Add psci reboot-modes Shivendra Pratap
2026-03-05 10:57 ` Konrad Dybcio
2026-03-04 18:03 ` [PATCH v20 08/10] arm64: dts: qcom: lemans: " Shivendra Pratap
2026-03-05 11:33 ` Konrad Dybcio
2026-03-05 17:52 ` Shivendra Pratap
2026-03-04 18:03 ` [PATCH v20 09/10] arm64: dts: qcom: monaco: " Shivendra Pratap
2026-03-04 18:03 ` [PATCH v20 10/10] arm64: dts: qcom: talos: " Shivendra Pratap
2026-04-06 7:36 ` [PATCH v20 00/10] Implement PSCI reboot mode driver for PSCI resets Pankaj Patil
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=96079c7d-647f-4843-b847-b1e50e3c7ad3@oss.qualcomm.com \
--to=shivendra.pratap@oss.qualcomm.com \
--cc=Souvik.Chakravarty@arm.com \
--cc=andersson@kernel.org \
--cc=andre.draszik@linaro.org \
--cc=andy.yan@rock-chips.com \
--cc=arnd@arndb.de \
--cc=brgl@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dmitry.baryshkov@oss.qualcomm.com \
--cc=florian.fainelli@broadcom.com \
--cc=john.stultz@linaro.org \
--cc=kathiravan.thirumoorthy@oss.qualcomm.com \
--cc=konradybcio@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=krzk@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=lpieralisi@kernel.org \
--cc=mark.rutland@arm.com \
--cc=matthias.bgg@gmail.com \
--cc=moritz.fischer@ettus.com \
--cc=mukesh.ojha@oss.qualcomm.com \
--cc=robh@kernel.org \
--cc=sre@kernel.org \
--cc=srini@kernel.org \
--cc=sudeep.holla@kernel.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