Skip to contentSkip to conversation

Arm GICv5: Host driver implementation

PATCH Superseded Lorenzo Pieralisi 5 participants 49 messages May 6, 2025 – May 12, 2025

Subsystems (5)

v3 of 7 Superseded Latest is v7 →

lore
Share & tools
lore

Lorenzo Pieralisi

author maintainer
#0 lore raw

v3 cover Arm GICv5: Host driver implementation

Implement the irqchip kernel driver for the Arm GICv5 architecture, as described in the GICv5 beta0 specification, available at:

https://developer.arm.com/documentation/aes0070

The GICv5 architecture is composed of multiple components:

- one or more IRS (Interrupt Routing Service)
- zero or more ITS (Interrupt Translation Service)
- zero or more IWB (Interrupt Wire Bridge)

The GICv5 host kernel driver is organized into units corresponding to GICv5 components.

The GICv5 architecture defines the following interrupt types:

- PPI (PE-Private Peripheral Interrupt)
- SPI (Shared Peripheral Interrupt)
- LPI (Logical Peripheral Interrupt)

This series adds sysreg entries required to automatically generate GICv5 registers handling code, one patch per-register.

This patch series is split into patches matching *logical* entities, to make the review easier.

Logical entities:

- PPI
- IRS/SPI
- LPI/IPI
- SMP enablement
- ITS

The salient points of the driver are summarized below.

=============
1. Testing
=============

Patchset tested with an architecturally compliant FVP model with the following setup:

- 1 IRS
- 1 and 2 ITSes
- 1 and 2 IWBs

configured with different parameters that vary the IRS(IST) and ITS(DT/ITT) table levels and INTID/DEVICEID/EVENTID bits.

A Trusted-Firmware (TF-A) prototype was used for device tree bindings and component initializations.

================
2. Driver design
================

=====================
2.1 GICv5 DT bindings
=====================

The DT bindings attempt to map directly to the GICv5 component hierarchy, with a top level node corresponding to the GICv5 "system", having IRS child nodes, that have in turn ITS child nodes.

The IWB is defined in a separate schema; its relationship with the ITS is explicit through the msi-parent property required to define the IWB deviceID.

===================
2.2 GICv5 top level
===================

The top-level GICv5 irqchip driver implements separate IRQ domains - one for each interrupt type, PPI (PE-Private Peripheral Interrupt), SPI (Shared Peripheral Interrupt) and LPI (Logical Peripheral Interrupt).

The top-level exception handler routes the IRQ to the relevant IRQ domain for handling according to the interrupt type detected when the IRQ is acknowledged.

All IRQs are set to the same priority value.

The driver assumes that the GICv5 components implement enough physical address bits to address the full system RAM, as required by the architecture; it does not check whether the physical address ranges of memory allocated for IRS/ITS tables are within the GICv5 physical address range.

Components are probed by relying on the early DT irqchip probing scheme. The probing is carried out hierarchically, starting from the top level.

The IWB driver has been dropped owing to issues encountered with core code DOMAIN_BUS_WIRED_TO_MSI bus token handling:

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

=============
2.3 GICv5 IRS
=============

The GICv5 IRS driver probes and manages SPI interrupts by detecting their presence and by providing the top-level driver the information required to set up the SPI interrupt domain.

The GICv5 IRS driver also parses from firmware Interrupt AFFinity ID (IAFFID) IDs identifying cores and sets up IRS IRQ routing.

The GICv5 IRS driver allocates memory to handle the IRS tables.

The IRS LPI interrupts state is kept in an Interrupt State Table (IST) and it is managed through CPU instructions.

The IRS driver allocates the IST table that, depending on available HW features can be either 1- or 2-level.

If the IST is 2-level, memory for the level-2 table entries is allocated on demand (ie when LPIs are requested), using an IRS mechanism to make level-1 entry valid on demand after the IST has already been enabled.

Chunks of memory allocated for IST entries can be smaller or larger than PAGE_SIZE and are required to be physically contiguous within an IST level (i.e. a linear IST is a single memory block, a 2-level IST is made up of a block of memory for the L1 table, whose entries point at different L2 tables that are in turn allocated as memory chunks).

LPI INTIDs are allocated in software using an IDA. IDA does not support allocating ranges, which is a bit cumbersome because this forces us to allocate IDs one by one where the LPIs could actually be allocated in chunks.

An IDA was chosen because basically it is a dynamic bitmap, which carries out memory allocation automatically.

Other drivers/subsystems made different choices to allocate ranges, an IDA was chosen since it is part of the core kernel and an IDA range API is in the making.

IPIs are implemented using LPIs and a hierarchical domain is created specifically for IPIs using the LPI domain as a parent.

arm64 IPI management core code is augmented with a new API to handle IPIs that are not per-cpu interrupts and force the affinity of the LPI backing an IPI to a specific and immutable value.

=============
2.4 GICv5 ITS
=============

The ITS driver reuses the existing GICv3/v4 MSI-parent infrastructure and on top builds an IRQ domain needed to enable message based IRQs.

ITS tables - DT (device table) and ITT (Interrupt Translation Table) are allocated according to the number of required deviceIDs and eventIDs on a per device basis. The ITS driver relies on the kmalloc() interface because memory pages must be physically contiguous within a table level and can be < or > than PAGE_SIZE.

=============
2.5 GICv5 IWB
=============

The IWB driver has been dropped owing to issues encountered with core code DOMAIN_BUS_WIRED_TO_MSI bus token handling:

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

===================
3. Acknowledgements
===================

The patchset was co-developed with T.Hayes and S.Bischoff from Arm - thank you so much for your help.

A big thank you to M.Zyngier for his fundamental help/advice.

If you have some time to help us review this series and get it into shape, thank you very much.

---
Changes in v3:
- Reintroduced v1 patch split to simplify review
- Reworked IRS/ITS iopoll loop, split in atomic/non-atomic
- Cleaned-up IRS/ITS code with macros addressing review comments
- Dropped IWB driver waiting for IRQ core code to be fixed for DOMAIN_BUS_WIRED_TO_MSI
https://lore.kernel.org/lkml/[email protected]/
- Moved headers to arch/arm64 and include/linux/irqchip
- Reworked GSB barriers definition
- Added extensive GSB/ISB barriers comments
- Limited error checking on IRS/ITS code - introduced couple of fatal BUG_ON checks
- Link to v2: https://lore.kernel.org/r/[email protected]

Changes in v2:
- Squashed patches [18-21] into a single logical entity
- Replaced maple tree with IDA for LPI IDs allocation
- Changed coding style to tip-maintainer guidelines
- Tried to consolidate poll wait mechanism into fewer functions
- Added comments related to _relaxed accessors, barriers and kmalloc limitations
- Removed IPI affinity check hotplug callback
- Applied DT schema changes requested, moved IWB into a separate schema
- Fixed DT examples
- Fixed guard() usage
- Link to v1: https://lore.kernel.org/r/[email protected]

---
Lorenzo Pieralisi (24):
dt-bindings: interrupt-controller: Add Arm GICv5 arm64/sysreg: Add GCIE field to ID_AA64PFR2_EL1 arm64/sysreg: Add ICC_PPI_PRIORITY<n>_EL1 arm64/sysreg: Add ICC_ICSR_EL1
arm64/sysreg: Add ICC_PPI_HMR<n>_EL1 arm64/sysreg: Add ICC_PPI_ENABLER<n>_EL1 arm64/sysreg: Add ICC_PPI_{C/S}ACTIVER<n>_EL1 arm64/sysreg: Add ICC_PPI_{C/S}PENDR<n>_EL1 arm64/sysreg: Add ICC_CR0_EL1
arm64/sysreg: Add ICC_PCR_EL1
arm64/sysreg: Add ICC_IDR0_EL1
arm64/sysreg: Add ICH_HFGRTR_EL2
arm64/sysreg: Add ICH_HFGWTR_EL2
arm64/sysreg: Add ICH_HFGITR_EL2
arm64: Disable GICv5 read/write/instruction traps
arm64: cpucaps: Rename GICv3 CPU interface capability
arm64: cpucaps: Add GICv5 CPU interface (GCIE) capability
arm64: Add support for GICv5 GSB barriers irqchip/gic-v5: Add GICv5 PPI support irqchip/gic-v5: Add GICv5 IRS/SPI support irqchip/gic-v5: Add GICv5 LPI/IPI support irqchip/gic-v5: Enable GICv5 SMP booting irqchip/gic-v5: Add GICv5 ITS support
arm64: Kconfig: Enable GICv5

Marc Zyngier (1):
arm64: smp: Support non-SGIs for IPIs

 .../interrupt-controller/arm,gic-v5-iwb.yaml       |   76 ++
 .../bindings/interrupt-controller/arm,gic-v5.yaml  |  196 ++++
 MAINTAINERS                                        |   10 +
 arch/arm64/Kconfig                                 |    1 +
 arch/arm64/include/asm/barrier.h                   |    3 +
 arch/arm64/include/asm/el2_setup.h                 |   45 +
 arch/arm64/include/asm/smp.h                       |   24 +-
 arch/arm64/include/asm/sysreg.h                    |   83 +-
 arch/arm64/kernel/cpufeature.c                     |   17 +-
 arch/arm64/kernel/smp.c                            |  156 ++-
 arch/arm64/tools/cpucaps                           |    3 +-
 arch/arm64/tools/sysreg                            |  495 +++++++-
 drivers/irqchip/Kconfig                            |   12 +
 drivers/irqchip/Makefile                           |    4 +-
 drivers/irqchip/irq-gic-common.h                   |    2 -
 ...3-its-msi-parent.c => irq-gic-its-msi-parent.c} |    3 +-
 drivers/irqchip/irq-gic-its-msi-parent.h           |   13 +
 drivers/irqchip/irq-gic-v3-its.c                   |    3 +-
 drivers/irqchip/irq-gic-v5-irs.c                   |  819 ++++++++++++++
 drivers/irqchip/irq-gic-v5-its.c                   | 1176 ++++++++++++++++++++
 drivers/irqchip/irq-gic-v5.c                       | 1046 +++++++++++++++++
 drivers/irqchip/irq-gic.c                          |    2 +-
 include/linux/irqchip/arm-gic-v5.h                 |  387 +++++++
 23 files changed, 4507 insertions(+), 69 deletions(-)

---
base-commit: 0af2f6be1b4281385b618cb86ad946eded089ac8
change-id: 20250408-gicv5-host-749f316afe84

Best regards,

Signature · 1 line
Lorenzo Pieralisi <[email protected]>
author maintainer
#1 lore raw

PATCH v3 1/25 dt-bindings: interrupt-controller: Add Arm GICv5

The GICv5 interrupt controller architecture is composed of:

- one or more Interrupt Routing Service (IRS)
- zero or more Interrupt Translation Service (ITS)
- zero or more Interrupt Wire Bridge (IWB)

Describe a GICv5 implementation by specifying a top level node corresponding to the GICv5 system component.

IRS nodes are added as GICv5 system component children.

An ITS is associated with an IRS so ITS nodes are described as IRS children - use the hierarchy explicitly in the device tree to define the association.

IWB nodes are described as a separate schema.

An IWB is connected to a single ITS, the connection is made explicit through the msi-parent property and therefore is not required to be explicit through a parent-child relationship in the device tree.

Cc Conor Dooley <[email protected]>
Cc Rob Herring <[email protected]>
Cc Krzysztof Kozlowski <[email protected]>
Cc Marc Zyngier <[email protected]>
---
 .../interrupt-controller/arm,gic-v5-iwb.yaml       |  76 ++++++++
 .../bindings/interrupt-controller/arm,gic-v5.yaml  | 196 +++++++++++++++++++++
 MAINTAINERS                                        |   7 +
 3 files changed, 279 insertions(+)
Documentation/devicetree/bindings/interrupt-controller/arm,gic-v5-iwb.yaml new file +76 -0
new file mode 100644
index 0000000000000000000000000000000000000000..b3eb89567b3457e91b93588d7db1cef69b6b9813
@@ -0,0 +1,76 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/interrupt-controller/arm,gic-v5-iwb.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: ARM Generic Interrupt Controller, version 5 Interrupt Wire Bridge (IWB)
+
+maintainers:
+  - Lorenzo Pieralisi <[email protected]>
+  - Marc Zyngier <[email protected]>
+
+description: |
+  The GICv5 architecture defines the guidelines to implement GICv5
+  compliant interrupt controllers for AArch64 systems.
+
+  The GICv5 specification can be found at
+  https://developer.arm.com/documentation/aes0070
+
+  GICv5 has zero or more Interrupt Wire Bridges (IWB) that are responsible
+  for translating wire signals into interrupt messages to the GICv5 ITS.
+
+allOf:
+  - $ref: /schemas/interrupt-controller.yaml#
+
+properties:
+  compatible:
+    const: arm,gic-v5-iwb
+
+  interrupt-controller: true
+
+  "#address-cells":
+    const: 0
+
+  "#interrupt-cells":
+    description: |
+      The 1st cell corresponds to the IWB wire.
+
+      The 2nd cell is the flags, encoded as follows:
+      bits[3:0] trigger type and level flags.
+
+      1 = low-to-high edge triggered
+      2 = high-to-low edge triggered
+      4 = active high level-sensitive
+      8 = active low level-sensitive
+
+    const: 2
+
+  reg:
+    items:
+      - description: IWB control frame
+
+  msi-parent:
+    maxItems: 1
+
+required:
+  - compatible
+  - reg
+  - msi-parent
+
+additionalProperties: false
+
+examples:
+  - |
+    interrupt-controller@2f000000 {
+      compatible = "arm,gic-v5-iwb";
+      #address-cells = <0>;
+
+      interrupt-controller;
+      #interrupt-cells = <2>;
+
+      reg = <0x2f000000 0x10000>;
+
+      msi-parent = <&its0 64>;
+    };
+...
Documentation/devicetree/bindings/interrupt-controller/arm,gic-v5.yaml new file +196 -0

196 lines not on this page · raw message

MAINTAINERS +7 -0
index 96b82704950184bd71623ff41fc4df31e4c7fe87..1902291c3cccc06d27c5f79123e67774cf9a0e43 100644
@@ -1901,6 +1901,13 @@ F:	drivers/irqchip/irq-gic*.[ch]
 F:	include/linux/irqchip/arm-gic*.h
 F:	include/linux/irqchip/arm-vgic-info.h
 
+ARM GENERIC INTERRUPT CONTROLLER V5 DRIVERS
+M:	Lorenzo Pieralisi <[email protected]>
+M:	Marc Zyngier <[email protected]>
+L:	[email protected] (moderated for non-subscribers)
+S:	Maintained
+F:	Documentation/devicetree/bindings/interrupt-controller/arm,gic-v5*.yaml
+
 ARM HDLCD DRM DRIVER
 M:	Liviu Dudau <[email protected]>
 S:	Supported
Signature · 1 line
2.48.0
maintainer
#2 lore raw

Re: [PATCH v3 01/25] dt-bindings: interrupt-controller: Add Arm GICv5

Quoted 59 lines · Lorenzo Pieralisi

The GICv5 interrupt controller architecture is composed of:

- one or more Interrupt Routing Service (IRS)
- zero or more Interrupt Translation Service (ITS)
- zero or more Interrupt Wire Bridge (IWB)

Describe a GICv5 implementation by specifying a top level node corresponding to the GICv5 system component.

IRS nodes are added as GICv5 system component children.

An ITS is associated with an IRS so ITS nodes are described as IRS children - use the hierarchy explicitly in the device tree to define the association.

IWB nodes are described as a separate schema.

An IWB is connected to a single ITS, the connection is made explicit through the msi-parent property and therefore is not required to be explicit through a parent-child relationship in the device tree.

Cc Conor Dooley <[email protected]>
Cc Rob Herring <[email protected]>
Cc Krzysztof Kozlowski <[email protected]>
Cc Marc Zyngier <[email protected]>
---
 .../interrupt-controller/arm,gic-v5-iwb.yaml       |  76 ++++++++
 .../bindings/interrupt-controller/arm,gic-v5.yaml  | 196 +++++++++++++++++++++
 MAINTAINERS                                        |   7 +
 3 files changed, 279 insertions(+)
Documentation/devicetree/bindings/interrupt-controller/arm,gic-v5-iwb.yaml new file +20 -0
new file mode 100644
index 0000000000000000000000000000000000000000..b3eb89567b3457e91b93588d7db1cef69b6b9813
@@ -0,0 +1,76 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/interrupt-controller/arm,gic-v5-iwb.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: ARM Generic Interrupt Controller, version 5 Interrupt Wire Bridge (IWB)
+
+maintainers:
+  - Lorenzo Pieralisi <[email protected]>
+  - Marc Zyngier <[email protected]>
+
+description: |
+  The GICv5 architecture defines the guidelines to implement GICv5
+  compliant interrupt controllers for AArch64 systems.
+
+  The GICv5 specification can be found at
+  https://developer.arm.com/documentation/aes0070
+
+  GICv5 has zero or more Interrupt Wire Bridges (IWB) that are responsible

Documentation/devicetree/bindings/interrupt-controller/arm,gic-v5-iwb.yaml line 30

Quoted 10 lines
Documentation/devicetree/bindings/interrupt-controller/arm,gic-v5-iwb.yaml new file +10 -0
+  for translating wire signals into interrupt messages to the GICv5 ITS.
+
+allOf:
+  - $ref: /schemas/interrupt-controller.yaml#
+
+properties:
+  compatible:
+    const: arm,gic-v5-iwb
+
+  interrupt-controller: true

Move next to #interrupt-cells

Quoted 9 lines
Documentation/devicetree/bindings/interrupt-controller/arm,gic-v5-iwb.yaml new file +9 -0
+
+  "#address-cells":
+    const: 0
+
+  "#interrupt-cells":
+    description: |
+      The 1st cell corresponds to the IWB wire.
+
+      The 2nd cell is the flags, encoded as follows:

Documentation/devicetree/bindings/interrupt-controller/arm,gic-v5-iwb.yaml line 49

Quoted 10 lines
Documentation/devicetree/bindings/interrupt-controller/arm,gic-v5-iwb.yaml new file +10 -0
+      bits[3:0] trigger type and level flags.
+
+      1 = low-to-high edge triggered
+      2 = high-to-low edge triggered
+      4 = active high level-sensitive
+      8 = active low level-sensitive
+
+    const: 2
+
+  reg:

Generally, the order is compatible, reg, common properties, vendor properties, child nodes. Related properties grouped together and alphabetical order (ignoring '#') within common and vendor properties.

Documentation/devicetree/bindings/interrupt-controller/arm,gic-v5-iwb.yaml line 59

Quoted 10 lines
Documentation/devicetree/bindings/interrupt-controller/arm,gic-v5-iwb.yaml new file +10 -0
+    items:
+      - description: IWB control frame
+
+  msi-parent:
+    maxItems: 1
+
+required:
+  - compatible
+  - reg
+  - msi-parent

interrupt-controller and #interrupt-cells should be required

Documentation/devicetree/bindings/interrupt-controller/arm,gic-v5-iwb.yaml line 72

Quoted 13 lines
Documentation/devicetree/bindings/interrupt-controller/arm,gic-v5-iwb.yaml new file +13 -0
+
+additionalProperties: false
+
+examples:
+  - |
+    interrupt-controller@2f000000 {
+      compatible = "arm,gic-v5-iwb";
+      #address-cells = <0>;
+
+      interrupt-controller;
+      #interrupt-cells = <2>;
+
+      reg = <0x2f000000 0x10000>;

Use the same order as the schema.

Quoted 70 lines
Documentation/devicetree/bindings/interrupt-controller/arm,gic-v5-iwb.yaml new file +4 -0
+
+      msi-parent = <&its0 64>;
+    };
+...
Documentation/devicetree/bindings/interrupt-controller/arm,gic-v5.yaml new file +60 -0
new file mode 100644
index 0000000000000000000000000000000000000000..1ba0a2088e6d15bacae22c9fc9eebc4ce5c51b0b
@@ -0,0 +1,196 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/interrupt-controller/arm,gic-v5.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: ARM Generic Interrupt Controller, version 5
+
+maintainers:
+  - Lorenzo Pieralisi <[email protected]>
+  - Marc Zyngier <[email protected]>
+
+description: |
+  The GICv5 architecture defines the guidelines to implement GICv5
+  compliant interrupt controllers for AArch64 systems.
+
+  The GICv5 specification can be found at
+  https://developer.arm.com/documentation/aes0070
+
+  The GICv5 architecture is composed of multiple components:
+    - one or more IRS (Interrupt Routing Service)
+    - zero or more ITS (Interrupt Translation Service)
+
+  The architecture defines:
+    - PE-Private Peripheral Interrupts (PPI)
+    - Shared Peripheral Interrupts (SPI)
+    - Logical Peripheral Interrupts (LPI)
+
+allOf:
+  - $ref: /schemas/interrupt-controller.yaml#
+
+properties:
+  compatible:
+    const: arm,gic-v5
+
+  interrupt-controller: true
+
+  "#address-cells":
+    enum: [ 1, 2 ]
+
+  "#size-cells":
+    enum: [ 1, 2 ]
+
+  ranges: true
+
+  "#interrupt-cells":
+    description: |
+      The 1st cell corresponds to the INTID.Type field in the INTID; 1 for PPI,
+      3 for SPI. LPI interrupts must not be described in the bindings since
+      they are allocated dynamically by the software component managing them.
+
+      The 2nd cell contains the interrupt INTID.ID field.
+
+      The 3rd cell is the flags, encoded as follows:
+      bits[3:0] trigger type and level flags.
+
+        1 = low-to-high edge triggered
+        2 = high-to-low edge triggered
+        4 = active high level-sensitive
+        8 = active low level-sensitive

Documentation/devicetree/bindings/interrupt-controller/arm,gic-v5.yaml line 70

Quoted 10 lines
Documentation/devicetree/bindings/interrupt-controller/arm,gic-v5.yaml new file +10 -0
+
+    const: 3
+
+  interrupts:
+    description:
+      The VGIC maintenance interrupt.
+    maxItems: 1
+
+required:
+  - compatible

If you always have an IRS which you say there is, then #address-cells, #size-cells, and ranges are required. And interrupt-controller and #interrupt-cells.

