diff mbox series

[RESEND,1/2] dt-bindings: firmware: arm, scmi: define support for name based regulators

Message ID fcd130891cc1d52cb09b8bfc866ab7ef1ce3b2a1.1643069954.git.quic_collinsd@quicinc.com (mailing list archive)
State New, archived
Headers show
Series regulator: scmi: add support for registering SCMI regulators by name | expand

Commit Message

David Collins Jan. 25, 2022, 12:27 a.m. UTC
Allow SCMI regulator subnodes to be specified either by ID using
the "reg" property or by name using the "regulator-name" property.

Name based SCMI regulator specification helps ensure that an SCMI
agent doesn't need to be aware of the numbering scheme used for
Voltage Domains by the SCMI platform.  It also ensures that the
correct Voltage Domain is selected for a given physical regulator.
This cannot be guaranteed with numeric Voltage Domain IDs alone.

Signed-off-by: David Collins <quic_collinsd@quicinc.com>
Reviewed-by: Rob Herring <robh@kernel.org>
---
 .../devicetree/bindings/firmware/arm,scmi.yaml        | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

Comments

Mark Brown Jan. 28, 2022, 7:32 p.m. UTC | #1
On Mon, Jan 24, 2022 at 04:27:35PM -0800, David Collins wrote:

> Name based SCMI regulator specification helps ensure that an SCMI
> agent doesn't need to be aware of the numbering scheme used for

What is a "SCMI agent" in this context?  This is changing how the DT
bindings are specified, at some point things are going to need to be
hard coded.

> +              regulator-name: true
> +
> +            anyOf:
> +              - required:
> +                  - reg
> +              - required:
> +                  - regulator-name

This is abusing the existing regulator-name property which is there to
allow a human readable descriptive string to be attached to a regulator.
It should have no effect other than being included in diagnostic output.
David Collins Jan. 28, 2022, 11:09 p.m. UTC | #2
On 1/28/22 11:32 AM, Mark Brown wrote:
> On Mon, Jan 24, 2022 at 04:27:35PM -0800, David Collins wrote:
> 
>> Name based SCMI regulator specification helps ensure that an SCMI
>> agent doesn't need to be aware of the numbering scheme used for
> 
> What is a "SCMI agent" in this context?  This is changing how the DT
> bindings are specified, at some point things are going to need to be
> hard coded.

An SCMI agent is the entity that issues SCMI commands (i.e. the
consumer).  An SCMI platform is the entity that receives the SCMI
commands and performs the necessary operations (i.e. the provider).
This is the terminology used in the ARM SCMI spec [1].

A typical system layout could have an agent that is the application
processor (running Linux) and a platform that is an embedded controller.

The system layout that this patch is targeted for consists of an SCMI
platform implemented in software in the primary Linux OS on the
application processor and an SCMI agent in a guest VM (also running
Linux).  This provides paravirtualized regulator control to the guest VM
where full virtualization is not supported.

During the course of development of these software images, it may be
necessary to add or reorder the set of SCMI voltage domains (regulators)
implemented on the platform side.  If the voltage domains are only
identified and matched based on the ID number, then it is easy for the
platform and agent to get out of sync.

Using the voltage domain name instead of ID number for identification
and matching provides robust assurance of correct regulator usage in the
face of domains being added, removed, or reordered on the platform side.


>> +              regulator-name: true
>> +
>> +            anyOf:
>> +              - required:
>> +                  - reg
>> +              - required:
>> +                  - regulator-name
> 
> This is abusing the existing regulator-name property which is there to
> allow a human readable descriptive string to be attached to a regulator.
> It should have no effect other than being included in diagnostic output.

Would you be ok with a new DT property being added in place of
"regulator-name" in this patch which serves the same matching purpose
(perhaps "arm,scmi-domain-name")?

Thanks,
David

[1]: https://developer.arm.com/documentation/den0056/latest
Mark Brown Feb. 2, 2022, 5:38 p.m. UTC | #3
On Fri, Jan 28, 2022 at 03:09:30PM -0800, David Collins wrote:
> On 1/28/22 11:32 AM, Mark Brown wrote:
> > On Mon, Jan 24, 2022 at 04:27:35PM -0800, David Collins wrote:

> >> Name based SCMI regulator specification helps ensure that an SCMI
> >> agent doesn't need to be aware of the numbering scheme used for

> > What is a "SCMI agent" in this context?  This is changing how the DT
> > bindings are specified, at some point things are going to need to be
> > hard coded.

> The system layout that this patch is targeted for consists of an SCMI
> platform implemented in software in the primary Linux OS on the
> application processor and an SCMI agent in a guest VM (also running
> Linux).  This provides paravirtualized regulator control to the guest VM
> where full virtualization is not supported.

