Skip to contentSkip to conversation

Add Apple Mac System Management Controller GPIOs

PATCH Superseded Russell King (Oracle) 15 participants 171 messages Sep 1, 2022 – Nov 22, 2022 3 messages not in the archive Page 2 of 2

Subsystems (7)
lore
Share & tools
lore
#153 lore raw

Re: [PATCH v3 3/7] dt-bindings: mfd: add binding for Apple Mac System Management Controller

In reply to Rob Herring
Quoted 90 lines · Rob Herring
Quoted 75 lines · Russell King (Oracle)
Quoted 4 lines · Krzysztof Kozlowski
Quoted 1 line · Russell King (Oracle)

Add a DT binding for the Apple Mac System Management Controller.

Drop the second, redundant "binding" from subject. It's already in prefix.

Yet another thing that's been there from the start... how many more things are you going to pick up in subsequent versions of the patch? When does this stop?

In any case, taking your comment literally,

"dt-bindings: mfd: add for Apple Mac System Management Controller"

makes no sense, so presumably you want something more than that.

In any case, I see several recent cases already merged which follow the pattern that I've used and that you've reviewed.

Quoted 56 lines
Quoted 41 lines
---
 .../devicetree/bindings/mfd/apple,smc.yaml    | 67 +++++++++++++++++++
 1 file changed, 67 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mfd/apple,smc.yaml
Documentation/devicetree/bindings/mfd/apple,smc.yaml new file +29 -0
new file mode 100644
index 000000000000..014eba5a1bbc
@@ -0,0 +1,67 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/mfd/apple,smc.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Apple Mac System Management Controller
+
+maintainers:
+  - Hector Martin <[email protected]>
+
+description:
+  Apple Mac System Management Controller implements various functions
+  such as GPIO, RTC, power, reboot.
+
+properties:
+  compatible:
+    items:
+      - enum:
+          - apple,t6000-smc
+          - apple,t8103-smc
+          - apple,t8112-smc
+      - const: apple,smc
+
+  reg:
+    items:
+      - description: SMC area
+      - description: SRAM area
+

Documentation/devicetree/bindings/mfd/apple,smc.yaml line 39

Quoted 10 lines
Documentation/devicetree/bindings/mfd/apple,smc.yaml new file +10 -0
+  reg-names:
+    items:
+      - const: smc
+      - const: sram
+
+  mboxes:
+    maxItems: 1
+
+  gpio:
+    $ref: /schemas/gpio/gpio-macsmc.yaml

So this depends on other patch, so:
1. You need mention the dependency in cover letter (nothing there),
2. Re-order patches.

Quoted 3 lines
Quoted 1 line

The GPIO cannot go separate tree and this must be explicitly communicated.

Sigh, getting an order that is sensible is really bloody difficult.

It's not. Sub-devices before the MFD. The only time that doesn't work is when the sub-devices put the parent MFD in their example. The solution there is don't do that. Just 1 complete example in the MFD schema and no examples in the sub-devices.

Quoted 1 line

I'm quite sure Lee is only going to want to apply the mfd bits.

Indeed. I can't seem to make Lee care... All the schemas should really be applied together.

Quoted 9 lines
Quoted 3 lines

Then
what do we do with the other bits? GPIO stuff via the GPIO tree, then wait a cycle before the rest can be merged. Or what?

The schemas must be picked up in the same cycle. I don't care so much if subsystem maintainers' trees have warnings if they don't care, but I do care for linux-next. If the subsystem bits aren't picked up, then I'll pick them up if it comes to that.

We can take all the schemas and DT changes via asahi-soc if that works for you. This also lets us move forward with more related DT changes that would apply on top of things already in that branch. Then Lee only has to take the mfd core bits (and possibly the RTKit platform part, or we can figure something else out for that).

- Hector

#154 lore raw

Re: [PATCH v3 3/7] dt-bindings: mfd: add binding for Apple Mac System Management Controller

In reply to Rob Herring
Quoted 76 lines · Rob Herring
Quoted 75 lines · Russell King (Oracle)
Quoted 4 lines · Krzysztof Kozlowski
Quoted 1 line · Russell King (Oracle)

Add a DT binding for the Apple Mac System Management Controller.

Drop the second, redundant "binding" from subject. It's already in prefix.

Yet another thing that's been there from the start... how many more things are you going to pick up in subsequent versions of the patch? When does this stop?

In any case, taking your comment literally,

"dt-bindings: mfd: add for Apple Mac System Management Controller"

makes no sense, so presumably you want something more than that.

In any case, I see several recent cases already merged which follow the pattern that I've used and that you've reviewed.

Quoted 56 lines
Quoted 41 lines
---
 .../devicetree/bindings/mfd/apple,smc.yaml    | 67 +++++++++++++++++++
 1 file changed, 67 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mfd/apple,smc.yaml
Documentation/devicetree/bindings/mfd/apple,smc.yaml new file +29 -0
new file mode 100644
index 000000000000..014eba5a1bbc
@@ -0,0 +1,67 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/mfd/apple,smc.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Apple Mac System Management Controller
+
+maintainers:
+  - Hector Martin <[email protected]>
+
+description:
+  Apple Mac System Management Controller implements various functions
+  such as GPIO, RTC, power, reboot.
+
+properties:
+  compatible:
+    items:
+      - enum:
+          - apple,t6000-smc
+          - apple,t8103-smc
+          - apple,t8112-smc
+      - const: apple,smc
+
+  reg:
+    items:
+      - description: SMC area
+      - description: SRAM area
+

Documentation/devicetree/bindings/mfd/apple,smc.yaml line 39

Quoted 10 lines
Documentation/devicetree/bindings/mfd/apple,smc.yaml new file +10 -0
+  reg-names:
+    items:
+      - const: smc
+      - const: sram
+
+  mboxes:
+    maxItems: 1
+
+  gpio:
+    $ref: /schemas/gpio/gpio-macsmc.yaml

So this depends on other patch, so:
1. You need mention the dependency in cover letter (nothing there),
2. Re-order patches.

Quoted 8 lines
Quoted 3 lines
Quoted 1 line

The GPIO cannot go separate tree and this must be explicitly communicated.

Sigh, getting an order that is sensible is really bloody difficult.

It's not. Sub-devices before the MFD. The only time that doesn't work is when the sub-devices put the parent MFD in their example. The solution there is don't do that. Just 1 complete example in the MFD schema and no examples in the sub-devices.

Meanwhile, I was told by Krzysztof that DT schemas must always have an example. So, different person, different story.

Anyway, I've washed my hands of this farce with this series. I'm not planning to post another version of it. I've had enough of this crap.

Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
#155 lore raw

Re: [PATCH v3 3/7] dt-bindings: mfd: add binding for Apple Mac System Management Controller

Quoted 81 lines · Russell King (Oracle)
Quoted 80 lines · Rob Herring
Quoted 78 lines · Russell King (Oracle)
Quoted 4 lines · Krzysztof Kozlowski
Quoted 1 line · Russell King (Oracle)

Add a DT binding for the Apple Mac System Management Controller.

Drop the second, redundant "binding" from subject. It's already in prefix.

Yet another thing that's been there from the start... how many more things are you going to pick up in subsequent versions of the patch? When does this stop?

In any case, taking your comment literally,

"dt-bindings: mfd: add for Apple Mac System Management Controller"

makes no sense, so presumably you want something more than that.

In any case, I see several recent cases already merged which follow the pattern that I've used and that you've reviewed.

Quoted 56 lines
Quoted 41 lines
---
 .../devicetree/bindings/mfd/apple,smc.yaml    | 67 +++++++++++++++++++
 1 file changed, 67 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mfd/apple,smc.yaml
Documentation/devicetree/bindings/mfd/apple,smc.yaml new file +29 -0
new file mode 100644
index 000000000000..014eba5a1bbc
@@ -0,0 +1,67 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/mfd/apple,smc.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Apple Mac System Management Controller
+
+maintainers:
+  - Hector Martin <[email protected]>
+
+description:
+  Apple Mac System Management Controller implements various functions
+  such as GPIO, RTC, power, reboot.
+
+properties:
+  compatible:
+    items:
+      - enum:
+          - apple,t6000-smc
+          - apple,t8103-smc
+          - apple,t8112-smc
+      - const: apple,smc
+
+  reg:
+    items:
+      - description: SMC area
+      - description: SRAM area
+