Quoted 19 lines
Documentation/devicetree/bindings/interrupt-controller/arm,gic-v5.yaml new file +19 -0
+
+patternProperties:
+  "^irs@[0-9a-f]+$":
+    type: object
+    description:
+      GICv5 has one or more Interrupt Routing Services (IRS) that are
+      responsible for handling IRQ state and routing.
+
+    additionalProperties: false
+
+    properties:
+      compatible:
+        const: arm,gic-v5-irs
+
+      "#address-cells":
+        enum: [ 1, 2 ]
+
+      "#size-cells":
+        enum: [ 1, 2 ]

Documentation/devicetree/bindings/interrupt-controller/arm,gic-v5.yaml line 99

Quoted 10 lines
Documentation/devicetree/bindings/interrupt-controller/arm,gic-v5.yaml new file +10 -0
+
+      ranges: true
+
+      dma-noncoherent:
+        description:
+          Present if the GIC IRS permits programming shareability and
+          cacheability attributes but is connected to a non-coherent
+          downstream interconnect.
+
+      reg:

Move after compatible

Quoted 33 lines
Documentation/devicetree/bindings/interrupt-controller/arm,gic-v5.yaml new file +33 -0
+        minItems: 1
+        items:
+          - description: IRS control frame
+          - description: IRS setlpi frame
+
+      cpus:
+        description:
+          CPUs managed by the IRS.
+
+      arm,iaffids:
+        $ref: /schemas/types.yaml#/definitions/uint16-array
+        description:
+          Interrupt AFFinity ID (IAFFID) associated with the CPU whose
+          CPU node phandle is at the same index in the cpus array.
+
+    patternProperties:
+      "^msi-controller@[0-9a-f]+$":
+        type: object
+        description:
+          GICv5 has zero or more Interrupt Translation Services (ITS) that are
+          used to route Message Signalled Interrupts (MSI) to the CPUs. Each
+          ITS is connected to an IRS.
+        additionalProperties: false
+
+        properties:
+          compatible:
+            const: arm,gic-v5-its
+
+          dma-noncoherent:
+            description:
+              Present if the GIC ITS permits programming shareability and
+              cacheability attributes but is connected to a non-coherent
+              downstream interconnect.

Documentation/devicetree/bindings/interrupt-controller/arm,gic-v5.yaml line 142

Quoted 10 lines
Documentation/devicetree/bindings/interrupt-controller/arm,gic-v5.yaml new file +10 -0
+
+          msi-controller: true
+
+          "#msi-cells":
+            description:
+              The single msi-cell is the DeviceID of the device which will
+              generate the MSI.
+            const: 1
+
+          reg:

Move after compatible.

Quoted 39 lines
Documentation/devicetree/bindings/interrupt-controller/arm,gic-v5.yaml new file +39 -0
+            items:
+              - description: ITS control frame
+              - description: ITS translate frame
+
+        required:
+          - compatible
+          - msi-controller
+          - "#msi-cells"
+          - reg
+
+    required:
+      - compatible
+      - reg
+      - cpus
+      - arm,iaffids
+
+additionalProperties: false
+
+examples:
+  - |
+    interrupt-controller {
+      compatible = "arm,gic-v5";
+      #interrupt-cells = <3>;
+      #address-cells = <1>;
+      #size-cells = <1>;
+      ranges;
+
+      interrupt-controller;
+
+      interrupts = <1 25 4>;
+
+      irs@2f1a0000 {
+        compatible = "arm,gic-v5-irs";
+        #address-cells = <1>;
+        #size-cells = <1>;
+        ranges;
+
+        reg = <0x2f1a0000 0x10000>;  // IRS_CONFIG_FRAME for NS
+

Documentation/devicetree/bindings/interrupt-controller/arm,gic-v5.yaml line 191

Quoted 10 lines
Documentation/devicetree/bindings/interrupt-controller/arm,gic-v5.yaml new file +10 -0
+        arm,iaffids = /bits/ 16 <0 1 2 3 4 5 6 7>;
+        cpus = <&cpu0>, <&cpu1>, <&cpu2>, <&cpu3>, <&cpu4>, <&cpu5>, <&cpu6>, <&cpu7>;
+
+        msi-controller@2f120000 {
+          compatible = "arm,gic-v5-its";
+
+          msi-controller;
+          #msi-cells = <1>;
+
+          reg = <0x2f120000 0x10000    // ITS_CONFIG_FRAME for NS

Enclose each entry in <>'s.

Quoted 27 lines
Documentation/devicetree/bindings/interrupt-controller/arm,gic-v5.yaml new file +5 -0
+                 0x2f130000 0x10000>;  // ITS_TRANSLATE_FRAME
+        };
+      };
+    };
+...
MAINTAINERS +7 -1
index 96b82704950184bd71623ff41fc4df31e4c7fe87..1902291c3cccc06d27c5f79123e67774cf9a0e43 100644
@@ -1901,6 +1901,13 @@ F:       drivers/irqchip/irq-gic*.[ch]
 F:     include/linux/irqchip/arm-gic*.h
 F:     include/linux/irqchip/arm-vgic-info.h
 
+ARM GENERIC INTERRUPT CONTROLLER V5 DRIVERS
+M:     Lorenzo Pieralisi <[email protected]>
+M:     Marc Zyngier <[email protected]>
+L:     [email protected] (moderated for non-subscribers)
+S:     Maintained
+F:     Documentation/devicetree/bindings/interrupt-controller/arm,gic-v5*.yaml
+
 ARM HDLCD DRM DRIVER
 M:     Liviu Dudau <[email protected]>
 S:     Supported
 
--

2.48.0

author maintainer
#3 lore raw

Re: [PATCH v3 01/25] dt-bindings: interrupt-controller: Add Arm GICv5

Quoted 64 lines · Rob Herring
Quoted 63 lines · Lorenzo Pieralisi

The GICv5 interrupt controller architecture is composed of:

- one or more Interrupt Routing Service (IRS)
- zero or more Interrupt Translation Service (ITS)
- zero or more Interrupt Wire Bridge (IWB)

Describe a GICv5 implementation by specifying a top level node corresponding to the GICv5 system component.

IRS nodes are added as GICv5 system component children.

An ITS is associated with an IRS so ITS nodes are described as IRS children - use the hierarchy explicitly in the device tree to define the association.

IWB nodes are described as a separate schema.

An IWB is connected to a single ITS, the connection is made explicit through the msi-parent property and therefore is not required to be explicit through a parent-child relationship in the device tree.

Cc Conor Dooley <[email protected]>
Cc Rob Herring <[email protected]>
Cc Krzysztof Kozlowski <[email protected]>
Cc Marc Zyngier <[email protected]>
---
 .../interrupt-controller/arm,gic-v5-iwb.yaml       |  76 ++++++++
 .../bindings/interrupt-controller/arm,gic-v5.yaml  | 196 +++++++++++++++++++++
 MAINTAINERS                                        |   7 +
 3 files changed, 279 insertions(+)
Documentation/devicetree/bindings/interrupt-controller/arm,gic-v5-iwb.yaml new file +24 -0
new file mode 100644
index 0000000000000000000000000000000000000000..b3eb89567b3457e91b93588d7db1cef69b6b9813
@@ -0,0 +1,76 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/interrupt-controller/arm,gic-v5-iwb.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: ARM Generic Interrupt Controller, version 5 Interrupt Wire Bridge (IWB)
+
+maintainers:
+  - Lorenzo Pieralisi <[email protected]>
+  - Marc Zyngier <[email protected]>
+
+description: |
+  The GICv5 architecture defines the guidelines to implement GICv5
+  compliant interrupt controllers for AArch64 systems.
+
+  The GICv5 specification can be found at
+  https://developer.arm.com/documentation/aes0070
+
+  GICv5 has zero or more Interrupt Wire Bridges (IWB) that are responsible
+  for translating wire signals into interrupt messages to the GICv5 ITS.
+
+allOf:
+  - $ref: /schemas/interrupt-controller.yaml#
Quoted 8 lines

Documentation/devicetree/bindings/interrupt-controller/arm,gic-v5-iwb.yaml line 30

Quoted 6 lines
Documentation/devicetree/bindings/interrupt-controller/arm,gic-v5-iwb.yaml new file +6 -0
+
+properties:
+  compatible:
+    const: arm,gic-v5-iwb
+
+  interrupt-controller: true

Move next to #interrupt-cells

I will move it below #interrupt-cells (ie alphabetical order ignoring '#'), is that OK (it is a bit counterintuitive, that's why I am asking) ?

Same goes for msi-controller after #msi-cells.

Quoted 15 lines
Quoted 15 lines
Documentation/devicetree/bindings/interrupt-controller/arm,gic-v5-iwb.yaml new file +15 -0
+
+  "#address-cells":
+    const: 0
+
+  "#interrupt-cells":
+    description: |
+      The 1st cell corresponds to the IWB wire.
+
+      The 2nd cell is the flags, encoded as follows:
+      bits[3:0] trigger type and level flags.
+
+      1 = low-to-high edge triggered
+      2 = high-to-low edge triggered
+      4 = active high level-sensitive
+      8 = active low level-sensitive
Quoted 8 lines

Documentation/devicetree/bindings/interrupt-controller/arm,gic-v5-iwb.yaml line 49

Quoted 4 lines
Documentation/devicetree/bindings/interrupt-controller/arm,gic-v5-iwb.yaml new file +4 -0
+
+    const: 2
+
+  reg:

Generally, the order is compatible, reg, common properties, vendor properties, child nodes. Related properties grouped together and alphabetical order (ignoring '#') within common and vendor properties.

Updated, noted.

Quoted 4 lines
Quoted 4 lines
Documentation/devicetree/bindings/interrupt-controller/arm,gic-v5-iwb.yaml new file +4 -0
+    items:
+      - description: IWB control frame
+
+  msi-parent:
Quoted 8 lines

Documentation/devicetree/bindings/interrupt-controller/arm,gic-v5-iwb.yaml line 59

Quoted 6 lines
Documentation/devicetree/bindings/interrupt-controller/arm,gic-v5-iwb.yaml new file +6 -0
+    maxItems: 1
+
+required:
+  - compatible
+  - reg
+  - msi-parent

interrupt-controller and #interrupt-cells should be required

Done.

Quoted 7 lines
Quoted 7 lines
Documentation/devicetree/bindings/interrupt-controller/arm,gic-v5-iwb.yaml new file +7 -0
+
+additionalProperties: false
+
+examples:
+  - |
+    interrupt-controller@2f000000 {
+      compatible = "arm,gic-v5-iwb";
Quoted 8 lines

Documentation/devicetree/bindings/interrupt-controller/arm,gic-v5-iwb.yaml line 72

Quoted 6 lines
Documentation/devicetree/bindings/interrupt-controller/arm,gic-v5-iwb.yaml new file +6 -0
+      #address-cells = <0>;
+
+      interrupt-controller;
+      #interrupt-cells = <2>;
+
+      reg = <0x2f000000 0x10000>;

Use the same order as the schema.

Done.

Quoted 77 lines
Quoted 77 lines
Documentation/devicetree/bindings/interrupt-controller/arm,gic-v5-iwb.yaml new file +4 -0
+
+      msi-parent = <&its0 64>;
+    };
+...
Documentation/devicetree/bindings/interrupt-controller/arm,gic-v5.yaml new file +66 -0
new file mode 100644
index 0000000000000000000000000000000000000000..1ba0a2088e6d15bacae22c9fc9eebc4ce5c51b0b
@@ -0,0 +1,196 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/interrupt-controller/arm,gic-v5.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: ARM Generic Interrupt Controller, version 5
+
+maintainers:
+  - Lorenzo Pieralisi <[email protected]>
+  - Marc Zyngier <[email protected]>
+
+description: |
+  The GICv5 architecture defines the guidelines to implement GICv5
+  compliant interrupt controllers for AArch64 systems.
+
+  The GICv5 specification can be found at
+  https://developer.arm.com/documentation/aes0070
+
+  The GICv5 architecture is composed of multiple components:
+    - one or more IRS (Interrupt Routing Service)
+    - zero or more ITS (Interrupt Translation Service)
+
+  The architecture defines:
+    - PE-Private Peripheral Interrupts (PPI)
+    - Shared Peripheral Interrupts (SPI)
+    - Logical Peripheral Interrupts (LPI)
+
+allOf:
+  - $ref: /schemas/interrupt-controller.yaml#
+
+properties:
+  compatible:
+    const: arm,gic-v5
+
+  interrupt-controller: true
+
+  "#address-cells":
+    enum: [ 1, 2 ]
+
+  "#size-cells":
+    enum: [ 1, 2 ]
+
+  ranges: true
+
+  "#interrupt-cells":
+    description: |
+      The 1st cell corresponds to the INTID.Type field in the INTID; 1 for PPI,
+      3 for SPI. LPI interrupts must not be described in the bindings since
+      they are allocated dynamically by the software component managing them.
+
+      The 2nd cell contains the interrupt INTID.ID field.
+
+      The 3rd cell is the flags, encoded as follows:
+      bits[3:0] trigger type and level flags.
+
+        1 = low-to-high edge triggered
+        2 = high-to-low edge triggered
+        4 = active high level-sensitive
+        8 = active low level-sensitive
+
+    const: 3
+
+  interrupts:
+    description:
+      The VGIC maintenance interrupt.
Quoted 8 lines

Documentation/devicetree/bindings/interrupt-controller/arm,gic-v5.yaml line 70

Quoted 4 lines
Documentation/devicetree/bindings/interrupt-controller/arm,gic-v5.yaml new file +4 -0
+    maxItems: 1
+
+required:
+  - compatible

If you always have an IRS which you say there is, then #address-cells, #size-cells, and ranges are required. And interrupt-controller and #interrupt-cells.

Right, done.

Quoted 23 lines
Quoted 23 lines
Documentation/devicetree/bindings/interrupt-controller/arm,gic-v5.yaml new file +23 -0
+
+patternProperties:
+  "^irs@[0-9a-f]+$":
+    type: object
+    description:
+      GICv5 has one or more Interrupt Routing Services (IRS) that are
+      responsible for handling IRQ state and routing.
+
+    additionalProperties: false
+
+    properties:
+      compatible:
+        const: arm,gic-v5-irs
+
+      "#address-cells":
+        enum: [ 1, 2 ]
+
+      "#size-cells":
+        enum: [ 1, 2 ]
+
+      ranges: true
+
+      dma-noncoherent:
Quoted 8 lines

Documentation/devicetree/bindings/interrupt-controller/arm,gic-v5.yaml line 99

Quoted 6 lines
Documentation/devicetree/bindings/interrupt-controller/arm,gic-v5.yaml new file +6 -0
+        description:
+          Present if the GIC IRS permits programming shareability and
+          cacheability attributes but is connected to a non-coherent
+          downstream interconnect.
+
+      reg:

Move after compatible

Done.

Quoted 37 lines
Quoted 37 lines
Documentation/devicetree/bindings/interrupt-controller/arm,gic-v5.yaml new file +37 -0
+        minItems: 1
+        items:
+          - description: IRS control frame
+          - description: IRS setlpi frame
+
+      cpus:
+        description:
+          CPUs managed by the IRS.
+
+      arm,iaffids:
+        $ref: /schemas/types.yaml#/definitions/uint16-array
+        description:
+          Interrupt AFFinity ID (IAFFID) associated with the CPU whose
+          CPU node phandle is at the same index in the cpus array.
+
+    patternProperties:
+      "^msi-controller@[0-9a-f]+$":
+        type: object
+        description:
+          GICv5 has zero or more Interrupt Translation Services (ITS) that are
+          used to route Message Signalled Interrupts (MSI) to the CPUs. Each
+          ITS is connected to an IRS.
+        additionalProperties: false
+
+        properties:
+          compatible:
+            const: arm,gic-v5-its
+
+          dma-noncoherent:
+            description:
+              Present if the GIC ITS permits programming shareability and
+              cacheability attributes but is connected to a non-coherent
+              downstream interconnect.
+
+          msi-controller: true
+
+          "#msi-cells":
Quoted 8 lines

Documentation/devicetree/bindings/interrupt-controller/arm,gic-v5.yaml line 142

Quoted 6 lines
Documentation/devicetree/bindings/interrupt-controller/arm,gic-v5.yaml new file +6 -0
+            description:
+              The single msi-cell is the DeviceID of the device which will
+              generate the MSI.
+            const: 1
+
+          reg:

Move after compatible.

Done.

Quoted 43 lines
Quoted 43 lines
Documentation/devicetree/bindings/interrupt-controller/arm,gic-v5.yaml new file +43 -0
+            items:
+              - description: ITS control frame
+              - description: ITS translate frame
+
+        required:
+          - compatible
+          - msi-controller
+          - "#msi-cells"
+          - reg
+
+    required:
+      - compatible
+      - reg
+      - cpus
+      - arm,iaffids
+
+additionalProperties: false
+
+examples:
+  - |
+    interrupt-controller {
+      compatible = "arm,gic-v5";
+      #interrupt-cells = <3>;
+      #address-cells = <1>;
+      #size-cells = <1>;
+      ranges;
+
+      interrupt-controller;
+
+      interrupts = <1 25 4>;
+
+      irs@2f1a0000 {
+        compatible = "arm,gic-v5-irs";
+        #address-cells = <1>;
+        #size-cells = <1>;
+        ranges;
+
+        reg = <0x2f1a0000 0x10000>;  // IRS_CONFIG_FRAME for NS
+
+        arm,iaffids = /bits/ 16 <0 1 2 3 4 5 6 7>;
+        cpus = <&cpu0>, <&cpu1>, <&cpu2>, <&cpu3>, <&cpu4>, <&cpu5>, <&cpu6>, <&cpu7>;
+
+        msi-controller@2f120000 {
Quoted 8 lines

Documentation/devicetree/bindings/interrupt-controller/arm,gic-v5.yaml line 191

Quoted 6 lines
Documentation/devicetree/bindings/interrupt-controller/arm,gic-v5.yaml new file +6 -0
+          compatible = "arm,gic-v5-its";
+
+          msi-controller;
+          #msi-cells = <1>;
+
+          reg = <0x2f120000 0x10000    // ITS_CONFIG_FRAME for NS

Enclose each entry in <>'s.

Done.

Thanks a lot,
Lorenzo

Quoted 27 lines
Quoted 27 lines
Documentation/devicetree/bindings/interrupt-controller/arm,gic-v5.yaml new file +5 -0
+                 0x2f130000 0x10000>;  // ITS_TRANSLATE_FRAME
+        };
+      };
+    };
+...
MAINTAINERS +7 -1
index 96b82704950184bd71623ff41fc4df31e4c7fe87..1902291c3cccc06d27c5f79123e67774cf9a0e43 100644
@@ -1901,6 +1901,13 @@ F:       drivers/irqchip/irq-gic*.[ch]
 F:     include/linux/irqchip/arm-gic*.h
 F:     include/linux/irqchip/arm-vgic-info.h
 
+ARM GENERIC INTERRUPT CONTROLLER V5 DRIVERS
+M:     Lorenzo Pieralisi <[email protected]>
+M:     Marc Zyngier <[email protected]>
+L:     [email protected] (moderated for non-subscribers)
+S:     Maintained
+F:     Documentation/devicetree/bindings/interrupt-controller/arm,gic-v5*.yaml
+
 ARM HDLCD DRM DRIVER
 M:     Liviu Dudau <[email protected]>
 S:     Supported
 
--

2.48.0

author maintainer
#4 lore raw

PATCH v3 2/25 arm64/sysreg: Add GCIE field to ID_AA64PFR2_EL1

In reply to Lorenzo Pieralisi

Add field reporting the GCIE feature to ID_AA64PFR2_EL1 sysreg.

Cc Will Deacon <[email protected]>
Cc Catalin Marinas <[email protected]>
Cc Marc Zyngier <[email protected]>
---
 arch/arm64/tools/sysreg | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
arch/arm64/tools/sysreg +4 -1
index f9476848a2edfad53bb4af7f68bc05cb2a4af9ce..06e1fb5e126b41b7e41fffa0a00553d73197ac3c 100644
@@ -1023,7 +1023,10 @@ UnsignedEnum	19:16	UINJ
 	0b0000	NI
 	0b0001	IMP
 EndEnum
-Res0	15:12
+UnsignedEnum	15:12	GCIE
+	0b0000	NI
+	0b0001	IMP
+EndEnum
 UnsignedEnum	11:8	MTEFAR
 	0b0000	NI
 	0b0001	IMP
Signature · 1 line
2.48.0
author maintainer
#5 lore raw

PATCH v3 3/25 arm64/sysreg: Add ICC_PPI_PRIORITY<n>_EL1

In reply to Lorenzo Pieralisi

Add ICC_PPI_PRIORITY<n>_EL1 sysreg description.

Cc Will Deacon <[email protected]>
Cc Catalin Marinas <[email protected]>
Cc Marc Zyngier <[email protected]>
---
 arch/arm64/tools/sysreg | 83 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 83 insertions(+)
arch/arm64/tools/sysreg +83 -0
index 06e1fb5e126b41b7e41fffa0a00553d73197ac3c..0cc1268c0bfad8266da47b441e80c603e46c00ae 100644
@@ -2310,6 +2310,89 @@ Field	31	C
 Field	30:0	P
 EndSysreg
 