> During the course of development of these software images, it may be
> necessary to add or reorder the set of SCMI voltage domains (regulators)
> implemented on the platform side.  If the voltage domains are only
> identified and matched based on the ID number, then it is easy for the
> platform and agent to get out of sync.

> Using the voltage domain name instead of ID number for identification
> and matching provides robust assurance of correct regulator usage in the
> face of domains being added, removed, or reordered on the platform side.

This seems like a scenario where the DT should be being generated at
runtime along with the virtualisation of the platform?  TBH a setup
where this is an issue feels like it's asking for trouble.

> >> +              regulator-name: true

> > This is abusing the existing regulator-name property which is there to
> > allow a human readable descriptive string to be attached to a regulator.
> > It should have no effect other than being included in diagnostic output.

> Would you be ok with a new DT property being added in place of
> "regulator-name" in this patch which serves the same matching purpose
> (perhaps "arm,scmi-domain-name")?

Yes, it needs to be a new property.
David Collins Feb. 3, 2022, 12:09 a.m. UTC | #4
On 2/2/22 9:38 AM, Mark Brown wrote:
>> The system layout that this patch is targeted for consists of an SCMI
>> platform implemented in software in the primary Linux OS on the
>> application processor and an SCMI agent in a guest VM (also running
>> Linux).  This provides paravirtualized regulator control to the guest VM
>> where full virtualization is not supported.
> 
>> During the course of development of these software images, it may be
>> necessary to add or reorder the set of SCMI voltage domains (regulators)
>> implemented on the platform side.  If the voltage domains are only
>> identified and matched based on the ID number, then it is easy for the
>> platform and agent to get out of sync.
> 
>> Using the voltage domain name instead of ID number for identification
>> and matching provides robust assurance of correct regulator usage in the
>> face of domains being added, removed, or reordered on the platform side.
> 
> This seems like a scenario where the DT should be being generated at
> runtime along with the virtualisation of the platform?  TBH a setup
> where this is an issue feels like it's asking for trouble.

I'm not familiar with runtime device tree generation.  Could you please
point to an example of it or documentation for it?  How would this
handle kernel devices on the VM side which need a phandle to an
scmi-regulator DT subnode in order to get a pointer to the corresponding
regulator device at runtime via devm_regulator_get()?

>>>> +              regulator-name: true
> 
>>> This is abusing the existing regulator-name property which is there to
>>> allow a human readable descriptive string to be attached to a regulator.
>>> It should have no effect other than being included in diagnostic output.
> 
>> Would you be ok with a new DT property being added in place of
>> "regulator-name" in this patch which serves the same matching purpose
>> (perhaps "arm,scmi-domain-name")?
> 
> Yes, it needs to be a new property.

Ok, I'll modify the series in V2 to use a different property.

Thanks,
David
Mark Brown Feb. 3, 2022, 11:28 a.m. UTC | #5
On Wed, Feb 02, 2022 at 04:09:43PM -0800, David Collins wrote:
> On 2/2/22 9:38 AM, Mark Brown wrote:

> > This seems like a scenario where the DT should be being generated at
> > runtime along with the virtualisation of the platform?  TBH a setup
> > where this is an issue feels like it's asking for trouble.

> I'm not familiar with runtime device tree generation.  Could you please
> point to an example of it or documentation for it?  How would this
> handle kernel devices on the VM side which need a phandle to an
> scmi-regulator DT subnode in order to get a pointer to the corresponding
> regulator device at runtime via devm_regulator_get()?

I believe qemu does this for the virt machine.  I'm not sure what you're
seeing as particularly complex about generating regulator links in
particular though?
diff mbox series

Patch

diff --git a/Documentation/devicetree/bindings/firmware/arm,scmi.yaml b/Documentation/devicetree/bindings/firmware/arm,scmi.yaml
index 5c4c6782e052..bc4a84fe25d2 100644
--- a/Documentation/devicetree/bindings/firmware/arm,scmi.yaml
+++ b/Documentation/devicetree/bindings/firmware/arm,scmi.yaml
@@ -155,7 +155,7 @@  properties:
           The list of all regulators provided by this SCMI controller.
 
         patternProperties:
-          '^regulators@[0-9a-f]+$':
+          '^regulator.+$':
             type: object
             $ref: "../regulator/regulator.yaml#"
 
@@ -164,8 +164,13 @@  properties:
                 maxItems: 1
                 description: Identifier for the voltage regulator.
 
-            required:
-              - reg
+              regulator-name: true
+
+            anyOf:
+              - required:
+                  - reg
+              - required:
+                  - regulator-name
 
 additionalProperties: false