Documentation/devicetree/bindings/mfd/apple,smc.yaml line 39

Quoted 10 lines
Documentation/devicetree/bindings/mfd/apple,smc.yaml new file +10 -0
+  reg-names:
+    items:
+      - const: smc
+      - const: sram
+
+  mboxes:
+    maxItems: 1
+
+  gpio:
+    $ref: /schemas/gpio/gpio-macsmc.yaml

So this depends on other patch, so:
1. You need mention the dependency in cover letter (nothing there),
2. Re-order patches.

Quoted 1 line

The GPIO cannot go separate tree and this must be explicitly communicated.

Sigh, getting an order that is sensible is really bloody difficult.

Quoted 7 lines
Quoted 4 lines

It's not. Sub-devices before the MFD. The only time that doesn't work is when the sub-devices put the parent MFD in their example. The solution there is don't do that. Just 1 complete example in the MFD schema and no examples in the sub-devices.

Meanwhile, I was told by Krzysztof that DT schemas must always have an example. So, different person, different story.

Hm, where do you see a message I told you to always have examples? Maybe in some discussion I mentioned that examples are desired, but not always. There is no point in having example in MFD child device schema if it is already part of the parent MFD binding, where it is actually required for complete picture.

Best regards,
Krzysztof

#156 lore raw

Re: [PATCH v3 3/7] dt-bindings: mfd: add binding for Apple Mac System Management Controller

Quoted 87 lines · Krzysztof Kozlowski
Quoted 86 lines · Russell King (Oracle)
Quoted 84 lines · Rob Herring
Quoted 75 lines · Russell King (Oracle)
Quoted 4 lines · Krzysztof Kozlowski
Quoted 1 line · Russell King (Oracle)

Add a DT binding for the Apple Mac System Management Controller.

Drop the second, redundant "binding" from subject. It's already in prefix.

Yet another thing that's been there from the start... how many more things are you going to pick up in subsequent versions of the patch? When does this stop?

In any case, taking your comment literally,

"dt-bindings: mfd: add for Apple Mac System Management Controller"

makes no sense, so presumably you want something more than that.

In any case, I see several recent cases already merged which follow the pattern that I've used and that you've reviewed.

Quoted 56 lines
Quoted 41 lines
---
 .../devicetree/bindings/mfd/apple,smc.yaml    | 67 +++++++++++++++++++
 1 file changed, 67 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mfd/apple,smc.yaml
Documentation/devicetree/bindings/mfd/apple,smc.yaml new file +29 -0
new file mode 100644
index 000000000000..014eba5a1bbc
@@ -0,0 +1,67 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/mfd/apple,smc.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Apple Mac System Management Controller
+
+maintainers:
+  - Hector Martin <[email protected]>
+
+description:
+  Apple Mac System Management Controller implements various functions
+  such as GPIO, RTC, power, reboot.
+
+properties:
+  compatible:
+    items:
+      - enum:
+          - apple,t6000-smc
+          - apple,t8103-smc
+          - apple,t8112-smc
+      - const: apple,smc
+
+  reg:
+    items:
+      - description: SMC area
+      - description: SRAM area
+

Documentation/devicetree/bindings/mfd/apple,smc.yaml line 39

Quoted 10 lines
Documentation/devicetree/bindings/mfd/apple,smc.yaml new file +10 -0
+  reg-names:
+    items:
+      - const: smc
+      - const: sram
+
+  mboxes:
+    maxItems: 1
+
+  gpio:
+    $ref: /schemas/gpio/gpio-macsmc.yaml

So this depends on other patch, so:
1. You need mention the dependency in cover letter (nothing there),
2. Re-order patches.

Quoted 3 lines
Quoted 1 line

The GPIO cannot go separate tree and this must be explicitly communicated.

Sigh, getting an order that is sensible is really bloody difficult.

It's not. Sub-devices before the MFD. The only time that doesn't work is when the sub-devices put the parent MFD in their example. The solution there is don't do that. Just 1 complete example in the MFD schema and no examples in the sub-devices.

Quoted 8 lines
Quoted 2 lines

Meanwhile, I was told by Krzysztof that DT schemas must always have an example. So, different person, different story.

Hm, where do you see a message I told you to always have examples? Maybe in some discussion I mentioned that examples are desired, but not always. There is no point in having example in MFD child device schema if it is already part of the parent MFD binding, where it is actually required for complete picture.

[email protected]

and

[email protected]

For the GPIO macsec binding. So I'm getting contradictory information. First you say that I need an example in the gpio macsec DT binding yaml document.

Now I'm told it should go in the parent.

Make up your bloody minds and stop pissing me about. This is why I've given up trying to get this in.

Getting a consistent message would be nice, but it seems impossible.

Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
#157 lore raw

Re: [PATCH v3 3/7] dt-bindings: mfd: add binding for Apple Mac System Management Controller

Quoted 97 lines · Russell King (Oracle)
Quoted 87 lines · Krzysztof Kozlowski
Quoted 86 lines · Russell King (Oracle)
Quoted 84 lines · Rob Herring
Quoted 75 lines · Russell King (Oracle)
Quoted 4 lines · Krzysztof Kozlowski
Quoted 1 line · Russell King (Oracle)

Add a DT binding for the Apple Mac System Management Controller.

Drop the second, redundant "binding" from subject. It's already in prefix.

Yet another thing that's been there from the start... how many more things are you going to pick up in subsequent versions of the patch? When does this stop?

In any case, taking your comment literally,

"dt-bindings: mfd: add for Apple Mac System Management Controller"

makes no sense, so presumably you want something more than that.

In any case, I see several recent cases already merged which follow the pattern that I've used and that you've reviewed.

Quoted 56 lines
Quoted 41 lines
---
 .../devicetree/bindings/mfd/apple,smc.yaml    | 67 +++++++++++++++++++
 1 file changed, 67 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mfd/apple,smc.yaml
Documentation/devicetree/bindings/mfd/apple,smc.yaml new file +29 -0
new file mode 100644
index 000000000000..014eba5a1bbc
@@ -0,0 +1,67 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/mfd/apple,smc.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Apple Mac System Management Controller
+
+maintainers:
+  - Hector Martin <[email protected]>
+
+description:
+  Apple Mac System Management Controller implements various functions
+  such as GPIO, RTC, power, reboot.
+
+properties:
+  compatible:
+    items:
+      - enum:
+          - apple,t6000-smc
+          - apple,t8103-smc
+          - apple,t8112-smc
+      - const: apple,smc
+
+  reg:
+    items:
+      - description: SMC area
+      - description: SRAM area
+

Documentation/devicetree/bindings/mfd/apple,smc.yaml line 39

Quoted 10 lines
Documentation/devicetree/bindings/mfd/apple,smc.yaml new file +10 -0
+  reg-names:
+    items:
+      - const: smc
+      - const: sram
+
+  mboxes:
+    maxItems: 1
+
+  gpio:
+    $ref: /schemas/gpio/gpio-macsmc.yaml

So this depends on other patch, so:
1. You need mention the dependency in cover letter (nothing there),
2. Re-order patches.

Quoted 3 lines
Quoted 1 line

The GPIO cannot go separate tree and this must be explicitly communicated.

Sigh, getting an order that is sensible is really bloody difficult.

It's not. Sub-devices before the MFD. The only time that doesn't work is when the sub-devices put the parent MFD in their example. The solution there is don't do that. Just 1 complete example in the MFD schema and no examples in the sub-devices.

Quoted 8 lines
Quoted 2 lines

Meanwhile, I was told by Krzysztof that DT schemas must always have an example. So, different person, different story.

Hm, where do you see a message I told you to always have examples? Maybe in some discussion I mentioned that examples are desired, but not always. There is no point in having example in MFD child device schema if it is already part of the parent MFD binding, where it is actually required for complete picture.