+SysregFields	ICC_PPI_PRIORITYRx_EL1
+Res0	63:61
+Field	60:56	Priority7
+Res0	55:53
+Field	52:48	Priority6
+Res0	47:45
+Field	44:40	Priority5
+Res0	39:37
+Field	36:32	Priority4
+Res0	31:29
+Field	28:24	Priority3
+Res0	23:21
+Field	20:16	Priority2
+Res0	15:13
+Field	12:8	Priority1
+Res0	7:5
+Field	4:0	Priority0
+EndSysregFields
+
+Sysreg	ICC_PPI_PRIORITYR0_EL1	3	0	12	14	0
+Fields	ICC_PPI_PRIORITYRx_EL1
+EndSysreg
+
+Sysreg	ICC_PPI_PRIORITYR1_EL1	3	0	12	14	1
+Fields	ICC_PPI_PRIORITYRx_EL1
+EndSysreg
+
+Sysreg	ICC_PPI_PRIORITYR2_EL1	3	0	12	14	2
+Fields	ICC_PPI_PRIORITYRx_EL1
+EndSysreg
+
+Sysreg	ICC_PPI_PRIORITYR3_EL1	3	0	12	14	3
+Fields	ICC_PPI_PRIORITYRx_EL1
+EndSysreg
+
+Sysreg	ICC_PPI_PRIORITYR4_EL1	3	0	12	14	4
+Fields	ICC_PPI_PRIORITYRx_EL1
+EndSysreg
+
+Sysreg	ICC_PPI_PRIORITYR5_EL1	3	0	12	14	5
+Fields	ICC_PPI_PRIORITYRx_EL1
+EndSysreg
+
+Sysreg	ICC_PPI_PRIORITYR6_EL1	3	0	12	14	6
+Fields	ICC_PPI_PRIORITYRx_EL1
+EndSysreg
+
+Sysreg	ICC_PPI_PRIORITYR7_EL1	3	0	12	14	7
+Fields	ICC_PPI_PRIORITYRx_EL1
+EndSysreg
+
+Sysreg	ICC_PPI_PRIORITYR8_EL1	3	0	12	15	0
+Fields	ICC_PPI_PRIORITYRx_EL1
+EndSysreg
+
+Sysreg	ICC_PPI_PRIORITYR9_EL1	3	0	12	15	1
+Fields	ICC_PPI_PRIORITYRx_EL1
+EndSysreg
+
+Sysreg	ICC_PPI_PRIORITYR10_EL1	3	0	12	15	2
+Fields	ICC_PPI_PRIORITYRx_EL1
+EndSysreg
+
+Sysreg	ICC_PPI_PRIORITYR11_EL1	3	0	12	15	3
+Fields	ICC_PPI_PRIORITYRx_EL1
+EndSysreg
+
+Sysreg	ICC_PPI_PRIORITYR12_EL1	3	0	12	15	4
+Fields	ICC_PPI_PRIORITYRx_EL1
+EndSysreg
+
+Sysreg	ICC_PPI_PRIORITYR13_EL1	3	0	12	15	5
+Fields	ICC_PPI_PRIORITYRx_EL1
+EndSysreg
+
+Sysreg	ICC_PPI_PRIORITYR14_EL1	3	0	12	15	6
+Fields	ICC_PPI_PRIORITYRx_EL1
+EndSysreg
+
+Sysreg	ICC_PPI_PRIORITYR15_EL1	3	0	12	15	7
+Fields	ICC_PPI_PRIORITYRx_EL1
+EndSysreg
+
 Sysreg	PMSELR_EL0	3	3	9	12	5
 Res0	63:5
 Field	4:0	SEL
Signature · 1 line
2.48.0
author maintainer
#6 lore raw

PATCH v3 4/25 arm64/sysreg: Add ICC_ICSR_EL1

In reply to Lorenzo Pieralisi

Add ICC_ICSR_EL1 register sysreg description.

Cc Will Deacon <[email protected]>
Cc Catalin Marinas <[email protected]>
Cc Marc Zyngier <[email protected]>
---
 arch/arm64/tools/sysreg | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
arch/arm64/tools/sysreg +14 -0
index 0cc1268c0bfad8266da47b441e80c603e46c00ae..985f2cdb67cfec6df335a3951ecb63f128f6da55 100644
@@ -2310,6 +2310,20 @@ Field	31	C
 Field	30:0	P
 EndSysreg
 
+Sysreg	ICC_ICSR_EL1	3	0	12	10	4
+Res0	63:48
+Field	47:32	IAFFID
+Res0	31:16
+Field	15:11	Priority
+Res0	10:6
+Field	5	HM
+Field	4	Active
+Field	3	IRM
+Field	2	Pending
+Field	1	Enabled
+Field	0	F
+EndSysreg
+
 SysregFields	ICC_PPI_PRIORITYRx_EL1
 Res0	63:61
 Field	60:56	Priority7
Signature · 1 line
2.48.0
author maintainer
#7 lore raw

PATCH v3 5/25 arm64/sysreg: Add ICC_PPI_HMR<n>_EL1

In reply to Lorenzo Pieralisi

Add ICC_PPI_HMR<n>_EL1 registers sysreg description.

Cc Will Deacon <[email protected]>
Cc Catalin Marinas <[email protected]>
Cc Marc Zyngier <[email protected]>
---
 arch/arm64/tools/sysreg | 75 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 75 insertions(+)
arch/arm64/tools/sysreg +75 -0
index 985f2cdb67cfec6df335a3951ecb63f128f6da55..d046d719d4f69801aeef51b5b9437a0eaa04134e 100644
@@ -2324,6 +2324,81 @@ Field	1	Enabled
 Field	0	F
 EndSysreg
 
+SysregFields	ICC_PPI_HMRx_EL1
+Field	63	HM63
+Field	62	HM62
+Field	61	HM61
+Field	60	HM60
+Field	59	HM59
+Field	58	HM58
+Field	57	HM57
+Field	56	HM56
+Field	55	HM55
+Field	54	HM54
+Field	53	HM53
+Field	52	HM52
+Field	51	HM51
+Field	50	HM50
+Field	49	HM49
+Field	48	HM48
+Field	47	HM47
+Field	46	HM46
+Field	45	HM45
+Field	44	HM44
+Field	43	HM43
+Field	42	HM42
+Field	41	HM41
+Field	40	HM40
+Field	39	HM39
+Field	38	HM38
+Field	37	HM37
+Field	36	HM36
+Field	35	HM35
+Field	34	HM34
+Field	33	HM33
+Field	32	HM32
+Field	31	HM31
+Field	30	HM30
+Field	29	HM29
+Field	28	HM28
+Field	27	HM27
+Field	26	HM26
+Field	25	HM25
+Field	24	HM24
+Field	23	HM23
+Field	22	HM22
+Field	21	HM21
+Field	20	HM20
+Field	19	HM19
+Field	18	HM18
+Field	17	HM17
+Field	16	HM16
+Field	15	HM15
+Field	14	HM14
+Field	13	HM13
+Field	12	HM12
+Field	11	HM11
+Field	10	HM10
+Field	9	HM9
+Field	8	HM8
+Field	7	HM7
+Field	6	HM6
+Field	5	HM5
+Field	4	HM4
+Field	3	HM3
+Field	2	HM2
+Field	1	HM1
+Field	0	HM0
+EndSysregFields
+
+Sysreg	ICC_PPI_HMR0_EL1	3	0	12	10	0
+Fields ICC_PPI_HMRx_EL1
+EndSysreg
+
+Sysreg	ICC_PPI_HMR1_EL1	3	0	12	10	1
+Fields ICC_PPI_HMRx_EL1
+EndSysreg
+
 SysregFields	ICC_PPI_PRIORITYRx_EL1
 Res0	63:61
 Field	60:56	Priority7
Signature · 1 line
2.48.0
author maintainer
#8 lore raw

PATCH v3 6/25 arm64/sysreg: Add ICC_PPI_ENABLER<n>_EL1

In reply to Lorenzo Pieralisi

Add ICC_PPI_ENABLER<n>_EL1 registers sysreg description.

Cc Will Deacon <[email protected]>
Cc Catalin Marinas <[email protected]>
Cc Marc Zyngier <[email protected]>
---
 arch/arm64/tools/sysreg | 75 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 75 insertions(+)
arch/arm64/tools/sysreg +75 -0
index d046d719d4f69801aeef51b5b9437a0eaa04134e..6c5552707ad88c145adc8b7ceb3f63da401191ea 100644
@@ -2399,6 +2399,81 @@ Sysreg	ICC_PPI_HMR1_EL1	3	0	12	10	1
 Fields ICC_PPI_HMRx_EL1
 EndSysreg
 
+SysregFields	ICC_PPI_ENABLERx_EL1
+Field	63	EN63
+Field	62	EN62
+Field	61	EN61
+Field	60	EN60
+Field	59	EN59
+Field	58	EN58
+Field	57	EN57
+Field	56	EN56
+Field	55	EN55
+Field	54	EN54
+Field	53	EN53
+Field	52	EN52
+Field	51	EN51
+Field	50	EN50
+Field	49	EN49
+Field	48	EN48
+Field	47	EN47
+Field	46	EN46
+Field	45	EN45
+Field	44	EN44
+Field	43	EN43
+Field	42	EN42
+Field	41	EN41
+Field	40	EN40
+Field	39	EN39
+Field	38	EN38
+Field	37	EN37
+Field	36	EN36
+Field	35	EN35
+Field	34	EN34
+Field	33	EN33
+Field	32	EN32
+Field	31	EN31
+Field	30	EN30
+Field	29	EN29
+Field	28	EN28
+Field	27	EN27
+Field	26	EN26
+Field	25	EN25
+Field	24	EN24
+Field	23	EN23
+Field	22	EN22
+Field	21	EN21
+Field	20	EN20
+Field	19	EN19
+Field	18	EN18
+Field	17	EN17
+Field	16	EN16
+Field	15	EN15
+Field	14	EN14
+Field	13	EN13
+Field	12	EN12
+Field	11	EN11
+Field	10	EN10
+Field	9	EN9
+Field	8	EN8
+Field	7	EN7
+Field	6	EN6
+Field	5	EN5
+Field	4	EN4
+Field	3	EN3
+Field	2	EN2
+Field	1	EN1
+Field	0	EN0
+EndSysregFields
+
+Sysreg	ICC_PPI_ENABLER0_EL1	3	0	12	10	6
+Fields ICC_PPI_ENABLERx_EL1
+EndSysreg
+
+Sysreg	ICC_PPI_ENABLER1_EL1	3	0	12	10	7
+Fields ICC_PPI_ENABLERx_EL1
+EndSysreg
+
 SysregFields	ICC_PPI_PRIORITYRx_EL1
 Res0	63:61
 Field	60:56	Priority7
Signature · 1 line
2.48.0
author maintainer
#9 lore raw

PATCH v3 7/25 arm64/sysreg: Add ICC_PPI_{C/S}ACTIVER<n>_EL1

In reply to Lorenzo Pieralisi

Add ICC_PPI_{C/S}ACTIVER<n>_EL1 registers description.

Cc Will Deacon <[email protected]>
Cc Catalin Marinas <[email protected]>
Cc Marc Zyngier <[email protected]>
---
 arch/arm64/tools/sysreg | 83 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 83 insertions(+)
arch/arm64/tools/sysreg +83 -0
index 6c5552707ad88c145adc8b7ceb3f63da401191ea..0485721e1575c9ed158210c6f02fb9af2828f2d5 100644
@@ -2474,6 +2474,89 @@ Sysreg	ICC_PPI_ENABLER1_EL1	3	0	12	10	7
 Fields ICC_PPI_ENABLERx_EL1
 EndSysreg
 
+SysregFields	ICC_PPI_ACTIVERx_EL1
+Field	63	Active63
+Field	62	Active62
+Field	61	Active61
+Field	60	Active60
+Field	59	Active59
+Field	58	Active58
+Field	57	Active57
+Field	56	Active56
+Field	55	Active55
+Field	54	Active54
+Field	53	Active53
+Field	52	Active52
+Field	51	Active51
+Field	50	Active50
+Field	49	Active49
+Field	48	Active48
+Field	47	Active47
+Field	46	Active46
+Field	45	Active45
+Field	44	Active44
+Field	43	Active43
+Field	42	Active42
+Field	41	Active41
+Field	40	Active40
+Field	39	Active39
+Field	38	Active38
+Field	37	Active37
+Field	36	Active36
+Field	35	Active35
+Field	34	Active34
+Field	33	Active33
+Field	32	Active32
+Field	31	Active31
+Field	30	Active30
+Field	29	Active29
+Field	28	Active28
+Field	27	Active27
+Field	26	Active26
+Field	25	Active25
+Field	24	Active24
+Field	23	Active23
+Field	22	Active22
+Field	21	Active21
+Field	20	Active20
+Field	19	Active19
+Field	18	Active18
+Field	17	Active17
+Field	16	Active16
+Field	15	Active15
+Field	14	Active14
+Field	13	Active13
+Field	12	Active12
+Field	11	Active11
+Field	10	Active10
+Field	9	Active9
+Field	8	Active8
+Field	7	Active7
+Field	6	Active6
+Field	5	Active5
+Field	4	Active4
+Field	3	Active3
+Field	2	Active2
+Field	1	Active1
+Field	0	Active0
+EndSysregFields
+
+Sysreg	ICC_PPI_CACTIVER0_EL1	3	0	12	13	0
+Fields ICC_PPI_ACTIVERx_EL1
+EndSysreg
+
+Sysreg	ICC_PPI_CACTIVER1_EL1	3	0	12	13	1
+Fields ICC_PPI_ACTIVERx_EL1
+EndSysreg
+
+Sysreg	ICC_PPI_SACTIVER0_EL1	3	0	12	13	2
+Fields ICC_PPI_ACTIVERx_EL1
+EndSysreg
+
+Sysreg	ICC_PPI_SACTIVER1_EL1	3	0	12	13	3
+Fields ICC_PPI_ACTIVERx_EL1
+EndSysreg
+
 SysregFields	ICC_PPI_PRIORITYRx_EL1
 Res0	63:61
 Field	60:56	Priority7
Signature · 1 line
2.48.0
author maintainer
#10 lore raw

PATCH v3 8/25 arm64/sysreg: Add ICC_PPI_{C/S}PENDR<n>_EL1

In reply to Lorenzo Pieralisi

Add ICC_PPI_{C/S}PENDR<n>_EL1 registers description.

Cc Will Deacon <[email protected]>
Cc Catalin Marinas <[email protected]>
Cc Marc Zyngier <[email protected]>
---
 arch/arm64/tools/sysreg | 83 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 83 insertions(+)
arch/arm64/tools/sysreg +83 -0
index 0485721e1575c9ed158210c6f02fb9af2828f2d5..7acad93718c56729ce2a333ed007243ec554dbc9 100644
@@ -2557,6 +2557,89 @@ Sysreg	ICC_PPI_SACTIVER1_EL1	3	0	12	13	3
 Fields ICC_PPI_ACTIVERx_EL1
 EndSysreg
 
+SysregFields	ICC_PPI_PENDRx_EL1
+Field	63	Pend63
+Field	62	Pend62
+Field	61	Pend61
+Field	60	Pend60
+Field	59	Pend59
+Field	58	Pend58
+Field	57	Pend57
+Field	56	Pend56
+Field	55	Pend55
+Field	54	Pend54
+Field	53	Pend53
+Field	52	Pend52
+Field	51	Pend51
+Field	50	Pend50
+Field	49	Pend49
+Field	48	Pend48
+Field	47	Pend47
+Field	46	Pend46
+Field	45	Pend45
+Field	44	Pend44
+Field	43	Pend43
+Field	42	Pend42
+Field	41	Pend41
+Field	40	Pend40
+Field	39	Pend39
+Field	38	Pend38
+Field	37	Pend37
+Field	36	Pend36
+Field	35	Pend35
+Field	34	Pend34
+Field	33	Pend33
+Field	32	Pend32
+Field	31	Pend31
+Field	30	Pend30
+Field	29	Pend29
+Field	28	Pend28
+Field	27	Pend27
+Field	26	Pend26
+Field	25	Pend25
+Field	24	Pend24
+Field	23	Pend23
+Field	22	Pend22
+Field	21	Pend21
+Field	20	Pend20
+Field	19	Pend19
+Field	18	Pend18
+Field	17	Pend17
+Field	16	Pend16
+Field	15	Pend15
+Field	14	Pend14
+Field	13	Pend13
+Field	12	Pend12
+Field	11	Pend11
+Field	10	Pend10
+Field	9	Pend9
+Field	8	Pend8
+Field	7	Pend7
+Field	6	Pend6
+Field	5	Pend5
+Field	4	Pend4
+Field	3	Pend3
+Field	2	Pend2
+Field	1	Pend1
+Field	0	Pend0
+EndSysregFields
+
+Sysreg	ICC_PPI_CPENDR0_EL1	3	0	12	13	4
+Fields ICC_PPI_PENDRx_EL1
+EndSysreg
+
+Sysreg	ICC_PPI_CPENDR1_EL1	3	0	12	13	5
+Fields ICC_PPI_PENDRx_EL1
+EndSysreg
+
+Sysreg	ICC_PPI_SPENDR0_EL1	3	0	12	13	6
+Fields ICC_PPI_PENDRx_EL1
+EndSysreg
+
+Sysreg	ICC_PPI_SPENDR1_EL1	3	0	12	13	7
+Fields ICC_PPI_PENDRx_EL1
+EndSysreg
+
 SysregFields	ICC_PPI_PRIORITYRx_EL1
 Res0	63:61
 Field	60:56	Priority7
Signature · 1 line
2.48.0
author maintainer
#11 lore raw

PATCH v3 9/25 arm64/sysreg: Add ICC_CR0_EL1

In reply to Lorenzo Pieralisi

Add ICC_CR0_EL1 register description.

Cc Will Deacon <[email protected]>
Cc Catalin Marinas <[email protected]>
Cc Marc Zyngier <[email protected]>
---
 arch/arm64/tools/sysreg | 8 ++++++++
 1 file changed, 8 insertions(+)
arch/arm64/tools/sysreg +8 -0
index 7acad93718c56729ce2a333ed007243ec554dbc9..c96243505031ea680c04a693fee2c96ad19e30ea 100644
@@ -2798,6 +2798,14 @@ Res0	14:12
 Field	11:0	AFFINITY
 EndSysreg
 
+Sysreg	ICC_CR0_EL1	3	1	12	0	1
+Res0	63:39
+Field	38	PID
+Field	37:32	IPPT
+Res0	31:1
+Field	0	EN
+EndSysreg
+
 Sysreg	CSSELR_EL1	3	2	0	0	0
 Res0	63:5
 Field	4	TnD
Signature · 1 line
2.48.0
author maintainer
#12 lore raw

PATCH v3 10/25 arm64/sysreg: Add ICC_PCR_EL1

In reply to Lorenzo Pieralisi

Add ICC_PCR_EL1 register description.

Cc Will Deacon <[email protected]>
Cc Catalin Marinas <[email protected]>
Cc Marc Zyngier <[email protected]>
---
 arch/arm64/tools/sysreg | 5 +++++
 1 file changed, 5 insertions(+)
arch/arm64/tools/sysreg +5 -0
index c96243505031ea680c04a693fee2c96ad19e30ea..9a2ddab8661c85586b0e91f7eaabd5a6b3409c67 100644
@@ -2806,6 +2806,11 @@ Res0	31:1
 Field	0	EN
 EndSysreg
 
+Sysreg	ICC_PCR_EL1	3	1	12	0	2
+Res0	63:5
+Field	4:0	PRIORITY
+EndSysreg
+
 Sysreg	CSSELR_EL1	3	2	0	0	0
 Res0	63:5
 Field	4	TnD
Signature · 1 line
2.48.0
author maintainer
#13 lore raw

PATCH v3 11/25 arm64/sysreg: Add ICC_IDR0_EL1

In reply to Lorenzo Pieralisi

Add ICC_IDR0_EL1 register description.

Cc Will Deacon <[email protected]>
Cc Catalin Marinas <[email protected]>
Cc Marc Zyngier <[email protected]>
---
 arch/arm64/tools/sysreg | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
arch/arm64/tools/sysreg +16 -0
index 9a2ddab8661c85586b0e91f7eaabd5a6b3409c67..1ec8113df713dfea6d38e39c42eba1e3dca5eea5 100644
@@ -2399,6 +2399,22 @@ Sysreg	ICC_PPI_HMR1_EL1	3	0	12	10	1
 Fields ICC_PPI_HMRx_EL1
 EndSysreg
 
+Sysreg	ICC_IDR0_EL1	3	0	12	10	2
+Res0	63:12
+UnsignedEnum	11:8	GCIE_LEGACY
+	0b0000	NI
+	0b0001	IMP
+EndEnum
+UnsignedEnum	7:4	PRI_BITS
+	0b0011	4BITS
+	0b0100	5BITS
+EndEnum
+UnsignedEnum	3:0	ID_BITS
+	0b0000	16BITS
+	0b0001	24BITS
+EndEnum
+EndSysreg
+
 SysregFields	ICC_PPI_ENABLERx_EL1
 Field	63	EN63
 Field	62	EN62
Signature · 1 line
2.48.0
author maintainer
#14 lore raw

PATCH v3 12/25 arm64/sysreg: Add ICH_HFGRTR_EL2

In reply to Lorenzo Pieralisi

Add ICH_HFGRTR_EL2 register description.

Cc Will Deacon <[email protected]>
Cc Catalin Marinas <[email protected]>
Cc Marc Zyngier <[email protected]>
---
 arch/arm64/tools/sysreg | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
arch/arm64/tools/sysreg +18 -0
index 1ec8113df713dfea6d38e39c42eba1e3dca5eea5..0c0e805481c84a14ae62d199466171d97d54ef90 100644
@@ -3583,6 +3583,24 @@ Field	31:16	PhyPARTID29
 Field	15:0	PhyPARTID28
 EndSysreg
 
+Sysreg	ICH_HFGRTR_EL2	3	4	12	9	4
+Res0	63:21
+Field	20	ICC_PPI_ACTIVERn_EL1
+Field	19	ICC_PPI_PRIORITYRn_EL1
+Field	18	ICC_PPI_PENDRn_EL1
+Field	17	ICC_PPI_ENABLERn_EL1
+Field	16	ICC_PPI_HMRn_EL1
+Res0	15:8
+Field	7	ICC_IAFFIDR_EL1
+Field	6	ICC_ICSR_EL1
+Field	5	ICC_PCR_EL1
+Field	4	ICC_HPPIR_EL1
+Field	3	ICC_HAPR_EL1
+Field	2	ICC_CR0_EL1
+Field	1	ICC_IDRn_EL1
+Field	0	ICC_APR_EL1
+EndSysreg
+
 Sysreg	ICH_HCR_EL2	3	4	12	11	0
 Res0	63:32
 Field	31:27	EOIcount
Signature · 1 line
2.48.0
author maintainer
#15 lore raw

PATCH v3 13/25 arm64/sysreg: Add ICH_HFGWTR_EL2

In reply to Lorenzo Pieralisi

