ARM PSCI: Add support for vendor-specific SYSTEM_RESET2
Subsystems (4)
v2 cover ARM PSCI: Add support for vendor-specific SYSTEM_RESET2
This patch adds support for vendor-specific SYSTEM_RESET2 to support Qualcomm target use cases of rebooting into a RAM dump download mode.
This patch series applies on top of [1].
[1]: https://lore.kernel.org/patchwork/cover/1185759/
Changes since v1:
- Address Sudeep's comments
Changes since RFC v2:
- None, tested on SM8250 MTP
Elliot Berman (3):
dt: psci: Add arm,psci-sys-reset2-type property
firmware: psci: Add support for dt-supplied SYSTEM_RESET2 type
arm64: dts: qcom: sm8250: Add vendor-specific PSCI system reset2 type
Documentation/devicetree/bindings/arm/psci.yaml | 5 +++++ arch/arm64/boot/dts/qcom/sm8250.dtsi | 1 + drivers/firmware/psci/psci.c | 22 ++++++++++++++++++---- include/uapi/linux/psci.h | 2 ++ 4 files changed, 26 insertions(+), 4 deletions(-)
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
PATCH v2 1/3 dt: psci: Add arm,psci-sys-reset2-type property
Some implementors of PSCI may relax the requirements of the PSCI architectural warm reset. In order to comply with PSCI specification, a different reset_type value must be used. The alternate PSCI SYSTEM_RESET2 may be used in all warm/soft reboot scenarios, replacing the architectural warm reset.
--- Documentation/devicetree/bindings/arm/psci.yaml | 5 +++++ 1 file changed, 5 insertions(+)
Documentation/devicetree/bindings/arm/psci.yaml +5 -0
@@ -102,6 +102,11 @@ properties: [1] Kernel documentation - ARM idle states bindings Documentation/devicetree/bindings/arm/idle-states.txt + arm,psci-sys-reset2-param: + $ref: /schemas/types.yaml#/definitions/uint32 + description: | + reset_param value to use during a warm or soft reboot. + "#power-domain-cells": description: The number of cells in a PM domain specifier as per binding in [3].
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
Re: [PATCH v2 1/3] dt: psci: Add arm,psci-sys-reset2-type property
Quoted 6 lines · Elliot Berman
Some implementors of PSCI may relax the requirements of the PSCI architectural warm reset. In order to comply with PSCI specification, a different
reset_typevalue must be used. The alternate PSCISYSTEM_RESET2may be used in all warm/soft reboot scenarios, replacing the architectural warm reset.
You forgot to update $subject accordingly. No need to respin for that now, unless you get any other comments.
Other than the $subject fix,
Signature · 2 lines
Regards, Sudeep
Mark Rutland
maintainerRe: [PATCH v2 1/3] dt: psci: Add arm,psci-sys-reset2-type property
In reply to Elliot BermanQuoted 3 lines · Elliot Berman
Some implementors of PSCI may relax the requirements of the PSCI architectural warm reset. In order to comply with PSCI specification, a different
reset_typevalue must be used.
This reads as-if you're saying the firmware isn't spec compliant, and this is a workaround in order to get the expected behaviour.
Can you please elaborate on what you mean by "relax the requirements" here? What's your firmware doing or not doing that you want to avoid?
Quoted 2 lines
The alternate PSCI
SYSTEM_RESET2may be used in all warm/soft reboot scenarios, replacing the architectural warm reset.
I assume you mean SYSTEM_REET2's SYSTEM_WARM_RESET reset? Please call that out explicitly by name -- it makes this easier to look up, and if/when more architectural resets are added the commit message won't become ambiguous.
Quoted 11 lines
Signed-off-by Elliot Berman <[email protected]>--- Documentation/devicetree/bindings/arm/psci.yaml | 5 +++++ 1 file changed, 5 insertions(+)Documentation/devicetree/bindings/arm/psci.yaml +0
-0
Documentation/devicetree/bindings/arm/psci.yaml properties: · line 108
Quoted 7 lines
Documentation/devicetree/bindings/arm/psci.yaml +4
-0@@ -102,6 +102,11 @@ properties: [1] Kernel documentation - ARM idle states bindings Documentation/devicetree/bindings/arm/idle-states.txt + arm,psci-sys-reset2-param: + $ref: /schemas/types.yaml#/definitions/uint32 + description: | + reset_param value to use during a warm or soft reboot.
A "soft" reboot isn't a PSCI concept, so I'm worried this is just hooking up magic values for Linux internals.
I'd like to better understand what you're trying to achieve here.
Thanks,
Mark.
Quoted 7 lines
Documentation/devicetree/bindings/arm/psci.yaml +1
-0+ "#power-domain-cells": description: The number of cells in a PM domain specifier as per binding in [3].Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
Re: [PATCH v2 1/3] dt: psci: Add arm,psci-sys-reset2-type property
Quoted 11 lines · Mark Rutland
Quoted 3 lines · Elliot Berman
Some implementors of PSCI may relax the requirements of the PSCI architectural warm reset. In order to comply with PSCI specification, a different
reset_typevalue must be used.This reads as-if you're saying the firmware isn't spec compliant, and this is a workaround in order to get the expected behaviour.
Can you please elaborate on what you mean by "relax the requirements" here? What's your firmware doing or not doing that you want to avoid?
Quoted 7 lines
Quoted 2 lines
The alternate PSCI
SYSTEM_RESET2may be used in all warm/soft reboot scenarios, replacing the architectural warm reset.I assume you mean SYSTEM_REET2's
SYSTEM_WARM_RESETreset? Please call that out explicitly by name -- it makes this easier to look up, and if/when more architectural resets are added the commit message won't become ambiguous.
I can reword to:
Some implementors of PSCI may wish to generally use a different reset type than SYSTEM_WARM_RESET. For instance, Qualcomm SoCs support an alternate reset_type which may be used in more warm reboot scenarios than SYSTEM_WARM_RESET permits (e.g. to reboot into recovery mode).
Quoted 15 lines
Quoted 15 lines
Signed-off-by Elliot Berman <[email protected]>--- Documentation/devicetree/bindings/arm/psci.yaml | 5 +++++ 1 file changed, 5 insertions(+)Documentation/devicetree/bindings/arm/psci.yaml +0
-0@@ -102,6 +102,11 @@ properties: [1] Kernel documentation - ARM idle states bindings Documentation/devicetree/bindings/arm/idle-states.txt
Quoted 8 lines
Documentation/devicetree/bindings/arm/psci.yaml properties: · line 108
Quoted 4 lines
Documentation/devicetree/bindings/arm/psci.yaml +4
-0+ arm,psci-sys-reset2-param: + $ref: /schemas/types.yaml#/definitions/uint32 + description: | + reset_param value to use during a warm or soft reboot.A "soft" reboot isn't a PSCI concept, so I'm worried this is just hooking up magic values for Linux internals.>
I'd like to better understand what you're trying to achieve here.
In Qualcomm use cases, we do not always want to preserve memory to caller's (i.e. Linux) exception level. For instance, crash recovery mode runs in higher exception level and would not continue booting into Linux except through a hard reset. Also, this early firmware doesn't have the ability to understand device tree or ACPI tables to know what memory to preserve.
Per discussion with Sudeep and Charles, this use case violates PSCI specification for SYSTEM_WARM_RESET reset type, but would be appropriate for a vendor-specific reset type. Thus, Qualcomm firmware supports a vendor-specific reset type which does not have the requirement to preserve memory to caller's EL or to describe what memory is to be preserved in DT or ACPI. If this vendor-specific reset type is used, then firmware checks various registers (e.g. download mode [1]) to alter the restart flow (e.g. to enter recovery mode). If no alternate flow is requested, then firmware would boot back into Linux, preserving memory.
Thanks,
Elliot
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
PATCH v2 2/3 firmware: psci: Add support for dt-supplied SYSTEM_RESET2 type
In reply to Elliot BermanSome implementors of PSCI may relax the requirements of the PSCI architectural warm reset. In order to comply with PSCI specification, a different reset_type value must be used. The alternate PSCI SYSTEM_RESET2 may be used in all warm/soft reboot scenarios, replacing the architectural warm reset.
--- drivers/firmware/psci/psci.c | 22 ++++++++++++++++++---- include/uapi/linux/psci.h | 2 ++ 2 files changed, 20 insertions(+), 4 deletions(-)
drivers/firmware/psci/psci.c +18 -4
@@ -90,6 +90,8 @@ static u32 psci_function_id[PSCI_FN_MAX];static u32 psci_cpu_suspend_feature;static bool psci_system_reset2_supported; +static u32 psci_sys_reset2_reset_param = +PSCI_1_1_SYSTEM_RESET2_SYSTEM_WARM_RESET ;static inline bool psci_has_ext_power_state (void ) {
@@ -272,11 +274,10 @@ static void psci_sys_reset(enum reboot_mode reboot_mode, const char *cmd)if ((reboot_mode ==REBOOT_WARM || reboot_mode ==REBOOT_SOFT ) && psci_system_reset2_supported) {/* -* 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); + invoke_psci_fn(PSCI_FN_NATIVE(1_1, SYSTEM_RESET2), + psci_sys_reset2_reset_param,0 ,0 ); }else {invoke_psci_fn (PSCI_0_2_FN_SYSTEM_RESET ,0 ,0 ,0 ); }
@@ -493,6 +494,7 @@ typedef int (*psci_initcall_t)(const struct device_node *);static int __init psci_0_2_init (struct device_node *np) {int err; +u32 param; err =get_set_conduit_method (np);if (err)
@@ -505,7 +507,19 @@ static int __init psci_0_2_init(struct device_node *np)* can be carried out according to the specific version reported * by firmware */ -return psci_probe (); + err =psci_probe (); +if (err) +return err; + +if (psci_system_reset2_supported && + !of_property_read_u32 (np,"arm,psci-sys-reset2-param" , ¶m)) { +if ((s32 )param >0 ) +pr_warn ("%08x is an invalid architectural reset type.\n" , + param); + psci_sys_reset2_reset_param = param; + } + +return 0 ; }/*
include/uapi/linux/psci.h +2 -0
@@ -55,6 +55,8 @@#define PSCI_1_0_FN64_SYSTEM_SUSPEND PSCI_0_2_FN64(14)#define PSCI_1_1_FN64_SYSTEM_RESET2 PSCI_0_2_FN64(18) +#define PSCI_1_1_SYSTEM_RESET2_SYSTEM_WARM_RESET 0 +/* PSCI v0.2 power state encoding for CPU_SUSPEND function */ #define PSCI_0_2_POWER_STATE_ID_MASK 0xffff#define PSCI_0_2_POWER_STATE_ID_SHIFT 0
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
Re: [PATCH v2 2/3] firmware: psci: Add support for dt-supplied SYSTEM_RESET2 type
Quoted 26 lines · Elliot Berman
Some implementors of PSCI may relax the requirements of the PSCI architectural warm reset. In order to comply with PSCI specification, a different
reset_typevalue must be used. The alternate PSCISYSTEM_RESET2may be used in all warm/soft reboot scenarios, replacing the architectural warm reset.Signed-off-by Elliot Berman <[email protected]>--- drivers/firmware/psci/psci.c | 22 ++++++++++++++++++---- include/uapi/linux/psci.h | 2 ++ 2 files changed, 20 insertions(+), 4 deletions(-)drivers/firmware/psci/psci.c +2
-0@@ -90,6 +90,8 @@ static u32 psci_function_id[PSCI_FN_MAX];static u32 psci_cpu_suspend_feature;static bool psci_system_reset2_supported; +static u32 psci_sys_reset2_reset_param = +PSCI_1_1_SYSTEM_RESET2_SYSTEM_WARM_RESET ;static inline bool psci_has_ext_power_state (void ) {
drivers/firmware/psci/psci.c static void psci_sys_reset(enum reboot_mode reboot_mode, const char *cmd) · line 276
Quoted 5 lines
drivers/firmware/psci/psci.c +0
-2@@ -272,11 +274,10 @@ static void psci_sys_reset(enum reboot_mode reboot_mode, const char *cmd)if ((reboot_mode ==REBOOT_WARM || reboot_mode ==REBOOT_SOFT ) && psci_system_reset2_supported) {/* -* reset_type[31] = 0 (architectural) -* reset_type[30:0] = 0 (SYSTEM_WARM_RESET)
Sorry for missing this earlier, you can move this comment above if others agree to not drop that info. I am fine with removing it too.
E
Quoted 18 lines
drivers/firmware/psci/psci.c +3
-1* cookie = 0 (ignored by the implementation) */ - invoke_psci_fn(PSCI_FN_NATIVE(1_1, SYSTEM_RESET2), 0, 0, 0); + invoke_psci_fn(PSCI_FN_NATIVE(1_1, SYSTEM_RESET2), + psci_sys_reset2_reset_param,0 ,0 ); }else {invoke_psci_fn (PSCI_0_2_FN_SYSTEM_RESET ,0 ,0 ,0 ); }@@ -493,6 +494,7 @@ typedef int (*psci_initcall_t)(const struct device_node *);static int __init psci_0_2_init (struct device_node *np) {int err; +u32 param; err =get_set_conduit_method (np);if (err)@@ -505,7 +507,19 @@ static int __init psci_0_2_init(struct device_node *np)* can be carried out according to the specific version reported
drivers/firmware/psci/psci.c static int __init psci_0_2_init(struct device_node *np) · line 516
Quoted 10 lines
drivers/firmware/psci/psci.c +7
-1* by firmware */ -return psci_probe (); + err =psci_probe (); +if (err) +return err; + +if (psci_system_reset2_supported && + !of_property_read_u32 (np,"arm,psci-sys-reset2-param" , ¶m)) { +if ((s32 )param >0 )
What is the point on signed comparison here ? You are assuming all vendor reset also as architecture by doing so which is wrong.
drivers/firmware/psci/psci.c static int __init psci_0_2_init(struct device_node *np) · line 518
Quoted 2 lines
drivers/firmware/psci/psci.c +2
-0+pr_warn ("%08x is an invalid architectural reset type.\n" , + param);
I thought the point was to have vendor reset here. Based on the 3/3 you see to have vendor reset bit set, you ignore that by doing signed comparison which is wrong and even the message is wrong. Specification defines only one architectural reset(WARM RESET) and all others need to be vendor specific.
--
Regards,
Sudeep
Re: [PATCH v2 2/3] firmware: psci: Add support for dt-supplied SYSTEM_RESET2 type
Quoted 33 lines · Sudeep Holla
Quoted 10 lines · Elliot Berman
drivers/firmware/psci/psci.c +1
-0@@ -493,6 +494,7 @@ typedef int (*psci_initcall_t)(const struct device_node *);static int __init psci_0_2_init (struct device_node *np) {int err; +u32 param; err =get_set_conduit_method (np);if (err)@@ -505,7 +507,19 @@ static int __init psci_0_2_init(struct device_node *np)* can be carried out according to the specific version reported drivers/firmware/psci/psci.c static int __init psci_0_2_init(struct device_node *np) · line 516
Quoted 10 lines
drivers/firmware/psci/psci.c +7
-1* by firmware */ -return psci_probe (); + err =psci_probe (); +if (err) +return err; + +if (psci_system_reset2_supported && + !of_property_read_u32 (np,"arm,psci-sys-reset2-param" , ¶m)) { +if ((s32 )param >0 )What is the point on signed comparison here ? You are assuming all vendor reset also as architecture by doing so which is wrong.
drivers/firmware/psci/psci.c static int __init psci_0_2_init(struct device_node *np) · line 518
Quoted 2 lines
drivers/firmware/psci/psci.c +2
-0+pr_warn ("%08x is an invalid architectural reset type.\n" , + param);I thought the point was to have vendor reset here. Based on the 3/3 you see to have vendor reset bit set, you ignore that by doing signed comparison which is wrong and even the message is wrong. Specification defines only one architectural reset(WARM RESET) and all others need to be vendor specific.
Quoted 4 lines
--
Regards,
Sudeep
I might've gone crazy, but all vendor-specific reset types would be negative when cast as s32. Thus the check returns true only for an invalid architectural reset type. I can switch to checking bits instead of using cast in v3 to avoid the confusion.
Alternatively, I could rename the DT property to "arm,psci-sys-reset2-vendor-param" and then always set the 31st bit so that it is impossible to provide an invalid architectural reset type in DT.
Let me know what is preferred.
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
Re: [PATCH v2 2/3] firmware: psci: Add support for dt-supplied SYSTEM_RESET2 type
On Tue, Feb 25, 2020 at 05:37:53PM -0800, Elliot Berman wrote:
[...]
Quoted 2 lines
Alternatively, I could rename the DT property to
"arm,psci-sys-reset2-vendor-param"
Yes much better.
Quoted 3 lines
and then always set the 31st bit so that it is impossible to provide an invalid architectural reset type in DT.
Indeed this is what I was expecting and hence raised issue here. So that one can't make use of architectural ID space just by adding param in DT.
--
Regards,
Sudeep
Re: [PATCH v2 2/3] firmware: psci: Add support for dt-supplied SYSTEM_RESET2 type
Quoted 9 lines · Sudeep Holla
On Tue, Feb 25, 2020 at 05:37:53PM -0800, Elliot Berman wrote:
[...]
Quoted 2 lines
Alternatively, I could rename the DT property to
"arm,psci-sys-reset2-vendor-param"Yes much better.
Just seconds after sending this I got a doubt as how is this being solved with ACPI. How is vendor specific reset achieved on ACPI system especially with other OSes ?
--
Regards,
Sudeep
Mark Rutland
maintainerRe: [PATCH v2 2/3] firmware: psci: Add support for dt-supplied SYSTEM_RESET2 type
In reply to Elliot BermanQuoted 5 lines · Elliot Berman
Some implementors of PSCI may relax the requirements of the PSCI architectural warm reset. In order to comply with PSCI specification, a different
reset_typevalue must be used. The alternate PSCISYSTEM_RESET2may be used in all warm/soft reboot scenarios, replacing the architectural warm reset.
As with the binding patch, this sounds like a workaround for a firmware bug. Can you please elaborate on what exactly your firmware does in this case?
Thanks,
Mark.
Quoted 79 lines
Signed-off-by Elliot Berman <[email protected]>--- drivers/firmware/psci/psci.c | 22 ++++++++++++++++++---- include/uapi/linux/psci.h | 2 ++ 2 files changed, 20 insertions(+), 4 deletions(-)drivers/firmware/psci/psci.c +18
-4@@ -90,6 +90,8 @@ static u32 psci_function_id[PSCI_FN_MAX];static u32 psci_cpu_suspend_feature;static bool psci_system_reset2_supported; +static u32 psci_sys_reset2_reset_param = +PSCI_1_1_SYSTEM_RESET2_SYSTEM_WARM_RESET ;static inline bool psci_has_ext_power_state (void ) {@@ -272,11 +274,10 @@ static void psci_sys_reset(enum reboot_mode reboot_mode, const char *cmd)if ((reboot_mode ==REBOOT_WARM || reboot_mode ==REBOOT_SOFT ) && psci_system_reset2_supported) {/* -* 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); + invoke_psci_fn(PSCI_FN_NATIVE(1_1, SYSTEM_RESET2), + psci_sys_reset2_reset_param,0 ,0 ); }else {invoke_psci_fn (PSCI_0_2_FN_SYSTEM_RESET ,0 ,0 ,0 ); }@@ -493,6 +494,7 @@ typedef int (*psci_initcall_t)(const struct device_node *);static int __init psci_0_2_init (struct device_node *np) {int err; +u32 param; err =get_set_conduit_method (np);if (err)@@ -505,7 +507,19 @@ static int __init psci_0_2_init(struct device_node *np)* can be carried out according to the specific version reported * by firmware */ -return psci_probe (); + err =psci_probe (); +if (err) +return err; + +if (psci_system_reset2_supported && + !of_property_read_u32 (np,"arm,psci-sys-reset2-param" , ¶m)) { +if ((s32 )param >0 ) +pr_warn ("%08x is an invalid architectural reset type.\n" , + param); + psci_sys_reset2_reset_param = param; + } + +return 0 ; }/* include/uapi/linux/psci.h +2
-0@@ -55,6 +55,8 @@#define PSCI_1_0_FN64_SYSTEM_SUSPEND PSCI_0_2_FN64(14)#define PSCI_1_1_FN64_SYSTEM_RESET2 PSCI_0_2_FN64(18) +#define PSCI_1_1_SYSTEM_RESET2_SYSTEM_WARM_RESET 0 +/* PSCI v0.2 power state encoding for CPU_SUSPEND function */ #define PSCI_0_2_POWER_STATE_ID_MASK 0xffff#define PSCI_0_2_POWER_STATE_ID_SHIFT 0Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
PATCH v2 3/3 arm64: dts: qcom: sm8250: Add vendor-specific PSCI system reset2 type
In reply to Elliot BermanQualcomm Technologies, Inc. SoCs do not guarantee that an architectural warm reset boots back into Linux kernel. For instance, if download mode or reboot reason cookies are set, the SoC would do a warm reset into an alternate exception level (e.g. a mode to collect RAM dumps) or application at EL1 (e.g. fastboot mode). Thus, Qualcomm Technologies, Inc. SoCs support a vendor-specific warm reset type that can be used in all instances of warm/soft reboots.
--- arch/arm64/boot/dts/qcom/sm8250.dtsi | 1 + 1 file changed, 1 insertion(+)
arch/arm64/boot/dts/qcom/sm8250.dtsi +1 -0
@@ -162,6 +162,7 @@ psci { compatible = "arm,psci-1.0"; method = "smc"; + arm,psci-sys-reset2-param = <0x80000000>; }; reserved_memory: reserved-memory {
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project