[2/3] dt-bindings: arm: Document reboot mode magic

Message ID 20231117-arm-psci-system_reset2-vendor-reboots-v1-2-03c4612153e2@quicinc.com
State New
Headers
Series Implement vendor resets for PSCI SYSTEM_RESET2 |

Commit Message

Elliot Berman Nov. 17, 2023, 9:18 p.m. UTC
  Add bindings to describe vendor-specific reboot modes. Values here
correspond to valid parameters to vendor-specific reset types in PSCI
SYSTEM_RESET2 call.

Signed-off-by: Elliot Berman <quic_eberman@quicinc.com>
---
 Documentation/devicetree/bindings/arm/psci.yaml | 36 +++++++++++++++++++++++--
 1 file changed, 34 insertions(+), 2 deletions(-)
  

Comments

Krzysztof Kozlowski Nov. 20, 2023, 10:56 a.m. UTC | #1
On 17/11/2023 22:18, Elliot Berman wrote:
> -
> -additionalProperties: false
> +  - if:
> +      properties:
> +        compatible:
> +          contains:
> +            const: arm,psci-1.0
> +    then:
> +      $ref: /schemas/power/reset/reboot-mode.yaml#
> +      properties:
> +        # "mode-normal" is just SYSTEM_RESET
> +        mode-normal: false
> +      patternProperties:
> +        "^mode-.*$":
> +          maxItems: 2

And if you tested the patch, it would tell you it can be max 1 item.

Best regards,
Krzysztof
  
Elliot Berman Nov. 20, 2023, 3:45 p.m. UTC | #2
On 11/20/2023 2:56 AM, Krzysztof Kozlowski wrote:
> On 17/11/2023 22:18, Elliot Berman wrote:
>> -
>> -additionalProperties: false
>> +  - if:
>> +      properties:
>> +        compatible:
>> +          contains:
>> +            const: arm,psci-1.0
>> +    then:
>> +      $ref: /schemas/power/reset/reboot-mode.yaml#
>> +      properties:
>> +        # "mode-normal" is just SYSTEM_RESET
>> +        mode-normal: false
>> +      patternProperties:
>> +        "^mode-.*$":
>> +          maxItems: 2
> 
> And if you tested the patch, it would tell you it can be max 1 item.

make dt_binding_check DT_SCHEMA_FILES=arm/psci.yaml

passes for me. Rob explained why it's working (and why it shouldn't), 
so I'll fix it according to his recommendation in v2.

Thanks,
Elliot
  
Krzysztof Kozlowski Nov. 20, 2023, 4:41 p.m. UTC | #3
On 20/11/2023 16:45, Elliot Berman wrote:
> 
> 
> On 11/20/2023 2:56 AM, Krzysztof Kozlowski wrote:
>> On 17/11/2023 22:18, Elliot Berman wrote:
>>> -
>>> -additionalProperties: false
>>> +  - if:
>>> +      properties:
>>> +        compatible:
>>> +          contains:
>>> +            const: arm,psci-1.0
>>> +    then:
>>> +      $ref: /schemas/power/reset/reboot-mode.yaml#
>>> +      properties:
>>> +        # "mode-normal" is just SYSTEM_RESET
>>> +        mode-normal: false
>>> +      patternProperties:
>>> +        "^mode-.*$":
>>> +          maxItems: 2
>>
>> And if you tested the patch, it would tell you it can be max 1 item.
> 
> make dt_binding_check DT_SCHEMA_FILES=arm/psci.yaml

psci.example.dtb: psci: mode-edl: [[0]] is too short
psci.example.dtb: psci: mode-bootloader: [[1, 2]] is too short

psci.example.dtb: psci: Unevaluated properties are not allowed
('mode-bootloader', 'mode-edl' were unexpected)

> 
> passes for me. Rob explained why it's working (and why it shouldn't), 
> so I'll fix it according to his recommendation in v2.

Then you wanted uint32-matrix.