Quoted 3 lines

[email protected]

and

That was independent schema, no references to MFD, thus my comment. If you post such stuff alone without indication it is part of MFD, what do you expect from reviewers?

Quoted 2 lines

[email protected]

Which was comment about MFD, right? It is expected to have example for MFD. I never said it is mandatory for every schema, which you implied in previous mailing.

Quoted 4 lines

For the GPIO macsec binding. So I'm getting contradictory information. First you say that I need an example in the gpio macsec DT binding yaml document.

First you split patches making reviewers life difficult. Then reviewers don't get entire concept and they answer based what they got.

Quoted 2 lines

Now I'm told it should go in the parent.

After posting entire patchset with context you can get better review, yes, that's right.

Quoted 3 lines

Make up your bloody minds and stop pissing me about. This is why I've given up trying to get this in.

I don't think it is constructive to discuss this with you anymore.

Quoted 3 lines

Getting a consistent message would be nice, but it seems impossible.

Best regards,
Krzysztof

#158 lore raw

Re: [PATCH v3 3/7] dt-bindings: mfd: add binding for Apple Mac System Management Controller

Quoted 125 lines · Krzysztof Kozlowski
Quoted 97 lines · Russell King (Oracle)
Quoted 87 lines · Krzysztof Kozlowski
Quoted 86 lines · Russell King (Oracle)
Quoted 84 lines · Rob Herring
Quoted 75 lines · Russell King (Oracle)
Quoted 4 lines · Krzysztof Kozlowski
Quoted 1 line · Russell King (Oracle)

Add a DT binding for the Apple Mac System Management Controller.

Drop the second, redundant "binding" from subject. It's already in prefix.

Yet another thing that's been there from the start... how many more things are you going to pick up in subsequent versions of the patch? When does this stop?

In any case, taking your comment literally,

"dt-bindings: mfd: add for Apple Mac System Management Controller"

makes no sense, so presumably you want something more than that.

In any case, I see several recent cases already merged which follow the pattern that I've used and that you've reviewed.

Quoted 56 lines
Quoted 41 lines
---
 .../devicetree/bindings/mfd/apple,smc.yaml    | 67 +++++++++++++++++++
 1 file changed, 67 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mfd/apple,smc.yaml
Documentation/devicetree/bindings/mfd/apple,smc.yaml new file +29 -0
new file mode 100644
index 000000000000..014eba5a1bbc
@@ -0,0 +1,67 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/mfd/apple,smc.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Apple Mac System Management Controller
+
+maintainers:
+  - Hector Martin <[email protected]>
+
+description:
+  Apple Mac System Management Controller implements various functions
+  such as GPIO, RTC, power, reboot.
+
+properties:
+  compatible:
+    items:
+      - enum:
+          - apple,t6000-smc
+          - apple,t8103-smc
+          - apple,t8112-smc
+      - const: apple,smc
+
+  reg:
+    items:
+      - description: SMC area
+      - description: SRAM area
+

Documentation/devicetree/bindings/mfd/apple,smc.yaml line 39

Quoted 10 lines
Documentation/devicetree/bindings/mfd/apple,smc.yaml new file +10 -0
+  reg-names:
+    items:
+      - const: smc
+      - const: sram
+
+  mboxes:
+    maxItems: 1
+
+  gpio:
+    $ref: /schemas/gpio/gpio-macsmc.yaml

So this depends on other patch, so:
1. You need mention the dependency in cover letter (nothing there),
2. Re-order patches.

Quoted 3 lines
Quoted 1 line

The GPIO cannot go separate tree and this must be explicitly communicated.

Sigh, getting an order that is sensible is really bloody difficult.

It's not. Sub-devices before the MFD. The only time that doesn't work is when the sub-devices put the parent MFD in their example. The solution there is don't do that. Just 1 complete example in the MFD schema and no examples in the sub-devices.

Quoted 8 lines
Quoted 2 lines

Meanwhile, I was told by Krzysztof that DT schemas must always have an example. So, different person, different story.

Hm, where do you see a message I told you to always have examples? Maybe in some discussion I mentioned that examples are desired, but not always. There is no point in having example in MFD child device schema if it is already part of the parent MFD binding, where it is actually required for complete picture.

Quoted 3 lines

[email protected]

and

That was independent schema, no references to MFD, thus my comment. If you post such stuff alone without indication it is part of MFD, what do you expect from reviewers?

Quoted 2 lines

[email protected]

Which was comment about MFD, right? It is expected to have example for MFD. I never said it is mandatory for every schema, which you implied in previous mailing.

Quoted 4 lines

For the GPIO macsec binding. So I'm getting contradictory information. First you say that I need an example in the gpio macsec DT binding yaml document.

First you split patches making reviewers life difficult. Then reviewers don't get entire concept and they answer based what they got.

Quoted 2 lines

Now I'm told it should go in the parent.

Quoted 13 lines

After posting entire patchset with context you can get better review, yes, that's right.

Quoted 3 lines

Make up your bloody minds and stop pissing me about. This is why I've given up trying to get this in.

I don't think it is constructive to discuss this with you anymore.

Quoted 3 lines

Getting a consistent message would be nice, but it seems impossible.

In which case you CLEARLY didn't read the cover message to that two patch series.

Again, YOU are giving contradictory information.

Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
#159 lore raw

Re: [PATCH v3 3/7] dt-bindings: mfd: add binding for Apple Mac System Management Controller

Quoted 7 lines · Russell King (Oracle)
Quoted 7 lines
Quoted 3 lines

Make up your bloody minds and stop pissing me about. This is why I've given up trying to get this in.

I don't think it is constructive to discuss this with you anymore.

Quoted 1 line
Quoted 6 lines
Quoted 3 lines
Quoted 2 lines

Getting a consistent message would be nice, but it seems impossible.

In which case you CLEARLY didn't read the cover message to that two patch series.

I have every day 100-200 new patches, so not every cover letter gets enough attention. Your did not say this is part of MFD, just mentioned some build dependency.

Anyway, job of submitter is to make the patch and its context readable to the reviewers.

There is literally nothing about including in parent MFD node in DT. Just take a look:

https://lore.kernel.org/all/[email protected]/

Or maybe you refer to this:
"previously posted before the last merge window."
Yes, so I will go through hundreds of emails from a week or months to satisfy you?

"this driver is dependent on the
Apple SMC driver in order to be buildable and usable."

The only hint... it's about driver, not MFD. Make it obvious for readers, not obvious for you.

"It is expected
that this Apple SMC driver will be merged via Lee's MFD tree."

Maybe there is dependency, maybe not, who the heck knows.

Quoted 1 line

Again, YOU are giving contradictory information.

Best regards,
Krzysztof

#160 lore raw

Re: [PATCH v3 3/7] dt-bindings: mfd: add binding for Apple Mac System Management Controller

Quoted 35 lines · Krzysztof Kozlowski
Quoted 7 lines · Russell King (Oracle)
Quoted 7 lines
Quoted 3 lines

Make up your bloody minds and stop pissing me about. This is why I've given up trying to get this in.

I don't think it is constructive to discuss this with you anymore.

Quoted 1 line
Quoted 6 lines
Quoted 3 lines
Quoted 2 lines

Getting a consistent message would be nice, but it seems impossible.

In which case you CLEARLY didn't read the cover message to that two patch series.

I have every day 100-200 new patches, so not every cover letter gets enough attention. Your did not say this is part of MFD, just mentioned some build dependency.

Anyway, job of submitter is to make the patch and its context readable to the reviewers.

There is literally nothing about including in parent MFD node in DT. Just take a look:

https://lore.kernel.org/all/[email protected]/

Or maybe you refer to this:
"previously posted before the last merge window."
Yes, so I will go through hundreds of emails from a week or months to satisfy you?

"this driver is dependent on the
Apple SMC driver in order to be buildable and usable."

Quoted 7 lines

The only hint... it's about driver, not MFD. Make it obvious for readers, not obvious for you.

