Support spaces in reboot mode framework
Subsystems (4)
cover Support spaces in reboot mode framework
Resending with updated recepients and cover subject.
PM8150 uses reboot-mode framework to set magic values for bootloader to read during next boot. dm-verity wants to use "dm-verity device corrupted" [1] as the restart command, however the reboot-mode framework does not support spaces in the command line as devicetree property names cannot have spaces. In order to support the PM8150 comamnds, this patch series adds two new optional array properties to reboot-mode framework: reboot-mode-names and reboot-mode-magic. The arrays supply the commands and magic values, respectively.
Elliot Berman (4):
dt-bindings: power: reset: Convert reboot-mode to YAML
dt-bindings: power: reset: Add alternate reboot mode format
power: reset: Add support for reboot mode alternate properties
arm64: dts: qcom: pm8150: Add reboot magic
.../bindings/power/reset/reboot-mode.txt | 25 --------- .../bindings/power/reset/reboot-mode.yaml | 64 ++++++++++++++++++++++ arch/arm64/boot/dts/qcom/pm8150.dtsi | 5 ++ drivers/power/reset/reboot-mode.c | 42 +++++++++++++- 4 files changed, 110 insertions(+), 26 deletions(-) delete mode 100644 Documentation/devicetree/bindings/power/reset/reboot-mode.txt create mode 100644 Documentation/devicetree/bindings/power/reset/reboot-mode.yaml
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
PATCH RESEND 1/4 dt-bindings: power: reset: Convert reboot-mode to YAML
Convert reboot-mode bindings to YAML.
--- .../bindings/power/reset/reboot-mode.txt | 25 ------------ .../bindings/power/reset/reboot-mode.yaml | 47 ++++++++++++++++++++++ 2 files changed, 47 insertions(+), 25 deletions(-) delete mode 100644 Documentation/devicetree/bindings/power/reset/reboot-mode.txt create mode 100644 Documentation/devicetree/bindings/power/reset/reboot-mode.yaml
Documentation/devicetree/bindings/power/reset/reboot-mode.txt deleted +0 -25
@@ -1,25 +0,0 @@ -Generic reboot mode core map driver - -This driver get reboot mode arguments and call the write -interface to store the magic value in special register -or ram. Then the bootloader can read it and take different -action according to the argument stored. - -All mode properties are vendor specific, it is a indication to tell -the bootloader what to do when the system reboots, and should be named -as mode-xxx = <magic> (xxx is mode name, magic should be a none-zero value). - -For example modes common on Android platform: -- mode-normal: Normal reboot mode, system reboot with command "reboot". -- mode-recovery: Android Recovery mode, it is a mode to format the device or update a new image. -- mode-bootloader: Android fastboot mode, it's a mode to re-flash partitions on the Android based device. -- mode-loader: A bootloader mode, it's a mode used to download image on Rockchip platform, - usually used in development. - -Example: - reboot-mode { - mode-normal = <BOOT_NORMAL>; - mode-recovery = <BOOT_RECOVERY>; - mode-bootloader = <BOOT_FASTBOOT>; - mode-loader = <BOOT_BL_DOWNLOAD>; - }
Documentation/devicetree/bindings/power/reset/reboot-mode.yaml new file +47 -0
47 lines not on this page · raw message
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
Re: [RESEND PATCH v1 1/4] dt-bindings: power: reset: Convert reboot-mode to YAML
Hi,
Thanks, queued.
-- Sebastian
Quoted 98 lines · Elliot Berman
Convert reboot-mode bindings to YAML.
Signed-off-by Elliot Berman <[email protected]>--- .../bindings/power/reset/reboot-mode.txt | 25 ------------ .../bindings/power/reset/reboot-mode.yaml | 47 ++++++++++++++++++++++ 2 files changed, 47 insertions(+), 25 deletions(-) delete mode 100644 Documentation/devicetree/bindings/power/reset/reboot-mode.txt create mode 100644 Documentation/devicetree/bindings/power/reset/reboot-mode.yamlDocumentation/devicetree/bindings/power/reset/reboot-mode.txt deleted +0
-25@@ -1,25 +0,0 @@ -Generic reboot mode core map driver - -This driver get reboot mode arguments and call the write -interface to store the magic value in special register -or ram. Then the bootloader can read it and take different -action according to the argument stored. - -All mode properties are vendor specific, it is a indication to tell -the bootloader what to do when the system reboots, and should be named -as mode-xxx = <magic> (xxx is mode name, magic should be a none-zero value). - -For example modes common on Android platform: -- mode-normal: Normal reboot mode, system reboot with command "reboot". -- mode-recovery: Android Recovery mode, it is a mode to format the device or update a new image. -- mode-bootloader: Android fastboot mode, it's a mode to re-flash partitions on the Android based device. -- mode-loader: A bootloader mode, it's a mode used to download image on Rockchip platform, - usually used in development. - -Example: - reboot-mode { - mode-normal = <BOOT_NORMAL>; - mode-recovery = <BOOT_RECOVERY>; - mode-bootloader = <BOOT_FASTBOOT>; - mode-loader = <BOOT_BL_DOWNLOAD>; - }Documentation/devicetree/bindings/power/reset/reboot-mode.yaml new file +47
-0@@ -0,0 +1,47 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/power/reset/reboot-mode.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Generic reboot mode core map + +maintainers: + - Andy Yan <[email protected]> + +description: | + This driver get reboot mode arguments and call the write + interface to store the magic value in special register + or ram. Then the bootloader can read it and take different + action according to the argument stored. + + All mode properties are vendor specific, it is a indication to tell + the bootloader what to do when the system reboots, and should be named + as mode-xxx = <magic> (xxx is mode name, magic should be a non-zero value). + + For example, modes common Android platform are: + - normal: Normal reboot mode, system reboot with command "reboot". + - recovery: Android Recovery mode, it is a mode to format the device or update a new image. + - bootloader: Android fastboot mode, it's a mode to re-flash partitions on the Android based device. + - loader: A bootloader mode, it's a mode used to download image on Rockchip platform, + usually used in development. + +properties: + mode-normal: + $ref: /schemas/types.yaml#/definitions/uint32 + description: | + Default value to set on a reboot if no command was provided. + +patternProperties: + "^mode-.*$": + $ref: /schemas/types.yaml#/definitions/uint32 + +examples: + - | + reboot-mode { + mode-normal = <0>; + mode-recovery = <1>; + mode-bootloader = <2>; + mode-loader = <3>; + }; +...Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
PATCH RESEND 2/4 dt-bindings: power: reset: Add alternate reboot mode format
In reply to Elliot BermanCurrent reboot-mode device tree schema does not support reboot commands with spaces in them [1]. Add an optional new node "reboot-mode-names" and "reboot-mode-magic" which add an array of strings and u32s, respectively which would permit any string in this framework.
--- .../devicetree/bindings/power/reset/reboot-mode.yaml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
Documentation/devicetree/bindings/power/reset/reboot-mode.yaml +17 -0
@@ -19,6 +19,9 @@ description: | the bootloader what to do when the system reboots, and should be named as mode-xxx = <magic> (xxx is mode name, magic should be a non-zero value). + reboot-mode-magic and reboot-mode-names may be used in addition/instead of + mode-xxx style. + For example, modes common Android platform are: - normal: Normal reboot mode, system reboot with command "reboot". - recovery: Android Recovery mode, it is a mode to format the device or update a new image.
@@ -32,6 +35,14 @@ properties: description: | Default value to set on a reboot if no command was provided. + reboot-mode-names: + $ref: /schemas/types.yaml#/definitions/string-array + description: List of reboot commands, paired with reboot-mode-magic by index + + reboot-mode-magic: + $ref: /schemas/types.yaml#/definitions/uint32-array + description: List of reboot magic, paired with reboot-mode-names by index + patternProperties: "^mode-.*$": $ref: /schemas/types.yaml#/definitions/uint32
@@ -44,4 +55,10 @@ examples: mode-bootloader = <2>; mode-loader = <3>; }; + + - | + reboot-mode { + reboot-mode-names = "normal", "bootloader", "dm-verity device corrupted"; + reboot-mode-magic = <0x0>, <0x1>, <0xf>; + }; ...
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
Re: [RESEND PATCH v1 2/4] dt-bindings: power: reset: Add alternate reboot mode format
Hi,
Quoted 10 lines · Elliot Berman
Current reboot-mode device tree schema does not support reboot commands with spaces in them [1]. Add an optional new node "reboot-mode-names" and "reboot-mode-magic" which add an array of strings and u32s, respectively which would permit any string in this framework.
Signed-off-by Elliot Berman <[email protected]>---
I'm waiting for an Ack from Rob for this one.
-- Sebastian
Quoted 47 lines
.../devicetree/bindings/power/reset/reboot-mode.yaml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)Documentation/devicetree/bindings/power/reset/reboot-mode.yaml +17
-0@@ -19,6 +19,9 @@ description: | the bootloader what to do when the system reboots, and should be named as mode-xxx = <magic> (xxx is mode name, magic should be a non-zero value). + reboot-mode-magic and reboot-mode-names may be used in addition/instead of + mode-xxx style. + For example, modes common Android platform are: - normal: Normal reboot mode, system reboot with command "reboot". - recovery: Android Recovery mode, it is a mode to format the device or update a new image.@@ -32,6 +35,14 @@ properties: description: | Default value to set on a reboot if no command was provided. + reboot-mode-names: + $ref: /schemas/types.yaml#/definitions/string-array + description: List of reboot commands, paired with reboot-mode-magic by index + + reboot-mode-magic: + $ref: /schemas/types.yaml#/definitions/uint32-array + description: List of reboot magic, paired with reboot-mode-names by index + patternProperties: "^mode-.*$": $ref: /schemas/types.yaml#/definitions/uint32@@ -44,4 +55,10 @@ examples: mode-bootloader = <2>; mode-loader = <3>; }; + + - | + reboot-mode { + reboot-mode-names = "normal", "bootloader", "dm-verity device corrupted"; + reboot-mode-magic = <0x0>, <0x1>, <0xf>; + };Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
Rob Herring
maintainerRe: [RESEND PATCH v1 2/4] dt-bindings: power: reset: Add alternate reboot mode format
In reply to Elliot BermanQuoted 4 lines · Elliot Berman
Current reboot-mode device tree schema does not support reboot commands with spaces in them [1]. Add an optional new node "reboot-mode-names" and "reboot-mode-magic" which add an array of strings and u32s, respectively which would permit any string in this framework.
Kind of a weak justification. The intent was for the names to be a key, not a multi word description which your example seems to be. Is "dm-verity device corrupted" something Android has already standardized on?
Quoted 14 lines
Signed-off-by Elliot Berman <[email protected]>--- .../devicetree/bindings/power/reset/reboot-mode.yaml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)Documentation/devicetree/bindings/power/reset/reboot-mode.yaml +0
-0
Documentation/devicetree/bindings/power/reset/reboot-mode.yaml description: | · line 23
Quoted 5 lines
Documentation/devicetree/bindings/power/reset/reboot-mode.yaml +2
-0@@ -19,6 +19,9 @@ description: | the bootloader what to do when the system reboots, and should be named as mode-xxx = <magic> (xxx is mode name, magic should be a non-zero value). + reboot-mode-magic and reboot-mode-names may be used in addition/instead of + mode-xxx style.
It should be either/or in my opinion, not both.
Documentation/devicetree/bindings/power/reset/reboot-mode.yaml properties: · line 42
Quoted 13 lines
Documentation/devicetree/bindings/power/reset/reboot-mode.yaml +6
-0+ For example, modes common Android platform are: - normal: Normal reboot mode, system reboot with command "reboot". - recovery: Android Recovery mode, it is a mode to format the device or update a new image.@@ -32,6 +35,14 @@ properties: description: | Default value to set on a reboot if no command was provided. + reboot-mode-names: + $ref: /schemas/types.yaml#/definitions/string-array + description: List of reboot commands, paired with reboot-mode-magic by index + + reboot-mode-magic:
'reboot-modes' would align with normal patterns.
Quoted 21 lines
Documentation/devicetree/bindings/power/reset/reboot-mode.yaml +9
-0+ $ref: /schemas/types.yaml#/definitions/uint32-array + description: List of reboot magic, paired with reboot-mode-names by index + patternProperties: "^mode-.*$": $ref: /schemas/types.yaml#/definitions/uint32@@ -44,4 +55,10 @@ examples: mode-bootloader = <2>; mode-loader = <3>; }; + + - | + reboot-mode { + reboot-mode-names = "normal", "bootloader", "dm-verity device corrupted"; + reboot-mode-magic = <0x0>, <0x1>, <0xf>; + };Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
Re: [RESEND PATCH v1 2/4] dt-bindings: power: reset: Add alternate reboot mode format
Quoted 10 lines · Rob Herring
Quoted 4 lines · Elliot Berman
Current reboot-mode device tree schema does not support reboot commands with spaces in them [1]. Add an optional new node "reboot-mode-names" and "reboot-mode-magic" which add an array of strings and u32s, respectively which would permit any string in this framework.
Kind of a weak justification. The intent was for the names to be a key, not a multi word description which your example seems to be. Is "dm-verity device corrupted" something Android has already standardized on?
+Eric/Sami to comment further
I wonder if you're thinking it's better to change the kernel_restart in dm-verity-target.c?
Alternatively, I could respin so that spaces in the reboot cmd is replaced with "-" in reboot_mode_notify(). This way, there is no need to change dm-verity driver or change devicetree schema. i.e.:
@@ -44,9 +44,13 @@ static int reboot_mode_notify(struct notifier_block *this,
{
struct reboot_mode_driver *reboot;
unsigned int magic;+ char *reboot_cmd;
+
+ reboot_cmd = kstrdup(cmd, GFP_KERNEL);
+ strreplace(reboot_cmd, ' ', '-');
reboot = container_of(this, struct reboot_mode_driver,reboot_notifier);
- magic = get_reboot_mode_magic(reboot, cmd);
+ magic = get_reboot_mode_magic(reboot, reboot_cmd);
if (magic)
reboot->write(reboot, magic);Quoted 18 lines
Quoted 18 lines
Signed-off-by Elliot Berman <[email protected]>--- .../devicetree/bindings/power/reset/reboot-mode.yaml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)Documentation/devicetree/bindings/power/reset/reboot-mode.yaml +0
-0@@ -19,6 +19,9 @@ description: | the bootloader what to do when the system reboots, and should be named as mode-xxx = <magic> (xxx is mode name, magic should be a non-zero value).
Quoted 4 lines
Documentation/devicetree/bindings/power/reset/reboot-mode.yaml description: | · line 23
Quoted 2 lines
Documentation/devicetree/bindings/power/reset/reboot-mode.yaml +2
-0+ reboot-mode-magic and reboot-mode-names may be used in addition/instead of + mode-xxx style.It should be either/or in my opinion, not both.
OK, I can fix in the next patch.
Quoted 9 lines
Quoted 9 lines
Documentation/devicetree/bindings/power/reset/reboot-mode.yaml +1
-0+ For example, modes common Android platform are: - normal: Normal reboot mode, system reboot with command "reboot". - recovery: Android Recovery mode, it is a mode to format the device or update a new image.@@ -32,6 +35,14 @@ properties: description: | Default value to set on a reboot if no command was provided.
Quoted 7 lines
Documentation/devicetree/bindings/power/reset/reboot-mode.yaml properties: · line 42
Quoted 5 lines
Documentation/devicetree/bindings/power/reset/reboot-mode.yaml +5
-0+ reboot-mode-names: + $ref: /schemas/types.yaml#/definitions/string-array + description: List of reboot commands, paired with reboot-mode-magic by index + + reboot-mode-magic:'reboot-modes' would align with normal patterns.
Ditto
Quoted 22 lines
Quoted 22 lines
Documentation/devicetree/bindings/power/reset/reboot-mode.yaml +9
-0+ $ref: /schemas/types.yaml#/definitions/uint32-array + description: List of reboot magic, paired with reboot-mode-names by index + patternProperties: "^mode-.*$": $ref: /schemas/types.yaml#/definitions/uint32@@ -44,4 +55,10 @@ examples: mode-bootloader = <2>; mode-loader = <3>; }; + + - | + reboot-mode { + reboot-mode-names = "normal", "bootloader", "dm-verity device corrupted"; + reboot-mode-magic = <0x0>, <0x1>, <0xf>; + };Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
PATCH RESEND 3/4 power: reset: Add support for reboot mode alternate properties
In reply to Elliot BermanReboot mode driver does not currently support reboot commands with spaces in them [1]. Add an optional new node "reboot-mode-names" and "reboot-mode-magic" which add an array of strings and u32s, respectively which would permit any string in this framework.
--- drivers/power/reset/reboot-mode.c | 42 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-)
drivers/power/reset/reboot-mode.c +41 -1
@@ -64,8 +64,9 @@ int reboot_mode_register(struct reboot_mode_driver *reboot)struct mode_info *info;struct property *prop;struct device_node *np = reboot->dev->of_node; +const char *mode_name;size_t len =strlen (PREFIX ); -int ret; +int ret, count, i;INIT_LIST_HEAD (&reboot->head);
@@ -101,6 +102,45 @@ int reboot_mode_register(struct reboot_mode_driver *reboot)list_add_tail (&info->list, &reboot->head); } + count =of_property_count_u32_elems (np,"reboot-mode-magic" ); +for (i =0 ; i < count; i++) { + info =devm_kzalloc (reboot->dev,sizeof (*info),GFP_KERNEL ); +if (!info) { + ret = -ENOMEM ; + goto error; + } + +if (of_property_read_string_index (np,"reboot-mode-names" , i, + &mode_name)) { +dev_err (reboot->dev,"unable to read reboot-mode-names[%d]\n" , + i); + ret = -EINVAL ; + goto error; + } + info->mode =kstrdup_const (mode_name,GFP_KERNEL ); +if (!info->mode) { + ret = -ENOMEM ; + goto error; + }else if (info->mode[0 ] =='\0' ) { +dev_err (reboot->dev,"invalid reboot-mode-names[%d]: too short!\n" , + i); +kfree_const (info->mode); + ret = -EINVAL ; + goto error; + } + +if (of_property_read_u32_index (np,"reboot-mode-magic" , i, + &info->magic)) { +dev_err (reboot->dev,"unable to read reboot-mode-magic[%d]\n" , + i); +kfree_const (info->mode); + ret = -EINVAL ; + goto error; + } + +list_add_tail (&info->list, &reboot->head); + } + reboot->reboot_notifier.notifier_call = reboot_mode_notify;register_reboot_notifier (&reboot->reboot_notifier);
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
PATCH RESEND 4/4 arm64: dts: qcom: pm8150: Add reboot magic
In reply to Elliot BermanAdd reboot command magic values for pm8150 pon device.
--- arch/arm64/boot/dts/qcom/pm8150.dtsi | 5 +++++ 1 file changed, 5 insertions(+)
arch/arm64/boot/dts/qcom/pm8150.dtsi +5 -0
@@ -50,6 +50,11 @@ pon: power-on@800 { compatible = "qcom,pm8916-pon"; reg = <0x0800>; + + reboot-mode-names = "bootloader", "recovery", + "dm-verity device corrupted"; + reboot-mode-magic = <0x1>, <0x2>, <0x4>; + pwrkey { compatible = "qcom,pm8941-pwrkey"; interrupts = <0x0 0x8 0x0 IRQ_TYPE_EDGE_BOTH>;
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project