irqchip: add TC9564 support
Subsystems (2)
cover irqchip: add TC9564 support
This series adds support for the "MSIGEN" (MSI generator) interrupt controller present within the Toshiba TC9564 SoC. This device collects interrupts generated within the TC9564 and forwards them to the host as MSIs.
The TC9564 attaches to a host system via PCIe. It includes a PCIe switch with three downstream ports. An embedded PCIe endpoint is attached to one of these ports, and it implements two PCI functions. Each PCI function implements an MSIGEN unit. Access to the registers used by an MSIGEN is provided by a PCI endpoint bus, which exposes BAR4 of the PCI function it is associated with.
-Alex
Alex Elder (1):
dt-bindings: interrupt-controller: introduce
toshiba,tc9564-msigen.yaml
Daniel Thompson (1):
irqchip: introduce TC9564 SoC MSIGEN support
.../toshiba,tc9564-msigen.yaml | 70 ++++++ MAINTAINERS | 7 + drivers/irqchip/Kconfig | 10 + drivers/irqchip/Makefile | 1 + drivers/irqchip/irq-tc9564-msigen.c | 203 ++++++++++++++++++ 5 files changed, 291 insertions(+) create mode 100644 Documentation/devicetree/bindings/interrupt-controller/toshiba,tc9564-msigen.yaml create mode 100644 drivers/irqchip/irq-tc9564-msigen.c
base-commit: becb95e45ef0dda9ffb35156d909d3da7a2789c3
Signature · 1 line
2.53.0
PATCH 1/2 dt-bindings: interrupt-controller: introduce toshiba,tc9564-msigen.yaml
Define the binding for the MSIGEN interrupt controller present in the Toshiba TC9564 SoC.
--- .../toshiba,tc9564-msigen.yaml | 70 +++++++++++++++++++ MAINTAINERS | 6 ++ 2 files changed, 76 insertions(+) create mode 100644 Documentation/devicetree/bindings/interrupt-controller/toshiba,tc9564-msigen.yaml
Documentation/devicetree/bindings/interrupt-controller/toshiba,tc9564-msigen.yaml new file +70 -0
@@ -0,0 +1,70 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/interrupt-controller/toshiba,tc9564-msigen.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Toshiba TC9564 MSIGEN Interrupt Controller + +maintainers: + - Daniel Thompson <[email protected]> + - Alex Elder <[email protected]> + +description: | + The Toshiba TC9564 is an SoC accessed by a host system through the + upstream PCIe port on the PCIe switch it implements. The switch + includes an embedded PCIe endpoint that provides access to various + SoC peripherals (including an interrupt controller) via its BARs. + + The TC9564 MSIGEN (MSI Generator) provides an interrupt controller + with 25 hardware interrupt lines. It aggregates internal interrupts + and generates a single PCIe MSI to the host. Each PCIe function + implements an MSIGEN instance. + + Each MSIGEN uses a gated clock and reset line. These are provided + by the clock and reset controllers internal to the TC9564. + +allOf: + - $ref: /schemas/interrupt-controller.yaml# + +properties: + compatible: + const: toshiba,tc9564-msigen + + reg: + maxItems: 1 + + interrupt-controller: true + + '#interrupt-cells': + const: 1 + + clocks: + maxItems: 1 + description: Gate clock from the TC9564 clock controller + + resets: + maxItems: 1 + description: Reset signal from the TC9564 reset controller + +required: + - compatible + - reg + - interrupt-controller + - '#interrupt-cells' + +additionalProperties: false + +examples: + - | + #include <dt-bindings/clock/toshiba,tc9564.h> + #include <dt-bindings/reset/toshiba,tc9564.h> + + interrupt-controller@f000 { + compatible = "toshiba,tc9564-msigen"; + reg = <0xf000 0x100>; + interrupt-controller; + #interrupt-cells = <1>; + clocks = <&tc9564_clock0 CLOCK_MSIGEN>; + resets = <&tc9564_reset0 RESET_MSIGEN>; + };
MAINTAINERS +6 -0
@@ -28173,6 +28173,12 @@ F: Documentation/devicetree/bindings/media/i2c/toshiba,tc358743.yaml F: drivers/media/i2c/tc358743* F: include/media/i2c/tc358743.h +TOSHIBA TC9564 MSIGEN DRIVER +M: Alex Elder <[email protected]> +M: Daniel Thompson <[email protected]> +S: Maintained +F: Documentation/devicetree/bindings/interrupt-controller/toshiba,tc9564-msigen.yaml + TOSHIBA TC9564 PCI DRIVER M: Alex Elder <[email protected]> M: Daniel Thompson <[email protected]>
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH 1/2] dt-bindings: interrupt-controller: introduce toshiba,tc9564-msigen.yaml
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider: - [Medium] dt-bindings: missing mandatory clock and reset properties in required list - [Low] dt-bindings…
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [Medium] dt-bindings: missing mandatory clock and reset properties in required list
- [Low] dt-bindings: non-existent header includes cause dt_binding_check failure
- [Low] dt-bindings: maintainer email addresses mismatch between MAINTAINERS and schema --
commit 8cfa6ac36f149ea1d1b37b717117b76943010968
Author: Alex Elder <[email protected]>
dt-bindings: interrupt-controller: introduce toshiba,tc9564-msigen.yaml
Define the binding for the MSIGEN interrupt controller present in the Toshiba TC9564 SoC.
Quoted 4 lines
Documentation/devicetree/bindings/interrupt-controller/toshiba,tc9564-msigen.yaml new file +0
-0
[ ... ]
Documentation/devicetree/bindings/interrupt-controller/toshiba,tc9564-msigen.yaml line 11
Quoted 5 lines
Documentation/devicetree/bindings/interrupt-controller/toshiba,tc9564-msigen.yaml new file +5
-0+title: Toshiba TC9564 MSIGEN Interrupt Controller + +maintainers: + - Daniel Thompson <[email protected]> + - Alex Elder <[email protected]>
[Severity: Low]
This isn't a bug, but is this email domain mismatch intentional? The email addresses listed here in the schema use @riscstar.com, but the MAINTAINERS file entry added in this same patch uses @kernel.org.
This might cause automated tooling to route patch series to incorrect or duplicate addresses.
[ ... ]
Documentation/devicetree/bindings/interrupt-controller/toshiba,tc9564-msigen.yaml line 54
Quoted 5 lines
Documentation/devicetree/bindings/interrupt-controller/toshiba,tc9564-msigen.yaml new file +5
-0+required: + - compatible + - reg + - interrupt-controller + - '#interrupt-cells'
[Severity: Medium]
Should clocks and resets be included in this required list? The binding documentation specifies that each MSIGEN uses a gated clock and reset line.
If they are omitted here, device trees with incomplete hardware configurations will silently pass schema validation, potentially leading to driver failures when attempting to ungate clocks or deassert resets on uninitialized hardware.
Documentation/devicetree/bindings/interrupt-controller/toshiba,tc9564-msigen.yaml line 61
Quoted 7 lines
Documentation/devicetree/bindings/interrupt-controller/toshiba,tc9564-msigen.yaml new file +7
-0+ +additionalProperties: false + +examples: + - | + #include <dt-bindings/clock/toshiba,tc9564.h> + #include <dt-bindings/reset/toshiba,tc9564.h>
[Severity: Low]
Does this cause make dt_binding_check to fail? It looks like these header files are not included in this patch series.
Including headers in the YAML example that do not exist in the source tree will usually cause the C preprocessor to fail during schema validation compilation.
[ ... ]
Quoted 3 lines
MAINTAINERS +0
-0
[ ... ]
Quoted 9 lines
F:
drivers/media/i2c/tc358743*
F:include/media/i2c/tc358743.hMAINTAINERS +6
-0+TOSHIBA TC9564 MSIGEN DRIVER +M: Alex Elder <[email protected]> +M: Daniel Thompson <[email protected]> +S: Maintained +F: Documentation/devicetree/bindings/interrupt-controller/toshiba,tc9564-msigen.yaml +
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Re: [PATCH 1/2] dt-bindings: interrupt-controller: introduce toshiba,tc9564-msigen.yaml
Quoted 30 lines · On 10/12/26 2:07 PM, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [Medium] dt-bindings: missing mandatory clock and reset properties in required list
- [Low] dt-bindings: non-existent header includes causedt_binding_checkfailure
- [Low] dt-bindings: maintainer email addresses mismatch betweenMAINTAINERSand schema --commit
8cfa6ac36f149ea1d1b37b717117b76943010968
Author: Alex Elder <[email protected]>dt-bindings: interrupt-controller: introduce toshiba,tc9564-msigen.yaml
Define the binding for the MSIGEN interrupt controller present in the Toshiba TC9564 SoC.
Quoted 4 lines
Documentation/devicetree/bindings/interrupt-controller/toshiba,tc9564-msigen.yaml new file +0
-0[ ... ]
Documentation/devicetree/bindings/interrupt-controller/toshiba,tc9564-msigen.yaml line 11
Quoted 5 lines
Documentation/devicetree/bindings/interrupt-controller/toshiba,tc9564-msigen.yaml new file +5
-0+title: Toshiba TC9564 MSIGEN Interrupt Controller + +maintainers: + - Daniel Thompson <[email protected]> + - Alex Elder <[email protected]>[Severity: Low]
This isn't a bug, but is this email domain mismatch intentional? The email addresses listed here in the schema use @riscstar.com, but theMAINTAINERSfile entry added in this same patch uses @kernel.org.
Quoted 2 lines
This might cause automated tooling to route patch series to incorrect or duplicate addresses.
Daniel and I are doing this work on behalf of RISCstar, but we use our @kernel.org addresses in the MAINTAINERS file.
[email protected] is the same person as [email protected] [email protected] is the same person as [email protected]
(We should both send updates to the .mailmap file...)
Quoted 11 lines
[ ... ]
Documentation/devicetree/bindings/interrupt-controller/toshiba,tc9564-msigen.yaml line 54
Quoted 5 lines
Documentation/devicetree/bindings/interrupt-controller/toshiba,tc9564-msigen.yaml new file +5
-0+required: + - compatible + - reg + - interrupt-controller + - '#interrupt-cells'[Severity: Medium]
Should clocks and resets be included in this required list? The binding documentation specifies that each MSIGEN uses a gated clock and reset line.
In the code, the calls to the clock and reset are not optional, so yes, these should be required. I will update this in version 2.
Quoted 4 lines
If they are omitted here, device trees with incomplete hardware configurations will silently pass schema validation, potentially leading to driver failures when attempting to ungate clocks or deassert resets on uninitialized hardware.
Quoted 11 lines
Documentation/devicetree/bindings/interrupt-controller/toshiba,tc9564-msigen.yaml line 61
Quoted 7 lines
Documentation/devicetree/bindings/interrupt-controller/toshiba,tc9564-msigen.yaml new file +7
-0+ +additionalProperties: false + +examples: + - | + #include <dt-bindings/clock/toshiba,tc9564.h> + #include <dt-bindings/reset/toshiba,tc9564.h>[Severity: Low]
Does this cause makedt_binding_checkto fail? It looks like these header files are not included in this patch series.
I just checked, and yes, in fact this does cause a failure.
I did check this, but it was in my test environment that includes a bunch of other drivers, etc. These two headers come from two other series that are currently out for review, and I neglected to mention this.
I'll try find a better way to handle this for the next version.
-Alex
Quoted 19 lines
luding headers in the YAML example that do not exist in the source tree will usually cause the C preprocessor to fail during schema validation compilation.
[ ... ]
Quoted 3 lines
MAINTAINERS +0
-0[ ... ]
Quoted 9 lines
F:
drivers/media/i2c/tc358743*
F:include/media/i2c/tc358743.hMAINTAINERS +6
-0+TOSHIBA TC9564 MSIGEN DRIVER +M: Alex Elder <[email protected]> +M: Daniel Thompson <[email protected]> +S: Maintained +F: Documentation/devicetree/bindings/interrupt-controller/toshiba,tc9564-msigen.yaml +
Re: [PATCH 1/2] dt-bindings: interrupt-controller: introduce toshiba,tc9564-msigen.yaml
In reply to Alex ElderQuoted 52 lines · Alex Elder
Define the binding for the MSIGEN interrupt controller present in the Toshiba TC9564 SoC.
Co-developed-by Daniel Thompson <[email protected]>Signed-off-by Daniel Thompson <[email protected]>Signed-off-by Alex Elder <[email protected]>--- .../toshiba,tc9564-msigen.yaml | 70 +++++++++++++++++++ MAINTAINERS | 6 ++ 2 files changed, 76 insertions(+) create mode 100644 Documentation/devicetree/bindings/interrupt-controller/toshiba,tc9564-msigen.yamlDocumentation/devicetree/bindings/interrupt-controller/toshiba,tc9564-msigen.yaml new file +34
-0@@ -0,0 +1,70 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/interrupt-controller/toshiba,tc9564-msigen.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Toshiba TC9564 MSIGEN Interrupt Controller + +maintainers: + - Daniel Thompson <[email protected]> + - Alex Elder <[email protected]> + +description: | + The Toshiba TC9564 is an SoC accessed by a host system through the + upstream PCIe port on the PCIe switch it implements. The switch + includes an embedded PCIe endpoint that provides access to various + SoC peripherals (including an interrupt controller) via its BARs. + + The TC9564 MSIGEN (MSI Generator) provides an interrupt controller + with 25 hardware interrupt lines. It aggregates internal interrupts + and generates a single PCIe MSI to the host. Each PCIe function + implements an MSIGEN instance. + + Each MSIGEN uses a gated clock and reset line. These are provided + by the clock and reset controllers internal to the TC9564. + +allOf: + - $ref: /schemas/interrupt-controller.yaml# + +properties: + compatible: + const: toshiba,tc9564-msigen + + reg:
Documentation/devicetree/bindings/interrupt-controller/toshiba,tc9564-msigen.yaml line 44
Quoted 10 lines
Documentation/devicetree/bindings/interrupt-controller/toshiba,tc9564-msigen.yaml new file +10
-0+ maxItems: 1 + + interrupt-controller: true + + '#interrupt-cells': + const: 1 + + clocks: + maxItems: 1 + description: Gate clock from the TC9564 clock controller
I'm surprised that the clock is not mandatory.. Realistically the reset is also mandatory, there's probably one instance of this on the device, where both clock and reset are connected. I'd add both to the required list.
Otherwise this looks
fine to me. I know you mentioned this device in the other series that we were discussing but I don't see how it is related and is perfectly fine to implement as a standalone device as you have done here.
Thanks,
Conor.
Quoted 46 lines
Documentation/devicetree/bindings/interrupt-controller/toshiba,tc9564-msigen.yaml new file +26
-0+ + resets: + maxItems: 1 + description: Reset signal from the TC9564 reset controller + +required: + - compatible + - reg + - interrupt-controller + - '#interrupt-cells' + +additionalProperties: false + +examples: + - | + #include <dt-bindings/clock/toshiba,tc9564.h> + #include <dt-bindings/reset/toshiba,tc9564.h> + + interrupt-controller@f000 { + compatible = "toshiba,tc9564-msigen"; + reg = <0xf000 0x100>; + interrupt-controller; + #interrupt-cells = <1>; + clocks = <&tc9564_clock0 CLOCK_MSIGEN>; + resets = <&tc9564_reset0 RESET_MSIGEN>; + };MAINTAINERS +6
-0@@ -28173,6 +28173,12 @@ F: Documentation/devicetree/bindings/media/i2c/toshiba,tc358743.yaml F: drivers/media/i2c/tc358743* F: include/media/i2c/tc358743.h +TOSHIBA TC9564 MSIGEN DRIVER +M: Alex Elder <[email protected]> +M: Daniel Thompson <[email protected]> +S: Maintained +F: Documentation/devicetree/bindings/interrupt-controller/toshiba,tc9564-msigen.yaml + TOSHIBA TC9564 PCI DRIVER M: Alex Elder <[email protected]> M: Daniel Thompson <[email protected]>Signature · 1 line
2.53.0
Re: [PATCH 1/2] dt-bindings: interrupt-controller: introduce toshiba,tc9564-msigen.yaml
Quoted 69 lines · Conor Dooley
Quoted 52 lines · Alex Elder
Define the binding for the MSIGEN interrupt controller present in the Toshiba TC9564 SoC.
Co-developed-by Daniel Thompson <[email protected]>Signed-off-by Daniel Thompson <[email protected]>Signed-off-by Alex Elder <[email protected]>--- .../toshiba,tc9564-msigen.yaml | 70 +++++++++++++++++++ MAINTAINERS | 6 ++ 2 files changed, 76 insertions(+) create mode 100644 Documentation/devicetree/bindings/interrupt-controller/toshiba,tc9564-msigen.yamlDocumentation/devicetree/bindings/interrupt-controller/toshiba,tc9564-msigen.yaml new file +34
-0@@ -0,0 +1,70 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/interrupt-controller/toshiba,tc9564-msigen.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Toshiba TC9564 MSIGEN Interrupt Controller + +maintainers: + - Daniel Thompson <[email protected]> + - Alex Elder <[email protected]> + +description: | + The Toshiba TC9564 is an SoC accessed by a host system through the + upstream PCIe port on the PCIe switch it implements. The switch + includes an embedded PCIe endpoint that provides access to various + SoC peripherals (including an interrupt controller) via its BARs. + + The TC9564 MSIGEN (MSI Generator) provides an interrupt controller + with 25 hardware interrupt lines. It aggregates internal interrupts + and generates a single PCIe MSI to the host. Each PCIe function + implements an MSIGEN instance. + + Each MSIGEN uses a gated clock and reset line. These are provided + by the clock and reset controllers internal to the TC9564. + +allOf: + - $ref: /schemas/interrupt-controller.yaml# + +properties: + compatible: + const: toshiba,tc9564-msigen + + reg:Documentation/devicetree/bindings/interrupt-controller/toshiba,tc9564-msigen.yaml line 44
Quoted 10 lines
Documentation/devicetree/bindings/interrupt-controller/toshiba,tc9564-msigen.yaml new file +10
-0+ maxItems: 1 + + interrupt-controller: true + + '#interrupt-cells': + const: 1 + + clocks: + maxItems: 1 + description: Gate clock from the TC9564 clock controllerI'm surprised that the clock is not mandatory.. Realistically the reset is also mandatory, there's probably one instance of this on the device, where both clock and reset are connected. I'd add both to the required list.
Quoted 4 lines
Otherwise this looks
fine to me. I know you mentioned this device in the other series that we were discussing but I don't see how it is related and is perfectly fine to implement as a standalone device as you have done here.
I still do not understand why do we need to describe the inner wirings of the tc9564 device. So far I found no posting of DTS showing proper usage of it on the host. Without proper usage, what is the point exactly to describe the inner specifics of tc9564?
Best regards,
Krzysztof
Re: [PATCH 1/2] dt-bindings: interrupt-controller: introduce toshiba,tc9564-msigen.yaml
Quoted 75 lines · Krzysztof Kozlowski
Quoted 69 lines · Conor Dooley
Quoted 52 lines · Alex Elder
Define the binding for the MSIGEN interrupt controller present in the Toshiba TC9564 SoC.
Co-developed-by Daniel Thompson <[email protected]>Signed-off-by Daniel Thompson <[email protected]>Signed-off-by Alex Elder <[email protected]>--- .../toshiba,tc9564-msigen.yaml | 70 +++++++++++++++++++ MAINTAINERS | 6 ++ 2 files changed, 76 insertions(+) create mode 100644 Documentation/devicetree/bindings/interrupt-controller/toshiba,tc9564-msigen.yamlDocumentation/devicetree/bindings/interrupt-controller/toshiba,tc9564-msigen.yaml new file +34
-0@@ -0,0 +1,70 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/interrupt-controller/toshiba,tc9564-msigen.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Toshiba TC9564 MSIGEN Interrupt Controller + +maintainers: + - Daniel Thompson <[email protected]> + - Alex Elder <[email protected]> + +description: | + The Toshiba TC9564 is an SoC accessed by a host system through the + upstream PCIe port on the PCIe switch it implements. The switch + includes an embedded PCIe endpoint that provides access to various + SoC peripherals (including an interrupt controller) via its BARs. + + The TC9564 MSIGEN (MSI Generator) provides an interrupt controller + with 25 hardware interrupt lines. It aggregates internal interrupts + and generates a single PCIe MSI to the host. Each PCIe function + implements an MSIGEN instance. + + Each MSIGEN uses a gated clock and reset line. These are provided + by the clock and reset controllers internal to the TC9564. + +allOf: + - $ref: /schemas/interrupt-controller.yaml# + +properties: + compatible: + const: toshiba,tc9564-msigen + + reg:Documentation/devicetree/bindings/interrupt-controller/toshiba,tc9564-msigen.yaml line 44
Quoted 10 lines
Documentation/devicetree/bindings/interrupt-controller/toshiba,tc9564-msigen.yaml new file +10
-0+ maxItems: 1 + + interrupt-controller: true + + '#interrupt-cells': + const: 1 + + clocks: + maxItems: 1 + description: Gate clock from the TC9564 clock controllerI'm surprised that the clock is not mandatory.. Realistically the reset is also mandatory, there's probably one instance of this on the device, where both clock and reset are connected. I'd add both to the required list.
Quoted 4 lines
Otherwise this looks
fine to me. I know you mentioned this device in the other series that we were discussing but I don't see how it is related and is perfectly fine to implement as a standalone device as you have done here.
Quoted 4 lines
I still do not understand why do we need to describe the inner wirings of the tc9564 device. So far I found no posting of DTS showing proper usage of it on the host. Without proper usage, what is the point exactly to describe the inner specifics of tc9564?
And as shown here:
https://lore.kernel.org/all/[email protected]/
there is no single user of any of this (this=reset, clock, irqchip probably and more) in upstreamed patches.
I am getting tired to keep discussing it, so next time instead of words, please post CODE which is the argument - who uses any of these devices you keep adding.
Best regards,
Krzysztof
Re: [PATCH 1/2] dt-bindings: interrupt-controller: introduce toshiba,tc9564-msigen.yaml
Quoted 7 lines · Krzysztof Kozlowski
Quoted 4 lines
I still do not understand why do we need to describe the inner wirings of the tc9564 device. So far I found no posting of DTS showing proper usage of it on the host. Without proper usage, what is the point exactly to describe the inner specifics of tc9564?
And as shown here:
https://lore.kernel.org/all/[email protected]/
Quoted 6 lines
there is no single user of any of this (this=reset, clock, irqchip probably and more) in upstreamed patches.
I am getting tired to keep discussing it, so next time instead of words, please post CODE which is the argument - who uses any of these devices you keep adding.
I'll take a break from my in-order responses to messages, and will respond to this first.
Our ultimate goal is to support the two DWMAC interfaces attached to PCIe functions within the TC9564. This is a complex SoC which interfaces with the host via an upstream PCIe switch port, and incorporates an embedded PCIe endpoint with two functions.
Based on your request, I will plan to send *all* of the code that's required for DWMAC support for review later today and tomorrow. I have been pacing myself (in part not to inundate the lists with patches).
A block diagram representing the TC9564 SoC is included in this devicetree binding:
That explains (and attempts to show) that devices (including clock
and reset functionality) use PCI endpoint BARs for access to their registers. Other IP blocks shown are an address translation unit, a block of SRAM, two XGMAC interfaces, and an MSI generator for
each of the two embedded PCI functions.
To show the final DTS file, I have squashed the working code I have and refer you here, starting at line 994:
Note that this exposes many internal details of the SoC, which Krzysztof objected to here:
https://lore.kernel.org/lkml/[email protected]/
I responded, explaining some history on this code and asking for clarification on criteria for when it's acceptable to describe chip internals in devicetree, but received no answer.
The PCI endpoint bus enables a PCI endpoint to be treated as a *bus* that provides access to multiple peripherals, rather than as a simple single-peripheral device. This goes well beyond the capability of the PCI enumeration process to discover the nature of the hardware, leveraging devicetree as a hardware description language to describe the organization within a complex chip.
I understand the desire to consider the PCI endpoint (function) as the boundary for devicetree descriptions. But I also see great benefit from viewing the SoC as a subsystem in itself, whose IP blocks and connections between them are described using devicetree.
-Alex
Re: [PATCH 1/2] dt-bindings: interrupt-controller: introduce toshiba,tc9564-msigen.yaml
Quoted 11 lines · Alex Elder
Quoted 10 lines · Krzysztof Kozlowski
Quoted 4 lines
I still do not understand why do we need to describe the inner wirings of the tc9564 device. So far I found no posting of DTS showing proper usage of it on the host. Without proper usage, what is the point exactly to describe the inner specifics of tc9564?
And as shown here:
https://lore.kernel.org/all/[email protected]/there is no single user of any of this (this=reset, clock, irqchip probably and more) in upstreamed patches.
Quoted 6 lines
Quoted 3 lines
I am getting tired to keep discussing it, so next time instead of words, please post CODE which is the argument - who uses any of these devices you keep adding.
I'll take a break from my in-order responses to messages, and will respond to this first.
Not really replying to any of this, but figured it was worth mentioning that I am reviewing with the assumption that it's similar to the microchip lan9xxx devices that can either be a standalone SoC or connected as PCI endpoint.
You keep calling it an SoC, which I took to mean that this had linux-capable CPU cores on it. Is that not actually the case?
Quoted 51 lines
Our ultimate goal is to support the two DWMAC interfaces attached to PCIe functions within the TC9564. This is a complex SoC which interfaces with the host via an upstream PCIe switch port, and incorporates an embedded PCIe endpoint with two functions.
Based on your request, I will plan to send *all* of the code that's required for DWMAC support for review later today and tomorrow. I have been pacing myself (in part not to inundate the lists with patches).
A block diagram representing the TC9564 SoC is included in this devicetree binding:
That explains (and attempts to show) that devices (including clock and reset functionality) use PCI endpoint BARs for access to their registers. Other IP blocks shown are an address translation unit, a block of SRAM, two XGMAC interfaces, and an MSI generator for each of the two embedded PCI functions.
To show the final DTS file, I have squashed the working code I have and refer you here, starting at line 994:
Note that this exposes many internal details of the SoC, which Krzysztof objected to here:
https://lore.kernel.org/lkml/[email protected]/I responded, explaining some history on this code and asking for clarification on criteria for when it's acceptable to describe chip internals in devicetree, but received no answer.
The PCI endpoint bus enables a PCI endpoint to be treated as a *bus* that provides access to multiple peripherals, rather than as a simple single-peripheral device. This goes well beyond the capability of the PCI enumeration process to discover the nature of the hardware, leveraging devicetree as a hardware description language to describe the organization within a complex chip.
I understand the desire to consider the PCI endpoint (function) as the boundary for devicetree descriptions. But I also see great benefit from viewing the SoC as a subsystem in itself, whose IP blocks and connections between them are described using devicetree.
Re: [PATCH 1/2] dt-bindings: interrupt-controller: introduce toshiba,tc9564-msigen.yaml
Quoted 16 lines · Conor Dooley
Quoted 15 lines · Alex Elder
Quoted 13 lines · Krzysztof Kozlowski
Quoted 4 lines
I still do not understand why do we need to describe the inner wirings of the tc9564 device. So far I found no posting of DTS showing proper usage of it on the host. Without proper usage, what is the point exactly to describe the inner specifics of tc9564?
And as shown here:
https://lore.kernel.org/all/[email protected]/there is no single user of any of this (this=reset, clock, irqchip probably and more) in upstreamed patches.
I am getting tired to keep discussing it, so next time instead of words, please post CODE which is the argument - who uses any of these devices you keep adding.
Quoted 7 lines
Quoted 2 lines
I'll take a break from my in-order responses to messages, and will respond to this first.
Not really replying to any of this, but figured it was worth mentioning that I am reviewing with the assumption that it's similar to the microchip lan9xxx devices that can either be a standalone SoC or connected as PCI endpoint.
Yes, that was one of two things that this was modeled upon.
The other is the Raspberry Pi RP1, which is probably a more similar example.
Quoted 2 lines
You keep calling it an SoC, which I took to mean that this had linux-capable CPU cores on it. Is that not actually the case?
Well it is an SoC, in that it has numerous interacting components that are aggregated into a single chip.
It does, in fact, have an embedded CPU that uses SRAM, but it's just an Arm Cortex M3 and is not Linux capable.
So no, it is not a Linux-capable SoC the way the LAN966x is.
-Alex
Quoted 51 lines
Quoted 51 lines
Our ultimate goal is to support the two DWMAC interfaces attached to PCIe functions within the TC9564. This is a complex SoC which interfaces with the host via an upstream PCIe switch port, and incorporates an embedded PCIe endpoint with two functions.
Based on your request, I will plan to send *all* of the code that's required for DWMAC support for review later today and tomorrow. I have been pacing myself (in part not to inundate the lists with patches).
A block diagram representing the TC9564 SoC is included in this devicetree binding:
That explains (and attempts to show) that devices (including clock and reset functionality) use PCI endpoint BARs for access to their registers. Other IP blocks shown are an address translation unit, a block of SRAM, two XGMAC interfaces, and an MSI generator for each of the two embedded PCI functions.
To show the final DTS file, I have squashed the working code I have and refer you here, starting at line 994:
Note that this exposes many internal details of the SoC, which Krzysztof objected to here:
https://lore.kernel.org/lkml/[email protected]/I responded, explaining some history on this code and asking for clarification on criteria for when it's acceptable to describe chip internals in devicetree, but received no answer.
The PCI endpoint bus enables a PCI endpoint to be treated as a *bus* that provides access to multiple peripherals, rather than as a simple single-peripheral device. This goes well beyond the capability of the PCI enumeration process to discover the nature of the hardware, leveraging devicetree as a hardware description language to describe the organization within a complex chip.
I understand the desire to consider the PCI endpoint (function) as the boundary for devicetree descriptions. But I also see great benefit from viewing the SoC as a subsystem in itself, whose IP blocks and connections between them are described using devicetree.
Re: [PATCH 1/2] dt-bindings: interrupt-controller: introduce toshiba,tc9564-msigen.yaml
Quoted 27 lines · Alex Elder
Quoted 16 lines · Conor Dooley
Quoted 15 lines · Alex Elder
Quoted 13 lines · Krzysztof Kozlowski
Quoted 4 lines
I still do not understand why do we need to describe the inner wirings of the tc9564 device. So far I found no posting of DTS showing proper usage of it on the host. Without proper usage, what is the point exactly to describe the inner specifics of tc9564?
And as shown here:
https://lore.kernel.org/all/[email protected]/there is no single user of any of this (this=reset, clock, irqchip probably and more) in upstreamed patches.
I am getting tired to keep discussing it, so next time instead of words, please post CODE which is the argument - who uses any of these devices you keep adding.
Quoted 7 lines
Quoted 2 lines
I'll take a break from my in-order responses to messages, and will respond to this first.
Not really replying to any of this, but figured it was worth mentioning that I am reviewing with the assumption that it's similar to the microchip lan9xxx devices that can either be a standalone SoC or connected as PCI endpoint.
Yes, that was one of two things that this was modeled upon.
Quoted 8 lines
The other is the Raspberry Pi RP1, which is probably a more similar example.
Quoted 2 lines
You keep calling it an SoC, which I took to mean that this had linux-capable CPU cores on it. Is that not actually the case?
Well it is an SoC, in that it has numerous interacting components that are aggregated into a single chip.
If that's it, I wouldn't really call this an SoC, you're just going to confuse people (like me!) into thinking that this device can work standalone...
Quoted 2 lines
It does, in fact, have an embedded CPU that uses SRAM, but it's just an Arm Cortex M3 and is not Linux capable.
...but maybe it can, depending on whether the devices being discussed appear in the address space of the M3 or if the M3 is just some sort of monitor CPU running firmware and bringing the device out of reset.
Quoted 2 lines
So no, it is not a Linux-capable SoC the way the LAN966x is.
IIRC the LAN966x didn't expose the various peripherals as different discoverable PCI functions and was just like "hey, we're a LAN966x". What made it special was that there was already drivers etc for this device from being an SoC, so the DT overlay solution neatly made use of the existing stuff for the device.
If your device only exposes a single function for the whole device, I feel like aping the LAN966x and describing it in DT via an overlay is reasonable.
Cheers,
Conor.
Quoted 52 lines
Quoted 51 lines
Quoted 51 lines
Our ultimate goal is to support the two DWMAC interfaces attached to PCIe functions within the TC9564. This is a complex SoC which interfaces with the host via an upstream PCIe switch port, and incorporates an embedded PCIe endpoint with two functions.
Based on your request, I will plan to send *all* of the code that's required for DWMAC support for review later today and tomorrow. I have been pacing myself (in part not to inundate the lists with patches).
A block diagram representing the TC9564 SoC is included in this devicetree binding:
That explains (and attempts to show) that devices (including clock and reset functionality) use PCI endpoint BARs for access to their registers. Other IP blocks shown are an address translation unit, a block of SRAM, two XGMAC interfaces, and an MSI generator for each of the two embedded PCI functions.
To show the final DTS file, I have squashed the working code I have and refer you here, starting at line 994:
Note that this exposes many internal details of the SoC, which Krzysztof objected to here:
https://lore.kernel.org/lkml/[email protected]/I responded, explaining some history on this code and asking for clarification on criteria for when it's acceptable to describe chip internals in devicetree, but received no answer.
The PCI endpoint bus enables a PCI endpoint to be treated as a *bus* that provides access to multiple peripherals, rather than as a simple single-peripheral device. This goes well beyond the capability of the PCI enumeration process to discover the nature of the hardware, leveraging devicetree as a hardware description language to describe the organization within a complex chip.
I understand the desire to consider the PCI endpoint (function) as the boundary for devicetree descriptions. But I also see great benefit from viewing the SoC as a subsystem in itself, whose IP blocks and connections between them are described using devicetree.
Re: [PATCH 1/2] dt-bindings: interrupt-controller: introduce toshiba,tc9564-msigen.yaml
Quoted 41 lines · Conor Dooley
Quoted 27 lines · Alex Elder
Quoted 16 lines · Conor Dooley
Quoted 15 lines · Alex Elder
Quoted 13 lines · Krzysztof Kozlowski
Quoted 4 lines
I still do not understand why do we need to describe the inner wirings of the tc9564 device. So far I found no posting of DTS showing proper usage of it on the host. Without proper usage, what is the point exactly to describe the inner specifics of tc9564?
And as shown here:
https://lore.kernel.org/all/[email protected]/there is no single user of any of this (this=reset, clock, irqchip probably and more) in upstreamed patches.
I am getting tired to keep discussing it, so next time instead of words, please post CODE which is the argument - who uses any of these devices you keep adding.
Quoted 7 lines
Quoted 2 lines
I'll take a break from my in-order responses to messages, and will respond to this first.
Not really replying to any of this, but figured it was worth mentioning that I am reviewing with the assumption that it's similar to the microchip lan9xxx devices that can either be a standalone SoC or connected as PCI endpoint.
Yes, that was one of two things that this was modeled upon.
Quoted 8 lines
The other is the Raspberry Pi RP1, which is probably a more similar example.
Quoted 2 lines
You keep calling it an SoC, which I took to mean that this had linux-capable CPU cores on it. Is that not actually the case?
Well it is an SoC, in that it has numerous interacting components that are aggregated into a single chip.
If that's it, I wouldn't really call this an SoC, you're just going to confuse people (like me!) into thinking that this device can work standalone...
Quoted 6 lines
Quoted 2 lines
It does, in fact, have an embedded CPU that uses SRAM, but it's just an Arm Cortex M3 and is not Linux capable.
...but maybe it can, depending on whether the devices being discussed appear in the address space of the M3 or if the M3 is just some sort of monitor CPU running firmware and bringing the device out of reset.
FWIW I'm believe you *could* build a standalone system using the Cortex-M3. It has direct access to all the peripherals that we are describing using devicetree. However the C-M3 has very little RAM so the list of plausible fully-standalone systems is very short!
More likely would be a system design that gives the microcontroller ownership of just a few of the peripherals and is partially independent of the host. If that firmware was running a DT-centric OS such as Zephyr there might be binding reuse in that case.
I should be clear that this is entirely speculative at this point. We don't have such a firmware (we currently don't use any firmware at all).
Daniel.
PATCH 2/2 irqchip: introduce TC9564 SoC MSIGEN support
In reply to Alex ElderFrom: Daniel Thompson <[email protected]>
Define a new irqchip platform driver that represents the MSIGEN functionality present in the TC9564 SoC.
--- MAINTAINERS | 1 + drivers/irqchip/Kconfig | 10 ++ drivers/irqchip/Makefile | 1 + drivers/irqchip/irq-tc9564-msigen.c | 203 ++++++++++++++++++++++++++++ 4 files changed, 215 insertions(+) create mode 100644 drivers/irqchip/irq-tc9564-msigen.c
MAINTAINERS +1 -0
@@ -28178,6 +28178,7 @@ M: Alex Elder <[email protected]> M: Daniel Thompson <[email protected]> S: Maintained F: Documentation/devicetree/bindings/interrupt-controller/toshiba,tc9564-msigen.yaml +F: drivers/irqchip/irq-tc9564-msigen.c TOSHIBA TC9564 PCI DRIVER M: Alex Elder <[email protected]>
drivers/irqchip/Kconfig +10 -0
@@ -842,4 +842,14 @@ config SUNPLUS_SP7021_INTC chained controller, routing all interrupt source in P-Chip to the primary controller on C-Chip. +config TC9564_MSIGEN + tristate "Toshiba TC9564 MSI distributor" + depends on TC9564_PCI + depends on GENERIC_IRQ_CHIP + default TC9564_PCI + help + This enables support for the "MSIGEN" MSI distributor embedded + in the Toshiba TC9564. This device receives wired interrupts + within the TC9564 and raises them to the host using MSI. + endmenu
drivers/irqchip/Makefile +1 -0
@@ -135,3 +135,4 @@ obj-$(CONFIG_APPLE_AIC) += irq-apple-aic.o obj-$(CONFIG_MCHP_EIC) += irq-mchp-eic.o obj-$(CONFIG_SOPHGO_SG2042_MSI) += irq-sg2042-msi.o obj-$(CONFIG_SUNPLUS_SP7021_INTC) += irq-sp7021-intc.o +obj-$(CONFIG_TC9564_MSIGEN) += irq-tc9564-msigen.o
drivers/irqchip/irq-tc9564-msigen.c new file +203 -0
203 lines not on this page · raw message
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH 2/2] irqchip: introduce TC9564 SoC MSIGEN support
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider: - [High] irqchip/tc9564: uninitialized stack variables info and dgc_info - [High] irqchip/tc9564-msigen…
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [High] irqchip/tc9564: uninitialized stack variables info and dgc_info
- [High] irqchip/tc9564-msigen: Use-After-Free in handler during module removal
- [Low] kconfig: TC9564_MSIGEN depends on hidden symbol GENERIC_IRQ_CHIP
--
commit 3dfc2bc2208f270b240c50f9b867c34c54af58e0
Author: Daniel Thompson <[email protected]>
irqchip: introduce TC9564 SoC MSIGEN support
Define a new irqchip platform driver that represents the MSIGEN functionality present in the TC9564 SoC.
Quoted 4 lines
drivers/irqchip/Kconfig +0
-0
[ ... ]
drivers/irqchip/Kconfig config SUNPLUS_SP7021_INTC · line 848
Quoted 4 lines
drivers/irqchip/Kconfig +4
-0+config TC9564_MSIGEN + tristate "Toshiba TC9564 MSI distributor" + depends on TC9564_PCI + depends on GENERIC_IRQ_CHIP
[Severity: Low]
Is it intentional to use "depends on" instead of "select" for this hidden symbol?
Since GENERIC_IRQ_CHIP is a hidden boolean symbol (without a prompt), using "depends on" makes TC9564_MSIGEN impossible to enable on architectures or platforms that do not already natively select GENERIC_IRQ_CHIP.
Quoted 12 lines
drivers/irqchip/Kconfig +6
-0+ default TC9564_PCI + help + This enables support for the "MSIGEN" MSI distributor embedded + in the Toshiba TC9564. This device receives wired interrupts + within the TC9564 and raises them to the host using MSI. + endmenudrivers/irqchip/irq-tc9564-msigen.c new file +0
-0
[ ... ]
drivers/irqchip/irq-tc9564-msigen.c line 88
Quoted 5 lines
drivers/irqchip/irq-tc9564-msigen.c new file +5
-0+static void tc9564_msigen_irq_domain_exit (struct irq_domain *irq_domain) +{ +struct tc9564_msigen *msigen = irq_domain->host_data; + +irq_set_chained_handler_and_data (msigen->irq,NULL ,NULL );
[Severity: High]
Does this missing synchronization lead to a use-after-free?
When the chained handler is set to NULL during module removal, it doesn't wait for currently executing handlers to finish. If tc9564_msigen_irq_handler() is running concurrently on another CPU, it might access the irq_domain, generic chip, and unmapped register memory after they are freed by the removal path.
Should this call synchronize_irq() to ensure the concurrent handler has finished?
Quoted 1 line
+}
[ ... ]
drivers/irqchip/irq-tc9564-msigen.c line 120
Quoted 7 lines
drivers/irqchip/irq-tc9564-msigen.c new file +7
-0+static int tc9564_msigen_probe (struct platform_device *pdev) +{ +struct irq_domain_chip_generic_info dgc_info; +struct device *dev = &pdev->dev; +struct irq_domain *irq_domain; +struct tc9564_msigen *msigen; +struct irq_domain_info info;
[Severity: High]
Could these uninitialized stack variables cause a crash?
If info is not zero-initialized (e.g., using = {}), fields like info.parent will contain stack garbage. When passed to devm_irq_domain_instantiate(), could this result in dereferencing a wild pointer in __irq_domain_instantiate() if CONFIG_IRQ_DOMAIN_HIERARCHY is enabled?
Quoted 4 lines
drivers/irqchip/irq-tc9564-msigen.c new file +4
-0+struct reset_control *reset; +struct pci_dev *pci_dev; +struct clk *clk; +int ret;
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
Re: [PATCH 2/2] irqchip: introduce TC9564 SoC MSIGEN support
Quoted 4 lines · On 10/12/26 2:16 PM, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [High] irqchip/tc9564: uninitialized stack variables info anddgc_info
- [High] irqchip/tc9564-msigen: Use-After-Free in handler during module removal
- [Low] kconfig:TC9564_MSIGENdepends on hidden symbolGENERIC_IRQ_CHIP
I think all three of these are legitimate issues, and I describe below how they'll be fixed in the next version of the series.
Quoted 24 lines
--
commit
3dfc2bc2208f270b240c50f9b867c34c54af58e0
Author: Daniel Thompson <[email protected]>irqchip: introduce TC9564 SoC MSIGEN support
Define a new irqchip platform driver that represents the MSIGEN functionality present in the TC9564 SoC.
Quoted 4 lines
drivers/irqchip/Kconfig +0
-0[ ... ]
drivers/irqchip/Kconfig config SUNPLUS_SP7021_INTC · line 848
Quoted 4 lines
drivers/irqchip/Kconfig +4
-0+config TC9564_MSIGEN + tristate "Toshiba TC9564 MSI distributor" + depends on TC9564_PCI + depends on GENERIC_IRQ_CHIP[Severity: Low]
Is it intentional to use "depends on" instead of "select" for this hidden symbol?
Quoted 3 lines
Since
GENERIC_IRQ_CHIPis a hidden boolean symbol (without a prompt), using "depends on" makesTC9564_MSIGENimpossible to enable on architectures or platforms that do not already natively selectGENERIC_IRQ_CHIP.
When I used "select" for GENERIC_IRQ_CHIP, there is a recursive Kconfig dependency.
error: recursive dependency detected!
symbol GENERIC_IRQ_CHIP is selected by TC9564_MSIGEN symbol TC9564_MSIGEN depends on TC9564_PCI symbol TC9564_PCI depends on PCI_DYNAMIC_OF_NODES symbol PCI_DYNAMIC_OF_NODES depends on OF_IRQ symbol OF_IRQ depends on IRQ_DOMAIN
symbol IRQ_DOMAIN is selected by GENERIC_IRQ_CHIP
If I instead simply omit "depends on GENERIC_IRQ_CHIP" this circular dependency goes away. I can rely on TC9564_PCI to (eventually) cause GENERIC_IRQ_CHIP to get selected instead, so that's what I'll do in the next version.
Quoted 22 lines
Quoted 12 lines
drivers/irqchip/Kconfig +6
-0+ default TC9564_PCI + help + This enables support for the "MSIGEN" MSI distributor embedded + in the Toshiba TC9564. This device receives wired interrupts + within the TC9564 and raises them to the host using MSI. + endmenudrivers/irqchip/irq-tc9564-msigen.c new file +0
-0[ ... ]
drivers/irqchip/irq-tc9564-msigen.c line 88
Quoted 5 lines
drivers/irqchip/irq-tc9564-msigen.c new file +5
-0+static void tc9564_msigen_irq_domain_exit (struct irq_domain *irq_domain) +{ +struct tc9564_msigen *msigen = irq_domain->host_data; + +irq_set_chained_handler_and_data (msigen->irq,NULL ,NULL );[Severity: High]
Does this missing synchronization lead to a use-after-free?
Quoted 7 lines
When the chained handler is set to NULL during module removal, it doesn't wait for currently executing handlers to finish. If
tc9564_msigen_irq_handler()is running concurrently on another CPU, it might access theirq_domain, generic chip, and unmapped register memory after they are freed by the removal path.Should this call
synchronize_irq()to ensure the concurrent handler has finished?
Sounds like it should. I will investigate further, but presumably this suggestion will be included in the next version.
Quoted 13 lines
Quoted 2 lines
+}
[ ... ]
drivers/irqchip/irq-tc9564-msigen.c line 120
Quoted 7 lines
drivers/irqchip/irq-tc9564-msigen.c new file +7
-0+static int tc9564_msigen_probe (struct platform_device *pdev) +{ +struct irq_domain_chip_generic_info dgc_info; +struct device *dev = &pdev->dev; +struct irq_domain *irq_domain; +struct tc9564_msigen *msigen; +struct irq_domain_info info;[Severity: High]
Could these uninitialized stack variables cause a crash?
I missed this. Yes, the info structure is (further) initialized in the code below, so it should be initially zeroed. This will be fixed in the next version.
-Alex
Quoted 10 lines
If info is not zero-initialized (e.g., using = {}), fields like info.parent will contain stack garbage. When passed to
devm_irq_domain_instantiate(), could this result in dereferencing a wild pointer in__irq_domain_instantiate()ifCONFIG_IRQ_DOMAIN_HIERARCHYis enabled?Quoted 4 lines
drivers/irqchip/irq-tc9564-msigen.c new file +4
-0+struct reset_control *reset; +struct pci_dev *pci_dev; +struct clk *clk; +int ret;
Thomas Gleixner
maintainerRe: [PATCH 2/2] irqchip: introduce TC9564 SoC MSIGEN support
In reply to Alex Elderdrivers/irqchip/Kconfig config SUNPLUS_SP7021_INTC · line 848
Quoted 4 lines · Alex Elder
drivers/irqchip/Kconfig +4
-0+config TC9564_MSIGEN + tristate "Toshiba TC9564 MSI distributor" + depends on TC9564_PCI + depends on GENERIC_IRQ_CHIP
s/depends/select/
Otherwise this relies on some other driver to select GENERIC_IRQ_CHIP...
drivers/irqchip/irq-tc9564-msigen.c line 19
Quoted 8 lines
drivers/irqchip/irq-tc9564-msigen.c new file +8
-0+/** +* struct tc9564_msigen - Context for MSIGEN IRQ domain +* @ioaddr: Pointer to mapped MSIGEN memory +* @irq: IRQ number for MSIGEN +*/ +struct tc9564_msigen { +void __iomem *ioaddr; +unsigned int irq;
https://docs.kernel.org/process/maintainer-tip.html#struct-declarations-and-initializers
Quoted 14 lines
drivers/irqchip/irq-tc9564-msigen.c new file +14
-0+}; + +#define HWIRQ_COUNT 25 + +#define MSI_OUT_EN_OFFSET 0x0000 +#define MSI_MASK_CLR_OFFSET 0x000c +#define MSI_MASK_VALUE BIT(0) +#define MSI_INT_STS_OFFSET 0x0010 + +static void tc9564_msigen_irq_handler (struct irq_desc *desc) +{ +struct irq_domain *irq_domain =irq_desc_get_handler_data (desc); +struct irq_chip *chip =irq_desc_get_chip (desc); +struct irq_chip_generic *gc;
drivers/irqchip/irq-tc9564-msigen.c line 43
Quoted 10 lines
drivers/irqchip/irq-tc9564-msigen.c new file +10
-0+unsigned long status; +unsigned long hwirq; + + gc =irq_get_domain_generic_chip (irq_domain,0 ); + +chained_irq_enter (chip, desc); + + status =irq_reg_readl (gc,MSI_INT_STS_OFFSET ); +for_each_set_bit (hwirq, &status,HWIRQ_COUNT ) +generic_handle_domain_irq (irq_domain, hwirq);
You want to use generic_handle_demux_domain_irq(), which allows you to actually implement affinity settings for individual interrupts.
Quoted 5 lines
drivers/irqchip/irq-tc9564-msigen.c new file +5
-0+/* +* Clear the MSI flag. Most interrupts within TC9564 are level-high +* type. If any interrupts are still asserted then clearing this flag +* will cause the (edge-triggered) MSI to be regenerated. +*/
drivers/irqchip/irq-tc9564-msigen.c line 80
Quoted 10 lines
drivers/irqchip/irq-tc9564-msigen.c new file +10
-0+irq_reg_writel (gc,MSI_MASK_VALUE ,MSI_MASK_CLR_OFFSET ); + +chained_irq_exit (chip, desc); +} +static int tc9564_msigen_irq_domain_init (struct irq_domain *irq_domain) +{ +struct tc9564_msigen *msigen = irq_domain->host_data; + +irq_set_chained_handler_and_data (msigen->irq, tc9564_msigen_irq_handler, + irq_domain);
No line break required. You have 100 characters. All over the place.
Quoted 1 line
+/* Find the PCI device we're associated with (not necessarily the parent) */
What does that mean and why is this platform device driver dealing with a PCI device in the first place?
This really wants proper comments explaining this in the source _and_ the change log of this patch. And no, your sloppy cover letter explanation does not cut it at all.
drivers/irqchip/irq-tc9564-msigen.c line 116
Quoted 5 lines
drivers/irqchip/irq-tc9564-msigen.c new file +4
-0+static struct pci_dev *tc9564_msigen_find_pci_dev (struct device *dev) +static int tc9564_msigen_probe(struct platform_device *pdev) +{ +struct irq_domain_chip_generic_info dgc_info;
Struct is uninitialized.
drivers/irqchip/irq-tc9564-msigen.c line 120
Quoted 4 lines
drivers/irqchip/irq-tc9564-msigen.c new file +4
-0+struct device *dev = &pdev->dev; +struct irq_domain *irq_domain; +struct tc9564_msigen *msigen; +struct irq_domain_info info;
Ditto. Look at other drivers how this is done correctly.
drivers/irqchip/irq-tc9564-msigen.c line 129
Quoted 9 lines
drivers/irqchip/irq-tc9564-msigen.c new file +9
-0+struct reset_control *reset; +struct pci_dev *pci_dev; +struct clk *clk; +int ret; + + pci_dev =tc9564_msigen_find_pci_dev (dev); +if (IS_ERR (pci_dev)) +return dev_err_probe (dev,PTR_ERR (pci_dev), +"failed to find PCI device\n" );
See bracket rules in the documentation I linked to or simply get rid of that line break. Same all over the place.
Quoted 6 lines
drivers/irqchip/irq-tc9564-msigen.c new file +6
-0+ dgc_info.name ="tc9564-msigen" ; + dgc_info.handler = handle_level_irq; + dgc_info.irqs_per_chip =HWIRQ_COUNT ; + dgc_info.num_ct =1 ; + dgc_info.init = tc9564_msigen_irq_chip_init; + dgc_info.exit = tc9564_msigen_irq_chip_exit;
drivers/irqchip/irq-tc9564-msigen.c line 176
Quoted 10 lines
drivers/irqchip/irq-tc9564-msigen.c new file +10
-0+ + info.fwnode =of_fwnode_handle (dev->of_node); + info.domain_flags =IRQ_DOMAIN_FLAG_DESTROY_GC ; + info.size =HWIRQ_COUNT ; + info.hwirq_max =HWIRQ_COUNT ; + info.ops = &irq_generic_chip_ops; + info.host_data = msigen; + info.dgc_info = &dgc_info; + info.init = tc9564_msigen_irq_domain_init; + info.exit = tc9564_msigen_irq_domain_exit;
Both initializations (except for info.host_data) can be done at the declaration with a static initialization, which avoids that parts of the structs contain random stack content. No?
Please look through the sashiko comments as well.
Thanks,
tglx
Re: [PATCH 2/2] irqchip: introduce TC9564 SoC MSIGEN support
Quoted 9 lines · Thomas Gleixner
drivers/irqchip/Kconfig config SUNPLUS_SP7021_INTC · line 848
Quoted 4 lines · Alex Elder
drivers/irqchip/Kconfig +4
-0+config TC9564_MSIGEN + tristate "Toshiba TC9564 MSI distributor" + depends on TC9564_PCI + depends on GENERIC_IRQ_CHIPs/depends/select/
Otherwise this relies on some other driver to select
GENERIC_IRQ_CHIP...
The reason this uses "depends on" rather than "select" is to avoid a recursive dependency.
error: recursive dependency detected!
symbol GENERIC_IRQ_CHIP is selected by TC9564_MSIGEN symbol TC9564_MSIGEN depends on TC9564_PCI
symbol TC9564_PCI depends on PCI_DYNAMIC_OF_NODES symbol PCI_DYNAMIC_OF_NODES depends on OF_IRQ
symbol OF_IRQ depends on IRQ_DOMAIN
symbol IRQ_DOMAIN is selected by GENERIC_IRQ_CHIP
For a resolution refer to Documentation/kbuild/kconfig-language.rst
We already depend on TC9564_PCI (and use it as the default value).
GENERIC_IRQ_CHIP gets selected by IRQ_DOMAIN, which we get from OF_IRQ, from PCI_DYNAMIC_OF_NODES, from TC9564_PCI.
Should I just drop "depends on GENERIC_IRQ_CHIP"?
Quoted 11 lines
drivers/irqchip/irq-tc9564-msigen.c line 19
Quoted 9 lines
drivers/irqchip/irq-tc9564-msigen.c new file +8
-0+/** +* struct tc9564_msigen - Context for MSIGEN IRQ domain +* @ioaddr: Pointer to mapped MSIGEN memory +* @irq: IRQ number for MSIGEN +*/ +struct tc9564_msigen { +void __iomem *ioaddr; +unsigned int irq;https://docs.kernel.org/process/maintainer-tip.html#struct-declarations-and-initializers
I'll fix the alignment for these.
Quoted 19 lines
Quoted 19 lines
drivers/irqchip/irq-tc9564-msigen.c new file +19
-0+}; + +#define HWIRQ_COUNT 25 + +#define MSI_OUT_EN_OFFSET 0x0000 +#define MSI_MASK_CLR_OFFSET 0x000c +#define MSI_MASK_VALUE BIT(0) +#define MSI_INT_STS_OFFSET 0x0010 + +static void tc9564_msigen_irq_handler (struct irq_desc *desc) +{ +struct irq_domain *irq_domain =irq_desc_get_handler_data (desc); +struct irq_chip *chip =irq_desc_get_chip (desc); +struct irq_chip_generic *gc; +unsigned long status; +unsigned long hwirq; + + gc =irq_get_domain_generic_chip (irq_domain,0 ); +
Quoted 8 lines
drivers/irqchip/irq-tc9564-msigen.c line 43
Quoted 5 lines
drivers/irqchip/irq-tc9564-msigen.c new file +5
-0+chained_irq_enter (chip, desc); + + status =irq_reg_readl (gc,MSI_INT_STS_OFFSET ); +for_each_set_bit (hwirq, &status,HWIRQ_COUNT ) +generic_handle_domain_irq (irq_domain, hwirq);You want to use
generic_handle_demux_domain_irq(), which allows you to actually implement affinity settings for individual interrupts.
That sounds better, thanks for pointing it out.
Quoted 9 lines
Quoted 9 lines
drivers/irqchip/irq-tc9564-msigen.c new file +9
-0+/* +* Clear the MSI flag. Most interrupts within TC9564 are level-high +* type. If any interrupts are still asserted then clearing this flag +* will cause the (edge-triggered) MSI to be regenerated. +*/ +irq_reg_writel (gc,MSI_MASK_VALUE ,MSI_MASK_CLR_OFFSET ); + +chained_irq_exit (chip, desc); +}
Quoted 8 lines
drivers/irqchip/irq-tc9564-msigen.c line 80
Quoted 6 lines
drivers/irqchip/irq-tc9564-msigen.c new file +6
-0+static int tc9564_msigen_irq_domain_init (struct irq_domain *irq_domain) +{ +struct tc9564_msigen *msigen = irq_domain->host_data; + +irq_set_chained_handler_and_data (msigen->irq, tc9564_msigen_irq_handler, + irq_domain);No line break required. You have 100 characters. All over the place.
OK. I normally stick with 80 columns but since you prefer 100 I'll adjust the formatting throughout this file to use that.
Quoted 4 lines
Quoted 1 line
+/* Find the PCI device we're associated with (not necessarily the parent) */
What does that mean and why is this platform device driver dealing with a PCI device in the first place?
We have modeled this chip using PCI endpoint bus, which allows a PCI endpoint to present a child bus that implements multiple device functions via each of its BARs (or a single bus can represent multiple BARs). Device nodes within a pci-ep-bus sub-node use a platform device that is matched by compatible string.
This MSIGEN block collects interrupts from multiple sources within the chip and translates them into MSIs delivered to the host. We know that this block is subordinate to a PCI device. If this were a direct child of the PCI device, we would just look at the parent. But because the pci-ep-bus is in there, we need to go to the grandparent. The code loops as it travels up rather than assuming it's parent->parent.
(Daniel might have more to say on this--if so he'll chime in.)
Quoted 3 lines
This really wants proper comments explaining this in the source _and_ the change log of this patch. And no, your sloppy cover letter explanation does not cut it at all.
There are several distinct but interrelated drivers and it's been a bit repetitive to explain some of these things. I'll incorporate better big-picture descriptions both in the code and in the patch headers in the next version.
Quoted 7 lines
drivers/irqchip/irq-tc9564-msigen.c line 116
Quoted 5 lines
drivers/irqchip/irq-tc9564-msigen.c new file +4
-0+static struct pci_dev *tc9564_msigen_find_pci_dev (struct device *dev) +static int tc9564_msigen_probe(struct platform_device *pdev) +{ +struct irq_domain_chip_generic_info dgc_info;Struct is uninitialized.
You're right, these should have been zeroed.
Quoted 8 lines
drivers/irqchip/irq-tc9564-msigen.c line 120
Quoted 5 lines
drivers/irqchip/irq-tc9564-msigen.c new file +4
-0+struct device *dev = &pdev->dev; +struct irq_domain *irq_domain; +struct tc9564_msigen *msigen; +struct irq_domain_info info;Ditto. Look at other drivers how this is done correctly.
Quoted 12 lines
drivers/irqchip/irq-tc9564-msigen.c line 129
Quoted 9 lines
drivers/irqchip/irq-tc9564-msigen.c new file +9
-0+struct reset_control *reset; +struct pci_dev *pci_dev; +struct clk *clk; +int ret; + + pci_dev =tc9564_msigen_find_pci_dev (dev); +if (IS_ERR (pci_dev)) +return dev_err_probe (dev,PTR_ERR (pci_dev), +"failed to find PCI device\n" );See bracket rules in the documentation I linked to or simply get rid of that line break. Same all over the place.
So you want brackets around the muti-line body of the if statement.
Switching to 100 column line widths might make this become moot. In any case, understood.
Quoted 12 lines
Quoted 12 lines
drivers/irqchip/irq-tc9564-msigen.c new file +12
-0+ dgc_info.name ="tc9564-msigen" ; + dgc_info.handler = handle_level_irq; + dgc_info.irqs_per_chip =HWIRQ_COUNT ; + dgc_info.num_ct =1 ; + dgc_info.init = tc9564_msigen_irq_chip_init; + dgc_info.exit = tc9564_msigen_irq_chip_exit; + + info.fwnode =of_fwnode_handle (dev->of_node); + info.domain_flags =IRQ_DOMAIN_FLAG_DESTROY_GC ; + info.size =HWIRQ_COUNT ; + info.hwirq_max =HWIRQ_COUNT ; + info.ops = &irq_generic_chip_ops;
Quoted 8 lines
drivers/irqchip/irq-tc9564-msigen.c line 176
Quoted 4 lines
drivers/irqchip/irq-tc9564-msigen.c new file +4
-0+ info.host_data = msigen; + info.dgc_info = &dgc_info; + info.init = tc9564_msigen_irq_domain_init; + info.exit = tc9564_msigen_irq_domain_exit;Both initializations (except for info.host_data) can be done at the declaration with a static initialization, which avoids that parts of the structs contain random stack content. No?
Yes.
I personally don't prefer initializing structs and unions where they are defined as stack variable. But you're right, they need to get zeroed in that case.
Anyway, I'll do what you suggest.
Quoted 1 line
Please look through the sashiko comments as well.
Yes I think I responded to all issues in both of them, indicating how (and whether) I intend to address each.
Thank you for your review.
-Alex
Quoted 4 lines
Thanks,
tglx