"It is expected
that this Apple SMC driver will be merged via Lee's MFD tree."

Maybe there is dependency, maybe not, who the heck knows.

Everything that needed to be said was said in the cover message.

I'm not going to bother continuing with this thread because there is nothing more to be said. This is getting utterly idiotic.

Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
maintainer
#137 lore raw

Re: [PATCH v3 1/7] mfd: Add core Apple Mac SMC driver

In reply to Russell King (Oracle)
Quoted 9 lines · Russell King

From: Hector Martin <[email protected]>

This driver implements support for the SMC (System Management Controller) in Apple Macs. In contrast to the existing applesmc driver, it uses pluggable backends that allow it to support different SMC implementations, and uses the MFD subsystem to expose the core SMC functionality so that specific features (gpio, hwmon, battery, etc.) can be implemented by separate drivers in their respective downstream subsystems.

Could we have Russell's ASCII simplified architecture model here please?

Quoted 16 lines
---
 drivers/mfd/Kconfig        |   4 +
 drivers/mfd/Makefile       |   1 +
 drivers/mfd/macsmc.c       | 239 +++++++++++++++++++++++++++++++++++++
 include/linux/mfd/macsmc.h | 104 ++++++++++++++++
 4 files changed, 348 insertions(+)
 create mode 100644 drivers/mfd/macsmc.c
 create mode 100644 include/linux/mfd/macsmc.h
drivers/mfd/Kconfig +0 -0
index 8b93856de432..f73e098b7228 100644

drivers/mfd/Kconfig config MFD_CROS_EC_DEV · line 228

Quoted 5 lines
drivers/mfd/Kconfig +2 -0
@@ -224,6 +224,10 @@ config MFD_CROS_EC_DEV
 	  To compile this driver as a module, choose M here: the module will be
 	  called cros-ec-dev.
 
+config MFD_MACSMC
+	tristate

Is this selectable?

Worth having a description?

drivers/mfd/Kconfig config MFD_CROS_EC_DEV · line 229

Quoted 1 line
drivers/mfd/Kconfig +1 -0
+	select MFD_CORE

Help section?

Copy / paste from the commit log should be enough.

Quoted 21 lines
drivers/mfd/Kconfig +0 -0
 config MFD_MADERA
 	tristate "Cirrus Logic Madera codecs"
 	select MFD_CORE
drivers/mfd/Makefile +1 -0
index 7ed3ef4a698c..a5271b578d31 100644
@@ -17,6 +17,7 @@ obj-$(CONFIG_MFD_CROS_EC_DEV)	+= cros_ec_dev.o
 obj-$(CONFIG_MFD_ENE_KB3930)	+= ene-kb3930.o
 obj-$(CONFIG_MFD_EXYNOS_LPASS)	+= exynos-lpass.o
 obj-$(CONFIG_MFD_GATEWORKS_GSC)	+= gateworks-gsc.o
+obj-$(CONFIG_MFD_MACSMC)	+= macsmc.o
 
 obj-$(CONFIG_HTC_PASIC3)	+= htc-pasic3.o
 obj-$(CONFIG_HTC_I2CPLD)	+= htc-i2cpld.o
drivers/mfd/macsmc.c new file +0 -0
new file mode 100644
index 000000000000..e5c3957efea4

drivers/mfd/macsmc.c line 3

Quoted 3 lines
drivers/mfd/macsmc.c new file +3 -0
@@ -0,0 +1,239 @@
+// SPDX-License-Identifier: GPL-2.0-only OR MIT
+/*
+ * Apple SMC core framework

"SMC (System Management Controller)"

Tiny nit: '\n'

drivers/mfd/macsmc.c line 4

Quoted 1 line
drivers/mfd/macsmc.c new file +1 -0
+ * Copyright The Asahi Linux Contributors

Missing (C)

Would you like an Author(s) line here?

drivers/mfd/macsmc.c line 12

Quoted 8 lines
drivers/mfd/macsmc.c new file +8 -0
+ */
+
+#include <linux/device.h>
+#include <linux/mfd/core.h>
+#include <linux/mfd/macsmc.h>
+#include <linux/mutex.h>
+#include <linux/notifier.h>
+

Would you be kind enough to add a header here to describe the attributes please. Some of them are non-standard.

Quoted 125 lines
drivers/mfd/macsmc.c new file +125 -0
+struct apple_smc {
+	struct device *dev;
+
+	void *be_cookie;
+	const struct apple_smc_backend_ops *be;
+
+	struct mutex mutex;
+
+	u32 key_count;
+	smc_key first_key;
+	smc_key last_key;
+
+	struct blocking_notifier_head event_handlers;
+};
+
+static const struct mfd_cell apple_smc_devs[] = {
+	MFD_CELL_OF("macsmc-gpio", NULL, NULL, 0, 0, "apple,smc-gpio"),
+	MFD_CELL_NAME("macsmc-hid"),
+	MFD_CELL_NAME("macsmc-power"),
+	MFD_CELL_NAME("macsmc-reboot"),
+	MFD_CELL_OF("macsmc-rtc", NULL, NULL, 0, 0, "apple,smc-rtc"),
+};
+
+int apple_smc_read(struct apple_smc *smc, smc_key key, void *buf, size_t size)
+{
+	int ret;
+
+	mutex_lock(&smc->mutex);
+	ret = smc->be->read_key(smc->be_cookie, key, buf, size);
+	mutex_unlock(&smc->mutex);
+
+	return ret;
+}
+EXPORT_SYMBOL(apple_smc_read);
+
+int apple_smc_write(struct apple_smc *smc, smc_key key, void *buf, size_t size)
+{
+	int ret;
+
+	mutex_lock(&smc->mutex);
+	ret = smc->be->write_key(smc->be_cookie, key, buf, size);
+	mutex_unlock(&smc->mutex);
+
+	return ret;
+}
+EXPORT_SYMBOL(apple_smc_write);
+
+int apple_smc_write_atomic(struct apple_smc *smc, smc_key key, void *buf, size_t size)
+{
+	int ret;
+
+	/*
+	 * Will fail if SMC is busy. This is only used by SMC reboot/poweroff
+	 * final calls, so it doesn't really matter at that point.
+	 */
+	if (!mutex_trylock(&smc->mutex))
+		return -EBUSY;
+
+	ret = smc->be->write_key_atomic(smc->be_cookie, key, buf, size);
+	mutex_unlock(&smc->mutex);
+
+	return ret;
+}
+EXPORT_SYMBOL(apple_smc_write_atomic);
+
+int apple_smc_rw(struct apple_smc *smc, smc_key key, void *wbuf, size_t wsize,
+		 void *rbuf, size_t rsize)
+{
+	int ret;
+
+	mutex_lock(&smc->mutex);
+	ret = smc->be->rw_key(smc->be_cookie, key, wbuf, wsize, rbuf, rsize);
+	mutex_unlock(&smc->mutex);
+
+	return ret;
+}
+EXPORT_SYMBOL(apple_smc_rw);
+
+int apple_smc_get_key_by_index(struct apple_smc *smc, int index, smc_key *key)
+{
+	int ret;
+
+	mutex_lock(&smc->mutex);
+	ret = smc->be->get_key_by_index(smc->be_cookie, index, key);
+	mutex_unlock(&smc->mutex);
+
+	return ret;
+}
+EXPORT_SYMBOL(apple_smc_get_key_by_index);
+
+int apple_smc_get_key_info(struct apple_smc *smc, smc_key key, struct apple_smc_key_info *info)
+{
+	int ret;
+
+	mutex_lock(&smc->mutex);
+	ret = smc->be->get_key_info(smc->be_cookie, key, info);
+	mutex_unlock(&smc->mutex);
+
+	return ret;
+}
+EXPORT_SYMBOL(apple_smc_get_key_info);
+
+int apple_smc_find_first_key_index(struct apple_smc *smc, smc_key key)
+{
+	int start = 0, count = smc->key_count;
+	int ret;
+
+	if (key <= smc->first_key)
+		return 0;
+	if (key > smc->last_key)
+		return smc->key_count;
+
+	while (count > 1) {
+		int pivot = start + ((count - 1) >> 1);
+		smc_key pkey;
+
+		ret = apple_smc_get_key_by_index(smc, pivot, &pkey);
+		if (ret < 0)
+			return ret;
+
+		if (pkey == key)
+			return pivot;
+
+		pivot++;
+

drivers/mfd/macsmc.c line 147

Quoted 10 lines
drivers/mfd/macsmc.c new file +10 -0
+		if (pkey < key) {
+			count -= pivot - start;
+			start = pivot;
+		} else {
+			count = pivot - start;
+		}
+	}
+
+	return start;
+}