Add ICH_HFGWTR_EL2 register description to sysreg.

Cc Will Deacon <[email protected]>
Cc Catalin Marinas <[email protected]>
Cc Marc Zyngier <[email protected]>
---
 arch/arm64/tools/sysreg | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
arch/arm64/tools/sysreg +15 -0
index 0c0e805481c84a14ae62d199466171d97d54ef90..1b519e35000be328acfe26d51e098059f9cf9ef2 100644
@@ -3601,6 +3601,21 @@ Field	1	ICC_IDRn_EL1
 Field	0	ICC_APR_EL1
 EndSysreg
 
+Sysreg	ICH_HFGWTR_EL2	3	4	12	9	6
+Res0	63:21
+Field	20	ICC_PPI_ACTIVERn_EL1
+Field	19	ICC_PPI_PRIORITYRn_EL1
+Field	18	ICC_PPI_PENDRn_EL1
+Field	17	ICC_PPI_ENABLERn_EL1
+Res0	16:7
+Field	6	ICC_ICSR_EL1
+Field	5	ICC_PCR_EL1
+Res0    4:3
+Field	2	ICC_CR0_EL1
+Res0	1
+Field	0	ICC_APR_EL1
+EndSysreg
+
 Sysreg	ICH_HCR_EL2	3	4	12	11	0
 Res0	63:32
 Field	31:27	EOIcount
Signature · 1 line
2.48.0
author maintainer
#16 lore raw

PATCH v3 14/25 arm64/sysreg: Add ICH_HFGITR_EL2

In reply to Lorenzo Pieralisi

Add ICH_HFGITR_EL2 register description to sysreg.

Cc Will Deacon <[email protected]>
Cc Catalin Marinas <[email protected]>
Cc Marc Zyngier <[email protected]>
---
 arch/arm64/tools/sysreg | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
arch/arm64/tools/sysreg +15 -0
index 1b519e35000be328acfe26d51e098059f9cf9ef2..5af0dea6e775ea680686dbe4bc836b5f5b69fbc7 100644
@@ -3616,6 +3616,21 @@ Res0	1
 Field	0	ICC_APR_EL1
 EndSysreg
 
+Sysreg	ICH_HFGITR_EL2	3	4	12	9	7
+Res0	63:11
+Field	10	GICRCDNMIA
+Field	9	GICRCDIA
+Field	8	GICCDDI
+Field	7	GICCDEOI
+Field	6	GICCDHM
+Field	5	GICCRDRCFG
+Field	4	GICCDPEND
+Field	3	GICCDAFF
+Field	2	GICCDPRI
+Field	1	GICCDDIS
+Field	0	GICCDEN
+EndSysreg
+
 Sysreg	ICH_HCR_EL2	3	4	12	11	0
 Res0	63:32
 Field	31:27	EOIcount
Signature · 1 line
2.48.0
author maintainer
#17 lore raw

PATCH v3 15/25 arm64: Disable GICv5 read/write/instruction traps

In reply to Lorenzo Pieralisi

GICv5 trap configuration registers value is UNKNOWN at reset.

Initialize GICv5 EL2 trap configuration registers to prevent trapping GICv5 instruction/register access upon entering the kernel.

Cc Will Deacon <[email protected]>
Cc Catalin Marinas <[email protected]>
Cc Marc Zyngier <[email protected]>
---
 arch/arm64/include/asm/el2_setup.h | 45 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)
arch/arm64/include/asm/el2_setup.h +45 -0
index ebceaae3c749b84395c9c5eccf0caf874697ad11..109b72b657d2fbb6d39e0446c10d1b62e0a780b3 100644
@@ -165,6 +165,50 @@
 .Lskip_gicv3_\@:
 .endm
 
+/* GICv5 system register access */
+.macro __init_el2_gicv5
+	mrs_s	x0, SYS_ID_AA64PFR2_EL1
+	ubfx	x0, x0, #ID_AA64PFR2_EL1_GCIE_SHIFT, #4
+	cbz	x0, .Lskip_gicv5_\@
+
+	mov	x0, #(ICH_HFGITR_EL2_GICRCDNMIA		| \
+		      ICH_HFGITR_EL2_GICRCDIA		| \
+		      ICH_HFGITR_EL2_GICCDDI		| \
+		      ICH_HFGITR_EL2_GICCDEOI		| \
+		      ICH_HFGITR_EL2_GICCDHM		| \
+		      ICH_HFGITR_EL2_GICCRDRCFG		| \
+		      ICH_HFGITR_EL2_GICCDPEND		| \
+		      ICH_HFGITR_EL2_GICCDAFF		| \
+		      ICH_HFGITR_EL2_GICCDPRI		| \
+		      ICH_HFGITR_EL2_GICCDDIS		| \
+		      ICH_HFGITR_EL2_GICCDEN)
+	msr_s	SYS_ICH_HFGITR_EL2, x0		// Disable instruction traps
+	mov_q	x0, (ICH_HFGRTR_EL2_ICC_PPI_ACTIVERn_EL1	| \
+		     ICH_HFGRTR_EL2_ICC_PPI_PRIORITYRn_EL1	| \
+		     ICH_HFGRTR_EL2_ICC_PPI_PENDRn_EL1		| \
+		     ICH_HFGRTR_EL2_ICC_PPI_ENABLERn_EL1	| \
+		     ICH_HFGRTR_EL2_ICC_PPI_HMRn_EL1		| \
+		     ICH_HFGRTR_EL2_ICC_IAFFIDR_EL1		| \
+		     ICH_HFGRTR_EL2_ICC_ICSR_EL1		| \
+		     ICH_HFGRTR_EL2_ICC_PCR_EL1			| \
+		     ICH_HFGRTR_EL2_ICC_HPPIR_EL1		| \
+		     ICH_HFGRTR_EL2_ICC_HAPR_EL1		| \
+		     ICH_HFGRTR_EL2_ICC_CR0_EL1			| \
+		     ICH_HFGRTR_EL2_ICC_IDRn_EL1		| \
+		     ICH_HFGRTR_EL2_ICC_APR_EL1)
+	msr_s	SYS_ICH_HFGRTR_EL2, x0		// Disable reg read traps
+	mov_q	x0, (ICH_HFGWTR_EL2_ICC_PPI_ACTIVERn_EL1	| \
+		     ICH_HFGWTR_EL2_ICC_PPI_PRIORITYRn_EL1	| \
+		     ICH_HFGWTR_EL2_ICC_PPI_PENDRn_EL1		| \
+		     ICH_HFGWTR_EL2_ICC_PPI_ENABLERn_EL1	| \
+		     ICH_HFGWTR_EL2_ICC_ICSR_EL1		| \
+		     ICH_HFGWTR_EL2_ICC_PCR_EL1			| \
+		     ICH_HFGWTR_EL2_ICC_CR0_EL1			| \
+		     ICH_HFGWTR_EL2_ICC_APR_EL1)
+	msr_s	SYS_ICH_HFGWTR_EL2, x0		// Disable reg write traps
+.Lskip_gicv5_\@:
+.endm
+
 .macro __init_el2_hstr
 	msr	hstr_el2, xzr			// Disable CP15 traps to EL2
 .endm
@@ -323,6 +367,7 @@
 	__init_el2_lor
 	__init_el2_stage2
 	__init_el2_gicv3
+	__init_el2_gicv5
 	__init_el2_hstr
 	__init_el2_mpam
 	__init_el2_nvhe_idregs
Signature · 1 line
2.48.0
author maintainer
#18 lore raw

PATCH v3 16/25 arm64: cpucaps: Rename GICv3 CPU interface capability

In reply to Lorenzo Pieralisi

In preparation for adding a GICv5 CPU interface capability, rework the existing GICv3 CPUIF capability - change its name and description so that the subsequent GICv5 CPUIF capability can be added with a more consistent naming on top.

---
 arch/arm64/kernel/cpufeature.c | 10 +++++-----
 arch/arm64/tools/cpucaps       |  2 +-
 drivers/irqchip/irq-gic.c      |  2 +-
 3 files changed, 7 insertions(+), 7 deletions(-)