Best regards,
Krzysztof
  
Elliot Berman Nov. 20, 2023, 5:09 p.m. UTC | #4
On 11/20/2023 8:41 AM, Krzysztof Kozlowski wrote:
> On 20/11/2023 16:45, Elliot Berman wrote:
>>
>>
>> On 11/20/2023 2:56 AM, Krzysztof Kozlowski wrote:
>>> On 17/11/2023 22:18, Elliot Berman wrote:
>>>> -
>>>> -additionalProperties: false
>>>> +  - if:
>>>> +      properties:
>>>> +        compatible:
>>>> +          contains:
>>>> +            const: arm,psci-1.0
>>>> +    then:
>>>> +      $ref: /schemas/power/reset/reboot-mode.yaml#
>>>> +      properties:
>>>> +        # "mode-normal" is just SYSTEM_RESET
>>>> +        mode-normal: false
>>>> +      patternProperties:
>>>> +        "^mode-.*$":
>>>> +          maxItems: 2
>>>
>>> And if you tested the patch, it would tell you it can be max 1 item.
>>
>> make dt_binding_check DT_SCHEMA_FILES=arm/psci.yaml
> 
> psci.example.dtb: psci: mode-edl: [[0]] is too short
> psci.example.dtb: psci: mode-bootloader: [[1, 2]] is too short
> 
> psci.example.dtb: psci: Unevaluated properties are not allowed
> ('mode-bootloader', 'mode-edl' were unexpected)
> 

Ah, tip of tree for dt-schema doesn't seem to report the error.

Doesn't report the error:
dt-validate --version
2023.10.dev17+g58feadb

Reports the error:
dt-validate --version
2023.9

Looks likely related to generated the processed-schema.json rather
than dt-validate itself. The tip of tree dt-validate does report
the error if processed-schema.json is generated by 2023.9 tool,
but not if the schema was also generated by tip-of-tree mkschema.

I'll try bisecting the error and report back.

>>
>> passes for me. Rob explained why it's working (and why it shouldn't), 
>> so I'll fix it according to his recommendation in v2.
> 
> Then you wanted uint32-matrix.
> 
> 
> Best regards,
> Krzysztof
>
  

Patch

diff --git a/Documentation/devicetree/bindings/arm/psci.yaml b/Documentation/devicetree/bindings/arm/psci.yaml
index 0c5381e081bd..ac95c1610287 100644
--- a/Documentation/devicetree/bindings/arm/psci.yaml
+++ b/Documentation/devicetree/bindings/arm/psci.yaml
@@ -136,8 +136,29 @@  allOf:
       required:
         - cpu_off
         - cpu_on
-
-additionalProperties: false
+  - if:
+      properties:
+        compatible:
+          contains:
+            const: arm,psci-1.0
+    then:
+      $ref: /schemas/power/reset/reboot-mode.yaml#
+      properties:
+        # "mode-normal" is just SYSTEM_RESET
+        mode-normal: false
+      patternProperties:
+        "^mode-.*$":
+          maxItems: 2
+          description: |
+            Describes a vendor-specific reset type. The string after "mode-"
+            maps a reboot mode to the parameters in the PSCI SYSTEM_RESET2 call.
+
+            Parameters are named mode-xxx = <type[, cookie]>, where xxx
+            is the name of the magic reboot mode, type is the lower 31 bits
+            of the reset_type, and, optionally, the cookie value. If the cookie
+            is not provided, it is defaulted to zero.
+
+unevaluatedProperties: false
 
 examples:
   - |+
@@ -260,4 +281,15 @@  examples:
         domain-idle-states = <&CLUSTER_RET>, <&CLUSTER_PWRDN>;
       };
     };
+
+  - |+
+
+    // Case 5: SYSTEM_RESET2 vendor resets
+    psci {
+      compatible = "arm,psci-1.0";
+      method = "smc";
+
+      mode-edl = <0>;
+      mode-bootloader = <1 2>;
+    };
 ...