Maybe a 1 or 2 line comment to provide an overview of what's happening in here please.

Quoted 22 lines
drivers/mfd/macsmc.c new file +22 -0
+EXPORT_SYMBOL(apple_smc_find_first_key_index);
+
+int apple_smc_get_key_count(struct apple_smc *smc)
+{
+	return smc->key_count;
+}
+EXPORT_SYMBOL(apple_smc_get_key_count);
+
+void apple_smc_event_received(struct apple_smc *smc, uint32_t event)
+{
+	dev_dbg(smc->dev, "Event: 0x%08x\n", event);
+	blocking_notifier_call_chain(&smc->event_handlers, event, NULL);
+}
+EXPORT_SYMBOL(apple_smc_event_received);
+
+int apple_smc_register_notifier(struct apple_smc *smc, struct notifier_block *n)
+{
+	return blocking_notifier_chain_register(&smc->event_handlers, n);
+}
+EXPORT_SYMBOL(apple_smc_register_notifier);
+
+int apple_smc_unregister_notifier(struct apple_smc *smc, struct notifier_block *n)

drivers/mfd/macsmc.c line 179

Quoted 10 lines
drivers/mfd/macsmc.c new file +10 -0
+{
+	return blocking_notifier_chain_unregister(&smc->event_handlers, n);
+}
+EXPORT_SYMBOL(apple_smc_unregister_notifier);
+
+void *apple_smc_get_cookie(struct apple_smc *smc)
+{
+	return smc->be_cookie;
+}
+EXPORT_SYMBOL(apple_smc_get_cookie);

These parts seem like abstraction for the sake of abstraction.

Any reason why the caller can't use the blocking_notifier_* API and look into the apple_smc for themselves.