arch/arm64/kernel/cpufeature.c +5 -5
index 9c4d6d552b25cb3a31d1fb267bd73d3f82513e69..cbb49de451f45fbee3100ea01e77b06352bd55ac 100644
@@ -2283,11 +2283,11 @@ static bool can_use_gic_priorities(const struct arm64_cpu_capabilities *entry,
 				   int scope)
 {
 	/*
-	 * ARM64_HAS_GIC_CPUIF_SYSREGS has a lower index, and is a boot CPU
+	 * ARM64_HAS_GICV3_CPUIF has a lower index, and is a boot CPU
 	 * feature, so will be detected earlier.
 	 */
-	BUILD_BUG_ON(ARM64_HAS_GIC_PRIO_MASKING <= ARM64_HAS_GIC_CPUIF_SYSREGS);
-	if (!cpus_have_cap(ARM64_HAS_GIC_CPUIF_SYSREGS))
+	BUILD_BUG_ON(ARM64_HAS_GIC_PRIO_MASKING <= ARM64_HAS_GICV3_CPUIF);
+	if (!cpus_have_cap(ARM64_HAS_GICV3_CPUIF))
 		return false;
 
 	return enable_pseudo_nmi;
@@ -2483,8 +2483,8 @@ static const struct arm64_cpu_capabilities arm64_features[] = {
 		.matches = has_always,
 	},
 	{
-		.desc = "GIC system register CPU interface",
-		.capability = ARM64_HAS_GIC_CPUIF_SYSREGS,
+		.desc = "GICv3 CPU interface",
+		.capability = ARM64_HAS_GICV3_CPUIF,
 		.type = ARM64_CPUCAP_STRICT_BOOT_CPU_FEATURE,
 		.matches = has_useable_gicv3_cpuif,
 		ARM64_CPUID_FIELDS(ID_AA64PFR0_EL1, GIC, IMP)
arch/arm64/tools/cpucaps +1 -1
index 772c1b008e437ed34cedb1c0f663c4dcea8f6759..860ec49cc0530885c138b7dc7f67d58cd69b2593 100644
@@ -34,7 +34,7 @@ HAS_GENERIC_AUTH
 HAS_GENERIC_AUTH_ARCH_QARMA3
 HAS_GENERIC_AUTH_ARCH_QARMA5
 HAS_GENERIC_AUTH_IMP_DEF
-HAS_GIC_CPUIF_SYSREGS
+HAS_GICV3_CPUIF
 HAS_GIC_PRIO_MASKING
 HAS_GIC_PRIO_RELAXED_SYNC
 HAS_HCR_NV1
drivers/irqchip/irq-gic.c +1 -1
index 6503573557fdf295bc543b16b64e3e7dd6841321..1269ab8eb726afbb80849fd062612861680cb4d1 100644
@@ -54,7 +54,7 @@
 
 static void gic_check_cpu_features(void)
 {
-	WARN_TAINT_ONCE(this_cpu_has_cap(ARM64_HAS_GIC_CPUIF_SYSREGS),
+	WARN_TAINT_ONCE(this_cpu_has_cap(ARM64_HAS_GICV3_CPUIF),
 			TAINT_CPU_OUT_OF_SPEC,
 			"GICv3 system registers enabled, broken firmware!\n");
 }
Signature · 1 line
2.48.0
author maintainer
#19 lore raw

PATCH v3 17/25 arm64: cpucaps: Add GICv5 CPU interface (GCIE) capability

In reply to Lorenzo Pieralisi

Implement the GCIE capability as a strict boot cpu capability to detect whether architectural GICv5 support is available in HW.

Plug it in with a naming consistent with the existing GICv3 CPU interface capability.

Cc Will Deacon <[email protected]>
Cc Catalin Marinas <[email protected]>
Cc Marc Zyngier <[email protected]>
---
 arch/arm64/kernel/cpufeature.c | 7 +++++++
 arch/arm64/tools/cpucaps       | 1 +
 2 files changed, 8 insertions(+)
arch/arm64/kernel/cpufeature.c +7 -0
index cbb49de451f45fbee3100ea01e77b06352bd55ac..4d5163a20ee0fb09380ea5f1f2d37afb7257edfb 100644
@@ -3041,6 +3041,13 @@ static const struct arm64_cpu_capabilities arm64_features[] = {
 		.matches = has_pmuv3,
 	},
 #endif
+	{
+		.desc = "GICv5 CPU interface",
+		.type = ARM64_CPUCAP_STRICT_BOOT_CPU_FEATURE,
+		.capability = ARM64_HAS_GICV5_CPUIF,
+		.matches = has_cpuid_feature,
+		ARM64_CPUID_FIELDS(ID_AA64PFR2_EL1, GCIE, IMP)
+	},
 	{},
 };
 
arch/arm64/tools/cpucaps +1 -0
index 860ec49cc0530885c138b7dc7f67d58cd69b2593..c36f4165e2bb460abde81baf453199f62dd265b0 100644
@@ -35,6 +35,7 @@ HAS_GENERIC_AUTH_ARCH_QARMA3
 HAS_GENERIC_AUTH_ARCH_QARMA5
 HAS_GENERIC_AUTH_IMP_DEF
 HAS_GICV3_CPUIF
+HAS_GICV5_CPUIF
 HAS_GIC_PRIO_MASKING
 HAS_GIC_PRIO_RELAXED_SYNC
 HAS_HCR_NV1
Signature · 1 line
2.48.0
author maintainer
#20 lore raw

PATCH v3 18/25 arm64: smp: Support non-SGIs for IPIs

In reply to Lorenzo Pieralisi

From: Marc Zyngier <[email protected]>

The arm64 arch has relied so far on GIC architectural software generated interrupt (SGIs) to handle IPIs. Those are per-cpu software generated interrupts.

arm64 architecture code that allocates the IPIs virtual IRQs and IRQ descriptors was written accordingly.

On GICv5 systems, IPIs are implemented using LPIs that are not per-cpu interrupts - they are just normal routable IRQs.

Add arch code to set-up IPIs on systems where they are handled using normal routable IRQs.

For those systems, force the IRQ affinity (and make it immutable) to the cpu a given IRQ was assigned to.

[[email protected]: fixed ipi/irq conversion, irq flags]
[lpieralisi: changed affinity set-up, log]
Cc Will Deacon <[email protected]>
Cc Catalin Marinas <[email protected]>
---
 arch/arm64/include/asm/smp.h |   7 ++-
 arch/arm64/kernel/smp.c      | 139 ++++++++++++++++++++++++++++++++-----------
 2 files changed, 111 insertions(+), 35 deletions(-)
arch/arm64/include/asm/smp.h +6 -1
index 2510eec026f7e3d6f0ecf1197c3a81b183ddd216..d6fd6efb66a673ae33825971e4aa07e791c02ee5 100644
@@ -53,7 +53,12 @@ extern void smp_init_cpus(void);
 /*
  * Register IPI interrupts with the arch SMP code
  */
-extern void set_smp_ipi_range(int ipi_base, int nr_ipi);
+extern void set_smp_ipi_range_percpu(int ipi_base, int nr_ipi, int ncpus);
+
+static inline void set_smp_ipi_range(int ipi_base, int n)
+{
+	set_smp_ipi_range_percpu(ipi_base, n, 0);
+}
 
 /*
  * Called from the secondary holding pen, this is the secondary CPU entry point.
arch/arm64/kernel/smp.c +105 -34

202 lines not on this page · raw message

Signature · 1 line
2.48.0
author maintainer
#21 lore raw

PATCH v3 19/25 arm64: Add support for GICv5 GSB barriers

In reply to Lorenzo Pieralisi

The GICv5 architecture introduces two barriers instructions (GSB SYS, GSB ACK) that are used to manage interrupt effects.

Rework macro used to emit the SB barrier instruction and implement the GSB barriers on top of it.

---
 arch/arm64/include/asm/barrier.h |  3 +++
 arch/arm64/include/asm/sysreg.h  | 10 +++++++---
 2 files changed, 10 insertions(+), 3 deletions(-)
arch/arm64/include/asm/barrier.h +3 -0
index 1ca947d5c93963d33fe8fb02d6037fc71bd9fd7a..f5801b0ba9e9e7e0433f16ffedf0ec7dfb3e358e 100644
@@ -44,6 +44,9 @@
 						 SB_BARRIER_INSN"nop\n",	\
 						 ARM64_HAS_SB))
 
+#define gsb_ack()	asm volatile(GSB_ACK_BARRIER_INSN : : : "memory")
+#define gsb_sys()	asm volatile(GSB_SYS_BARRIER_INSN : : : "memory")
+
 #ifdef CONFIG_ARM64_PSEUDO_NMI
 #define pmr_sync()						\
 	do {							\
arch/arm64/include/asm/sysreg.h +7 -3
index 2639d3633073de10f5040a7efff059021f847530..e7734f90bb723bfbd8be99f16dd6d6fdc7fa57e8 100644
@@ -112,10 +112,14 @@
 /* Register-based PAN access, for save/restore purposes */
 #define SYS_PSTATE_PAN			sys_reg(3, 0, 4, 2, 3)
 
-#define __SYS_BARRIER_INSN(CRm, op2, Rt) \
-	__emit_inst(0xd5000000 | sys_insn(0, 3, 3, (CRm), (op2)) | ((Rt) & 0x1f))
+#define __SYS_BARRIER_INSN(op0, op1, CRn, CRm, op2, Rt)		\
+	__emit_inst(0xd5000000				|	\
+	sys_insn((op0), (op1), (CRn), (CRm), (op2))	|	\
+	((Rt) & 0x1f))
 
-#define SB_BARRIER_INSN			__SYS_BARRIER_INSN(0, 7, 31)
+#define SB_BARRIER_INSN			__SYS_BARRIER_INSN(0, 3, 3, 0, 7, 31)
+#define GSB_SYS_BARRIER_INSN		__SYS_BARRIER_INSN(1, 0, 12, 0, 0, 31)
+#define GSB_ACK_BARRIER_INSN		__SYS_BARRIER_INSN(1, 0, 12, 0, 1, 31)
 
 #define SYS_DC_ISW			sys_insn(1, 0, 7, 6, 2)
 #define SYS_DC_IGSW			sys_insn(1, 0, 7, 6, 4)
Signature · 1 line
2.48.0
author maintainer
#22 lore raw

PATCH v3 20/25 irqchip/gic-v5: Add GICv5 PPI support

In reply to Lorenzo Pieralisi

The GICv5 CPU interface implements support for PE-Private Peripheral Interrupts (PPI), that are handled (enabled/prioritized/delivered) entirely within the CPU interface hardware.

To enable PPI interrupts, implement the baseline GICv5 host kernel driver infrastructure required to handle interrupts on a GICv5 system.

Add the exception handling code path and definitions for GICv5 instructions.

Add GICv5 PPI handling code as a specific IRQ domain to:

- Set-up PPI priority
- Manage PPI configuration and state
- Manage IRQ flow handler
- IRQs allocation/free
- Hook-up a PPI specific IRQchip to provide the relevant methods

PPI IRQ priority is chosen as the minimum allowed priority by the system design (after probing the number of priority bits implemented by the CPU interface).

---
 MAINTAINERS                        |   2 +
 arch/arm64/include/asm/sysreg.h    |  23 ++
 drivers/irqchip/Kconfig            |   5 +
 drivers/irqchip/Makefile           |   1 +
 drivers/irqchip/irq-gic-v5.c       | 454 +++++++++++++++++++++++++++++++++++++
 include/linux/irqchip/arm-gic-v5.h |  19 ++
 6 files changed, 504 insertions(+)
MAINTAINERS +2 -0
index 1902291c3cccc06d27c5f79123e67774cf9a0e43..49c377febad72e77dd6d480105c2b6bffa81f9a6 100644
@@ -1907,6 +1907,8 @@ M:	Marc Zyngier <[email protected]>
 L:	[email protected] (moderated for non-subscribers)
 S:	Maintained
 F:	Documentation/devicetree/bindings/interrupt-controller/arm,gic-v5*.yaml
+F:	drivers/irqchip/irq-gic-v5*.[ch]
+F:	include/linux/irqchip/arm-gic-v5.h
 
 ARM HDLCD DRM DRIVER
 M:	Liviu Dudau <[email protected]>
arch/arm64/include/asm/sysreg.h +23 -0
index e7734f90bb723bfbd8be99f16dd6d6fdc7fa57e8..4b48d00842c5750299f2983ecd72f19f2865c0e3 100644
@@ -1079,6 +1079,29 @@
 
 #define GCS_CAP(x)	((((unsigned long)x) & GCS_CAP_ADDR_MASK) | \
 					       GCS_CAP_VALID_TOKEN)
+/*
+ * Definitions for GICv5 instructions
+ */
+#define GICV5_OP_GIC_CDDI		sys_insn(1, 0, 12, 2, 0)
+#define GICV5_OP_GIC_CDEOI		sys_insn(1, 0, 12, 1, 7)
+#define GICV5_OP_GICR_CDIA		sys_insn(1, 0, 12, 3, 0)
+
+/* Shift and mask definitions for GIC CDDI */
+#define GICV5_GIC_CDDI_TYPE_MASK	GENMASK_ULL(31, 29)
+#define GICV5_GIC_CDDI_TYPE(r)		FIELD_GET(GICV5_GIC_CDDI_TYPE_MASK, r)
+#define GICV5_GIC_CDDI_ID_MASK		GENMASK_ULL(23, 0)
+#define GICV5_GIC_CDDI_ID(r)		FIELD_GET(GICV5_GIC_CDDI_ID_MASK, r)
+
+/* Shift and mask definitions for GICR CDIA */
+#define GICV5_GIC_CDIA_VALID_MASK	BIT_ULL(32)
+#define GICV5_GIC_CDIA_VALID(r)		FIELD_GET(GICV5_GIC_CDIA_VALID_MASK, r)
+#define GICV5_GIC_CDIA_TYPE_MASK	GENMASK_ULL(31, 29)
+#define GICV5_GIC_CDIA_TYPE(r)		FIELD_GET(GICV5_GIC_CDIA_TYPE_MASK, r)
+#define GICV5_GIC_CDIA_ID_MASK		GENMASK_ULL(23, 0)
+#define GICV5_GIC_CDIA_ID(r)		FIELD_GET(GICV5_GIC_CDIA_ID_MASK, r)
+
+#define gicr_insn(insn)			read_sysreg_s(GICV5_OP_GICR_##insn)
+#define gic_insn(v, insn)		write_sysreg_s(v, GICV5_OP_GIC_##insn)
 
 #define ARM64_FEATURE_FIELD_BITS	4
 
drivers/irqchip/Kconfig +5 -0
index cec05e443083b8982b3e72f4212d808a22883914..6b3d70924186bd8ca04294832409d1e379c9cbd4 100644
@@ -54,6 +54,11 @@ config ARM_GIC_V3_ITS_FSL_MC
 	depends on FSL_MC_BUS
 	default ARM_GIC_V3_ITS
 
+config ARM_GIC_V5
+	bool
+	select IRQ_DOMAIN_HIERARCHY
+	select GENERIC_IRQ_EFFECTIVE_AFF_MASK
+
 config ARM_NVIC
 	bool
 	select IRQ_DOMAIN_HIERARCHY
drivers/irqchip/Makefile +1 -0
index 365bcea9a61ff89e2cb41034125b3fc8cd494d81..3f8225bba5f0f9ce5dbb629b6d4782eacf85da44 100644
@@ -35,6 +35,7 @@ obj-$(CONFIG_ARM_GIC_V3)		+= irq-gic-v3.o irq-gic-v3-mbi.o irq-gic-common.o
 obj-$(CONFIG_ARM_GIC_V3_ITS)		+= irq-gic-v3-its.o irq-gic-v4.o irq-gic-v3-its-msi-parent.o
 obj-$(CONFIG_ARM_GIC_V3_ITS_FSL_MC)	+= irq-gic-v3-its-fsl-mc-msi.o
 obj-$(CONFIG_PARTITION_PERCPU)		+= irq-partition-percpu.o
+obj-$(CONFIG_ARM_GIC_V5)		+= irq-gic-v5.o
 obj-$(CONFIG_HISILICON_IRQ_MBIGEN)	+= irq-mbigen.o
 obj-$(CONFIG_ARM_NVIC)			+= irq-nvic.o
 obj-$(CONFIG_ARM_VIC)			+= irq-vic.o
drivers/irqchip/irq-gic-v5.c new file +454 -0

454 lines not on this page · raw message

include/linux/irqchip/arm-gic-v5.h new file +19 -0
new file mode 100644
index 0000000000000000000000000000000000000000..cc3da79e615b2b6ee27456e98c17061e4508030f
@@ -0,0 +1,19 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Copyright (C) 2025 ARM Limited, All Rights Reserved.
+ */
+#ifndef __LINUX_IRQCHIP_ARM_GIC_V5_H
+#define __LINUX_IRQCHIP_ARM_GIC_V5_H
+
+#include <asm/sysreg.h>
+
+#define GICV5_HWIRQ_ID			GENMASK(23, 0)
+#define GICV5_HWIRQ_TYPE		GENMASK(31, 29)
+#define GICV5_HWIRQ_INTID		GENMASK_ULL(31, 0)
+
+#define GICV5_HWIRQ_TYPE_PPI		UL(0x1)
+
+#define GICV5_PPI_HM_EDGE		UL(0x0)
+#define GICV5_PPI_HM_LEVEL		UL(0x1)
+
+#endif
Signature · 1 line
2.48.0
#23 lore raw

Re: [PATCH v3 20/25] irqchip/gic-v5: Add GICv5 PPI support

Review

Quoted 2 lines · Lorenzo Pieralisi
(quoted diff) +2 -0
+
+static u8 pri_bits = 5;

__ro_after_init ?

Quoted 1 line

+#define GICV5_IRQ_PRI_MASK 0x1f

Please put a new line before the #define and use a TAB between the symbol and the value.

drivers/irqchip/irq-gic-v5.c line 20

Quoted 2 lines
drivers/irqchip/irq-gic-v5.c new file +2 -0
+#define GICV5_IRQ_PRI_MI \
+		(GICV5_IRQ_PRI_MASK & GENMASK(4, 5 - pri_bits))

No line break required. You have 100 characters

Quoted 15 lines
drivers/irqchip/irq-gic-v5.c new file +15 -0
+#define READ_PPI_REG(irq, reg)							\
+	({									\
+		u64 __ppi_val;							\
+										\
+		if (irq < 64)							\
+			__ppi_val = read_sysreg_s(SYS_ICC_PPI_##reg##R0_EL1);	\
+		else								\
+			__ppi_val = read_sysreg_s(SYS_ICC_PPI_##reg##R1_EL1);	\
+		__ppi_val;							\
+	})
+
+#define WRITE_PPI_REG(set, irq, bit, reg)					\
+	do {									\
+		if (set) {							\
+			if (irq < 64)						\

drivers/irqchip/irq-gic-v5.c line 136

Quoted 10 lines
drivers/irqchip/irq-gic-v5.c new file +10 -0
+				write_sysreg_s(bit, SYS_ICC_PPI_S##reg##R0_EL1);\
+			else							\
+				write_sysreg_s(bit, SYS_ICC_PPI_S##reg##R1_EL1);\
+		} else {							\
+			if (irq < 64)						\
+				write_sysreg_s(bit, SYS_ICC_PPI_C##reg##R0_EL1);\
+			else							\
+				write_sysreg_s(bit, SYS_ICC_PPI_C##reg##R1_EL1);\
+		}								\
+	} while (0)

I'm not convinced that these need to be macros.

static __always_inline u64 read_ppi_sysreg_s(unsigned int irq, const unsigned int which)

{
        switch (which) {
        case PPI_HM:
        	return irq < 64 ? read_sysreg_s(SYS_ICC_PPI_HM_R0_EL1) :
                		  read_sysreg_s(SYS_ICC_PPI_HM_R1_EL1;
        case ....:

        default:
                BUILD_BUG_ON(1);
        }
}

static __always_inline void write_ppi_sysreg_s(unsigned int irq, bool set, const unsigned int which)

{
	u64 bit = BIT_ULL(irq % 64);

        switch (which) {  
        case PPI_HM:
        	if (irq < 64)
                	write_sysreg_s(bit, SYS_ICC_PPI_HM_R0_EL1);
                else
                	write_sysreg_s(bit, SYS_ICC_PPI_HM_R1_EL1;
                return;
        case ....:

        default:
                BUILD_BUG_ON(1);
        }
}

Or something like that.

Quoted 4 lines
drivers/irqchip/irq-gic-v5.c new file +4 -0
+static int gicv5_ppi_set_type(struct irq_data *d, unsigned int type)
+{
+	/*
+	 * The PPI trigger mode is not configurable at runtime,

drivers/irqchip/irq-gic-v5.c line 151

Quoted 10 lines
drivers/irqchip/irq-gic-v5.c new file +10 -0
+	 * therefore this function simply confirms that the `type`
+	 * parameter matches what is present.
+	 */
+	u64 hmr = READ_PPI_REG(d->hwirq, HM);
+
+	switch (type) {
+	case IRQ_TYPE_LEVEL_HIGH:
+	case IRQ_TYPE_LEVEL_LOW:
+		if (((hmr >> (d->hwirq % 64)) & 0x1) != GICV5_PPI_HM_LEVEL)
+			return -EINVAL;

Blink!

How does this test distinguish between LEVEL_LOW and LEVEL_HIGH? It only tests for level, no? So the test is interesting at best ...

Secondly this comparison is confusing at best especially given that you mask with a hex constant (0x1) first.

     		if (hmr & BIT_UL(d->hwirq % 64))
                	return -EINVAL;

Aside of that why do you have a set_type() function if there is no way to set the type?

Quoted 4 lines
drivers/irqchip/irq-gic-v5.c new file +4 -0
+
+static int gicv5_ppi_irq_get_irqchip_state(struct irq_data *d,
+					   enum irqchip_irq_state which,
+					   bool *val)

drivers/irqchip/irq-gic-v5.c line 178

Quoted 10 lines
drivers/irqchip/irq-gic-v5.c new file +10 -0
+{
+	u64 pendr, activer, hwirq_id_bit = BIT_ULL(d->hwirq % 64);
+
+	switch (which) {
+	case IRQCHIP_STATE_PENDING:
+		pendr = READ_PPI_REG(d->hwirq, SPEND);
+
+		*val = !!(pendr & hwirq_id_bit);
+
+		return 0;
		*val = !!(read_ppi_reg(d->hwirq, PPI_SPEND) & bit);
                return 0;

would take up less space and be readable.

drivers/irqchip/irq-gic-v5.c line 189

Quoted 11 lines
drivers/irqchip/irq-gic-v5.c new file +11 -0
+	case IRQCHIP_STATE_ACTIVE:
+		activer = READ_PPI_REG(d->hwirq, SACTIVE);
+
+		*val = !!(activer & hwirq_id_bit);
+
+		return 0;
+	default:
+		pr_debug("Unexpected PPI irqchip state\n");
+	}
+
+	return -EINVAL;

Move the return into the default case.

drivers/irqchip/irq-gic-v5.c line 398

Quoted 6 lines
drivers/irqchip/irq-gic-v5.c new file +6 -0
+static int __init gicv5_init_domains(struct fwnode_handle *handle)
+{
+	struct irq_domain *d;
+
+	d = irq_domain_create_linear(handle, PPI_NR, &gicv5_irq_ppi_domain_ops,
+				     NULL);

Please use the full 100 charactes all over the place.

drivers/irqchip/irq-gic-v5.c line 405

Quoted 7 lines
drivers/irqchip/irq-gic-v5.c new file +7 -0
+	if (!d)
+		return -ENOMEM;
+
+	irq_domain_update_bus_token(d, DOMAIN_BUS_WIRED);
+	gicv5_global_data.ppi_domain = d;
+
+	gicv5_global_data.fwnode = handle;

The random choices of seperating code with new lines are really amazing.

drivers/irqchip/irq-gic-v5.c line 432

Quoted 5 lines
drivers/irqchip/irq-gic-v5.c new file +5 -0
+static int __init gicv5_of_init(struct device_node *node, struct device_node *parent)
+{
+	int ret;
+
+	ret = gicv5_init_domains(&node->fwnode);
        int ret = ....;

Review

Quoted 1 line
(quoted diff) +1 -0
+	if (ret)

Thanks,

tglx

author maintainer
#24 lore raw

Re: [PATCH v3 20/25] irqchip/gic-v5: Add GICv5 PPI support

Quoted 5 lines · Thomas Gleixner

Review

Quoted 2 lines · Lorenzo Pieralisi
(quoted diff) +2 -0
+
+static u8 pri_bits = 5;

__ro_after_init ?

Ok.

Quoted 5 lines
Quoted 2 lines

+#define GICV5_IRQ_PRI_MASK 0x1f

Please put a new line before the #define and use a TAB between the symbol and the value.

Ok, sorry.

Quoted 4 lines

drivers/irqchip/irq-gic-v5.c line 20

Quoted 2 lines
drivers/irqchip/irq-gic-v5.c new file +2 -0
+#define GICV5_IRQ_PRI_MI \
+		(GICV5_IRQ_PRI_MASK & GENMASK(4, 5 - pri_bits))

No line break required. You have 100 characters

Right.

Quoted 59 lines
Quoted 15 lines
drivers/irqchip/irq-gic-v5.c new file +15 -0
+#define READ_PPI_REG(irq, reg)							\
+	({									\
+		u64 __ppi_val;							\
+										\
+		if (irq < 64)							\
+			__ppi_val = read_sysreg_s(SYS_ICC_PPI_##reg##R0_EL1);	\
+		else								\
+			__ppi_val = read_sysreg_s(SYS_ICC_PPI_##reg##R1_EL1);	\
+		__ppi_val;							\
+	})
+
+#define WRITE_PPI_REG(set, irq, bit, reg)					\
+	do {									\
+		if (set) {							\
+			if (irq < 64)						\

drivers/irqchip/irq-gic-v5.c line 136

Quoted 10 lines
drivers/irqchip/irq-gic-v5.c new file +10 -0
+				write_sysreg_s(bit, SYS_ICC_PPI_S##reg##R0_EL1);\
+			else							\
+				write_sysreg_s(bit, SYS_ICC_PPI_S##reg##R1_EL1);\
+		} else {							\
+			if (irq < 64)						\
+				write_sysreg_s(bit, SYS_ICC_PPI_C##reg##R0_EL1);\
+			else							\
+				write_sysreg_s(bit, SYS_ICC_PPI_C##reg##R1_EL1);\
+		}								\
+	} while (0)

I'm not convinced that these need to be macros.

static __always_inline u64 read_ppi_sysreg_s(unsigned int irq, const unsigned int which)

{
        switch (which) {
        case PPI_HM:
        	return irq < 64 ? read_sysreg_s(SYS_ICC_PPI_HM_R0_EL1) :
                		  read_sysreg_s(SYS_ICC_PPI_HM_R1_EL1;
        case ....:

        default:
                BUILD_BUG_ON(1);
        }
}

static __always_inline void write_ppi_sysreg_s(unsigned int irq, bool set, const unsigned int which)

{
	u64 bit = BIT_ULL(irq % 64);

        switch (which) {  
        case PPI_HM:
        	if (irq < 64)
                	write_sysreg_s(bit, SYS_ICC_PPI_HM_R0_EL1);
                else
                	write_sysreg_s(bit, SYS_ICC_PPI_HM_R1_EL1;
                return;
        case ....:

        default:
                BUILD_BUG_ON(1);
        }
}
Quoted 1 line

Or something like that.

Done.

Quoted 17 lines
Quoted 4 lines
drivers/irqchip/irq-gic-v5.c new file +4 -0
+static int gicv5_ppi_set_type(struct irq_data *d, unsigned int type)
+{
+	/*
+	 * The PPI trigger mode is not configurable at runtime,

drivers/irqchip/irq-gic-v5.c line 151

Quoted 10 lines
drivers/irqchip/irq-gic-v5.c new file +10 -0
+	 * therefore this function simply confirms that the `type`
+	 * parameter matches what is present.
+	 */
+	u64 hmr = READ_PPI_REG(d->hwirq, HM);
+
+	switch (type) {
+	case IRQ_TYPE_LEVEL_HIGH:
+	case IRQ_TYPE_LEVEL_LOW:
+		if (((hmr >> (d->hwirq % 64)) & 0x1) != GICV5_PPI_HM_LEVEL)
+			return -EINVAL;

Blink!

Quoted 2 lines

How does this test distinguish between LEVEL_LOW and LEVEL_HIGH? It only tests for level, no? So the test is interesting at best ...

There is no HIGH/LOW concept for level interrupts in the architecture, level interrupts are asserted/de-asserted. On top of that, as you already noticed, for PPIs this can't even be changed so this function is utterly pointless.

Quoted 8 lines

Secondly this comparison is confusing at best especially given that you mask with a hex constant (0x1) first.

     		if (hmr & BIT_UL(d->hwirq % 64))
                	return -EINVAL;

Aside of that why do you have a set_type() function if there is no way to set the type?

Yes, that's useless, the kernel is not there to validate firmware, I will remove it.

Quoted 18 lines
Quoted 4 lines
drivers/irqchip/irq-gic-v5.c new file +4 -0
+
+static int gicv5_ppi_irq_get_irqchip_state(struct irq_data *d,
+					   enum irqchip_irq_state which,
+					   bool *val)

drivers/irqchip/irq-gic-v5.c line 178

Quoted 10 lines
drivers/irqchip/irq-gic-v5.c new file +10 -0
+{
+	u64 pendr, activer, hwirq_id_bit = BIT_ULL(d->hwirq % 64);
+
+	switch (which) {
+	case IRQCHIP_STATE_PENDING:
+		pendr = READ_PPI_REG(d->hwirq, SPEND);
+
+		*val = !!(pendr & hwirq_id_bit);
+
+		return 0;
		*val = !!(read_ppi_reg(d->hwirq, PPI_SPEND) & bit);
                return 0;
Quoted 1 line

would take up less space and be readable.

Ok done.

Quoted 5 lines
Quoted 5 lines
drivers/irqchip/irq-gic-v5.c new file +5 -0
+	case IRQCHIP_STATE_ACTIVE:
+		activer = READ_PPI_REG(d->hwirq, SACTIVE);
+
+		*val = !!(activer & hwirq_id_bit);
+
Quoted 8 lines

drivers/irqchip/irq-gic-v5.c line 189

Quoted 6 lines
drivers/irqchip/irq-gic-v5.c new file +6 -0
+		return 0;
+	default:
+		pr_debug("Unexpected PPI irqchip state\n");
+	}
+
+	return -EINVAL;

Move the return into the default case.

Ok.

Quoted 8 lines

drivers/irqchip/irq-gic-v5.c line 398

Quoted 6 lines
drivers/irqchip/irq-gic-v5.c new file +6 -0
+static int __init gicv5_init_domains(struct fwnode_handle *handle)
+{
+	struct irq_domain *d;
+
+	d = irq_domain_create_linear(handle, PPI_NR, &gicv5_irq_ppi_domain_ops,
+				     NULL);

Please use the full 100 charactes all over the place.

Ok.

Quoted 10 lines

drivers/irqchip/irq-gic-v5.c line 405

Quoted 7 lines
drivers/irqchip/irq-gic-v5.c new file +7 -0
+	if (!d)
+		return -ENOMEM;
+
+	irq_domain_update_bus_token(d, DOMAIN_BUS_WIRED);
+	gicv5_global_data.ppi_domain = d;
+
+	gicv5_global_data.fwnode = handle;

The random choices of seperating code with new lines are really amazing.

I separated code that initializes the domain from one that initialises fwnode - it made sense to *me*, I don't know what makes sense to others unless there are rules (or a script/bot reformatting the code for a given subsytem) that one can follow I am afraid.

Quoted 7 lines

drivers/irqchip/irq-gic-v5.c line 432

Quoted 5 lines
drivers/irqchip/irq-gic-v5.c new file +5 -0
+static int __init gicv5_of_init(struct device_node *node, struct device_node *parent)
+{
+	int ret;
+
+	ret = gicv5_init_domains(&node->fwnode);
        int ret = ....;

Ok.

Quoted 5 lines

Review

Quoted 1 line
(quoted diff) +1 -0
+	if (ret)

Thanks,

tglx

Thanks for reviewing.

Lorenzo

maintainer
#25 lore raw

Re: [PATCH v3 20/25] irqchip/gic-v5: Add GICv5 PPI support

In reply to Thomas Gleixner
Quoted 3 lines · Thomas Gleixner

How does this test distinguish between LEVEL_LOW and LEVEL_HIGH? It only tests for level, no? So the test is interesting at best ...

There is no distinction between HIGH and LOW, RISING and FALLING, in any revision of the GIC architecture.

	M.
Signature · 1 line
Without deviation from the norm, progress is not possible.
#26 lore raw

Re: [PATCH v3 20/25] irqchip/gic-v5: Add GICv5 PPI support

Quoted 8 lines · Marc Zyngier
Quoted 3 lines · Thomas Gleixner

How does this test distinguish between LEVEL_LOW and LEVEL_HIGH? It only tests for level, no? So the test is interesting at best ...

There is no distinction between HIGH and LOW, RISING and FALLING, in any revision of the GIC architecture.

Then pretending that there is a set_type() functionality is pretty daft

maintainer
#27 lore raw

Re: [PATCH v3 20/25] irqchip/gic-v5: Add GICv5 PPI support

Quoted 5 lines · Thomas Gleixner
Quoted 3 lines · Marc Zyngier
Quoted 1 line · Thomas Gleixner
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

How does this test distinguish between LEVEL_LOW and LEVEL_HIGH? It only tests for level, no? So the test is interesting at best ...

There is no distinction between HIGH and LOW, RISING and FALLING, in any revision of the GIC architecture.

Then pretending that there is a set_type() functionality is pretty daft

You still need to distinguish between level and edge when this is programmable (which is the case for a subset of the PPIs).

	M.
Signature · 1 line
Without deviation from the norm, progress is not possible.
#28 lore raw

Re: [PATCH v3 20/25] irqchip/gic-v5: Add GICv5 PPI support

Quoted 10 lines · Marc Zyngier
Quoted 8 lines · Thomas Gleixner
Quoted 6 lines · Marc Zyngier
Quoted 3 lines · Thomas Gleixner

How does this test distinguish between LEVEL_LOW and LEVEL_HIGH? It only tests for level, no? So the test is interesting at best ...

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

There is no distinction between HIGH and LOW, RISING and FALLING, in any revision of the GIC architecture.

Then pretending that there is a set_type() functionality is pretty daft

You still need to distinguish between level and edge when this is programmable (which is the case for a subset of the PPIs).

Fair enough, but can we please add a comment to this function which explains this oddity.

Thanks,

tglx

author maintainer
#29 lore raw

Re: [PATCH v3 20/25] irqchip/gic-v5: Add GICv5 PPI support

Quoted 14 lines · Thomas Gleixner
Quoted 13 lines · Marc Zyngier
Quoted 11 lines · Thomas Gleixner
Quoted 8 lines · Marc Zyngier
Quoted 3 lines · Thomas Gleixner

How does this test distinguish between LEVEL_LOW and LEVEL_HIGH? It only tests for level, no? So the test is interesting at best ...

There is no distinction between HIGH and LOW, RISING and FALLING, in any revision of the GIC architecture.

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

Then pretending that there is a set_type() functionality is pretty daft

You still need to distinguish between level and edge when this is programmable (which is the case for a subset of the PPIs).

Fair enough, but can we please add a comment to this function which explains this oddity.

GICv5 PPIs handling mode is fixed (ie ICC_PPI_HMR<n>_EL1 is RO), can't be programmed, I removed the irq_set_type() function (for the PPI irqchip).

Lorenzo

author maintainer
#30 lore raw

Re: [PATCH v3 20/25] irqchip/gic-v5: Add GICv5 PPI support

In reply to Thomas Gleixner
Quoted 14 lines · Thomas Gleixner
Quoted 13 lines · Marc Zyngier
Quoted 11 lines · Thomas Gleixner
Quoted 8 lines · Marc Zyngier
Quoted 3 lines · Thomas Gleixner

How does this test distinguish between LEVEL_LOW and LEVEL_HIGH? It only tests for level, no? So the test is interesting at best ...

There is no distinction between HIGH and LOW, RISING and FALLING, in any revision of the GIC architecture.

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

Then pretending that there is a set_type() functionality is pretty daft

You still need to distinguish between level and edge when this is programmable (which is the case for a subset of the PPIs).

Fair enough, but can we please add a comment to this function which explains this oddity.

Getting back to this, I would need your/Marc's input on this.

I think it is fair to remove the irq_set_type() irqchip callback for GICv5 PPIs because there is nothing to set, as I said handling mode for these IRQs is fixed. I don't think this can cause any trouble (IIUC a value within the IRQF_TRIGGER_MASK should be set on requesting an IRQ to "force" the trigger to be programmed and even then core code would not fail if the irq_set_type() irqchip callback is not implemented).

I am thinking about *existing* drivers that request GICv3 PPIs with values in IRQF_TRIGGER_MASK set (are there any ? Don't think so but you know better than I do), when we switch over to GICv5 we would have no irq_set_type() callback for PPIs but I think we are still fine, not implementing irqchip.irq_set_type() is correct IMO.

On the other hand, given that on GICv5 PPI handling mode is fixed, do you think that in the ppi_irq_domain_ops.translate() callback, I should check the type the firmware provided and fail the translation if it does not match the HW hardcoded value ?

Obviously if firmware exposes the wrong type that's a firmware bug but I was wondering whether it is better to fail the firmware-to-Linux IRQ translation if the firmware provided type is wrong rather than carry on pretending that the type is correct (I was abusing the irq_set_type() callback to do just that - namely, check that the type provided by firmware matches HW but I think that's the wrong place to put it).

Thanks !
Lorenzo

maintainer
#31 lore raw

Re: [PATCH v3 20/25] irqchip/gic-v5: Add GICv5 PPI support

Quoted 34 lines · Lorenzo Pieralisi
Quoted 14 lines · Thomas Gleixner
Quoted 13 lines · Marc Zyngier
Quoted 11 lines · Thomas Gleixner
Quoted 8 lines · Marc Zyngier
Quoted 3 lines · Thomas Gleixner

How does this test distinguish between LEVEL_LOW and LEVEL_HIGH? It only tests for level, no? So the test is interesting at best ...

There is no distinction between HIGH and LOW, RISING and FALLING, in any revision of the GIC architecture.

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

Then pretending that there is a set_type() functionality is pretty daft

You still need to distinguish between level and edge when this is programmable (which is the case for a subset of the PPIs).

Fair enough, but can we please add a comment to this function which explains this oddity.

Getting back to this, I would need your/Marc's input on this.

I think it is fair to remove the irq_set_type() irqchip callback for GICv5 PPIs because there is nothing to set, as I said handling mode for these IRQs is fixed. I don't think this can cause any trouble (IIUC a value within the IRQF_TRIGGER_MASK should be set on requesting an IRQ to "force" the trigger to be programmed and even then core code would not fail if the irq_set_type() irqchip callback is not implemented).

Quoted 5 lines

I am thinking about *existing* drivers that request GICv3 PPIs with values in IRQF_TRIGGER_MASK set (are there any ? Don't think so but you know better than I do), when we switch over to GICv5 we would have no irq_set_type() callback for PPIs but I think we are still fine, not implementing irqchip.irq_set_type() is correct IMO.

Nobody seems to use a hardcoded trigger (well, there is one exception, but that's to paper over a firmware bug).

Quoted 4 lines

On the other hand, given that on GICv5 PPI handling mode is fixed, do you think that in the ppi_irq_domain_ops.translate() callback, I should check the type the firmware provided and fail the translation if it does not match the HW hardcoded value ?

Why? The fact that the firmware is wrong doesn't change the hardware integration. It just indicates that whoever wrote the firmware didn't read the documentation.

Even more, I wonder what the benefit of having that information in the firmware tables if the only thing that matters in the immutable HW view. Yes, having it in the DT/ACPI simplifies the job of the kernel (only one format to parse). But it is overall useless information.

Quoted 6 lines

Obviously if firmware exposes the wrong type that's a firmware bug but I was wondering whether it is better to fail the firmware-to-Linux IRQ translation if the firmware provided type is wrong rather than carry on pretending that the type is correct (I was abusing the irq_set_type() callback to do just that - namely, check that the type provided by firmware matches HW but I think that's the wrong place to put it).

I don't think there is anything to do. Worse case, you spit a pr_warn_once() and carry on.

Thanks,

	M.
Signature · 1 line
Without deviation from the norm, progress is not possible.
author maintainer
#32 lore raw

Re: [PATCH v3 20/25] irqchip/gic-v5: Add GICv5 PPI support

Quoted 36 lines · Marc Zyngier
Quoted 34 lines · Lorenzo Pieralisi
Quoted 14 lines · Thomas Gleixner
Quoted 13 lines · Marc Zyngier
Quoted 11 lines · Thomas Gleixner
Quoted 8 lines · Marc Zyngier
Quoted 3 lines · Thomas Gleixner

How does this test distinguish between LEVEL_LOW and LEVEL_HIGH? It only tests for level, no? So the test is interesting at best ...

There is no distinction between HIGH and LOW, RISING and FALLING, in any revision of the GIC architecture.

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

Then pretending that there is a set_type() functionality is pretty daft

You still need to distinguish between level and edge when this is programmable (which is the case for a subset of the PPIs).

Fair enough, but can we please add a comment to this function which explains this oddity.

Getting back to this, I would need your/Marc's input on this.

I think it is fair to remove the irq_set_type() irqchip callback for GICv5 PPIs because there is nothing to set, as I said handling mode for these IRQs is fixed. I don't think this can cause any trouble (IIUC a value within the IRQF_TRIGGER_MASK should be set on requesting an IRQ to "force" the trigger to be programmed and even then core code would not fail if the irq_set_type() irqchip callback is not implemented).

Quoted 8 lines
Quoted 5 lines

I am thinking about *existing* drivers that request GICv3 PPIs with values in IRQF_TRIGGER_MASK set (are there any ? Don't think so but you know better than I do), when we switch over to GICv5 we would have no irq_set_type() callback for PPIs but I think we are still fine, not implementing irqchip.irq_set_type() is correct IMO.

Nobody seems to use a hardcoded trigger (well, there is one exception, but that's to paper over a firmware bug).

That's what I get if I remove the PPI irq_set_type() callback (just one timer, removed others because they add nothing) and enable debug for kernel/irq/manage.c (+additional printout):

genirq: No set_type function for IRQ 70 (GICv5-PPI)

  __irq_set_trigger+0x13c/0x180
  __setup_irq+0x3d8/0x7c0
  __request_percpu_irq+0xbc/0x114
  arch_timer_register+0x84/0x140
  arch_timer_of_init+0x180/0x1d0
  timer_probe+0x74/0x124
  time_init+0x18/0x58
  start_kernel+0x198/0x384
  __primary_switched+0x88/0x90

arch_timer: check_ppi_trigger irq 70 flags 8
genirq: enable_percpu_irq irq 70 type 8
genirq: No set_type function for IRQ 70 (GICv5-PPI)

  __irq_set_trigger+0x13c/0x180
  enable_percpu_irq+0x100/0x140
  arch_timer_starting_cpu+0x54/0xb8
  cpuhp_issue_call+0x254/0x3a8
  __cpuhp_setup_state_cpuslocked+0x208/0x2c8
  __cpuhp_setup_state+0x50/0x74
  arch_timer_register+0xc4/0x140
  arch_timer_of_init+0x180/0x1d0
  timer_probe+0x74/0x124
  time_init+0x18/0x58
  start_kernel+0x198/0x384
  __primary_switched+0x88/0x90

I noticed that, if the irq_set_type() function is not implemented, we don't execute (in __irq_set_trigger()):

irq_settings_set_level(desc);
irqd_set(&desc->irq_data, IRQD_LEVEL);

which in turn means that irqd_is_level_type(&desc->irq_data) is false for PPIs (ie arch timers, despite being level interrupts).

An immediate side effect is that they show as edge in:

/proc/interrupts

but that's just what I could notice.

Should I set them myself in PPI translate/alloc functions ?

Removing the irq_set_type() for PPIs does not seem so innocuous, it is a bit complex to check all ramifications, please let me know if you spot something I have missed.

Quoted 5 lines
Quoted 4 lines

On the other hand, given that on GICv5 PPI handling mode is fixed, do you think that in the ppi_irq_domain_ops.translate() callback, I should check the type the firmware provided and fail the translation if it does not match the HW hardcoded value ?

Quoted 8 lines

Why? The fact that the firmware is wrong doesn't change the hardware integration. It just indicates that whoever wrote the firmware didn't read the documentation.

Even more, I wonder what the benefit of having that information in the firmware tables if the only thing that matters in the immutable HW view. Yes, having it in the DT/ACPI simplifies the job of the kernel (only one format to parse). But it is overall useless information.

Yes, that I agree but it would force firmware bindings to special case PPIs to remove the type (#interrupt-cells and co.).

From what I read I understand I must ignore the PPI type provided by firmware.

Quoted 9 lines
Quoted 6 lines

Obviously if firmware exposes the wrong type that's a firmware bug but I was wondering whether it is better to fail the firmware-to-Linux IRQ translation if the firmware provided type is wrong rather than carry on pretending that the type is correct (I was abusing the irq_set_type() callback to do just that - namely, check that the type provided by firmware matches HW but I think that's the wrong place to put it).

I don't think there is anything to do. Worse case, you spit a pr_warn_once() and carry on.

Thanks,
Lorenzo

author maintainer
#33 lore raw

Re: [PATCH v3 20/25] irqchip/gic-v5: Add GICv5 PPI support

On Thu, May 08, 2025 at 12:44:45PM +0200, Lorenzo Pieralisi wrote:

[...]

Quoted 5 lines

I noticed that, if the irq_set_type() function is not implemented, we don't execute (in __irq_set_trigger()):

irq_settings_set_level(desc);
irqd_set(&desc->irq_data, IRQD_LEVEL);

I don't get why the settings above are written only if the irqchip has an irq_set_type() method, maybe they should be updated in irqdomain code (?) where:

irqd_set_trigger_type()

is executed after creating the fwspec mapping ?

Is it possible we never noticed because we have always had irqchips that do implement irq_set_type() ?

Again, I don't know the history behind the IRQD_LEVEL flag so it is just a question, I'd need to get this clarified though please if I remove the PPI irq_set_type() callback.

Thanks,
Lorenzo

Quoted 47 lines

which in turn means that irqd_is_level_type(&desc->irq_data) is false for PPIs (ie arch timers, despite being level interrupts).

An immediate side effect is that they show as edge in:

/proc/interrupts

but that's just what I could notice.

Should I set them myself in PPI translate/alloc functions ?

Removing the irq_set_type() for PPIs does not seem so innocuous, it is a bit complex to check all ramifications, please let me know if you spot something I have missed.

Quoted 5 lines
Quoted 4 lines

On the other hand, given that on GICv5 PPI handling mode is fixed, do you think that in the ppi_irq_domain_ops.translate() callback, I should check the type the firmware provided and fail the translation if it does not match the HW hardcoded value ?

Quoted 8 lines

Why? The fact that the firmware is wrong doesn't change the hardware integration. It just indicates that whoever wrote the firmware didn't read the documentation.

Even more, I wonder what the benefit of having that information in the firmware tables if the only thing that matters in the immutable HW view. Yes, having it in the DT/ACPI simplifies the job of the kernel (only one format to parse). But it is overall useless information.

Yes, that I agree but it would force firmware bindings to special case PPIs to remove the type (#interrupt-cells and co.).

From what I read I understand I must ignore the PPI type provided by firmware.

Quoted 9 lines
Quoted 6 lines

Obviously if firmware exposes the wrong type that's a firmware bug but I was wondering whether it is better to fail the firmware-to-Linux IRQ translation if the firmware provided type is wrong rather than carry on pretending that the type is correct (I was abusing the irq_set_type() callback to do just that - namely, check that the type provided by firmware matches HW but I think that's the wrong place to put it).

I don't think there is anything to do. Worse case, you spit a pr_warn_once() and carry on.

Thanks,
Lorenzo

author maintainer
#34 lore raw

Re: [PATCH v3 20/25] irqchip/gic-v5: Add GICv5 PPI support

Quoted 16 lines · Lorenzo Pieralisi

On Thu, May 08, 2025 at 12:44:45PM +0200, Lorenzo Pieralisi wrote:

[...]

Quoted 5 lines

I noticed that, if the irq_set_type() function is not implemented, we don't execute (in __irq_set_trigger()):

irq_settings_set_level(desc);
irqd_set(&desc->irq_data, IRQD_LEVEL);

I don't get why the settings above are written only if the irqchip has an irq_set_type() method, maybe they should be updated in irqdomain code (?) where:

irqd_set_trigger_type()

Quoted 8 lines

is executed after creating the fwspec mapping ?

Is it possible we never noticed because we have always had irqchips that do implement irq_set_type() ?

Again, I don't know the history behind the IRQD_LEVEL flag so it is just a question, I'd need to get this clarified though please if I remove the PPI irq_set_type() callback.

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/powerpc/platforms/52xx/mpc52xx_pic.c?h=v6.15-rc5#n218

There are other examples in powerpc, this does not look right to me.

Lorenzo

Quoted 50 lines

Thanks,
Lorenzo

Quoted 47 lines

which in turn means that irqd_is_level_type(&desc->irq_data) is false for PPIs (ie arch timers, despite being level interrupts).

An immediate side effect is that they show as edge in:

/proc/interrupts

but that's just what I could notice.

Should I set them myself in PPI translate/alloc functions ?

Removing the irq_set_type() for PPIs does not seem so innocuous, it is a bit complex to check all ramifications, please let me know if you spot something I have missed.

Quoted 5 lines
Quoted 4 lines

On the other hand, given that on GICv5 PPI handling mode is fixed, do you think that in the ppi_irq_domain_ops.translate() callback, I should check the type the firmware provided and fail the translation if it does not match the HW hardcoded value ?

Quoted 8 lines

Why? The fact that the firmware is wrong doesn't change the hardware integration. It just indicates that whoever wrote the firmware didn't read the documentation.

Even more, I wonder what the benefit of having that information in the firmware tables if the only thing that matters in the immutable HW view. Yes, having it in the DT/ACPI simplifies the job of the kernel (only one format to parse). But it is overall useless information.

Yes, that I agree but it would force firmware bindings to special case PPIs to remove the type (#interrupt-cells and co.).

From what I read I understand I must ignore the PPI type provided by firmware.

Quoted 9 lines
Quoted 6 lines

Obviously if firmware exposes the wrong type that's a firmware bug but I was wondering whether it is better to fail the firmware-to-Linux IRQ translation if the firmware provided type is wrong rather than carry on pretending that the type is correct (I was abusing the irq_set_type() callback to do just that - namely, check that the type provided by firmware matches HW but I think that's the wrong place to put it).

I don't think there is anything to do. Worse case, you spit a pr_warn_once() and carry on.

Thanks,
Lorenzo

maintainer
#35 lore raw

Re: [PATCH v3 20/25] irqchip/gic-v5: Add GICv5 PPI support

Quoted 23 lines · Lorenzo Pieralisi
Quoted 21 lines · Lorenzo Pieralisi

On Thu, May 08, 2025 at 12:44:45PM +0200, Lorenzo Pieralisi wrote:

[...]

Quoted 5 lines

I noticed that, if the irq_set_type() function is not implemented, we don't execute (in __irq_set_trigger()):

irq_settings_set_level(desc);
irqd_set(&desc->irq_data, IRQD_LEVEL);

I don't get why the settings above are written only if the irqchip has an irq_set_type() method, maybe they should be updated in irqdomain code (?) where:

irqd_set_trigger_type()

is executed after creating the fwspec mapping ?

Is it possible we never noticed because we have always had irqchips that do implement irq_set_type() ?

Quoted 7 lines
Quoted 3 lines

Again, I don't know the history behind the IRQD_LEVEL flag so it is just a question, I'd need to get this clarified though please if I remove the PPI irq_set_type() callback.

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/powerpc/platforms/52xx/mpc52xx_pic.c?h=v6.15-rc5#n218

There are other examples in powerpc, this does not look right to me.

I don't see what's wrong with this, given that PPC is about 15 years behind the curve when it comes to interrupt management. Better than Sparc or Alpha, though. So they do whatever was possible at the time this code was written.

It doesn't mean that you need to align with the worse we have in the tree!

	M.
Signature · 1 line
Without deviation from the norm, progress is not possible.
maintainer
#36 lore raw

Re: [PATCH v3 20/25] irqchip/gic-v5: Add GICv5 PPI support

In reply to Lorenzo Pieralisi
Quoted 87 lines · Lorenzo Pieralisi
Quoted 36 lines · Marc Zyngier
Quoted 34 lines · Lorenzo Pieralisi
Quoted 14 lines · Thomas Gleixner
Quoted 13 lines · Marc Zyngier
Quoted 11 lines · Thomas Gleixner
Quoted 8 lines · Marc Zyngier
Quoted 3 lines · Thomas Gleixner

How does this test distinguish between LEVEL_LOW and LEVEL_HIGH? It only tests for level, no? So the test is interesting at best ...

There is no distinction between HIGH and LOW, RISING and FALLING, in any revision of the GIC architecture.

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

Then pretending that there is a set_type() functionality is pretty daft

You still need to distinguish between level and edge when this is programmable (which is the case for a subset of the PPIs).

Fair enough, but can we please add a comment to this function which explains this oddity.

Getting back to this, I would need your/Marc's input on this.

I think it is fair to remove the irq_set_type() irqchip callback for GICv5 PPIs because there is nothing to set, as I said handling mode for these IRQs is fixed. I don't think this can cause any trouble (IIUC a value within the IRQF_TRIGGER_MASK should be set on requesting an IRQ to "force" the trigger to be programmed and even then core code would not fail if the irq_set_type() irqchip callback is not implemented).

Quoted 8 lines
Quoted 5 lines

I am thinking about *existing* drivers that request GICv3 PPIs with values in IRQF_TRIGGER_MASK set (are there any ? Don't think so but you know better than I do), when we switch over to GICv5 we would have no irq_set_type() callback for PPIs but I think we are still fine, not implementing irqchip.irq_set_type() is correct IMO.

Nobody seems to use a hardcoded trigger (well, there is one exception, but that's to paper over a firmware bug).

That's what I get if I remove the PPI irq_set_type() callback (just one timer, removed others because they add nothing) and enable debug for kernel/irq/manage.c (+additional printout):

genirq: No set_type function for IRQ 70 (GICv5-PPI)

  __irq_set_trigger+0x13c/0x180
  __setup_irq+0x3d8/0x7c0
  __request_percpu_irq+0xbc/0x114
  arch_timer_register+0x84/0x140
  arch_timer_of_init+0x180/0x1d0
  timer_probe+0x74/0x124
  time_init+0x18/0x58
  start_kernel+0x198/0x384
  __primary_switched+0x88/0x90

arch_timer: check_ppi_trigger irq 70 flags 8
genirq: enable_percpu_irq irq 70 type 8
genirq: No set_type function for IRQ 70 (GICv5-PPI)

  __irq_set_trigger+0x13c/0x180
  enable_percpu_irq+0x100/0x140
  arch_timer_starting_cpu+0x54/0xb8
  cpuhp_issue_call+0x254/0x3a8
  __cpuhp_setup_state_cpuslocked+0x208/0x2c8
  __cpuhp_setup_state+0x50/0x74
  arch_timer_register+0xc4/0x140
  arch_timer_of_init+0x180/0x1d0
  timer_probe+0x74/0x124
  time_init+0x18/0x58
  start_kernel+0x198/0x384
  __primary_switched+0x88/0x90

I noticed that, if the irq_set_type() function is not implemented, we don't execute (in __irq_set_trigger()):

irq_settings_set_level(desc);
irqd_set(&desc->irq_data, IRQD_LEVEL);

which in turn means that irqd_is_level_type(&desc->irq_data) is false for PPIs (ie arch timers, despite being level interrupts).

Quoted 7 lines

An immediate side effect is that they show as edge in:

/proc/interrupts

but that's just what I could notice.

Should I set them myself in PPI translate/alloc functions ?

When I say "do it in alloc", I mean "do whatever is needed to set things up so that we can safely ignore the absence of the .irq_set_type() callback -- this may even include some slight modification of the core code, but that's not big deal".

Quoted 3 lines

Removing the irq_set_type() for PPIs does not seem so innocuous, it is a bit complex to check all ramifications, please let me know if you spot something I have missed.

See above.

Quoted 15 lines
Quoted 6 lines
Quoted 5 lines

On the other hand, given that on GICv5 PPI handling mode is fixed, do you think that in the ppi_irq_domain_ops.translate() callback, I should check the type the firmware provided and fail the translation if it does not match the HW hardcoded value ?

Quoted 8 lines

Why? The fact that the firmware is wrong doesn't change the hardware integration. It just indicates that whoever wrote the firmware didn't read the documentation.

Even more, I wonder what the benefit of having that information in the firmware tables if the only thing that matters in the immutable HW view. Yes, having it in the DT/ACPI simplifies the job of the kernel (only one format to parse). But it is overall useless information.

Quoted 5 lines

Yes, that I agree but it would force firmware bindings to special case PPIs to remove the type (#interrupt-cells and co.).

From what I read I understand I must ignore the PPI type provided by firmware.

You could warn on spotting that is inconsistent, but the HW view is the only one that actually matters.

	M.
Signature · 1 line
Without deviation from the norm, progress is not possible.
author maintainer
#37 lore raw

PATCH v3 21/25 irqchip/gic-v5: Add GICv5 IRS/SPI support

In reply to Lorenzo Pieralisi

The GICv5 Interrupt Routing Service (IRS) component implements interrupt management and routing in the GICv5 architecture.

A GICv5 system comprises one or more IRSes, that together handle the interrupt routing and state for the system.

An IRS supports Shared Peripheral Interrupts (SPIs), that are interrupt sources directly connected to the IRS; they do not rely on memory for storage. The number of supported SPIs is fixed for a given implementation and can be probed through IRS IDR registers.

SPI interrupt state and routing are managed through GICv5 instructions.

Each core (PE in GICv5 terms) in a GICv5 system is identified with an Interrupt AFFinity ID (IAFFID).

An IRS manages a set of cores that are connected to it.

Firmware provides a topology description that the driver uses to detect to which IRS a CPU (ie an IAFFID) is associated with.

Use probeable information and firmware description to initialize the IRSes and implement GICv5 IRS SPIs support through an SPI-specific IRQ domain.

The GICv5 IRS driver:

- Probes IRSes in the system to detect SPI ranges
- Associates an IRS with a set of cores connected to it
- Adds an IRQchip structure for SPI handling

SPIs priority is set to a value corresponding to the lowest permissible priority in the system (taking into account the implemented priority bits of the IRS and CPU interface).

Since all IRQs are set to the same priority value, the value itself does not matter as long as it is a valid one.

---
 arch/arm64/include/asm/sysreg.h    |  50 +++++
 drivers/irqchip/Makefile           |   2 +-
 drivers/irqchip/irq-gic-v5-irs.c   | 433 +++++++++++++++++++++++++++++++++++++
 drivers/irqchip/irq-gic-v5.c       | 317 +++++++++++++++++++++++++--
 include/linux/irqchip/arm-gic-v5.h | 130 +++++++++++
 5 files changed, 917 insertions(+), 15 deletions(-)
arch/arm64/include/asm/sysreg.h +50 -0
index 4b48d00842c5750299f2983ecd72f19f2865c0e3..c735721cf083e8b59e88bd5888fa2519f40cc51e 100644
@@ -1082,16 +1082,66 @@
 /*
  * Definitions for GICv5 instructions
  */
+#define GICV5_OP_GIC_CDAFF		sys_insn(1, 0, 12, 1, 3)
 #define GICV5_OP_GIC_CDDI		sys_insn(1, 0, 12, 2, 0)
+#define GICV5_OP_GIC_CDDIS		sys_insn(1, 0, 12, 1, 0)
+#define GICV5_OP_GIC_CDEN		sys_insn(1, 0, 12, 1, 1)
 #define GICV5_OP_GIC_CDEOI		sys_insn(1, 0, 12, 1, 7)
+#define GICV5_OP_GIC_CDPEND		sys_insn(1, 0, 12, 1, 4)
+#define GICV5_OP_GIC_CDPRI		sys_insn(1, 0, 12, 1, 2)
+#define GICV5_OP_GIC_CDRCFG		sys_insn(1, 0, 12, 1, 5)
 #define GICV5_OP_GICR_CDIA		sys_insn(1, 0, 12, 3, 0)
 
+/* Shift and mask definitions for GIC CDAFF */
+#define GICV5_GIC_CDAFF_IAFFID_MASK	GENMASK_ULL(47, 32)
+#define GICV5_GIC_CDAFF_IAFFID(r)	FIELD_GET(GICV5_GIC_CDAFF_IAFFID_MASK, r)
+#define GICV5_GIC_CDAFF_TYPE_MASK	GENMASK_ULL(31, 29)
+#define GICV5_GIC_CDAFF_TYPE(r)		FIELD_GET(GICV5_GIC_CDAFF_TYPE_MASK, r)
+#define GICV5_GIC_CDAFF_IRM_MASK	BIT_ULL(28)
+#define GICV5_GIC_CDAFF_IRM(r)		FIELD_GET(GICV5_GIC_CDAFF_IRM_MASK, r)
+#define GICV5_GIC_CDAFF_ID_MASK		GENMASK_ULL(23, 0)
+#define GICV5_GIC_CDAFF_ID(r)		FIELD_GET(GICV5_GIC_CDAFF_ID_MASK, r)
+
 /* Shift and mask definitions for GIC CDDI */
 #define GICV5_GIC_CDDI_TYPE_MASK	GENMASK_ULL(31, 29)
 #define GICV5_GIC_CDDI_TYPE(r)		FIELD_GET(GICV5_GIC_CDDI_TYPE_MASK, r)
 #define GICV5_GIC_CDDI_ID_MASK		GENMASK_ULL(23, 0)
 #define GICV5_GIC_CDDI_ID(r)		FIELD_GET(GICV5_GIC_CDDI_ID_MASK, r)
 
+/* Shift and mask definitions for GIC CDDIS */
+#define GICV5_GIC_CDDIS_TYPE_MASK	GENMASK_ULL(31, 29)
+#define GICV5_GIC_CDDIS_TYPE(r)		FIELD_GET(GICV5_GIC_CDDIS_TYPE_MASK, r)
+#define GICV5_GIC_CDDIS_ID_MASK		GENMASK_ULL(23, 0)
+#define GICV5_GIC_CDDIS_ID(r)		FIELD_GET(GICV5_GIC_CDDIS_ID_MASK, r)
+
+/* Shift and mask definitions for GIC CDEN */
+#define GICV5_GIC_CDEN_TYPE_MASK	GENMASK_ULL(31, 29)
+#define GICV5_GIC_CDEN_TYPE(r)		FIELD_GET(GICV5_GIC_CDEN_TYPE_MASK, r)
+#define GICV5_GIC_CDEN_ID_MASK		GENMASK_ULL(23, 0)
+#define GICV5_GIC_CDEN_ID(r)		FIELD_GET(GICV5_GIC_CDEN_ID_MASK, r)
+
+/* Shift and mask definitions for GIC CDPEND */
+#define GICV5_GIC_CDPEND_PENDING_MASK	BIT_ULL(32)
+#define GICV5_GIC_CDPEND_PENDING(r)	FIELD_GET(GICV5_GIC_CDPEND_PENDING_MASK, r)
+#define GICV5_GIC_CDPEND_TYPE_MASK	GENMASK_ULL(31, 29)
+#define GICV5_GIC_CDPEND_TYPE(r)	FIELD_GET(GICV5_GIC_CDPEND_TYPE_MASK, r)
+#define GICV5_GIC_CDPEND_ID_MASK	GENMASK_ULL(23, 0)
+#define GICV5_GIC_CDPEND_ID(r)		FIELD_GET(GICV5_GIC_CDPEND_ID_MASK, r)
+
+/* Shift and mask definitions for GIC CDPRI */
+#define GICV5_GIC_CDPRI_PRIORITY_MASK	GENMASK_ULL(39, 35)
+#define GICV5_GIC_CDPRI_PRIORITY(r)	FIELD_GET(GICV5_GIC_CDPRI_PRIORITY_MASK, r)
+#define GICV5_GIC_CDPRI_TYPE_MASK	GENMASK_ULL(31, 29)
+#define GICV5_GIC_CDPRI_TYPE(r)		FIELD_GET(GICV5_GIC_CDPRI_TYPE_MASK, r)
+#define GICV5_GIC_CDPRI_ID_MASK		GENMASK_ULL(23, 0)
+#define GICV5_GIC_CDPRI_ID(r)		FIELD_GET(GICV5_GIC_CDPRI_ID_MASK, r)
+
+/* Shift and mask definitions for GIC CDRCFG */
+#define GICV5_GIC_CDRCFG_TYPE_MASK	GENMASK_ULL(31, 29)
+#define GICV5_GIC_CDRCFG_TYPE(r)	FIELD_GET(GICV5_GIC_CDRCFG_TYPE_MASK, r)
+#define GICV5_GIC_CDRCFG_ID_MASK	GENMASK_ULL(23, 0)
+#define GICV5_GIC_CDRCFG_ID(r)		FIELD_GET(GICV5_GIC_CDRCFG_ID_MASK, r)
+
 /* Shift and mask definitions for GICR CDIA */
 #define GICV5_GIC_CDIA_VALID_MASK	BIT_ULL(32)
 #define GICV5_GIC_CDIA_VALID(r)		FIELD_GET(GICV5_GIC_CDIA_VALID_MASK, r)
drivers/irqchip/Makefile +1 -1
index 3f8225bba5f0f9ce5dbb629b6d4782eacf85da44..3d9c47fa3fdf40b7452c059d84fe8ac24c91bc0f 100644
@@ -35,7 +35,7 @@ obj-$(CONFIG_ARM_GIC_V3)		+= irq-gic-v3.o irq-gic-v3-mbi.o irq-gic-common.o
 obj-$(CONFIG_ARM_GIC_V3_ITS)		+= irq-gic-v3-its.o irq-gic-v4.o irq-gic-v3-its-msi-parent.o
 obj-$(CONFIG_ARM_GIC_V3_ITS_FSL_MC)	+= irq-gic-v3-its-fsl-mc-msi.o
 obj-$(CONFIG_PARTITION_PERCPU)		+= irq-partition-percpu.o
-obj-$(CONFIG_ARM_GIC_V5)		+= irq-gic-v5.o
+obj-$(CONFIG_ARM_GIC_V5)		+= irq-gic-v5.o irq-gic-v5-irs.o
 obj-$(CONFIG_HISILICON_IRQ_MBIGEN)	+= irq-mbigen.o
 obj-$(CONFIG_ARM_NVIC)			+= irq-nvic.o
 obj-$(CONFIG_ARM_VIC)			+= irq-vic.o
drivers/irqchip/irq-gic-v5-irs.c new file +433 -0

433 lines not on this page · raw message

drivers/irqchip/irq-gic-v5.c +303 -14

443 lines not on this page · raw message

include/linux/irqchip/arm-gic-v5.h +130 -0

144 lines not on this page · raw message

Signature · 1 line
2.48.0
author maintainer
#38 lore raw

PATCH v3 22/25 irqchip/gic-v5: Add GICv5 LPI/IPI support

In reply to Lorenzo Pieralisi

An IRS supports Logical Peripheral Interrupts (LPIs) and implement Linux IPIs on top of it.

LPIs are used for interrupt signals that are translated by a GICv5 ITS (Interrupt Translation Service) but also for software generated IRQs - namely interrupts that are not driven by a HW signal, ie IPIs.

LPIs rely on memory storage for interrupt routing and state.

LPIs state and routing information is kept in the Interrupt State Table (IST).

IRSes provide support for 1- or 2-level IST tables configured to support a maximum number of interrupts that depend on the OS configuration and the HW capabilities.

On systems that provide 2-level IST support, always allow the maximum number of LPIs; On systems with only 1-level support, limit the number of LPIs to 2^12 to prevent wasting memory (presumably a system that supports a 1-level only IST is not expecting a large number of interrupts).

On a 2-level IST system, L2 entries are allocated on demand.

The IST table memory is allocated using the kmalloc() interface; the allocation required may be smaller than a page and must be made up of contiguous physical pages if larger than a page.

On systems where the IRS is not cache-coherent with the CPUs, cache mainteinance operations are executed to clean and invalidate the allocated memory to the point of coherency making it visible to the IRS components.

On GICv5 systems, IPIs are implemented using LPIs.

Add an LPI IRQ domain and implement an IPI-specific IRQ domain created as a child/subdomain of the LPI domain to allocate the required number of LPIs needed to implement the IPIs.

IPIs are backed by LPIs, add LPIs allocation/de-allocation functions.

The LPI INTID namespace is managed using an IDA to alloc/free LPI INTIDs.

Associate an IPI irqchip with IPI IRQ descriptors to provide core code with the irqchip.ipi_send_single() method required to raise an IPI.

---
 arch/arm64/include/asm/smp.h       |  17 ++
 arch/arm64/kernel/smp.c            |  17 --
 drivers/irqchip/irq-gic-v5-irs.c   | 361 +++++++++++++++++++++++++++++++++++++
 drivers/irqchip/irq-gic-v5.c       | 284 ++++++++++++++++++++++++++++-
 include/linux/irqchip/arm-gic-v5.h |  59 ++++++
 5 files changed, 719 insertions(+), 19 deletions(-)
arch/arm64/include/asm/smp.h +17 -0
index d6fd6efb66a673ae33825971e4aa07e791c02ee5..d48ef6d5abcc77d1c06ad8e91e72006acf662078 100644
@@ -50,6 +50,23 @@ struct seq_file;
  */
 extern void smp_init_cpus(void);
 
+enum ipi_msg_type {
+	IPI_RESCHEDULE,
+	IPI_CALL_FUNC,
+	IPI_CPU_STOP,
+	IPI_CPU_STOP_NMI,
+	IPI_TIMER,
+	IPI_IRQ_WORK,
+	NR_IPI,
+	/*
+	 * Any enum >= NR_IPI and < MAX_IPI is special and not tracable
+	 * with trace_ipi_*
+	 */
+	IPI_CPU_BACKTRACE = NR_IPI,
+	IPI_KGDB_ROUNDUP,
+	MAX_IPI
+};
+
 /*
  * Register IPI interrupts with the arch SMP code
  */
arch/arm64/kernel/smp.c +0 -17
index 3f3712e47c94c62836fb89cd4bfb3595fbb41557..148145979d83f67469075df1c8b5e366ffe9d907 100644
@@ -64,23 +64,6 @@ struct secondary_data secondary_data;
 /* Number of CPUs which aren't online, but looping in kernel text. */
 static int cpus_stuck_in_kernel;
 
-enum ipi_msg_type {
-	IPI_RESCHEDULE,
-	IPI_CALL_FUNC,
-	IPI_CPU_STOP,
-	IPI_CPU_STOP_NMI,
-	IPI_TIMER,
-	IPI_IRQ_WORK,
-	NR_IPI,
-	/*
-	 * Any enum >= NR_IPI and < MAX_IPI is special and not tracable
-	 * with trace_ipi_*
-	 */
-	IPI_CPU_BACKTRACE = NR_IPI,
-	IPI_KGDB_ROUNDUP,
-	MAX_IPI
-};
-
 static int ipi_irq_base __ro_after_init;
 static int nr_ipi __ro_after_init = NR_IPI;
 
drivers/irqchip/irq-gic-v5-irs.c +361 -0

397 lines not on this page · raw message

drivers/irqchip/irq-gic-v5.c +282 -2

402 lines not on this page · raw message

include/linux/irqchip/arm-gic-v5.h +59 -0

107 lines not on this page · raw message

Signature · 1 line
2.48.0
#39 lore raw

Re: [PATCH v3 22/25] irqchip/gic-v5: Add GICv5 LPI/IPI support

drivers/irqchip/irq-gic-v5-irs.c static void irs_writel_relaxed(struct gicv5_irs_chip_data *irs_data, · line 288

Quoted 4 lines · Lorenzo Pieralisi
drivers/irqchip/irq-gic-v5-irs.c +4 -0
+static int __init gicv5_irs_init_ist(struct gicv5_irs_chip_data *irs_data)
+{
+	u32 lpi_id_bits, idr2_id_bits, idr2_min_lpi_id_bits,
+	    l2_iste_sz, l2sz, l2_iste_sz_split, idr2;

Please don't do that. That's horrible to read. If it does not fit into a single line, make it

       u32 a,....,h;
       u32 i,...,m;
author maintainer
#40 lore raw

Re: [PATCH v3 22/25] irqchip/gic-v5: Add GICv5 LPI/IPI support

Quoted 11 lines · Thomas Gleixner

drivers/irqchip/irq-gic-v5-irs.c static void irs_writel_relaxed(struct gicv5_irs_chip_data *irs_data, · line 288

Quoted 4 lines · Lorenzo Pieralisi
drivers/irqchip/irq-gic-v5-irs.c +4 -0
+static int __init gicv5_irs_init_ist(struct gicv5_irs_chip_data *irs_data)
+{
+	u32 lpi_id_bits, idr2_id_bits, idr2_min_lpi_id_bits,
+	    l2_iste_sz, l2sz, l2_iste_sz_split, idr2;

Please don't do that. That's horrible to read. If it does not fit into a single line, make it

       u32 a,....,h;
       u32 i,...,m;

Done.

Thanks,
Lorenzo

author maintainer
#41 lore raw

PATCH v3 23/25 irqchip/gic-v5: Enable GICv5 SMP booting

In reply to Lorenzo Pieralisi

Set up IPIs by allocating IPI IRQs for all cpus and call into arm64 core code to initialise IPIs IRQ descriptors and request the related IRQ.

Implement hotplug callback to enable interrupts on a cpu and register the cpu with an IRS.

---
 drivers/irqchip/irq-gic-v5.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
drivers/irqchip/irq-gic-v5.c +21 -0
index c2c05f4411197365079c7d997665c81e3a0f4b74..e4bb02a1988b01a23db61288ff1b1fe3db02e0e4 100644
@@ -5,6 +5,7 @@
 
 #define pr_fmt(fmt)	"GICv5: " fmt
 
+#include <linux/cpuhotplug.h>
 #include <linux/idr.h>
 #include <linux/irqdomain.h>
 #include <linux/slab.h>
@@ -875,6 +876,8 @@ static void gicv5_cpu_enable_interrupts(void)
 	write_sysreg_s(cr0, SYS_ICC_CR0_EL1);
 }
 
+static int base_ipi_virq;
+
 static int gicv5_starting_cpu(unsigned int cpu)
 {
 	if (WARN(!gicv5_cpuif_has_gcie(),
@@ -886,6 +889,22 @@ static int gicv5_starting_cpu(unsigned int cpu)
 	return gicv5_irs_register_cpu(cpu);
 }
 
+static void __init gicv5_smp_init(void)
+{
+	unsigned int num_ipis = GICV5_IPIS_PER_CPU * nr_cpu_ids;
+
+	cpuhp_setup_state_nocalls(CPUHP_AP_IRQ_GIC_STARTING,
+				  "irqchip/arm/gicv5:starting",
+				  gicv5_starting_cpu, NULL);
+
+	base_ipi_virq = irq_domain_alloc_irqs(gicv5_global_data.ipi_domain,
+					      num_ipis, NUMA_NO_NODE, NULL);
+	if (WARN(base_ipi_virq <= 0, "IPI IRQ allocation was not successful"))
+		return;
+
+	set_smp_ipi_range_percpu(base_ipi_virq, GICV5_IPIS_PER_CPU, nr_cpu_ids);
+}
+
 static void __init gicv5_free_domains(void)
 {
 	if (gicv5_global_data.ppi_domain)
@@ -1010,6 +1029,8 @@ static int __init gicv5_of_init(struct device_node *node, struct device_node *pa
 	if (ret)
 		goto out_int;
 
+	gicv5_smp_init();
+
 	return 0;
 out_int:
 	gicv5_cpu_disable_interrupts();
Signature · 1 line
2.48.0
author maintainer
#42 lore raw

PATCH v3 24/25 irqchip/gic-v5: Add GICv5 ITS support

In reply to Lorenzo Pieralisi

The GICv5 architecture implements Interrupt Translation Service (ITS) components in order to translate events coming from peripherals into interrupt events delivered to the connected IRSes.

Events (ie MSI memory writes to ITS translate frame), are translated by the ITS using tables kept in memory.

ITS translation tables for peripherals is kept in memory storage (device table [DT] and Interrupt Translation Table [ITT]) that is allocated by the driver on boot.

Both tables can be 1- or 2-level; the structure is chosen by the driver after probing the ITS HW parameters and checking the allowed table splits and supported {device/event}_IDbits.

DT table entries are allocated on demand (ie when a device is probed); the DT table is sized using the number of supported deviceID bits in that that's a system design decision (ie the number of deviceID bits implemented should reflect the number of devices expected in a system) therefore it makes sense to allocate a DT table that can cater for the maximum number of devices.

DT and ITT tables are allocated using the kmalloc interface; the allocation size may be smaller than a page or larger, and must provide contiguous memory pages.

LPIs INTIDs backing the device events are allocated one-by-one and only upon Linux IRQ allocation; this to avoid preallocating a large number of LPIs to cover the HW device MSI vector size whereas few MSI entries are actually enabled by a device.

ITS cacheability/shareability attributes are programmed according to the provided firmware ITS description.

The GICv5 ITS reuses the GICv3 MSI parent infrastructure, there is no need to duplicate it, make it common.

---
 MAINTAINERS                                        |    1 +
 drivers/irqchip/Kconfig                            |    7 +
 drivers/irqchip/Makefile                           |    5 +-
 drivers/irqchip/irq-gic-common.h                   |    2 -
 ...3-its-msi-parent.c => irq-gic-its-msi-parent.c} |    3 +-
 drivers/irqchip/irq-gic-its-msi-parent.h           |   13 +
 drivers/irqchip/irq-gic-v3-its.c                   |    3 +-
 drivers/irqchip/irq-gic-v5-irs.c                   |   25 +
 drivers/irqchip/irq-gic-v5-its.c                   | 1176 ++++++++++++++++++++
 drivers/irqchip/irq-gic-v5.c                       |    6 +-
 include/linux/irqchip/arm-gic-v5.h                 |  179 +++
 11 files changed, 1411 insertions(+), 9 deletions(-)
MAINTAINERS +1 -0
index 49c377febad72e77dd6d480105c2b6bffa81f9a6..5159c517ca1968e6df1678b269559257d2fcc86a 100644
@@ -1907,6 +1907,7 @@ M:	Marc Zyngier <[email protected]>
 L:	[email protected] (moderated for non-subscribers)
 S:	Maintained
 F:	Documentation/devicetree/bindings/interrupt-controller/arm,gic-v5*.yaml
+F:	drivers/irqchip/irq-gic-its-msi-parent.[ch]
 F:	drivers/irqchip/irq-gic-v5*.[ch]
 F:	include/linux/irqchip/arm-gic-v5.h
 
drivers/irqchip/Kconfig +7 -0
index 6b3d70924186bd8ca04294832409d1e379c9cbd4..d73f9bcde8fd995b5b6c33108b9d40b424437b3f 100644
@@ -41,10 +41,14 @@ config ARM_GIC_V3
 	select HAVE_ARM_SMCCC_DISCOVERY
 	select IRQ_MSI_IOMMU
 
+config ARM_GIC_ITS_PARENT
+	bool
+
 config ARM_GIC_V3_ITS
 	bool
 	select GENERIC_MSI_IRQ
 	select IRQ_MSI_LIB
+	select ARM_GIC_ITS_PARENT
 	default ARM_GIC_V3
 	select IRQ_MSI_IOMMU
 
@@ -58,6 +62,9 @@ config ARM_GIC_V5
 	bool
 	select IRQ_DOMAIN_HIERARCHY
 	select GENERIC_IRQ_EFFECTIVE_AFF_MASK
+	select GENERIC_MSI_IRQ
+	select IRQ_MSI_LIB
+	select ARM_GIC_ITS_PARENT
 
 config ARM_NVIC
 	bool
drivers/irqchip/Makefile +3 -2
index 3d9c47fa3fdf40b7452c059d84fe8ac24c91bc0f..18724910f2bdc20597d3d3e4852d593a4bd163da 100644
@@ -32,10 +32,11 @@ obj-$(CONFIG_ARCH_REALVIEW)		+= irq-gic-realview.o
 obj-$(CONFIG_IRQ_MSI_LIB)		+= irq-msi-lib.o
 obj-$(CONFIG_ARM_GIC_V2M)		+= irq-gic-v2m.o
 obj-$(CONFIG_ARM_GIC_V3)		+= irq-gic-v3.o irq-gic-v3-mbi.o irq-gic-common.o
-obj-$(CONFIG_ARM_GIC_V3_ITS)		+= irq-gic-v3-its.o irq-gic-v4.o irq-gic-v3-its-msi-parent.o
+obj-$(CONFIG_ARM_GIC_ITS_PARENT)	+= irq-gic-its-msi-parent.o
+obj-$(CONFIG_ARM_GIC_V3_ITS)		+= irq-gic-v3-its.o irq-gic-v4.o
 obj-$(CONFIG_ARM_GIC_V3_ITS_FSL_MC)	+= irq-gic-v3-its-fsl-mc-msi.o
 obj-$(CONFIG_PARTITION_PERCPU)		+= irq-partition-percpu.o
-obj-$(CONFIG_ARM_GIC_V5)		+= irq-gic-v5.o irq-gic-v5-irs.o
+obj-$(CONFIG_ARM_GIC_V5)		+= irq-gic-v5.o irq-gic-v5-irs.o irq-gic-v5-its.o
 obj-$(CONFIG_HISILICON_IRQ_MBIGEN)	+= irq-mbigen.o
 obj-$(CONFIG_ARM_NVIC)			+= irq-nvic.o
 obj-$(CONFIG_ARM_VIC)			+= irq-vic.o
drivers/irqchip/irq-gic-common.h +0 -2
index 020ecdf16901c9720e5746aec4d0b5b39d3625ed..710cab61d9195a0bd64d57e03c60852c4cd6ff8e 100644
@@ -29,8 +29,6 @@ void gic_enable_quirks(u32 iidr, const struct gic_quirk *quirks,
 void gic_enable_of_quirks(const struct device_node *np,
 			  const struct gic_quirk *quirks, void *data);
 
-extern const struct msi_parent_ops gic_v3_its_msi_parent_ops;
-
 #define RDIST_FLAGS_PROPBASE_NEEDS_FLUSHING    (1 << 0)
 #define RDIST_FLAGS_RD_TABLES_PREALLOCATED     (1 << 1)
 #define RDIST_FLAGS_FORCE_NON_SHAREABLE        (1 << 2)
drivers/irqchip/irq-gic-its-msi-parent.c renamed from drivers/irqchip/irq-gic-v3-its-msi-parent.c +1 -2
similarity index 98%
rename from drivers/irqchip/irq-gic-v3-its-msi-parent.c
rename to drivers/irqchip/irq-gic-its-msi-parent.c
index bdb04c8081480de468fb217b68c6933a8e1e2bd7..71edcdb2defdfd5b892d86354039d2e46b832ea5 100644
@@ -7,7 +7,6 @@
 #include <linux/acpi_iort.h>
 #include <linux/pci.h>
 
-#include "irq-gic-common.h"
 #include "irq-msi-lib.h"
 
 #define ITS_MSI_FLAGS_REQUIRED  (MSI_FLAG_USE_DEF_DOM_OPS |	\
@@ -200,7 +199,7 @@ static bool its_init_dev_msi_info(struct device *dev, struct irq_domain *domain,
 	return true;
 }
 
-const struct msi_parent_ops gic_v3_its_msi_parent_ops = {
+const struct msi_parent_ops gic_its_msi_parent_ops = {
 	.supported_flags	= ITS_MSI_FLAGS_SUPPORTED,
 	.required_flags		= ITS_MSI_FLAGS_REQUIRED,
 	.chip_flags		= MSI_CHIP_FLAG_SET_EOI | MSI_CHIP_FLAG_SET_ACK,
drivers/irqchip/irq-gic-its-msi-parent.h new file +13 -0
new file mode 100644
index 0000000000000000000000000000000000000000..e7bb7f3862eef379e5b85fe7bd5eb72f3586d3b7
@@ -0,0 +1,13 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Copyright (C) 2024 ARM Limited, All Rights Reserved.
+ */
+
+#ifndef _IRQ_GIC_ITS_MSI_PARENT_H
+#define _IRQ_GIC_ITS_MSI_PARENT_H
+
+#include <linux/msi.h>
+
+extern const struct msi_parent_ops gic_its_msi_parent_ops;
+
+#endif /* _IRQ_GIC_ITS_MSI_PARENT_H */
drivers/irqchip/irq-gic-v3-its.c +2 -1
index 0115ad6c82593de511c285d99437996919bfa308..6c51bf4e34a38103d612c74476d640cd4126e8b6 100644
@@ -41,6 +41,7 @@
 #include <asm/exception.h>
 
 #include "irq-gic-common.h"
+#include "irq-gic-its-msi-parent.h"
 #include "irq-msi-lib.h"
 
 #define ITS_FLAGS_CMDQ_NEEDS_FLUSHING		(1ULL << 0)
@@ -5139,7 +5140,7 @@ static int its_init_domain(struct its_node *its)
 
 	irq_domain_update_bus_token(inner_domain, DOMAIN_BUS_NEXUS);
 
-	inner_domain->msi_parent_ops = &gic_v3_its_msi_parent_ops;
+	inner_domain->msi_parent_ops = &gic_its_msi_parent_ops;
 	inner_domain->flags |= IRQ_DOMAIN_FLAG_MSI_PARENT;
 
 	return 0;
drivers/irqchip/irq-gic-v5-irs.c +25 -0
index a3de1c1b918c0ae123ae204f0dea6992db33ecd0..921472b958d84c6ded65c8f745bca90f7385e03f 100644
@@ -482,6 +482,23 @@ static int gicv5_irs_wait_for_idle(struct gicv5_irs_chip_data *irs_data)
 					GICV5_IRS_CR0_IDLE, NULL);
 }
 
+void gicv5_irs_syncr(void)
+{
+	struct gicv5_irs_chip_data *irs_data;
+	u32 syncr;
+
+	irs_data = list_first_entry_or_null(&irs_nodes,
+					    struct gicv5_irs_chip_data, entry);
+	if (WARN_ON(!irs_data))
+		return;
+
+	syncr = FIELD_PREP(GICV5_IRS_SYNCR_SYNC, 1);
+	irs_writel_relaxed(irs_data, syncr, GICV5_IRS_SYNCR);
+
+	gicv5_wait_for_op(irs_data->irs_base, GICV5_IRS_SYNC_STATUSR,
+			  GICV5_IRS_SYNC_STATUSR_IDLE);
+}
+
 int gicv5_irs_register_cpu(int cpuid)
 {
 	struct gicv5_irs_chip_data *irs_data;
@@ -776,6 +793,14 @@ int __init gicv5_irs_enable(void)
 	return 0;
 }
 
+void __init gicv5_irs_its_probe(void)
+{
+	struct gicv5_irs_chip_data *irs_data;
+
+	list_for_each_entry(irs_data, &irs_nodes, entry)
+		gicv5_its_of_probe(to_of_node(irs_data->fwnode));
+}
+
 int __init gicv5_irs_of_probe(struct device_node *parent)
 {
 	struct device_node *np;
drivers/irqchip/irq-gic-v5-its.c new file +1176 -0

1,176 lines not on this page · raw message

drivers/irqchip/irq-gic-v5.c +4 -2
index e4bb02a1988b01a23db61288ff1b1fe3db02e0e4..910d7cdc7fa502b1a9ed37a05b126a82c9dc2807 100644
@@ -57,12 +57,12 @@ static void release_lpi(u32 lpi)
 	ida_free(&lpi_ida, lpi);
 }
 
-static int gicv5_alloc_lpi(void)
+int gicv5_alloc_lpi(void)
 {
 	return alloc_lpi();
 }
 
-static void gicv5_free_lpi(u32 lpi)
+void gicv5_free_lpi(u32 lpi)
 {
 	release_lpi(lpi);
 }
@@ -1031,6 +1031,8 @@ static int __init gicv5_of_init(struct device_node *node, struct device_node *pa
 
 	gicv5_smp_init();
 
+	gicv5_irs_its_probe();
+
 	return 0;
 out_int:
 	gicv5_cpu_disable_interrupts();
include/linux/irqchip/arm-gic-v5.h +179 -0

224 lines not on this page · raw message

Signature · 1 line
2.48.0
#43 lore raw

Re: [PATCH v3 24/25] irqchip/gic-v5: Add GICv5 ITS support

kernel test robot noticed the following build warnings:

Hi Lorenzo,

kernel test robot noticed the following build warnings:

[auto build test WARNING on 0af2f6be1b4281385b618cb86ad946eded089ac8]

url:    https://github.com/intel-lab-lkp/linux/commits/Lorenzo-Pieralisi/dt-bindings-interrupt-controller-Add-Arm-GICv5/20250506-203528
base:   0af2f6be1b4281385b618cb86ad946eded089ac8
patch link:    https://lore.kernel.org/r/20250506-gicv5-host-v3-24-6edd5a92fd09%40kernel.org
patch subject: [PATCH v3 24/25] irqchip/gic-v5: Add GICv5 ITS support
compiler: clang version 20.1.2 (https://github.com/llvm/llvm-project 58df0ef89dd64126512e4ee27b4ac3fd8ddf6247)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

includecheck warnings: (new ones prefixed by >>)

>> include/linux/irqchip/arm-gic-v5.h: linux/iopoll.h is included more than once.

vim +8 include/linux/irqchip/arm-gic-v5.h

     7	
   > 8	#include <linux/iopoll.h>
     9	
    10	#include <asm/cacheflush.h>
  > 11	#include <linux/iopoll.h>
    12	
Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
author maintainer
#44 lore raw

PATCH v3 25/25 arm64: Kconfig: Enable GICv5

In reply to Lorenzo Pieralisi

Enable GICv5 driver code for the ARM64 architecture.

Cc Will Deacon <[email protected]>
Cc Catalin Marinas <[email protected]>
Cc Marc Zyngier <[email protected]>
---
 arch/arm64/Kconfig | 1 +
 1 file changed, 1 insertion(+)
arch/arm64/Kconfig +1 -0
index a182295e6f08bfa0f3e6f630dc4adfe797a4d273..f1b3c695b376717979ae864865238ae12ad65ca2 100644
@@ -128,6 +128,7 @@ config ARM64
 	select ARM_GIC_V2M if PCI
 	select ARM_GIC_V3
 	select ARM_GIC_V3_ITS if PCI
+	select ARM_GIC_V5
 	select ARM_PSCI_FW
 	select BUILDTIME_TABLE_SORT
 	select CLONE_BACKWARDS
Signature · 1 line
2.48.0
maintainer
#45 lore raw
In reply to Lorenzo Pieralisi
Quoted 9 lines · Lorenzo Pieralisi

=============
2.5 GICv5 IWB
=============

The IWB driver has been dropped owing to issues encountered with core code DOMAIN_BUS_WIRED_TO_MSI bus token handling:

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

This problem does not have much to do with DOMAIN_BUS_WIRED_TO_MSI.

The issues are that:

- the core code calls into the .prepare domain on a per-interrupt basis instead of on a per *device* basis. This is a complete violation of the MSI API, because .prepare is when you are supposed to perform resource reservation (in the GICv3 parlance, that's ITT allocation + MAPD command).

- the same function calls .prepare for a *single* interrupt, effectively telling the irqchip "my device has only one interrupt". Because I'm super generous (and don't like wasting precious bytes), I allocate 32 LPIs at the minimum. Only snag is that I could do with 300+ interrupts, and calling repeatedly doesn't help at all, since we cannot *grow* an ITT.

So this code needs to be taken to the backyard and beaten into shape before we can make use of it. My D05 (with its collection of MBIGENs) only works by accident at the moment, as I found out yesterday, and GICv5 IWB is in the same boat, since it reuses the msi-parent thing, and therefore the same heuristic.

I guess not having the IWB immediately isn't too big a deal, but I really didn't expect to find this...

Thanks,

	M.
Signature · 1 line
Without deviation from the norm, progress is not possible.
author maintainer
#46 lore raw
Quoted 22 lines · Marc Zyngier
Quoted 9 lines · Lorenzo Pieralisi

=============
2.5 GICv5 IWB
=============

The IWB driver has been dropped owing to issues encountered with core code DOMAIN_BUS_WIRED_TO_MSI bus token handling:

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

This problem does not have much to do with DOMAIN_BUS_WIRED_TO_MSI.

The issues are that:

- the core code calls into the .prepare domain on a per-interrupt basis instead of on a per *device* basis. This is a complete violation of the MSI API, because .prepare is when you are supposed to perform resource reservation (in the GICv3 parlance, that's ITT allocation + MAPD command).

Quoted 6 lines

- the same function calls .prepare for a *single* interrupt, effectively telling the irqchip "my device has only one interrupt". Because I'm super generous (and don't like wasting precious bytes), I allocate 32 LPIs at the minimum. Only snag is that I could do with 300+ interrupts, and calling repeatedly doesn't help at all, since we cannot *grow* an ITT.

On the IWB driver code that I could not post I noticed that it is true that the .prepare callback is called on a per-interrupt basis but the vector size is the domain size (ie number of wires) which is correct AFAICS, so the ITT size should be fine I don't get why it would need to grow.

The difference with this series is that on v3 LPIs are allocated on .prepare(), we allocate them on .alloc().

So yes, calling .prepare on a per-interrupt basis looks like a bug but if we allow reusing a deviceID (ie the "shared" thingy) it could be harmless.

Quoted 8 lines

So this code needs to be taken to the backyard and beaten into shape before we can make use of it. My D05 (with its collection of MBIGENs) only works by accident at the moment, as I found out yesterday, and GICv5 IWB is in the same boat, since it reuses the msi-parent thing, and therefore the same heuristic.

I guess not having the IWB immediately isn't too big a deal, but I really didn't expect to find this...

To be honest, it was expected. We found these snags while designing the code (that explains how IWB was structured in v1 - by the way) but we didn't know if the behaviour above was by construction, we always thought "we must be making a mistake".

The same goes for the fixed eventID but I would not resume that discussion again, there are things that are impossible to know unless you are aware of the background story behind them.

Thanks,
Lorenzo

maintainer
#47 lore raw
Quoted 31 lines · Lorenzo Pieralisi
Quoted 22 lines · Marc Zyngier
Quoted 9 lines · Lorenzo Pieralisi

=============
2.5 GICv5 IWB
=============

The IWB driver has been dropped owing to issues encountered with core code DOMAIN_BUS_WIRED_TO_MSI bus token handling:

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

This problem does not have much to do with DOMAIN_BUS_WIRED_TO_MSI.

The issues are that:

- the core code calls into the .prepare domain on a per-interrupt basis instead of on a per *device* basis. This is a complete violation of the MSI API, because .prepare is when you are supposed to perform resource reservation (in the GICv3 parlance, that's ITT allocation + MAPD command).

Quoted 6 lines

- the same function calls .prepare for a *single* interrupt, effectively telling the irqchip "my device has only one interrupt". Because I'm super generous (and don't like wasting precious bytes), I allocate 32 LPIs at the minimum. Only snag is that I could do with 300+ interrupts, and calling repeatedly doesn't help at all, since we cannot *grow* an ITT.

Quoted 5 lines

On the IWB driver code that I could not post I noticed that it is true that the .prepare callback is called on a per-interrupt basis but the vector size is the domain size (ie number of wires) which is correct AFAICS, so the ITT size should be fine I don't get why it would need to grow.

Look again. The only reason you are getting something that *looks* correct is that its_pmsi_prepare() has this nugget:

	/* Allocate at least 32 MSIs, and always as a power of 2 */
	nvec = max_t(int, 32, roundup_pow_of_two(nvec));

and that the IWB is, conveniently, in sets of 32. However, the caller of this function (__msi_domain_alloc_irqs()) passes a nvec value that is always exactly *1* when allocating an interrupt.

So you're just lucky that I picked a minimum ITT size that matches the IWB on your model. Configure your IWB to be, let's say, 256 interrupts and use the last one, and you'll have a very different behaviour.

Quoted 2 lines

The difference with this series is that on v3 LPIs are allocated on .prepare(), we allocate them on .alloc().

Absolutely not. Even on v3, we never allocate LPIs in .prepare(). We allocate the ITT, perform the MAPD, and that's it. That's why it's called *prepare*.

Quoted 3 lines

So yes, calling .prepare on a per-interrupt basis looks like a bug but if we allow reusing a deviceID (ie the "shared" thingy) it could be harmless.

Harmless? No. It is really *bad*. It means you lose any sort of sane tracking of what owns the ITT and how you can free things. Seeing a devid twice is the admission that we have no idea of what is going on.

GICv3 is already in that sorry state, but I am hopeful that GICv5 can be a bit less crap.

Quoted 6 lines
Quoted 6 lines

So this code needs to be taken to the backyard and beaten into shape before we can make use of it. My D05 (with its collection of MBIGENs) only works by accident at the moment, as I found out yesterday, and GICv5 IWB is in the same boat, since it reuses the msi-parent thing, and therefore the same heuristic.

Quoted 7 lines
Quoted 2 lines

I guess not having the IWB immediately isn't too big a deal, but I really didn't expect to find this...

To be honest, it was expected. We found these snags while designing the code (that explains how IWB was structured in v1 - by the way) but we didn't know if the behaviour above was by construction, we always thought "we must be making a mistake".

Then why didn't you report it? We could have caught this very early on, before the fscked-up code was in a stable release...

	M.
Signature · 1 line
Without deviation from the norm, progress is not possible.
author maintainer
#48 lore raw
Quoted 42 lines · Marc Zyngier
Quoted 31 lines · Lorenzo Pieralisi
Quoted 22 lines · Marc Zyngier
Quoted 9 lines · Lorenzo Pieralisi

=============
2.5 GICv5 IWB
=============

The IWB driver has been dropped owing to issues encountered with core code DOMAIN_BUS_WIRED_TO_MSI bus token handling:

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

This problem does not have much to do with DOMAIN_BUS_WIRED_TO_MSI.

The issues are that:

- the core code calls into the .prepare domain on a per-interrupt basis instead of on a per *device* basis. This is a complete violation of the MSI API, because .prepare is when you are supposed to perform resource reservation (in the GICv3 parlance, that's ITT allocation + MAPD command).

Quoted 6 lines

- the same function calls .prepare for a *single* interrupt, effectively telling the irqchip "my device has only one interrupt". Because I'm super generous (and don't like wasting precious bytes), I allocate 32 LPIs at the minimum. Only snag is that I could do with 300+ interrupts, and calling repeatedly doesn't help at all, since we cannot *grow* an ITT.

Quoted 5 lines

On the IWB driver code that I could not post I noticed that it is true that the .prepare callback is called on a per-interrupt basis but the vector size is the domain size (ie number of wires) which is correct AFAICS, so the ITT size should be fine I don't get why it would need to grow.

Look again. The only reason you are getting something that *looks* correct is that its_pmsi_prepare() has this nugget:

Quoted 6 lines
	/* Allocate at least 32 MSIs, and always as a power of 2 */
	nvec = max_t(int, 32, roundup_pow_of_two(nvec));

and that the IWB is, conveniently, in sets of 32. However, the caller of this function (__msi_domain_alloc_irqs()) passes a nvec value that is always exactly *1* when allocating an interrupt.

nvec is one but this does not work for the reason above, it works because of AFAICS (for the IWB set-up I have):

	msi_info = msi_get_domain_info(domain);
	if (msi_info->hwsize > nvec)
		nvec = msi_info->hwsize;
Quoted 3 lines

So you're just lucky that I picked a minimum ITT size that matches the IWB on your model.

Not really, we test with wires above 32, we end up calling .prepare() with the precise number of wires, don't know why that does not work for the MBIgen (possibly because the interrupt-controller platform devices are children of the "main" MBIgen platform device ? The IWB one is created by OF code, MBIgen has to create children, maybe that's what is going wrong with the device/domain hierarchy ?).

Quoted 2 lines

Configure your IWB to be, let's say, 256 interrupts and use the last one, and you'll have a very different behaviour.

See above.

Quoted 6 lines
Quoted 2 lines

The difference with this series is that on v3 LPIs are allocated on .prepare(), we allocate them on .alloc().

Absolutely not. Even on v3, we never allocate LPIs in .prepare(). We allocate the ITT, perform the MAPD, and that's it. That's why it's called *prepare*.

I supposed that's what its_lpi_alloc() does in its_create_device() but OK, won't mention that any further.

Quoted 10 lines
Quoted 3 lines

So yes, calling .prepare on a per-interrupt basis looks like a bug but if we allow reusing a deviceID (ie the "shared" thingy) it could be harmless.

Harmless? No. It is really *bad*. It means you lose any sort of sane tracking of what owns the ITT and how you can free things. Seeing a devid twice is the admission that we have no idea of what is going on.

GICv3 is already in that sorry state, but I am hopeful that GICv5 can be a bit less crap.

Well, GICv5 will have to cope with designs, hopefully deviceIDs sharing is a thing of the past I am not eulogizing the concept :)

Quoted 9 lines
Quoted 9 lines
Quoted 8 lines

So this code needs to be taken to the backyard and beaten into shape before we can make use of it. My D05 (with its collection of MBIGENs) only works by accident at the moment, as I found out yesterday, and GICv5 IWB is in the same boat, since it reuses the msi-parent thing, and therefore the same heuristic.

I guess not having the IWB immediately isn't too big a deal, but I really didn't expect to find this...

Quoted 7 lines
Quoted 4 lines

To be honest, it was expected. We found these snags while designing the code (that explains how IWB was structured in v1 - by the way) but we didn't know if the behaviour above was by construction, we always thought "we must be making a mistake".

Then why didn't you report it? We could have caught this very early on, before the fscked-up code was in a stable release...

We spotted it late March - planned to discuss the IWB design while reviewing v5.

Thanks,
Lorenzo