Quoted 28 lines
drivers/mfd/macsmc.c new file +28 -0
+struct apple_smc *apple_smc_probe(struct device *dev, const struct apple_smc_backend_ops *ops, void *cookie)
+{
+	struct apple_smc *smc;
+	u32 count;
+	int ret;
+
+	smc = devm_kzalloc(dev, sizeof(*smc), GFP_KERNEL);
+	if (!smc)
+		return ERR_PTR(-ENOMEM);
+
+	smc->dev = dev;
+	smc->be_cookie = cookie;
+	smc->be = ops;
+	mutex_init(&smc->mutex);
+	BLOCKING_INIT_NOTIFIER_HEAD(&smc->event_handlers);
+
+	ret = apple_smc_read_u32(smc, SMC_KEY(#KEY), &count);
+	if (ret)
+		return ERR_PTR(dev_err_probe(dev, ret, "Failed to get key count"));
+	smc->key_count = be32_to_cpu(count);
+
+	ret = apple_smc_get_key_by_index(smc, 0, &smc->first_key);
+	if (ret)
+		return ERR_PTR(dev_err_probe(dev, ret, "Failed to get first key"));
+
+	ret = apple_smc_get_key_by_index(smc, smc->key_count - 1, &smc->last_key);
+	if (ret)
+		return ERR_PTR(dev_err_probe(dev, ret, "Failed to get last key"));

drivers/mfd/macsmc.c line 218

Quoted 10 lines
drivers/mfd/macsmc.c new file +10 -0
+
+	/* Enable notifications */
+	apple_smc_write_flag(smc, SMC_KEY(NTAP), 1);
+
+	dev_info(dev, "Initialized (%d keys %p4ch..%p4ch)\n",
+		 smc->key_count, &smc->first_key, &smc->last_key);
+
+	dev_set_drvdata(dev, smc);
+
+	ret = mfd_add_devices(dev, -1, apple_smc_devs, ARRAY_SIZE(apple_smc_devs), NULL, 0, NULL);

Please replace the -1 with the defines provided.

drivers/mfd/macsmc.c line 219

Quoted 2 lines
drivers/mfd/macsmc.c new file +2 -0
+	if (ret)
+		return ERR_PTR(dev_err_probe(dev, ret, "Subdevice initialization failed"));

"Failed to register sub-devices"

drivers/mfd/macsmc.c line 228

Quoted 7 lines
drivers/mfd/macsmc.c new file +7 -0
+	return smc;
+}
+EXPORT_SYMBOL(apple_smc_probe);
+
+int apple_smc_remove(struct apple_smc *smc)
+{
+	mfd_remove_devices(smc->dev);

devm_*?

drivers/mfd/macsmc.c line 231

Quoted 2 lines
drivers/mfd/macsmc.c new file +2 -0
+	/* Disable notifications */
+	apple_smc_write_flag(smc, SMC_KEY(NTAP), 1);

The same command enables and disables notifications?

drivers/mfd/macsmc.c line 239

Quoted 7 lines
drivers/mfd/macsmc.c new file +7 -0
+	return 0;
+}
+EXPORT_SYMBOL(apple_smc_remove);
+
+MODULE_AUTHOR("Hector Martin <[email protected]>");
+MODULE_LICENSE("Dual MIT/GPL");
+MODULE_DESCRIPTION("Apple SMC core");

SMC (System Management Controller)

include/linux/mfd/macsmc.h line 3

Quoted 9 lines
include/linux/mfd/macsmc.h new file +3 -0
new file mode 100644
index 000000000000..99cfa23f27bd
@@ -0,0 +1,104 @@
+// SPDX-License-Identifier: GPL-2.0-only OR MIT
+/*
+ * Apple SMC core definitions

SMC (System Management Controller)

include/linux/mfd/macsmc.h line 10

Quoted 7 lines
include/linux/mfd/macsmc.h new file +7 -0
+ * Copyright (C) The Asahi Linux Contributors
+ */
+
+#ifndef _LINUX_MFD_MACSMC_H
+#define _LINUX_MFD_MACSMC_H
+
+struct apple_smc;

You can move the definition into here and omit this line.

Quoted 55 lines
include/linux/mfd/macsmc.h new file +55 -0
+typedef u32 smc_key;
+
+#define SMC_KEY(s) (smc_key)(_SMC_KEY(#s))
+#define _SMC_KEY(s) (((s)[0] << 24) | ((s)[1] << 16) | ((s)[2] << 8) | (s)[3])
+
+#define APPLE_SMC_READABLE BIT(7)
+#define APPLE_SMC_WRITABLE BIT(6)
+#define APPLE_SMC_FUNCTION BIT(4)
+
+struct apple_smc_key_info {
+	u8 size;
+	u32 type_code;
+	u8 flags;
+};
+
+int apple_smc_read(struct apple_smc *smc, smc_key key, void *buf, size_t size);
+int apple_smc_write(struct apple_smc *smc, smc_key key, void *buf, size_t size);
+int apple_smc_write_atomic(struct apple_smc *smc, smc_key key, void *buf, size_t size);
+int apple_smc_rw(struct apple_smc *smc, smc_key key, void *wbuf, size_t wsize,
+		 void *rbuf, size_t rsize);
+
+int apple_smc_get_key_count(struct apple_smc *smc);
+int apple_smc_find_first_key_index(struct apple_smc *smc, smc_key key);
+int apple_smc_get_key_by_index(struct apple_smc *smc, int index, smc_key *key);
+int apple_smc_get_key_info(struct apple_smc *smc, smc_key key, struct apple_smc_key_info *info);
+
+static inline bool apple_smc_key_exists(struct apple_smc *smc, smc_key key)
+{
+	return apple_smc_get_key_info(smc, key, NULL) >= 0;
+}
+
+#define APPLE_SMC_TYPE_OPS(type) \
+	static inline int apple_smc_read_##type(struct apple_smc *smc, smc_key key, type *p) \
+	{ \
+		int ret = apple_smc_read(smc, key, p, sizeof(*p)); \
+		return (ret < 0) ? ret : ((ret != sizeof(*p)) ? -EINVAL : 0); \
+	} \
+	static inline int apple_smc_write_##type(struct apple_smc *smc, smc_key key, type p) \
+	{ \
+		return apple_smc_write(smc, key, &p, sizeof(p)); \
+	} \
+	static inline int apple_smc_write_##type##_atomic(struct apple_smc *smc, smc_key key, type p) \
+	{ \
+		return apple_smc_write_atomic(smc, key, &p, sizeof(p)); \
+	} \
+	static inline int apple_smc_rw_##type(struct apple_smc *smc, smc_key key, \
+					      type w, type *r) \
+	{ \
+		int ret = apple_smc_rw(smc, key, &w, sizeof(w), r, sizeof(*r)); \
+		return (ret < 0) ? ret : ((ret != sizeof(*r)) ? -EINVAL : 0); \
+	}
+
+APPLE_SMC_TYPE_OPS(u64)
+APPLE_SMC_TYPE_OPS(u32)
+APPLE_SMC_TYPE_OPS(u16)

include/linux/mfd/macsmc.h line 76

Quoted 10 lines
include/linux/mfd/macsmc.h new file +10 -0
+APPLE_SMC_TYPE_OPS(u8)
+APPLE_SMC_TYPE_OPS(s64)
+APPLE_SMC_TYPE_OPS(s32)
+APPLE_SMC_TYPE_OPS(s16)
+APPLE_SMC_TYPE_OPS(s8)
+
+static inline int apple_smc_read_flag(struct apple_smc *smc, smc_key key)
+{
+	u8 val;
+	int ret = apple_smc_read_u8(smc, key, &val);

Nit: Please separate the declaration and assignment via function call with a line break in between.

Quoted 28 lines
include/linux/mfd/macsmc.h new file +28 -0
+	if (ret < 0)
+		return ret;
+	return val ? 1 : 0;
+}
+#define apple_smc_write_flag apple_smc_write_u8
+
+int apple_smc_register_notifier(struct apple_smc *smc, struct notifier_block *n);
+int apple_smc_unregister_notifier(struct apple_smc *smc, struct notifier_block *n);
+
+/* backend interface */
+
+struct apple_smc_backend_ops {
+	int (*read_key)(void *cookie, smc_key key, void *buf, size_t size);
+	int (*write_key)(void *cookie, smc_key key, void *buf, size_t size);
+	int (*write_key_atomic)(void *cookie, smc_key key, void *buf, size_t size);
+	int (*rw_key)(void *cookie, smc_key key, void *wbuf, size_t wsize,
+		      void *rbuf, size_t rsize);
+	int (*get_key_by_index)(void *cookie, int index, smc_key *key);
+	int (*get_key_info)(void *cookie, smc_key key, struct apple_smc_key_info *info);
+};
+
+struct apple_smc *apple_smc_probe(struct device *dev, const struct apple_smc_backend_ops *ops,
+				  void *cookie);
+void *apple_smc_get_cookie(struct apple_smc *smc);
+int apple_smc_remove(struct apple_smc *smc);
+void apple_smc_event_received(struct apple_smc *smc, uint32_t event);
+
+#endif
Signature · 1 line
Lee Jones [李琼斯]
maintainer
#161 lore raw

Re: [PATCH v3 3/7] dt-bindings: mfd: add binding for Apple Mac System Management Controller

In reply to Rob Herring
Quoted 85 lines · Rob Herring
Quoted 75 lines · Russell King (Oracle)
Quoted 4 lines · Krzysztof Kozlowski
Quoted 1 line · Russell King (Oracle)

Add a DT binding for the Apple Mac System Management Controller.

Drop the second, redundant "binding" from subject. It's already in prefix.

Yet another thing that's been there from the start... how many more things are you going to pick up in subsequent versions of the patch? When does this stop?

In any case, taking your comment literally,

"dt-bindings: mfd: add for Apple Mac System Management Controller"

makes no sense, so presumably you want something more than that.

In any case, I see several recent cases already merged which follow the pattern that I've used and that you've reviewed.

Quoted 56 lines
Quoted 41 lines
---
 .../devicetree/bindings/mfd/apple,smc.yaml    | 67 +++++++++++++++++++
 1 file changed, 67 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mfd/apple,smc.yaml
Documentation/devicetree/bindings/mfd/apple,smc.yaml new file +29 -0
new file mode 100644
index 000000000000..014eba5a1bbc
@@ -0,0 +1,67 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/mfd/apple,smc.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Apple Mac System Management Controller
+
+maintainers:
+  - Hector Martin <[email protected]>
+
+description:
+  Apple Mac System Management Controller implements various functions
+  such as GPIO, RTC, power, reboot.
+
+properties:
+  compatible:
+    items:
+      - enum:
+          - apple,t6000-smc
+          - apple,t8103-smc
+          - apple,t8112-smc
+      - const: apple,smc
+
+  reg:
+    items:
+      - description: SMC area
+      - description: SRAM area
+

Documentation/devicetree/bindings/mfd/apple,smc.yaml line 39

Quoted 10 lines
Documentation/devicetree/bindings/mfd/apple,smc.yaml new file +10 -0
+  reg-names:
+    items:
+      - const: smc
+      - const: sram
+
+  mboxes:
+    maxItems: 1
+
+  gpio:
+    $ref: /schemas/gpio/gpio-macsmc.yaml

So this depends on other patch, so:
1. You need mention the dependency in cover letter (nothing there),
2. Re-order patches.

Quoted 3 lines
Quoted 1 line

The GPIO cannot go separate tree and this must be explicitly communicated.

Sigh, getting an order that is sensible is really bloody difficult.

It's not. Sub-devices before the MFD. The only time that doesn't work is when the sub-devices put the parent MFD in their example. The solution there is don't do that. Just 1 complete example in the MFD schema and no examples in the sub-devices.

Quoted 4 lines
Quoted 1 line

I'm quite sure Lee is only going to want to apply the mfd bits.

Indeed. I can't seem to make Lee care... All the schemas should really be applied together.

I care about drivers. Happy to take the set as a whole if it helps.

Signature · 1 line
Lee Jones [李琼斯]
#138 lore raw

Re: [PATCH v3 1/7] mfd: Add core Apple Mac SMC driver

In reply to Russell King (Oracle)
Quoted 9 lines · Russell King

From: Hector Martin <[email protected]>

This driver implements support for the SMC (System Management Controller) in Apple Macs. In contrast to the existing applesmc driver, it uses pluggable backends that allow it to support different SMC implementations, and uses the MFD subsystem to expose the core SMC functionality so that specific features (gpio, hwmon, battery, etc.) can be implemented by separate drivers in their respective downstream subsystems.

...

drivers/mfd/macsmc.c line 218

Quoted 1 line
drivers/mfd/macsmc.c new file +1 -0
+	ret = mfd_add_devices(dev, -1, apple_smc_devs, ARRAY_SIZE(apple_smc_devs), NULL, 0, NULL);

PLATFORM_DEVID_NONE

Quoted 2 lines
(quoted diff) +2 -0
+	if (ret)
+		return ERR_PTR(dev_err_probe(dev, ret, "Subdevice initialization failed"));

...

Quoted 1 line

+EXPORT_SYMBOL(apple_smc_probe);

Namespace?

Signature · 2 lines
With Best Regards,
Andy Shevchenko
maintainer Reviewed-by on v3 2/7
#140 lore raw

Re: [PATCH v3 2/7] lib/vsprintf: Add support for generic FOURCCs by extending %p4cc

In reply to Russell King (Oracle)
Quoted 19 lines · Russell King

From: Hector Martin <[email protected]>

%p4cc is designed for DRM/V4L2 FOURCCs with their specific quirks, but it's useful to be able to print generic 4-character codes formatted as an integer. Extend it to add format specifiers for printing generic 32-bit FOURCCs with various endian semantics:

%p4ch Host-endian
%p4cl Little-endian
%p4cb Big-endian
%p4cr Reverse-endian

The endianness determines how bytes are interpreted as a u32, and the FOURCC is then always printed MSByte-first (this is the opposite of V4L/DRM FOURCCs). This covers most practical cases, e.g. %p4cr would allow printing LSByte-first FOURCCs stored in host endian order (other than the hex form being in character order, not the integer value).

Quoted 2 lines

See one nit below.

Quoted 14 lines
lib/vsprintf.c +2 -1
@@ -1762,27 +1762,50 @@ char *fourcc_string(char *buf, char *end, const u32 *fourcc,
 	char output[sizeof("0123 little-endian (0x01234567)")];
 	char *p = output;
 	unsigned int i;
+	bool pixel_fmt = false;
 	u32 orig, val;
 
-	if (fmt[1] != 'c' || fmt[2] != 'c')
+	if (fmt[1] != 'c')
 		return error_string(buf, end, "(%p4?)", spec);
 
 	if (check_pointer(&buf, end, fourcc, spec))

lib/vsprintf.c char *fourcc_string(char *buf, char *end, const u32 *fourcc, · line 1780

Quoted 10 lines
lib/vsprintf.c +6 -1
 		return buf;
 
 	orig = get_unaligned(fourcc);
-	val = orig & ~BIT(31);
+	switch (fmt[2]) {
+	case 'h':
+		val = orig;
+		break;
+	case 'r':
+		val = orig = swab32(orig);

I do not like much these multi assignments. I think that the result was not even defined in some older C standards. Though, I can't find it now. And even make W=3 does not warn about it.

lib/vsprintf.c char *fourcc_string(char *buf, char *end, const u32 *fourcc, · line 1787

Quoted 7 lines
lib/vsprintf.c +7 -0
+		break;
+	case 'l':
+		val = orig = le32_to_cpu(orig);
+		break;
+	case 'b':
+		val = orig = be32_to_cpu(orig);
+		break;

Best Regards,
Petr

#141 lore raw

Re: [PATCH v3 2/7] lib/vsprintf: Add support for generic FOURCCs by extending %p4cc

Quoted 1 line · Petr Mladek

On Tue 2022-11-08 16:33:22, Russell King wrote:

...

Quoted 13 lines

lib/vsprintf.c char *fourcc_string(char *buf, char *end, const u32 *fourcc, · line 1780

Quoted 8 lines
lib/vsprintf.c +6 -1
 	orig = get_unaligned(fourcc);
-	val = orig & ~BIT(31);
+	switch (fmt[2]) {
+	case 'h':
+		val = orig;
+		break;
+	case 'r':
+		val = orig = swab32(orig);

I do not like much these multi assignments. I think that the result was not even defined in some older C standards. Though, I can't find it now. And even make W=3 does not warn about it.

Quoted 7 lines

lib/vsprintf.c char *fourcc_string(char *buf, char *end, const u32 *fourcc, · line 1787

Quoted 7 lines
lib/vsprintf.c +7 -0
+		break;
+	case 'l':
+		val = orig = le32_to_cpu(orig);
+		break;
+	case 'b':
+		val = orig = be32_to_cpu(orig);
+		break;

Isn't easy to fix? Something like below?

	switch (fmt[2]) {
	case 'h':
		break;
	case 'r':
		orig = swab32(orig);
		break;
	case 'l':
		orig = le32_to_cpu(orig);
		break;
	case 'b':
		orig = be32_to_cpu(orig);
		break;

		...
	}
	val = orig;
Signature · 2 lines
With Best Regards,
Andy Shevchenko
#143 lore raw

Re: [PATCH v3 2/7] lib/vsprintf: Add support for generic FOURCCs by extending %p4cc

In reply to Petr Mladek
Quoted 43 lines · Petr Mladek
Quoted 19 lines · Russell King

From: Hector Martin <[email protected]>

%p4cc is designed for DRM/V4L2 FOURCCs with their specific quirks, but it's useful to be able to print generic 4-character codes formatted as an integer. Extend it to add format specifiers for printing generic 32-bit FOURCCs with various endian semantics:

%p4ch Host-endian
%p4cl Little-endian
%p4cb Big-endian
%p4cr Reverse-endian

The endianness determines how bytes are interpreted as a u32, and the FOURCC is then always printed MSByte-first (this is the opposite of V4L/DRM FOURCCs). This covers most practical cases, e.g. %p4cr would allow printing LSByte-first FOURCCs stored in host endian order (other than the hex form being in character order, not the integer value).

Quoted 2 lines

See one nit below.

Quoted 16 lines
lib/vsprintf.c +2 -1
@@ -1762,27 +1762,50 @@ char *fourcc_string(char *buf, char *end, const u32 *fourcc,
 	char output[sizeof("0123 little-endian (0x01234567)")];
 	char *p = output;
 	unsigned int i;
+	bool pixel_fmt = false;
 	u32 orig, val;
 
-	if (fmt[1] != 'c' || fmt[2] != 'c')
+	if (fmt[1] != 'c')
 		return error_string(buf, end, "(%p4?)", spec);
 
 	if (check_pointer(&buf, end, fourcc, spec))
 		return buf;
 
Quoted 12 lines

lib/vsprintf.c char *fourcc_string(char *buf, char *end, const u32 *fourcc, · line 1780

Quoted 8 lines
lib/vsprintf.c +6 -1
 	orig = get_unaligned(fourcc);
-	val = orig & ~BIT(31);
+	switch (fmt[2]) {
+	case 'h':
+		val = orig;
+		break;
+	case 'r':
+		val = orig = swab32(orig);

I do not like much these multi assignments. I think that the result was not even defined in some older C standards. Though, I can't find it now. And even make W=3 does not warn about it.

Err.

It's been supported for decades. I learnt about it back in 1992 when I was introduced to C by another experienced C programmer. It's been supported in ANSI C compilers. The Norcroft C compiler (which is strict ANSI) on Acorn platforms back in the late 1980s/1990s even supported it.

I think you're a bit out of date.

Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
maintainer
#142 lore raw

Re: [PATCH v3 2/7] lib/vsprintf: Add support for generic FOURCCs by extending %p4cc

In reply to Andy Shevchenko
Quoted 28 lines · Andy Shevchenko
Quoted 1 line · Petr Mladek

On Tue 2022-11-08 16:33:22, Russell King wrote:

...

Quoted 13 lines

lib/vsprintf.c char *fourcc_string(char *buf, char *end, const u32 *fourcc, · line 1780

Quoted 8 lines
lib/vsprintf.c +6 -1
 	orig = get_unaligned(fourcc);
-	val = orig & ~BIT(31);
+	switch (fmt[2]) {
+	case 'h':
+		val = orig;
+		break;
+	case 'r':
+		val = orig = swab32(orig);

I do not like much these multi assignments. I think that the result was not even defined in some older C standards. Though, I can't find it now. And even make W=3 does not warn about it.

Quoted 7 lines

lib/vsprintf.c char *fourcc_string(char *buf, char *end, const u32 *fourcc, · line 1787

Quoted 7 lines
lib/vsprintf.c +7 -0
+		break;
+	case 'l':
+		val = orig = le32_to_cpu(orig);
+		break;
+	case 'b':
+		val = orig = be32_to_cpu(orig);
+		break;

Isn't easy to fix? Something like below?

Quoted 16 lines
	switch (fmt[2]) {
	case 'h':
		break;
	case 'r':
		orig = swab32(orig);
		break;
	case 'l':
		orig = le32_to_cpu(orig);
		break;
	case 'b':
		orig = be32_to_cpu(orig);
		break;

		...
	}
	val = orig;

I though the same. Unfortunately, this is not valid for the "case c:" path where "orig" stays untouched:

	case 'c':
		/* Pixel formats are printed LSB-first */
		val = swab32(orig & ~BIT(31));
		pixel_fmt = true;
		break;

It is pity that "orig" is handled differently for the pixel and the generic formats.

But I am afraid that there is no good solution. The code will always be a mess when it tries to implement a messy definition.

It would be nice if the the FourCC format was used consistently in all subsystems in the first place.

IMPORTANT: This brings the questions.

Is there actually a standard how to print the original number in FourCC?

Do we really want to modify "orig" in the generic implementation?

Best Regards,
Petr

#144 lore raw

Re: [PATCH v3 2/7] lib/vsprintf: Add support for generic FOURCCs by extending %p4cc

In reply to Russell King (Oracle)
Quoted 16 lines · Russell King (Oracle)
Quoted 4 lines · Petr Mladek
Quoted 4 lines
lib/vsprintf.c +2 -1
 	orig = get_unaligned(fourcc);
-	val = orig & ~BIT(31);
+	switch (fmt[2]) {
+	case 'h':
Quoted 8 lines

lib/vsprintf.c char *fourcc_string(char *buf, char *end, const u32 *fourcc, · line 1780

Quoted 4 lines
lib/vsprintf.c +4 -0
+		val = orig;
+		break;
+	case 'r':
+		val = orig = swab32(orig);

I do not like much these multi assignments. I think that the result was not even defined in some older C standards. Though, I can't find it now. And even make W=3 does not warn about it.

Err.

Quoted 7 lines

It's been supported for decades. I learnt about it back in 1992 when I was introduced to C by another experienced C programmer. It's been supported in ANSI C compilers. The Norcroft C compiler (which is strict ANSI) on Acorn platforms back in the late 1980s/1990s even supported it.

I think you're a bit out of date.

Oh, and it's not like there isn't precedent for doing this in lib/vsprintf.c:

841a915d20c7 vsprintf: Do not have bprintf dereference pointers

+ len = copy = strlen(args);

If you grep lib/, there's many more examples. So, what is in Hectors patch is in no way any different from lots of other examples already merged into the kernel code.

Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
maintainer
#145 lore raw

Re: [PATCH v3 2/7] lib/vsprintf: Add support for generic FOURCCs by extending %p4cc

In reply to Russell King (Oracle)
Quoted 57 lines · Russell King (Oracle)
Quoted 43 lines · Petr Mladek
Quoted 19 lines · Russell King

From: Hector Martin <[email protected]>

%p4cc is designed for DRM/V4L2 FOURCCs with their specific quirks, but it's useful to be able to print generic 4-character codes formatted as an integer. Extend it to add format specifiers for printing generic 32-bit FOURCCs with various endian semantics:

%p4ch Host-endian
%p4cl Little-endian
%p4cb Big-endian
%p4cr Reverse-endian

The endianness determines how bytes are interpreted as a u32, and the FOURCC is then always printed MSByte-first (this is the opposite of V4L/DRM FOURCCs). This covers most practical cases, e.g. %p4cr would allow printing LSByte-first FOURCCs stored in host endian order (other than the hex form being in character order, not the integer value).

Quoted 2 lines

See one nit below.

Quoted 16 lines
lib/vsprintf.c +2 -1
@@ -1762,27 +1762,50 @@ char *fourcc_string(char *buf, char *end, const u32 *fourcc,
 	char output[sizeof("0123 little-endian (0x01234567)")];
 	char *p = output;
 	unsigned int i;
+	bool pixel_fmt = false;
 	u32 orig, val;
 
-	if (fmt[1] != 'c' || fmt[2] != 'c')
+	if (fmt[1] != 'c')
 		return error_string(buf, end, "(%p4?)", spec);
 
 	if (check_pointer(&buf, end, fourcc, spec))
 		return buf;
 
Quoted 12 lines

lib/vsprintf.c char *fourcc_string(char *buf, char *end, const u32 *fourcc, · line 1780

Quoted 8 lines
lib/vsprintf.c +6 -1
 	orig = get_unaligned(fourcc);
-	val = orig & ~BIT(31);
+	switch (fmt[2]) {
+	case 'h':
+		val = orig;
+		break;
+	case 'r':
+		val = orig = swab32(orig);

I do not like much these multi assignments. I think that the result was not even defined in some older C standards. Though, I can't find it now. And even make W=3 does not warn about it.

Quoted 7 lines

Err.

It's been supported for decades. I learnt about it back in 1992 when I was introduced to C by another experienced C programmer. It's been supported in ANSI C compilers. The Norcroft C compiler (which is strict ANSI) on Acorn platforms back in the late 1980s/1990s even supported it.

Ah, the problem probably was with a more complicated assignment. For example, the result of the following code is not obvious:

	  a = b = a++;

Best Regards,
Petr

maintainer
#146 lore raw

Re: [PATCH v3 2/7] lib/vsprintf: Add support for generic FOURCCs by extending %p4cc

In reply to Russell King (Oracle)
Quoted 40 lines · Russell King

From: Hector Martin <[email protected]>

%p4cc is designed for DRM/V4L2 FOURCCs with their specific quirks, but it's useful to be able to print generic 4-character codes formatted as an integer. Extend it to add format specifiers for printing generic 32-bit FOURCCs with various endian semantics:

%p4ch Host-endian
%p4cl Little-endian
%p4cb Big-endian
%p4cr Reverse-endian

The endianness determines how bytes are interpreted as a u32, and the FOURCC is then always printed MSByte-first (this is the opposite of V4L/DRM FOURCCs). This covers most practical cases, e.g. %p4cr would allow printing LSByte-first FOURCCs stored in host endian order (other than the hex form being in character order, not the integer value).

---
 Documentation/core-api/printk-formats.rst | 32 +++++++++++++++++++
 lib/test_printf.c                         | 39 +++++++++++++++++++----
 lib/vsprintf.c                            | 35 ++++++++++++++++----
 3 files changed, 93 insertions(+), 13 deletions(-)
Documentation/core-api/printk-formats.rst +5 -0
index dbe1aacc79d0..92a488884cf8 100644
@@ -625,6 +625,38 @@ Passed by reference.
 	%p4cc	Y10  little-endian (0x20303159)
 	%p4cc	NV12 big-endian (0xb231564e)
 
+Generic FourCC code
+-------------------
+
+::
+	%p4c[hrbl]	gP00 (0x67503030)

Documentation/core-api/printk-formats.rst Passed by reference. · line 642

Quoted 10 lines
Documentation/core-api/printk-formats.rst +10 -0
+
+Print a generic FourCC code, as both ASCII characters and its numerical
+value as hexadecimal.
+
+The additional ``h``, ``r``, ``b``, and ``l`` specifiers are used to specify
+host, reversed, big or little endian order data respectively. Host endian
+order means the data is interpreted as a 32-bit integer and the most
+significant byte is printed first; that is, the character code as printed
+matches the byte order stored in memory on big-endian systems, and is reversed
+on little-endian systems.

I though a bit more about the semantic and got a bit confused. It might be because I am not familiar with FourCC. Anyway, the description in the commit message provided some more clues.

The following documentation looks be more clear to me:

<proposal>
Generic FourCC code
-------------------

::

	%p4c[hrbl]	gP00 (0x67503030)

Print a generic FourCC code, as both ASCII characters and its numerical value as hexadecimal.

The generic FourCC code is always printed in the the big-endian format, the most significant byte first. This is the opposite of V4L/DRM FOURCCs.

The additional ``h``, ``r``, ``b``, and ``l`` specifiers define what endianes is used to load the stored value as 32-bit integer. The value might be stored as host-endian, reverse-host-endian, big-endian, or little endian.

Examples for a little-endian machine, host native load &(u32)0x67503030::

	%p4ch	gP00 (0x67503030)
	%p4cr	00Pg (0x30305067)
	%p4cb	00Pg (0x30305067)
	%p4cl	gP00 (0x67503030)

Examples for a big-endian machine, host native load &(u32)0x67503030::

	%p4ch	gP00 (0x67503030)
	%p4cr	00Pg (0x30305067)
	%p4cb	gP00 (0x67503030)
	%p4cl	00Pg (0x30305067)

</proposal>

Best Regards,
Petr