Arm GICv5: Host driver implementation
Subsystems (6)
Lorenzo Pieralisi
maintainerv4 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 reworked to match an MBIgen like interface, that is now being fixed, code fixing it was taken from this branch, driver was rebased on top of it:
git://git.kernel.org/pub/scm/linux/kernel/git/maz/arm-platforms.git irq/msi-prepare-teardown
=============
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 reworked to match an MBIgen like interface, that is now being fixed, code fixing it was taken from this branch, driver was rebased on top of it:
git://git.kernel.org/pub/scm/linux/kernel/git/maz/arm-platforms.git irq/msi-prepare-teardown
===================
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 v4:
- Added IWB new driver version based on MBIgen interface
- Added MSI alloc flag
- Rebased against git://git.kernel.org/pub/scm/linux/kernel/git/maz/arm-platforms.git irq/msi-prepare-teardown
- Made more coding style updates to comply with tip-maintainer
guidelines
- Updated PPI type handling
- Updated devicetree bindings
- Fixed includecheck warning
- Link to v3: https://lore.kernel.org/r/[email protected]
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 (25):
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 irqchip/gic-v5: Add GICv5 IWB support
arm64: Kconfig: Enable GICv5
Marc Zyngier (1):
arm64: smp: Support non-SGIs for IPIs
.../interrupt-controller/arm,gic-v5-iwb.yaml | 78 ++ .../bindings/interrupt-controller/arm,gic-v5.yaml | 202 ++++ 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 | 71 +- 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 | 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 | 818 +++++++++++++ drivers/irqchip/irq-gic-v5-its.c | 1205 ++++++++++++++++++++ drivers/irqchip/irq-gic-v5-iwb.c | 285 +++++ drivers/irqchip/irq-gic-v5.c | 1076 +++++++++++++++++ drivers/irqchip/irq-gic.c | 2 +- include/asm-generic/msi.h | 1 + include/linux/irqchip/arm-gic-v5.h | 396 +++++++ 25 files changed, 4857 insertions(+), 69 deletions(-)
---
base-commit: 7c651847bdce43bd9fdfc4311ccbe271c06968ed
change-id: 20250408-gicv5-host-749f316afe84
Best regards,
Signature · 1 line
Lorenzo Pieralisi <[email protected]>
Lorenzo Pieralisi
maintainerPATCH v4 1/26 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.
--- .../interrupt-controller/arm,gic-v5-iwb.yaml | 78 ++++++++ .../bindings/interrupt-controller/arm,gic-v5.yaml | 202 +++++++++++++++++++++ MAINTAINERS | 7 + 3 files changed, 287 insertions(+)
Documentation/devicetree/bindings/interrupt-controller/arm,gic-v5-iwb.yaml new file +78 -0
@@ -0,0 +1,78 @@ +# 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 + + reg: + items: + - description: IWB control frame + + "#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 + + interrupt-controller: true + + msi-parent: + maxItems: 1 + +required: + - compatible + - reg + - "#interrupt-cells" + - interrupt-controller + - msi-parent + +additionalProperties: false + +examples: + - | + interrupt-controller@2f000000 { + compatible = "arm,gic-v5-iwb"; + reg = <0x2f000000 0x10000>; + + #address-cells = <0>; + + #interrupt-cells = <2>; + interrupt-controller; + + msi-parent = <&its0 64>; + }; +...
Documentation/devicetree/bindings/interrupt-controller/arm,gic-v5.yaml new file +202 -0
202 lines not on this page · raw message
MAINTAINERS +7 -0
@@ -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
Re: [PATCH v4 01/26] dt-bindings: interrupt-controller: Add Arm GICv5
Quoted 26 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.
Signed-off-by Lorenzo Pieralisi <[email protected]>Cc Conor Dooley <[email protected]>Cc Rob Herring <[email protected]>Cc Krzysztof Kozlowski <[email protected]>Cc Marc Zyngier <[email protected]>
Quoted 6 lines
--- .../interrupt-controller/arm,gic-v5-iwb.yaml | 78 ++++++++ .../bindings/interrupt-controller/arm,gic-v5.yaml | 202 +++++++++++++++++++++ MAINTAINERS | 7 + 3 files changed, 287 insertions(+)
Lorenzo Pieralisi
maintainerRe: [PATCH v4 01/26] dt-bindings: interrupt-controller: Add Arm GICv5
In reply to Lorenzo Pieralisi[+Andre, Peter]
On Tue, May 13, 2025 at 07:47:54PM +0200, Lorenzo Pieralisi wrote:
[...]
Quoted 89 lines
Documentation/devicetree/bindings/interrupt-controller/arm,gic-v5.yaml new file +83
-0@@ -0,0 +1,202 @@ +# 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 + + "#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 + + interrupt-controller: true + + interrupts: + description: + The VGIC maintenance interrupt. + maxItems: 1 + +required: + - compatible + - "#address-cells" + - "#size-cells" + - ranges + - "#interrupt-cells" + - interrupt-controller + +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. +
Documentation/devicetree/bindings/interrupt-controller/arm,gic-v5.yaml line 93
Quoted 10 lines
Documentation/devicetree/bindings/interrupt-controller/arm,gic-v5.yaml new file +10
-0+ additionalProperties: false + + properties: + compatible: + const: arm,gic-v5-irs + + reg: + minItems: 1 + items: + - description: IRS control frame
I came across it while testing EL3 firmware, raising the topic for discussion.
The IRS (and the ITS) has a config frame (need to patch the typo s/control/config, already done) per interrupt domain supported, that is, it can have up to 4 config frames:
- EL3
- Secure
- Realm
- Non-Secure
The one described in this binding is the non-secure one.
IIUC, everything described in the DT represents the non-secure address space. Two questions:
- I don't have to spell out the IRS/ITS config frame (and SETLPI, by the way) as non-secure, since that's implicit, is that correct ?
- How can the schema describe, if present, EL3, Secure and Realm frames ?
It would be good if this schema could be reused in firmware to describe the platform, for that to happen we need to have the questions above resolved.
Thanks,
Lorenzo
Quoted 131 lines
Documentation/devicetree/bindings/interrupt-controller/arm,gic-v5.yaml new file +109
-0+ - description: IRS setlpi frame + + "#address-cells": + enum: [ 1, 2 ] + + "#size-cells": + enum: [ 1, 2 ] + + 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. + + 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 + + reg: + items: + - description: ITS control frame + - description: ITS translate frame + + dma-noncoherent: + description: + Present if the GIC ITS permits programming shareability and + cacheability attributes but is connected to a non-coherent + downstream interconnect. + + "#msi-cells": + description: + The single msi-cell is the DeviceID of the device which will + generate the MSI. + const: 1 + + msi-controller: true + + required: + - compatible + - reg + - "#msi-cells" + - msi-controller + + required: + - compatible + - reg + - cpus + - arm,iaffids + +additionalProperties: false + +examples: + - | + interrupt-controller { + compatible = "arm,gic-v5"; + + #interrupt-cells = <3>; + interrupt-controller; + + #address-cells = <1>; + #size-cells = <1>; + ranges; + + interrupts = <1 25 4>; + + irs@2f1a0000 { + compatible = "arm,gic-v5-irs"; + reg = <0x2f1a0000 0x10000>; // IRS_CONFIG_FRAME for NS + + #address-cells = <1>; + #size-cells = <1>; + ranges; + + cpus = <&cpu0>, <&cpu1>, <&cpu2>, <&cpu3>, <&cpu4>, <&cpu5>, <&cpu6>, <&cpu7>; + arm,iaffids = /bits/ 16 <0 1 2 3 4 5 6 7>; + + msi-controller@2f120000 { + compatible = "arm,gic-v5-its"; + reg = <0x2f120000 0x10000>, // ITS_CONFIG_FRAME for NS + <0x2f130000 0x10000>; // ITS_TRANSLATE_FRAME + + #msi-cells = <1>; + msi-controller; + + }; + }; + }; +...MAINTAINERS +7
-0@@ -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: SupportedSignature · 2 lines
-- 2.48.0
Re: [PATCH v4 01/26] dt-bindings: interrupt-controller: Add Arm GICv5
Quoted 21 lines · Lorenzo Pieralisi
[+Andre, Peter]
Documentation/devicetree/bindings/interrupt-controller/arm,gic-v5.yaml line 93
Quoted 4 lines · Lorenzo Pieralisi
Documentation/devicetree/bindings/interrupt-controller/arm,gic-v5.yaml new file +4
-0+ reg: + minItems: 1 + items: + - description: IRS control frameI came across it while testing EL3 firmware, raising the topic for discussion.
The IRS (and the ITS) has a config frame (need to patch the typo s/control/config, already done) per interrupt domain supported, that is, it can have up to 4 config frames:
- EL3
- Secure
- Realm
- Non-Secure
Quoted 4 lines
The one described in this binding is the non-secure one.
IIUC, everything described in the DT represents the non-secure address space.
The dt bindings do allow for describing Secure-world devices:Documentation/devicetree/bindings/arm/secure.txt has the details. We use this in QEMU so we can provide a DTB to guest EL3 firmware that tells it where the hardware is (and which EL3 can then pass on to an NS kernel). It would be helpful for the GICv5 binding to be defined in a way that we can do this for a GICv5 system too.
Quoted 4 lines
Two questions:
- I don't have to spell out the IRS/ITS config frame (and SETLPI, by the way) as non-secure, since that's implicit, is that correct ?
Do you want the DT binding to handle the case of "CPU and GIC do not implement EL3, and the only implemented security state is Secure" without the kernel needing to do something different from "ditto ditto but the only implemented security state is Nonsecure" ? (Currently booting.html says you must be in NS, so we effectively say we don't support booting on this particular unicorn :-) But the secure.txt bindings envisage "kernel got booted in S", mostly for the benefit of aarch32.)
Quoted 1 line
- How can the schema describe, if present, EL3, Secure and Realm frames ?
The tempting thing to do is to have regs[] list the frames in some given order, but the spec makes them not simple supersets, allowing all of:
* NS
* S
* NS, S, EL3
* NS, Realm, EL3
* NS, Realm, S, EL3
secure.txt says:
# The general principle of the naming scheme for Secure world bindings
# is that any property that needs a different value in the Secure world # can be supported by prefixing the property name with "secure-". So for # instance "secure-foo" would override "foo".
So maybe we could have
reg : the NS frame(s)
secure-reg : the S frame(s)
realm-reg : the Realm frame(s)
root-reg : the EL3 frame(s)
??
thanks
-- PMM
Lorenzo Pieralisi
maintainerRe: [PATCH v4 01/26] dt-bindings: interrupt-controller: Add Arm GICv5
Quoted 37 lines · Peter Maydell
Quoted 21 lines · Lorenzo Pieralisi
[+Andre, Peter]
Documentation/devicetree/bindings/interrupt-controller/arm,gic-v5.yaml line 93
Quoted 4 lines · Lorenzo Pieralisi
Documentation/devicetree/bindings/interrupt-controller/arm,gic-v5.yaml new file +4
-0+ reg: + minItems: 1 + items: + - description: IRS control frameI came across it while testing EL3 firmware, raising the topic for discussion.
The IRS (and the ITS) has a config frame (need to patch the typo s/control/config, already done) per interrupt domain supported, that is, it can have up to 4 config frames:
- EL3
- Secure
- Realm
- Non-SecureQuoted 4 lines
The one described in this binding is the non-secure one.
IIUC, everything described in the DT represents the non-secure address space.
The dt bindings do allow for describing Secure-world devices:
Documentation/devicetree/bindings/arm/secure.txthas the details. We use this in QEMU so we can provide a DTB to guest EL3 firmware that tells it where the hardware is (and which EL3 can then pass on to an NS kernel). It would be helpful for the GICv5 binding to be defined in a way that we can do this for a GICv5 system too.Quoted 2 lines
Two questions:
Quoted 7 lines
Quoted 2 lines
- I don't have to spell out the IRS/ITS config frame (and SETLPI, by the way) as non-secure, since that's implicit, is that correct ?
Do you want the DT binding to handle the case of "CPU and GIC do not implement EL3, and the only implemented security state is Secure" without the kernel needing to do something different from "ditto ditto but the only implemented security state is Nonsecure" ?
Not sure I follow you here sorry :)
Quoted 22 lines
(Currently booting.html says you must be in NS, so we effectively say we don't support booting on this particular unicorn :-) But the secure.txt bindings envisage "kernel got booted in S", mostly for the benefit of aarch32.)
Quoted 1 line
- How can the schema describe, if present, EL3, Secure and Realm frames ?
The tempting thing to do is to have regs[] list the frames in some given order, but the spec makes them not simple supersets, allowing all of:
* NS
* S
* NS, S, EL3
* NS, Realm, EL3
* NS, Realm, S, EL3secure.txt says:
# The general principle of the naming scheme for Secure world bindings# is that any property that needs a different value in the Secure world # can be supported by prefixing the property name with "secure-". So for # instance "secure-foo" would override "foo".
Quoted 7 lines
So maybe we could have
reg : the NS frame(s)
secure-reg : the S frame(s)
realm-reg : the Realm frame(s)
root-reg : the EL3 frame(s)??
I assume someone has to write the root/realm binding extensions.
In Documentation/devicetree/bindings/arm/secure.txt I don't think that reg is a contemplated property - I don't know if the list of properties is up-to-date.
If what you suggest is OK, is it really needed to add the {secure/realm/root}-reg property to this binding ?
Or implicitly a, say, realm-reg property is allowed using the yet-to-be-written realm.txt rules ?
This would also slightly change the "required" properties, a "reg" property would not be required if eg the GIC does not implement a NS interrupt domain (but we would require a secure-reg if it implements a secure interrupt domain). I am making this up, obviously, I don't know what's best to do here.
Lorenzo
Re: [PATCH v4 01/26] dt-bindings: interrupt-controller: Add Arm GICv5
Quoted 14 lines · Lorenzo Pieralisi
Quoted 13 lines · Peter Maydell
The dt bindings do allow for describing Secure-world devices:
Documentation/devicetree/bindings/arm/secure.txthas the details. We use this in QEMU so we can provide a DTB to guest EL3 firmware that tells it where the hardware is (and which EL3 can then pass on to an NS kernel). It would be helpful for the GICv5 binding to be defined in a way that we can do this for a GICv5 system too.Quoted 4 lines
Two questions:
- I don't have to spell out the IRS/ITS config frame (and SETLPI, by the way) as non-secure, since that's implicit, is that correct ?
Quoted 6 lines
Quoted 4 lines
Do you want the DT binding to handle the case of "CPU and GIC do not implement EL3, and the only implemented security state is Secure" without the kernel needing to do something different from "ditto ditto but the only implemented security state is Nonsecure" ?
Not sure I follow you here sorry :)
In a hypothetical system like that the dt could either define the (only) IRS frame in reg[], or in secure-reg[]. The former would let the kernel not care about the fact it was in Secure, but would be a bit weird. But I think we can probably ignore this hypothetical in favour of keeping the binding simple.
Quoted 28 lines
Quoted 28 lines
(Currently booting.html says you must be in NS, so we effectively say we don't support booting on this particular unicorn :-) But the secure.txt bindings envisage "kernel got booted in S", mostly for the benefit of aarch32.)
Quoted 1 line
- How can the schema describe, if present, EL3, Secure and Realm frames ?
The tempting thing to do is to have regs[] list the frames in some given order, but the spec makes them not simple supersets, allowing all of:
* NS
* S
* NS, S, EL3
* NS, Realm, EL3
* NS, Realm, S, EL3secure.txt says:
# The general principle of the naming scheme for Secure world bindings# is that any property that needs a different value in the Secure world # can be supported by prefixing the property name with "secure-". So for # instance "secure-foo" would override "foo".So maybe we could have
reg : the NS frame(s)
secure-reg : the S frame(s)
realm-reg : the Realm frame(s)
root-reg : the EL3 frame(s)
Quoted 7 lines
Quoted 1 line
??
I assume someone has to write the root/realm binding extensions.
In
Documentation/devicetree/bindings/arm/secure.txtI don't think that reg is a contemplated property - I don't know if the list of properties is up-to-date.
It's up to date in the sense that so far we've only needed to have the 'status' property have a secure- variant. My suggestion here is that we might extend that to also allow secure-reg, and to have root- and realm- prefixes too. Though I don't think we would want to permit secure-reg for any old device, so maybe something more-GICv5-specific would work better.
thanks
-- PMM
Lorenzo Pieralisi
maintainerRe: [PATCH v4 01/26] dt-bindings: interrupt-controller: Add Arm GICv5
[+Suzuki]
Quoted 64 lines · Peter Maydell
Quoted 14 lines · Lorenzo Pieralisi
Quoted 13 lines · Peter Maydell
The dt bindings do allow for describing Secure-world devices:
Documentation/devicetree/bindings/arm/secure.txthas the details. We use this in QEMU so we can provide a DTB to guest EL3 firmware that tells it where the hardware is (and which EL3 can then pass on to an NS kernel). It would be helpful for the GICv5 binding to be defined in a way that we can do this for a GICv5 system too.Quoted 4 lines
Two questions:
- I don't have to spell out the IRS/ITS config frame (and SETLPI, by the way) as non-secure, since that's implicit, is that correct ?
Quoted 6 lines
Quoted 4 lines
Do you want the DT binding to handle the case of "CPU and GIC do not implement EL3, and the only implemented security state is Secure" without the kernel needing to do something different from "ditto ditto but the only implemented security state is Nonsecure" ?
Not sure I follow you here sorry :)
In a hypothetical system like that the dt could either define the (only) IRS frame in reg[], or in secure-reg[]. The former would let the kernel not care about the fact it was in Secure, but would be a bit weird. But I think we can probably ignore this hypothetical in favour of keeping the binding simple.
Quoted 28 lines
Quoted 28 lines
(Currently booting.html says you must be in NS, so we effectively say we don't support booting on this particular unicorn :-) But the secure.txt bindings envisage "kernel got booted in S", mostly for the benefit of aarch32.)
Quoted 1 line
- How can the schema describe, if present, EL3, Secure and Realm frames ?
The tempting thing to do is to have regs[] list the frames in some given order, but the spec makes them not simple supersets, allowing all of:
* NS
* S
* NS, S, EL3
* NS, Realm, EL3
* NS, Realm, S, EL3secure.txt says:
# The general principle of the naming scheme for Secure world bindings# is that any property that needs a different value in the Secure world # can be supported by prefixing the property name with "secure-". So for # instance "secure-foo" would override "foo".So maybe we could have
reg : the NS frame(s)
secure-reg : the S frame(s)
realm-reg : the Realm frame(s)
root-reg : the EL3 frame(s)Quoted 7 lines
Quoted 1 line
??
I assume someone has to write the root/realm binding extensions.
In
Documentation/devicetree/bindings/arm/secure.txtI don't think that reg is a contemplated property - I don't know if the list of properties is up-to-date.
Quoted 7 lines
It's up to date in the sense that so far we've only needed to have the 'status' property have a secure- variant. My suggestion here is that we might extend that to also allow secure-reg, and to have root- and realm- prefixes too. Though I don't think we would want to permit secure-reg for any old device, so maybe something more-GICv5-specific would work better.
I am not sure this is a GICv5 only requirement (looking at SMMUv3, for instance and there might be more IPs that require security state awareness).
Or maybe it is a non-existing problem IIUC the paragraph below correctly (albeit to be frank I don't understand how to determine whether a dtb is consumed by eg secure-world-only).
"Note that it is still valid for bindings intended for purely Secure world consumers (like kernels that run entirely in Secure) to simply describe the view of Secure world using the standard bindings. These secure- bindings only need to be used where both the Secure and Normal world views need to be described in a single device tree."
I assume "standard bindings" there would mean that "reg" for the GICv5 would be just eg "config frame" with no NS/S/Realm/Root attached.
We don't strictly need to have the same dts file for NS and S (example), NS will never "need" the S bindings at least for GICv5.
Thoughts ?
Thanks,
Lorenzo
Re: [PATCH v4 01/26] dt-bindings: interrupt-controller: Add Arm GICv5
Quoted 12 lines · Lorenzo Pieralisi
[+Suzuki]
Quoted 7 lines · Peter Maydell
It's up to date in the sense that so far we've only needed to have the 'status' property have a secure- variant. My suggestion here is that we might extend that to also allow secure-reg, and to have root- and realm- prefixes too. Though I don't think we would want to permit secure-reg for any old device, so maybe something more-GICv5-specific would work better.
Quoted 3 lines
I am not sure this is a GICv5 only requirement (looking at SMMUv3, for instance and there might be more IPs that require security state awareness).
For the SMMUv3 I think we're OK, because there's no separate set of base SMMU registers for S vs NS; there are Secure VATOS registers and a Secure Command queue control page, but those addresses are discoverable by looking at SMMU registers so they don't need to be encoded in the DT.
Quoted 9 lines
Or maybe it is a non-existing problem IIUC the paragraph below correctly (albeit to be frank I don't understand how to determine whether a dtb is consumed by eg secure-world-only).
"Note that it is still valid for bindings intended for purely Secure world consumers (like kernels that run entirely in Secure) to simply describe the view of Secure world using the standard bindings. These secure- bindings only need to be used where both the Secure and Normal world views need to be described in a single device tree."
The purpose of this paragraph is to cover situations like the old versatile express cortex-a9 board, where the firmware booted the kernel in the Secure world. The kernel didn't care about that, the (non-autogenerated) device tree just told it where the devices were (and didn't mark them up with secure-status or anything). That setup (and the dts files for it) pre-date the addition of this secure-status binding documentation. The text is just saying that it isn't making that pre-existing setup retrospectively non-compliant.
Quoted 2 lines
I assume "standard bindings" there would mean that "reg" for the GICv5 would be just eg "config frame" with no NS/S/Realm/Root attached.
Yes, in the (hypothetical) GICv5 case the dt for a "boot in Secure" system would give the address of the Secure config frame.
Quoted 2 lines
We don't strictly need to have the same dts file for NS and S (example), NS will never "need" the S bindings at least for GICv5.
One common workflow is that EL3 firmware is passed a DTB, consumes it for its own purposes and passes it on to the NS kernel mostly untouched. This is particularly useful for QEMU where the DTB might have been autogenerated. So you do want to be able to express what EL3 needs and what NS needs in one DT.
thanks
-- PMM
Lorenzo Pieralisi
maintainerRe: [PATCH v4 01/26] dt-bindings: interrupt-controller: Add Arm GICv5
In reply to Peter MaydellQuoted 27 lines · Peter Maydell
Quoted 21 lines · Lorenzo Pieralisi
[+Andre, Peter]
Documentation/devicetree/bindings/interrupt-controller/arm,gic-v5.yaml line 93
Quoted 4 lines · Lorenzo Pieralisi
Documentation/devicetree/bindings/interrupt-controller/arm,gic-v5.yaml new file +4
-0+ reg: + minItems: 1 + items: + - description: IRS control frameI came across it while testing EL3 firmware, raising the topic for discussion.
The IRS (and the ITS) has a config frame (need to patch the typo s/control/config, already done) per interrupt domain supported, that is, it can have up to 4 config frames:
- EL3
- Secure
- Realm
- Non-SecureQuoted 4 lines
The one described in this binding is the non-secure one.
IIUC, everything described in the DT represents the non-secure address space.
Quoted 7 lines
The dt bindings do allow for describing Secure-world devices:
Documentation/devicetree/bindings/arm/secure.txthas the details. We use this in QEMU so we can provide a DTB to guest EL3 firmware that tells it where the hardware is (and which EL3 can then pass on to an NS kernel). It would be helpful for the GICv5 binding to be defined in a way that we can do this for a GICv5 system too.
It would be good to understand what DT {should/should not} describe and whether this DT usage to configure firmware is under the DT maintainers radar or it is an attempt at reusing it to avoid implementing a configuration scheme.
Rob, Krzysztof,
Any thoughts on the matter please ?
[...]
Quoted 8 lines
The tempting thing to do is to have regs[] list the frames in some given order, but the spec makes them not simple supersets, allowing all of:
* NS
* S
* NS, S, EL3
* NS, Realm, EL3
* NS, Realm, S, EL3
Maybe reg-names can help ? Even though first we need to understand what resources should be described in DT.
Current bindings are reviewed and I am not keen on dragging this discussion on forever - the information the kernel requires is there, I'd like to bring this to a close.
Thanks,
Lorenzo
Quoted 17 lines
secure.txt says:
# The general principle of the naming scheme for Secure world bindings# is that any property that needs a different value in the Secure world # can be supported by prefixing the property name with "secure-". So for # instance "secure-foo" would override "foo".So maybe we could have
reg : the NS frame(s)
secure-reg : the S frame(s)
realm-reg : the Realm frame(s)
root-reg : the EL3 frame(s)??
thanks
-- PMM
Re: [PATCH v4 01/26] dt-bindings: interrupt-controller: Add Arm GICv5
Quoted 10 lines · Lorenzo Pieralisi
Quoted 7 lines · Peter Maydell
The dt bindings do allow for describing Secure-world devices:
Documentation/devicetree/bindings/arm/secure.txthas the details. We use this in QEMU so we can provide a DTB to guest EL3 firmware that tells it where the hardware is (and which EL3 can then pass on to an NS kernel). It would be helpful for the GICv5 binding to be defined in a way that we can do this for a GICv5 system too.
Quoted 4 lines
It would be good to understand what DT {should/should not} describe and whether this DT usage to configure firmware is under the DT maintainers radar or it is an attempt at reusing it to avoid implementing a configuration scheme.
It is definitely on the radar, not under it -- that is the whole reason that we went to the effort to agree and document secure.txt in the upstream binding documentation :-)
-- PMM
Rob Herring
maintainerRe: [PATCH v4 01/26] dt-bindings: interrupt-controller: Add Arm GICv5
In reply to Lorenzo PieralisiQuoted 37 lines · Lorenzo Pieralisi
Quoted 27 lines · Peter Maydell
Quoted 21 lines · Lorenzo Pieralisi
[+Andre, Peter]
Documentation/devicetree/bindings/interrupt-controller/arm,gic-v5.yaml line 93
Quoted 4 lines · Lorenzo Pieralisi
Documentation/devicetree/bindings/interrupt-controller/arm,gic-v5.yaml new file +4
-0+ reg: + minItems: 1 + items: + - description: IRS control frameI came across it while testing EL3 firmware, raising the topic for discussion.
The IRS (and the ITS) has a config frame (need to patch the typo s/control/config, already done) per interrupt domain supported, that is, it can have up to 4 config frames:
- EL3
- Secure
- Realm
- Non-SecureQuoted 4 lines
The one described in this binding is the non-secure one.
IIUC, everything described in the DT represents the non-secure address space.
Quoted 7 lines
The dt bindings do allow for describing Secure-world devices:
Documentation/devicetree/bindings/arm/secure.txthas the details. We use this in QEMU so we can provide a DTB to guest EL3 firmware that tells it where the hardware is (and which EL3 can then pass on to an NS kernel). It would be helpful for the GICv5 binding to be defined in a way that we can do this for a GICv5 system too.
Quoted 8 lines
It would be good to understand what DT {should/should not} describe and whether this DT usage to configure firmware is under the DT maintainers radar or it is an attempt at reusing it to avoid implementing a configuration scheme.
Rob, Krzysztof,
Any thoughts on the matter please ?
I'm all for firmware using DT, but using a single DT for all components with an ABI between all components is an impractical dream. You can take that a step further even with a single DT for all processors in a system (aka System DT). Ultimately, the DT is a view of the system for a client (OS). Different views may need different DTs.
u-boot and Linux sharing a DT makes sense as they have the same world view. Secure and NS not so much.
Quoted 14 lines
[...]
Quoted 8 lines
The tempting thing to do is to have regs[] list the frames in some given order, but the spec makes them not simple supersets, allowing all of:
* NS
* S
* NS, S, EL3
* NS, Realm, EL3
* NS, Realm, S, EL3Maybe reg-names can help ? Even though first we need to understand what resources should be described in DT.
Quoted 13 lines
Current bindings are reviewed and I am not keen on dragging this discussion on forever - the information the kernel requires is there, I'd like to bring this to a close.
Thanks,
LorenzoQuoted 6 lines
secure.txt says:
# The general principle of the naming scheme for Secure world bindings# is that any property that needs a different value in the Secure world # can be supported by prefixing the property name with "secure-". So for # instance "secure-foo" would override "foo".
Today I would say a 'secure-' prefix is a mistake. To my knowledge, it's never been used anyways. But I don't have much visibility into what secure world firmware is doing.
Quoted 6 lines
Quoted 6 lines
So maybe we could have
reg : the NS frame(s)
secure-reg : the S frame(s)
realm-reg : the Realm frame(s)
root-reg : the EL3 frame(s)
Here's why. It really doesn't scale.
Rob
Re: [PATCH v4 01/26] dt-bindings: interrupt-controller: Add Arm GICv5
Quoted 10 lines · Rob Herring
Quoted 7 lines · Lorenzo Pieralisi
Quoted 5 lines · Peter Maydell
secure.txt says:
# The general principle of the naming scheme for Secure world bindings# is that any property that needs a different value in the Secure world # can be supported by prefixing the property name with "secure-". So for # instance "secure-foo" would override "foo".
Quoted 3 lines
Today I would say a 'secure-' prefix is a mistake. To my knowledge, it's never been used anyways. But I don't have much visibility into what secure world firmware is doing.
QEMU uses it for communicating with the secure firmware if you run secure firmware on the virt board. It's done that since we introduced that binding. Indeed that use case is *why* the binding is there. It works fine for the intended purpose, which is "most devices are visible in both S and NS, but a few things are S only (UART, a bit of RAM, secure-only flash").
-- PMM
Rob Herring
maintainerRe: [PATCH v4 01/26] dt-bindings: interrupt-controller: Add Arm GICv5
Quoted 16 lines · Peter Maydell
Quoted 10 lines · Rob Herring
Quoted 7 lines · Lorenzo Pieralisi
Quoted 5 lines · Peter Maydell
secure.txt says:
# The general principle of the naming scheme for Secure world bindings# is that any property that needs a different value in the Secure world # can be supported by prefixing the property name with "secure-". So for # instance "secure-foo" would override "foo".Quoted 3 lines
Today I would say a 'secure-' prefix is a mistake. To my knowledge, it's never been used anyways. But I don't have much visibility into what secure world firmware is doing.
Quoted 6 lines
QEMU uses it for communicating with the secure firmware if you run secure firmware on the virt board. It's done that since we introduced that binding. Indeed that use case is *why* the binding is there. It works fine for the intended purpose, which is "most devices are visible in both S and NS, but a few things are S only (UART, a bit of RAM, secure-only flash").
I meant "secure-" as a prefix allowed on *any* property, not "secure-status" specifically, which is the only thing QEMU uses AFAICT. IOW, I don't think we should be creating secure-reg, secure-interrupts, secure-clocks, etc.
Rob
Lorenzo Pieralisi
maintainerRe: [PATCH v4 01/26] dt-bindings: interrupt-controller: Add Arm GICv5
Quoted 24 lines · Rob Herring
Quoted 16 lines · Peter Maydell
Quoted 10 lines · Rob Herring
Quoted 7 lines · Lorenzo Pieralisi
Quoted 5 lines · Peter Maydell
secure.txt says:
# The general principle of the naming scheme for Secure world bindings# is that any property that needs a different value in the Secure world # can be supported by prefixing the property name with "secure-". So for # instance "secure-foo" would override "foo".Quoted 3 lines
Today I would say a 'secure-' prefix is a mistake. To my knowledge, it's never been used anyways. But I don't have much visibility into what secure world firmware is doing.
Quoted 6 lines
QEMU uses it for communicating with the secure firmware if you run secure firmware on the virt board. It's done that since we introduced that binding. Indeed that use case is *why* the binding is there. It works fine for the intended purpose, which is "most devices are visible in both S and NS, but a few things are S only (UART, a bit of RAM, secure-only flash").
Quoted 4 lines
I meant "secure-" as a prefix allowed on *any* property, not "secure-status" specifically, which is the only thing QEMU uses AFAICT. IOW, I don't think we should be creating secure-reg, secure-interrupts, secure-clocks, etc.
Reading secure.txt, what does it mean "device present and usable in the secure world" ?
So:
status = "disabled"
secure-status = "okay"
basically means that the device in question allows secure-only MMIO access, is that what it says ?
If that's the case and we really want to have all config frames in a single DT, would it be reasonable to have an IRS/ITS DT node per-frame ?
Then yes, the secure- tag is not enough any longer (because we have to cope with 4 interrupt domains) but that's a separate problem - again, this would leave the current reviewed bindings unchanged.
Other than that as I mentioned we could use (? aka clutching at straws) reg-names but I don't think it is correct to have in the DT address space that the CPU is not allowed to address.
Lorenzo
Marc Zyngier
maintainerRe: [PATCH v4 01/26] dt-bindings: interrupt-controller: Add Arm GICv5
Quoted 42 lines · Lorenzo Pieralisi
Quoted 24 lines · Rob Herring
Quoted 16 lines · Peter Maydell
Quoted 10 lines · Rob Herring
Quoted 7 lines · Lorenzo Pieralisi
Quoted 5 lines · Peter Maydell
secure.txt says:
# The general principle of the naming scheme for Secure world bindings# is that any property that needs a different value in the Secure world # can be supported by prefixing the property name with "secure-". So for # instance "secure-foo" would override "foo".Quoted 3 lines
Today I would say a 'secure-' prefix is a mistake. To my knowledge, it's never been used anyways. But I don't have much visibility into what secure world firmware is doing.
Quoted 6 lines
QEMU uses it for communicating with the secure firmware if you run secure firmware on the virt board. It's done that since we introduced that binding. Indeed that use case is *why* the binding is there. It works fine for the intended purpose, which is "most devices are visible in both S and NS, but a few things are S only (UART, a bit of RAM, secure-only flash").
Quoted 4 lines
I meant "secure-" as a prefix allowed on *any* property, not "secure-status" specifically, which is the only thing QEMU uses AFAICT. IOW, I don't think we should be creating secure-reg, secure-interrupts, secure-clocks, etc.
Reading secure.txt, what does it mean "device present and usable in the secure world" ?
So:
status = "disabled"
secure-status = "okay"basically means that the device in question allows secure-only MMIO access, is that what it says ?
Quoted 7 lines
If that's the case and we really want to have all config frames in a single DT, would it be reasonable to have an IRS/ITS DT node per-frame ?
Then yes, the secure- tag is not enough any longer (because we have to cope with 4 interrupt domains) but that's a separate problem - again, this would leave the current reviewed bindings unchanged.
No, this is the same problem, and we need a way to address it. "secure-*" doesn't cut it in a system with FEAT_RME, where resources are only available to a single Physical Address Space (PAS). So we need a way to qualify these resources with a PAS.
Either that, or we have to restrict DT to describe the view of a single PAS. Which Peter will understandably be unhappy about.
Thanks,
M.
Signature · 1 line
Jazz isn't dead. It just smells funny.
Lorenzo Pieralisi
maintainerRe: [PATCH v4 01/26] dt-bindings: interrupt-controller: Add Arm GICv5
Quoted 48 lines · Marc Zyngier
Quoted 46 lines · Lorenzo Pieralisi
Quoted 24 lines · Rob Herring
Quoted 16 lines · Peter Maydell
Quoted 10 lines · Rob Herring
Quoted 7 lines · Lorenzo Pieralisi
Quoted 5 lines · Peter Maydell
secure.txt says:
# The general principle of the naming scheme for Secure world bindings# is that any property that needs a different value in the Secure world # can be supported by prefixing the property name with "secure-". So for # instance "secure-foo" would override "foo".Quoted 3 lines
Today I would say a 'secure-' prefix is a mistake. To my knowledge, it's never been used anyways. But I don't have much visibility into what secure world firmware is doing.
Quoted 6 lines
QEMU uses it for communicating with the secure firmware if you run secure firmware on the virt board. It's done that since we introduced that binding. Indeed that use case is *why* the binding is there. It works fine for the intended purpose, which is "most devices are visible in both S and NS, but a few things are S only (UART, a bit of RAM, secure-only flash").
Quoted 4 lines
I meant "secure-" as a prefix allowed on *any* property, not "secure-status" specifically, which is the only thing QEMU uses AFAICT. IOW, I don't think we should be creating secure-reg, secure-interrupts, secure-clocks, etc.
Reading secure.txt, what does it mean "device present and usable in the secure world" ?
So:
status = "disabled"
secure-status = "okay"basically means that the device in question allows secure-only MMIO access, is that what it says ?
If that's the case and we really want to have all config frames in a single DT, would it be reasonable to have an IRS/ITS DT node per-frame ?
Quoted 8 lines
Quoted 3 lines
Then yes, the secure- tag is not enough any longer (because we have to cope with 4 interrupt domains) but that's a separate problem - again, this would leave the current reviewed bindings unchanged.
No, this is the same problem, and we need a way to address it. "secure-*" doesn't cut it in a system with
FEAT_RME, where resources are only available to a single Physical Address Space (PAS). So we need a way to qualify these resources with a PAS.
Can I ask again what:
status = "disabled"
secure-status = "okay"
for a device means in practice in the current bindings ?
When I said "a separate problem", I meant that, extending secure- tag (that applies to the "status" property only) to cover other PASes is independent from the GICv5 binding *if* we define, for a single DT an eg IRS device per-PAS (with realm-status, root-status, describing what the reg property represents. Is that what secure-status does today ? Does it say "this device MMIO space is secure-only" ?).
It does not look like there is much appetite for tagging the reg property either and making it GICv5 specific is a shortcut IMO.
Quoted 2 lines
Either that, or we have to restrict DT to describe the view of a single PAS. Which Peter will understandably be unhappy about.
Well, I listed a couple of options in this thread, let's try to converge.
Thanks,
Lorenzo
Re: [PATCH v4 01/26] dt-bindings: interrupt-controller: Add Arm GICv5
Quoted 6 lines · Lorenzo Pieralisi
Can I ask again what:
status = "disabled"
secure-status = "okay"for a device means in practice in the current bindings ?
From software's point of view, it means "if you're NonSecure, ignore this; if you're Secure, feel free to use it".
From the point of view of something creating this DT node, the usual reason for setting up a node like that is that the device is only present in the Secure memory map, not the NS one; so marking it that way lets you tell the S firmware where the device is and also tell the NS kernel to ignore it so it doesn't try to probe for the device and fall over when it gets an exception.
Quoted 9 lines
When I said "a separate problem", I meant that, extending secure- tag (that applies to the "status" property only) to cover other PASes is independent from the GICv5 binding *if* we define, for a single DT an eg IRS device per-PAS (with realm-status, root-status, describing what the reg property represents. Is that what secure-status does today ? Does it say "this device MMIO space is secure-only" ?).
It does not look like there is much appetite for tagging the reg property either and making it GICv5 specific is a shortcut IMO.
I think something GICv5 specific is not unreasonable. secure.txt is careful to define the general principles of how the naming scheme works but then to restrict it only to the specific cases that we've blessed as OK. I think that's worked pretty well -- it's fitted the needs we have and the GICv5 is only the second time in a decade we've had to revisit and say "we also want XYZ" (the first being /secure-chosen/stdout-path, in 2018). I think that's a pretty decent track record. In adding whatever we want to do for GICv5, I agree with Rob that we don't want to accidentally open the door for more general use of secure-reg or whatever on other random devices.
thanks
-- PMM
Lorenzo Pieralisi
maintainerRe: [PATCH v4 01/26] dt-bindings: interrupt-controller: Add Arm GICv5
On Wed, Jun 04, 2025 at 09:09:27PM +0100, Peter Maydell wrote:
[...]
Quoted 11 lines
Quoted 9 lines
When I said "a separate problem", I meant that, extending secure- tag (that applies to the "status" property only) to cover other PASes is independent from the GICv5 binding *if* we define, for a single DT an eg IRS device per-PAS (with realm-status, root-status, describing what the reg property represents. Is that what secure-status does today ? Does it say "this device MMIO space is secure-only" ?).
It does not look like there is much appetite for tagging the reg property either and making it GICv5 specific is a shortcut IMO.
I think something GICv5 specific is not unreasonable.
We need to define up to 4 interrupt domains (so max 4 frames per component per frame type: EL3, Secure, Realm, Non-Secure).
Options:
1) Using reg and reg-names, I don't know if reg-names allows us to describe all possible resource names and the order does not matter, please let me know. Keep in mind that some resources are optional.
Something like, for an IRS:
reg-names = "el3-config", "secure-config", "realm-config", "non-secure-config", "el3-setlpi", "secure-setlpi", "realm-setlpi", "non-secure-setlpi";
With that, I would remove the description in the reg property and just say minItems: 1
This implicitly means that describing in DT a resource that the CPU possibly is not able to reach depending on security-state/exception level is OK. AFAICS reg-names achieves the same purpose of tagging below, at the end of the day it is a means to say eg "if you are non-secure stay away from something that does not belong to you".
2) We add a tagged "reg" property for GICv5 ("reg" refers to non-secure):
reg
el3-reg
secure-reg
realm-reg
3) We add a GICv5 tagged "status" property and define an eg IRS device per interrupt-domain ("status" refers to non-secure):
status
el3-status
secure-status
realm-status
4) Anything else that I have not thought of
What's the best option ? Please let me know, I'd like to repost the series at v6.16-rc1 with a solution.
Thanks,
Lorenzo
Lorenzo Pieralisi
maintainerRe: [PATCH v4 01/26] dt-bindings: interrupt-controller: Add Arm GICv5
In reply to Rob HerringQuoted 45 lines · Rob Herring
Quoted 44 lines · Lorenzo Pieralisi
Quoted 27 lines · Peter Maydell
Quoted 21 lines · Lorenzo Pieralisi
[+Andre, Peter]
Documentation/devicetree/bindings/interrupt-controller/arm,gic-v5.yaml line 93
Quoted 4 lines · Lorenzo Pieralisi
Documentation/devicetree/bindings/interrupt-controller/arm,gic-v5.yaml new file +4
-0+ reg: + minItems: 1 + items: + - description: IRS control frameI came across it while testing EL3 firmware, raising the topic for discussion.
The IRS (and the ITS) has a config frame (need to patch the typo s/control/config, already done) per interrupt domain supported, that is, it can have up to 4 config frames:
- EL3
- Secure
- Realm
- Non-SecureQuoted 4 lines
The one described in this binding is the non-secure one.
IIUC, everything described in the DT represents the non-secure address space.
Quoted 7 lines
The dt bindings do allow for describing Secure-world devices:
Documentation/devicetree/bindings/arm/secure.txthas the details. We use this in QEMU so we can provide a DTB to guest EL3 firmware that tells it where the hardware is (and which EL3 can then pass on to an NS kernel). It would be helpful for the GICv5 binding to be defined in a way that we can do this for a GICv5 system too.It would be good to understand what DT {should/should not} describe and whether this DT usage to configure firmware is under the DT maintainers radar or it is an attempt at reusing it to avoid implementing a configuration scheme.
Rob, Krzysztof,
Quoted 8 lines
Quoted 1 line
Any thoughts on the matter please ?
I'm all for firmware using DT, but using a single DT for all components with an ABI between all components is an impractical dream. You can take that a step further even with a single DT for all processors in a system (aka System DT). Ultimately, the DT is a view of the system for a client (OS). Different views may need different DTs.
Specifically, for IRS/ITS frames then - what the current schema does is correct, namely, it does _not_ spell out whether the IRS/ITS config frame is NS/S/Realm/Root interrupt domain, that's information that the client implicitly assumes.
Are we OK with this approach ? This would leave open the possibility of having a DT per security-state.
If in the DT schema I define eg reg -> "IRS NS config frame" by construction the binding can't be used for anything else.
Please let me know if we are in agreement on this matter.
Lorenzo
Quoted 45 lines
u-boot and Linux sharing a DT makes sense as they have the same world view. Secure and NS not so much.
Quoted 14 lines
[...]
Quoted 8 lines
The tempting thing to do is to have regs[] list the frames in some given order, but the spec makes them not simple supersets, allowing all of:
* NS
* S
* NS, S, EL3
* NS, Realm, EL3
* NS, Realm, S, EL3Maybe reg-names can help ? Even though first we need to understand what resources should be described in DT.
Quoted 13 lines
Current bindings are reviewed and I am not keen on dragging this discussion on forever - the information the kernel requires is there, I'd like to bring this to a close.
Thanks,
LorenzoQuoted 6 lines
secure.txt says:
# The general principle of the naming scheme for Secure world bindings# is that any property that needs a different value in the Secure world # can be supported by prefixing the property name with "secure-". So for # instance "secure-foo" would override "foo".Today I would say a 'secure-' prefix is a mistake. To my knowledge, it's never been used anyways. But I don't have much visibility into what secure world firmware is doing.
Quoted 6 lines
Quoted 6 lines
So maybe we could have
reg : the NS frame(s)
secure-reg : the S frame(s)
realm-reg : the Realm frame(s)
root-reg : the EL3 frame(s)Here's why. It really doesn't scale.
Rob
Re: [PATCH v4 01/26] dt-bindings: interrupt-controller: Add Arm GICv5
Quoted 5 lines · Lorenzo Pieralisi
Specifically, for IRS/ITS frames then - what the current schema does is correct, namely, it does _not_ spell out whether the IRS/ITS config frame is NS/S/Realm/Root interrupt domain, that's information that the client implicitly assumes.
Quoted 7 lines
Are we OK with this approach ? This would leave open the possibility of having a DT per security-state.
If in the DT schema I define eg reg -> "IRS NS config frame" by construction the binding can't be used for anything else.
Please let me know if we are in agreement on this matter.
This would break the QEMU virt board -> EL3 guest firmware -> EL1 Linux flow. We need a binding which lets us optionally specify "oh by the way here is where the other non-NS frames are". I don't have a strong view on the specific syntax.
-- PMM
Lorenzo Pieralisi
maintainerRe: [PATCH v4 01/26] dt-bindings: interrupt-controller: Add Arm GICv5
Quoted 9 lines · Peter Maydell
Quoted 8 lines · Lorenzo Pieralisi
Specifically, for IRS/ITS frames then - what the current schema does is correct, namely, it does _not_ spell out whether the IRS/ITS config frame is NS/S/Realm/Root interrupt domain, that's information that the client implicitly assumes.
Are we OK with this approach ? This would leave open the possibility of having a DT per security-state.
Quoted 8 lines
Quoted 4 lines
If in the DT schema I define eg reg -> "IRS NS config frame" by construction the binding can't be used for anything else.
Please let me know if we are in agreement on this matter.
This would break the QEMU virt board -> EL3 guest firmware -> EL1 Linux flow. We need a binding which lets us optionally specify "oh by the way here is where the other non-NS frames are".
Do we "need" a binding ? Or, it is a nice-have to help configure QEmu (and other SW components, eg bootwrapper/TF-A, etc that decided to re-use DT for their own consumption) ?
And even so, why can't we have a DT per security state as-per Rob's reply ?
Given that only the "status" property is tagged with secure- today, may I ask please how does this work ?
What's "EL3 guest firmware" ? Does it use the secure-status property to detect that the respective device is secure/non-secure ?
And why does it have to be the same dtb we are passing to the OS client ?
Quoted 1 line
I don't have a strong view on the specific syntax.
I do because I don't want to revisit this later ;-)
Thanks,
Lorenzo
Lorenzo Pieralisi
maintainerPATCH v4 2/26 arm64/sysreg: Add GCIE field to ID_AA64PFR2_EL1
In reply to Lorenzo PieralisiAdd field reporting the GCIE feature to ID_AA64PFR2_EL1 sysreg.
--- arch/arm64/tools/sysreg | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
arch/arm64/tools/sysreg +4 -1
@@ -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
Lorenzo Pieralisi
maintainerPATCH v4 3/26 arm64/sysreg: Add ICC_PPI_PRIORITY<n>_EL1
In reply to Lorenzo PieralisiAdd ICC_PPI_PRIORITY<n>_EL1 sysreg description.
--- arch/arm64/tools/sysreg | 83 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+)
arch/arm64/tools/sysreg +83 -0
@@ -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
Lorenzo Pieralisi
maintainerPATCH v4 4/26 arm64/sysreg: Add ICC_ICSR_EL1
In reply to Lorenzo PieralisiAdd ICC_ICSR_EL1 register sysreg description.
--- arch/arm64/tools/sysreg | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
arch/arm64/tools/sysreg +14 -0
@@ -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
Lorenzo Pieralisi
maintainerPATCH v4 5/26 arm64/sysreg: Add ICC_PPI_HMR<n>_EL1
In reply to Lorenzo PieralisiAdd ICC_PPI_HMR<n>_EL1 registers sysreg description.
--- arch/arm64/tools/sysreg | 75 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+)
arch/arm64/tools/sysreg +75 -0
@@ -2310,6 +2310,81 @@ Field 31 C Field 30:0 P 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 + Sysreg ICC_ICSR_EL1 3 0 12 10 4 Res0 63:48 Field 47:32 IAFFID
Signature · 1 line
2.48.0
Lorenzo Pieralisi
maintainerPATCH v4 6/26 arm64/sysreg: Add ICC_PPI_ENABLER<n>_EL1
In reply to Lorenzo PieralisiAdd ICC_PPI_ENABLER<n>_EL1 registers sysreg description.
--- arch/arm64/tools/sysreg | 75 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+)
arch/arm64/tools/sysreg +75 -0
@@ -2399,6 +2399,81 @@ Field 1 Enabled Field 0 F 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
Lorenzo Pieralisi
maintainerPATCH v4 7/26 arm64/sysreg: Add ICC_PPI_{C/S}ACTIVER<n>_EL1
In reply to Lorenzo PieralisiAdd ICC_PPI_{C/S}ACTIVER<n>_EL1 registers description.
--- arch/arm64/tools/sysreg | 83 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+)
arch/arm64/tools/sysreg +83 -0
@@ -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
Lorenzo Pieralisi
maintainerPATCH v4 8/26 arm64/sysreg: Add ICC_PPI_{C/S}PENDR<n>_EL1
In reply to Lorenzo PieralisiAdd ICC_PPI_{C/S}PENDR<n>_EL1 registers description.
--- arch/arm64/tools/sysreg | 83 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+)
arch/arm64/tools/sysreg +83 -0
@@ -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
Lorenzo Pieralisi
maintainerPATCH v4 9/26 arm64/sysreg: Add ICC_CR0_EL1
In reply to Lorenzo PieralisiAdd ICC_CR0_EL1 register description.
--- arch/arm64/tools/sysreg | 8 ++++++++ 1 file changed, 8 insertions(+)
arch/arm64/tools/sysreg +8 -0
@@ -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
Lorenzo Pieralisi
maintainerPATCH v4 10/26 arm64/sysreg: Add ICC_PCR_EL1
In reply to Lorenzo PieralisiAdd ICC_PCR_EL1 register description.
--- arch/arm64/tools/sysreg | 5 +++++ 1 file changed, 5 insertions(+)
arch/arm64/tools/sysreg +5 -0
@@ -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
Lorenzo Pieralisi
maintainerPATCH v4 11/26 arm64/sysreg: Add ICC_IDR0_EL1
In reply to Lorenzo PieralisiAdd ICC_IDR0_EL1 register description.
--- arch/arm64/tools/sysreg | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
arch/arm64/tools/sysreg +16 -0
@@ -2385,6 +2385,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 + Sysreg ICC_ICSR_EL1 3 0 12 10 4 Res0 63:48 Field 47:32 IAFFID
Signature · 1 line
2.48.0
Lorenzo Pieralisi
maintainerPATCH v4 12/26 arm64/sysreg: Add ICH_HFGRTR_EL2
In reply to Lorenzo PieralisiAdd ICH_HFGRTR_EL2 register description.
--- arch/arm64/tools/sysreg | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
arch/arm64/tools/sysreg +18 -0
@@ -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
Lorenzo Pieralisi
maintainerPATCH v4 13/26 arm64/sysreg: Add ICH_HFGWTR_EL2
In reply to Lorenzo PieralisiAdd ICH_HFGWTR_EL2 register description to sysreg.
--- arch/arm64/tools/sysreg | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
arch/arm64/tools/sysreg +15 -0
@@ -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
Lorenzo Pieralisi
maintainerPATCH v4 14/26 arm64/sysreg: Add ICH_HFGITR_EL2
In reply to Lorenzo PieralisiAdd ICH_HFGITR_EL2 register description to sysreg.
--- arch/arm64/tools/sysreg | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
arch/arm64/tools/sysreg +15 -0
@@ -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
Re: [PATCH v4 14/26] arm64/sysreg: Add ICH_HFGITR_EL2
Quoted 6 lines · On Tue, 13 May 2025 19:48:07 +0200 Lorenzo Pieralisi <[email protected]>…
Add
ICH_HFGITR_EL2register description to sysreg.Signed-off-by Lorenzo Pieralisi <[email protected]>Cc Will Deacon <[email protected]>Cc Catalin Marinas <[email protected]>Cc Marc Zyngier <[email protected]>
Hi Lorenzo,
Quoted 10 lines
--- arch/arm64/tools/sysreg | 15 +++++++++++++++ 1 file changed, 15 insertions(+)arch/arm64/tools/sysreg +0
-0@@ -3616,6 +3616,21 @@ Res0 1 Field 0 ICC_APR_EL1
arch/arm64/tools/sysreg Res0 1 · line 3626
Quoted 10 lines
arch/arm64/tools/sysreg +8
-0EndSysreg +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
GICCDRCFG in the spec. (you have a bonus R)
Of course the real question was what am I avoiding that made checking these against the spec feel like a good idea? :)
FWIW with that fixed,
for patches 2 to 14.
Quoted 11 lines
arch/arm64/tools/sysreg +7
-0+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
Lorenzo Pieralisi
maintainerRe: [PATCH v4 14/26] arm64/sysreg: Add ICH_HFGITR_EL2
Quoted 24 lines · Jonathan Cameron
Quoted 6 lines · On Tue, 13 May 2025 19:48:07 +0200 Lorenzo Pieralisi <[email protected]>…
Add
ICH_HFGITR_EL2register description to sysreg.Signed-off-by Lorenzo Pieralisi <[email protected]>Cc Will Deacon <[email protected]>Cc Catalin Marinas <[email protected]>Cc Marc Zyngier <[email protected]>Hi Lorenzo,
Quoted 12 lines
--- arch/arm64/tools/sysreg | 15 +++++++++++++++ 1 file changed, 15 insertions(+)arch/arm64/tools/sysreg +0
-0@@ -3616,6 +3616,21 @@ Res0 1 Field 0 ICC_APR_EL1 EndSysreg
Quoted 10 lines
arch/arm64/tools/sysreg Res0 1 · line 3626
Quoted 8 lines
arch/arm64/tools/sysreg +8
-0+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 GICCRDRCFGGICCDRCFG in the spec. (you have a bonus R)
Bah. Good catch - I should move to autogeneration.
Quoted 2 lines
Of course the real question was what am I avoiding that made checking these against the spec feel like a good idea? :)
:)
Quoted 3 lines
FWIW with that fixed,
Reviewed-by Jonathan Cameron <[email protected]>for patches 2 to 14.
Thanks,
Lorenzo
Quoted 12 lines
Quoted 11 lines
arch/arm64/tools/sysreg +7
-0+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
Lorenzo Pieralisi
maintainerPATCH v4 15/26 arm64: Disable GICv5 read/write/instruction traps
In reply to Lorenzo PieralisiGICv5 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.
--- arch/arm64/include/asm/el2_setup.h | 45 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+)
arch/arm64/include/asm/el2_setup.h +45 -0
@@ -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
Lorenzo Pieralisi
maintainerPATCH v4 16/26 arm64: cpucaps: Rename GICv3 CPU interface capability
In reply to Lorenzo PieralisiIn 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
@@ -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
@@ -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
@@ -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
Lorenzo Pieralisi
maintainerPATCH v4 17/26 arm64: cpucaps: Add GICv5 CPU interface (GCIE) capability
In reply to Lorenzo PieralisiImplement 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.
--- arch/arm64/kernel/cpufeature.c | 7 +++++++ arch/arm64/tools/cpucaps | 1 + 2 files changed, 8 insertions(+)
arch/arm64/kernel/cpufeature.c +7 -0
@@ -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
@@ -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
Lorenzo Pieralisi
maintainerPATCH v4 18/26 arm64: smp: Support non-SGIs for IPIs
In reply to Lorenzo PieralisiFrom: 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.
--- 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
@@ -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
Lorenzo Pieralisi
maintainerRe: [PATCH v4 18/26] arm64: smp: Support non-SGIs for IPIs
On Tue, May 13, 2025 at 07:48:11PM +0200, Lorenzo Pieralisi wrote:
[...]
Quoted 157 lines
/*
* Called from the secondary holding pen, this is the secondary CPU entry point.arch/arm64/kernel/smp.c +77
-15@@ -83,7 +83,26 @@ enum ipi_msg_type {static int ipi_irq_base__ro_after_init ;static int nr_ipi__ro_after_init =NR_IPI ; -static struct irq_desc *ipi_desc[MAX_IPI ]__ro_after_init ; + +struct ipi_descs { +struct irq_desc *descs[MAX_IPI ]; +}; + +static DEFINE_PER_CPU(struct ipi_descs, pcpu_ipi_desc); + +#define get_ipi_desc (__cpu, __ipi) (per_cpu_ptr(&pcpu_ipi_desc, __cpu)->descs[__ipi]) + +static bool percpu_ipi_descs__ro_after_init ; + +static int ipi_to_irq (int ipi,int cpu) +{ +return ipi_irq_base + (cpu * nr_ipi) + ipi; +} + +static int irq_to_ipi (int irq) +{ +return (irq - ipi_irq_base) % nr_ipi; +}static bool crash_stop;@@ -844,7 +863,7 @@ int arch_show_interrupts(struct seq_file *p, int prec)seq_printf (p,"%*s%u:%s" , prec -1 ,"IPI" , i, prec >=4 ?" " :"" );for_each_online_cpu (cpu) -seq_printf (p,"%10u " ,irq_desc_kstat_cpu (ipi_desc[i], cpu)); +seq_printf (p,"%10u " ,irq_desc_kstat_cpu (get_ipi_desc (cpu, i), cpu));seq_printf (p," %s\n" , ipi_types[i]); }@@ -919,7 +938,13 @@ static void __noreturn ipi_cpu_crash_stop(unsigned int cpu, struct pt_regs *regsstatic void arm64_backtrace_ipi (cpumask_t *mask) { -__ipi_send_mask (ipi_desc[IPI_CPU_BACKTRACE ], mask); +unsigned int cpu; + +if (!percpu_ipi_descs) +__ipi_send_mask (get_ipi_desc (0 ,IPI_CPU_BACKTRACE ), mask); +else +for_each_cpu (cpu, mask) +__ipi_send_single (get_ipi_desc (cpu,IPI_CPU_BACKTRACE ), cpu); }void arch_trigger_cpumask_backtrace (const cpumask_t *mask,int exclude_cpu)@@ -944,7 +969,7 @@ void kgdb_roundup_cpus(void)if (cpu == this_cpu)continue ; - __ipi_send_single(ipi_desc[IPI_KGDB_ROUNDUP], cpu); + __ipi_send_single(get_ipi_desc(cpu, IPI_KGDB_ROUNDUP), cpu); } }#endif @@ -1013,14 +1038,21 @@ static void do_handle_IPI(int ipinr)static irqreturn_t ipi_handler (int irq,void *data) { -do_handle_IPI (irq - ipi_irq_base); +do_handle_IPI (irq_to_ipi (irq));return IRQ_HANDLED ; }static void smp_cross_call (const struct cpumask *target,unsigned int ipinr) { +unsigned int cpu; +trace_ipi_raise (target, ipi_types[ipinr]); -__ipi_send_mask (ipi_desc[ipinr], target); + +if (!percpu_ipi_descs) +__ipi_send_mask (get_ipi_desc (0 , ipinr), target); +else +for_each_cpu (cpu, target) +__ipi_send_single (get_ipi_desc (cpu, ipinr), cpu); }static bool ipi_should_be_nmi (enum ipi_msg_type ipi)@@ -1046,11 +1078,15 @@ static void ipi_setup(int cpu)return ;for (i =0 ; i < nr_ipi; i++) { -if (ipi_should_be_nmi (i)) { -prepare_percpu_nmi (ipi_irq_base + i); -enable_percpu_nmi (ipi_irq_base + i,0 ); +if (!percpu_ipi_descs) { +if (ipi_should_be_nmi (i)) { +prepare_percpu_nmi (ipi_irq_base + i); +enable_percpu_nmi (ipi_irq_base + i,0 ); + }else { +enable_percpu_irq (ipi_irq_base + i,0 ); + } }else { -enable_percpu_irq (ipi_irq_base + i,0 ); +enable_irq (irq_desc_get_irq (get_ipi_desc (cpu, i))); } } }@@ -1064,44 +1100,79 @@ static void ipi_teardown(int cpu)return ;for (i =0 ; i < nr_ipi; i++) { -if (ipi_should_be_nmi (i)) { -disable_percpu_nmi (ipi_irq_base + i); -teardown_percpu_nmi (ipi_irq_base + i); +if (!percpu_ipi_descs) { +if (ipi_should_be_nmi (i)) { +disable_percpu_nmi (ipi_irq_base + i); +teardown_percpu_nmi (ipi_irq_base + i); + }else { +disable_percpu_irq (ipi_irq_base + i); + } }else { -disable_percpu_irq (ipi_irq_base + i); +disable_irq (irq_desc_get_irq (get_ipi_desc (cpu, i))); } } }#endif -void __init set_smp_ipi_range (int ipi_base,int n) +static void ipi_setup_ppi (int ipi) +{ +int err, irq, cpu; + + irq = ipi_irq_base + ipi; + +if (ipi_should_be_nmi (irq)) { + err =request_percpu_nmi (irq, ipi_handler,"IPI" , &irq_stat); +WARN (err,"Could not request IRQ %d as NMI, err=%d\n" , irq, err); + }else { + err =request_percpu_irq (irq, ipi_handler,"IPI" , &irq_stat); +WARN (err,"Could not request IRQ %d as IRQ, err=%d\n" , irq, err); + } + +for_each_possible_cpu (cpu) +get_ipi_desc (cpu, ipi) =irq_to_desc (irq); + +irq_set_status_flags (irq,IRQ_HIDDEN ); +} + +static void ipi_setup_lpi (int ipi,int ncpus) +{ +for (int cpu =0 ; cpu < ncpus; cpu++) {
arch/arm64/kernel/smp.c static void ipi_teardown(int cpu) · line 1149
Quoted 10 lines
arch/arm64/kernel/smp.c +10
-0+int err, irq; + + irq =ipi_to_irq (ipi, cpu); + + err =irq_force_affinity (irq,cpumask_of (cpu)); + +WARN (err,"Could not force affinity IRQ %d, err=%d\n" , irq, err); + + err =request_irq (irq, ipi_handler,IRQF_NO_AUTOEN ,"IPI" , + &irq_stat);
Heads-up, kbuild bot (sparse) barfed (correctly) at this, because the &irq_stat pointer does not match the request_irq() void *dev_id parameter signature (it is void __percpu *).
Of course, the &irq_stat parameter is unused so this is harmless.
I would just pass NULL (because AFAICS irq_stat in the action handler is unused), the question is why are we passing &irq_stat in request_percpu_irq() if that's unused in ipi_handler() ?
Was it used before and we removed its usage ? Should we clean it up for completeness ?
Thanks,
Lorenzo
Quoted 52 lines
arch/arm64/kernel/smp.c +18
-19+ +WARN (err,"Could not request IRQ %d, err=%d\n" , irq, err); + +irq_set_status_flags (irq, (IRQ_HIDDEN |IRQ_NO_BALANCING_MASK )); + +get_ipi_desc (cpu, ipi) =irq_to_desc (irq); + } +} + +void __init set_smp_ipi_range_percpu (int ipi_base,int n,int ncpus) {int i;WARN_ON (n <MAX_IPI ); nr_ipi =min (n,MAX_IPI ); -for (i =0 ; i < nr_ipi; i++) { -int err; - -if (ipi_should_be_nmi (i)) { - err =request_percpu_nmi (ipi_base + i, ipi_handler, -"IPI" , &irq_stat); -WARN (err,"Could not request IPI %d as NMI, err=%d\n" , - i, err); - }else { - err =request_percpu_irq (ipi_base + i, ipi_handler, -"IPI" , &irq_stat); -WARN (err,"Could not request IPI %d as IRQ, err=%d\n" , - i, err); - } - - ipi_desc[i] =irq_to_desc (ipi_base + i); -irq_set_status_flags (ipi_base + i,IRQ_HIDDEN ); - } - + percpu_ipi_descs = !!ncpus; ipi_irq_base = ipi_base; +for (i =0 ; i < nr_ipi; i++) { +if (!percpu_ipi_descs) +ipi_setup_ppi (i); +else +ipi_setup_lpi (i, ncpus); + } +/* Setup the boot CPU immediately */ ipi_setup (smp_processor_id ()); }Signature · 2 lines
-- 2.48.0
Lorenzo Pieralisi
maintainerRe: [PATCH v4 18/26] arm64: smp: Support non-SGIs for IPIs
Quoted 176 lines · Lorenzo Pieralisi
On Tue, May 13, 2025 at 07:48:11PM +0200, Lorenzo Pieralisi wrote:
[...]
Quoted 157 lines
/*
* Called from the secondary holding pen, this is the secondary CPU entry point.arch/arm64/kernel/smp.c +77
-15@@ -83,7 +83,26 @@ enum ipi_msg_type {static int ipi_irq_base__ro_after_init ;static int nr_ipi__ro_after_init =NR_IPI ; -static struct irq_desc *ipi_desc[MAX_IPI ]__ro_after_init ; + +struct ipi_descs { +struct irq_desc *descs[MAX_IPI ]; +}; + +static DEFINE_PER_CPU(struct ipi_descs, pcpu_ipi_desc); + +#define get_ipi_desc (__cpu, __ipi) (per_cpu_ptr(&pcpu_ipi_desc, __cpu)->descs[__ipi]) + +static bool percpu_ipi_descs__ro_after_init ; + +static int ipi_to_irq (int ipi,int cpu) +{ +return ipi_irq_base + (cpu * nr_ipi) + ipi; +} + +static int irq_to_ipi (int irq) +{ +return (irq - ipi_irq_base) % nr_ipi; +}static bool crash_stop;@@ -844,7 +863,7 @@ int arch_show_interrupts(struct seq_file *p, int prec)seq_printf (p,"%*s%u:%s" , prec -1 ,"IPI" , i, prec >=4 ?" " :"" );for_each_online_cpu (cpu) -seq_printf (p,"%10u " ,irq_desc_kstat_cpu (ipi_desc[i], cpu)); +seq_printf (p,"%10u " ,irq_desc_kstat_cpu (get_ipi_desc (cpu, i), cpu));seq_printf (p," %s\n" , ipi_types[i]); }@@ -919,7 +938,13 @@ static void __noreturn ipi_cpu_crash_stop(unsigned int cpu, struct pt_regs *regsstatic void arm64_backtrace_ipi (cpumask_t *mask) { -__ipi_send_mask (ipi_desc[IPI_CPU_BACKTRACE ], mask); +unsigned int cpu; + +if (!percpu_ipi_descs) +__ipi_send_mask (get_ipi_desc (0 ,IPI_CPU_BACKTRACE ), mask); +else +for_each_cpu (cpu, mask) +__ipi_send_single (get_ipi_desc (cpu,IPI_CPU_BACKTRACE ), cpu); }void arch_trigger_cpumask_backtrace (const cpumask_t *mask,int exclude_cpu)@@ -944,7 +969,7 @@ void kgdb_roundup_cpus(void)if (cpu == this_cpu)continue ; - __ipi_send_single(ipi_desc[IPI_KGDB_ROUNDUP], cpu); + __ipi_send_single(get_ipi_desc(cpu, IPI_KGDB_ROUNDUP), cpu); } }#endif @@ -1013,14 +1038,21 @@ static void do_handle_IPI(int ipinr)static irqreturn_t ipi_handler (int irq,void *data) { -do_handle_IPI (irq - ipi_irq_base); +do_handle_IPI (irq_to_ipi (irq));return IRQ_HANDLED ; }static void smp_cross_call (const struct cpumask *target,unsigned int ipinr) { +unsigned int cpu; +trace_ipi_raise (target, ipi_types[ipinr]); -__ipi_send_mask (ipi_desc[ipinr], target); + +if (!percpu_ipi_descs) +__ipi_send_mask (get_ipi_desc (0 , ipinr), target); +else +for_each_cpu (cpu, target) +__ipi_send_single (get_ipi_desc (cpu, ipinr), cpu); }static bool ipi_should_be_nmi (enum ipi_msg_type ipi)@@ -1046,11 +1078,15 @@ static void ipi_setup(int cpu)return ;for (i =0 ; i < nr_ipi; i++) { -if (ipi_should_be_nmi (i)) { -prepare_percpu_nmi (ipi_irq_base + i); -enable_percpu_nmi (ipi_irq_base + i,0 ); +if (!percpu_ipi_descs) { +if (ipi_should_be_nmi (i)) { +prepare_percpu_nmi (ipi_irq_base + i); +enable_percpu_nmi (ipi_irq_base + i,0 ); + }else { +enable_percpu_irq (ipi_irq_base + i,0 ); + } }else { -enable_percpu_irq (ipi_irq_base + i,0 ); +enable_irq (irq_desc_get_irq (get_ipi_desc (cpu, i))); } } }@@ -1064,44 +1100,79 @@ static void ipi_teardown(int cpu)return ;for (i =0 ; i < nr_ipi; i++) { -if (ipi_should_be_nmi (i)) { -disable_percpu_nmi (ipi_irq_base + i); -teardown_percpu_nmi (ipi_irq_base + i); +if (!percpu_ipi_descs) { +if (ipi_should_be_nmi (i)) { +disable_percpu_nmi (ipi_irq_base + i); +teardown_percpu_nmi (ipi_irq_base + i); + }else { +disable_percpu_irq (ipi_irq_base + i); + } }else { -disable_percpu_irq (ipi_irq_base + i); +disable_irq (irq_desc_get_irq (get_ipi_desc (cpu, i))); } } }#endif -void __init set_smp_ipi_range (int ipi_base,int n) +static void ipi_setup_ppi (int ipi) +{ +int err, irq, cpu; + + irq = ipi_irq_base + ipi; + +if (ipi_should_be_nmi (irq)) { + err =request_percpu_nmi (irq, ipi_handler,"IPI" , &irq_stat); +WARN (err,"Could not request IRQ %d as NMI, err=%d\n" , irq, err); + }else { + err =request_percpu_irq (irq, ipi_handler,"IPI" , &irq_stat); +WARN (err,"Could not request IRQ %d as IRQ, err=%d\n" , irq, err); + } + +for_each_possible_cpu (cpu) +get_ipi_desc (cpu, ipi) =irq_to_desc (irq); + +irq_set_status_flags (irq,IRQ_HIDDEN ); +} + +static void ipi_setup_lpi (int ipi,int ncpus) +{ +for (int cpu =0 ; cpu < ncpus; cpu++) {arch/arm64/kernel/smp.c static void ipi_teardown(int cpu) · line 1149
Quoted 10 lines
arch/arm64/kernel/smp.c +10
-0+int err, irq; + + irq =ipi_to_irq (ipi, cpu); + + err =irq_force_affinity (irq,cpumask_of (cpu)); + +WARN (err,"Could not force affinity IRQ %d, err=%d\n" , irq, err); + + err =request_irq (irq, ipi_handler,IRQF_NO_AUTOEN ,"IPI" , + &irq_stat);Heads-up, kbuild bot (sparse) barfed (correctly) at this, because the
&irq_statpointer does not match therequest_irq()void*dev_idparameter signature (it is void__percpu*).
Quoted 5 lines
Of course, the
&irq_statparameter is unused so this is harmless.I would just pass NULL (because AFAICS
irq_statin the action handler is unused), the question is why are we passing&irq_statinrequest_percpu_irq()if that's unused inipi_handler()?
Right, we have to have it there even if the ipi_handler() does not use it, that's as much as I can gather by checking the request_percpu_irq() interface and the percpu flow handler (handle_percpu_devid_irq()) used for SGIs IRQs on GICv3.
For non-SGI IPIs, I will just pass NULL to request_irq() as void *dev_id because AFAICS it is not used in arm64 ipi_handler() (I use the handle_percpu_irq() flow handler), I applied the fix-up locally FYI.
Lorenzo
Re: [PATCH v4 18/26] arm64: smp: Support non-SGIs for IPIs
In reply to Lorenzo PieralisiQuoted 18 lines · On Tue, 13 May 2025 19:48:11 +0200 Lorenzo Pieralisi <[email protected]>…
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.
Quoted 7 lines
Signed-off-by Marc Zyngier <[email protected]>[[email protected]: fixed ipi/irq conversion, irq flags]Signed-off-by Timothy Hayes <[email protected]>[lpieralisi: changed affinity set-up, log]Signed-off-by Lorenzo Pieralisi <[email protected]>Cc Will Deacon <[email protected]>Cc Catalin Marinas <[email protected]>
Hi Lorenzo,
A few trivial comments inline.
Review
Quoted 2 lines
(quoted diff) +2
-0+ +static int ipi_to_irq(int ipi, int cpu)
Maybe this naming needs a breadcrumb to indicate this only applies only to lpi case as it's directly computed in the old ppi code? A comment might do the job.
Quoted 9 lines
arch/arm64/kernel/smp.c +8
-0+{ +return ipi_irq_base + (cpu * nr_ipi) + ipi; +} + +static int irq_to_ipi (int irq) +{ +return (irq - ipi_irq_base) % nr_ipi; +}
arch/arm64/kernel/smp.c static void ipi_teardown(int cpu) · line 1145
Quoted 10 lines
arch/arm64/kernel/smp.c +9
-0+static void ipi_setup_lpi (int ipi,int ncpus) +{ +for (int cpu =0 ; cpu < ncpus; cpu++) { +int err, irq; + + irq =ipi_to_irq (ipi, cpu); + + err =irq_force_affinity (irq,cpumask_of (cpu)); +
Trivial local consistency thing but maybe no blank line here or...
arch/arm64/kernel/smp.c static void ipi_teardown(int cpu) · line 1150
Quoted 5 lines
arch/arm64/kernel/smp.c +5
-0+WARN (err,"Could not force affinity IRQ %d, err=%d\n" , irq, err); + + err =request_irq (irq, ipi_handler,IRQF_NO_AUTOEN ,"IPI" , + &irq_stat); +
here to match the style in ipi_setup_ppi()
Quoted 7 lines
arch/arm64/kernel/smp.c +7
-0+WARN (err,"Could not request IRQ %d, err=%d\n" , irq, err); + +irq_set_status_flags (irq, (IRQ_HIDDEN |IRQ_NO_BALANCING_MASK )); + +get_ipi_desc (cpu, ipi) =irq_to_desc (irq); + } +}
Lorenzo Pieralisi
maintainerRe: [PATCH v4 18/26] arm64: smp: Support non-SGIs for IPIs
Quoted 30 lines · Jonathan Cameron
Quoted 18 lines · On Tue, 13 May 2025 19:48:11 +0200 Lorenzo Pieralisi <[email protected]>…
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.
Quoted 7 lines
Signed-off-by Marc Zyngier <[email protected]>[[email protected]: fixed ipi/irq conversion, irq flags]Signed-off-by Timothy Hayes <[email protected]>[lpieralisi: changed affinity set-up, log]Signed-off-by Lorenzo Pieralisi <[email protected]>Cc Will Deacon <[email protected]>Cc Catalin Marinas <[email protected]>Hi Lorenzo,
Quoted 8 lines
A few trivial comments inline.
Review
Quoted 2 lines
(quoted diff) +2
-0+ +static int ipi_to_irq(int ipi, int cpu)Maybe this naming needs a breadcrumb to indicate this only applies only to lpi case as it's directly computed in the old ppi code? A comment might do the job.
Maybe rename it to ipi_to_irq_percpu() (similar to what we did for set_smp_ipi_range()) and then
static int ipi_to_irq(int ipi)
{
ipi_to_irq_percpu(ipi, 0);
}and use ipi_to_irq() in ppi code ?
Likely overkill, not a big deal anyway.
Quoted 20 lines
Quoted 9 lines
arch/arm64/kernel/smp.c +8
-0+{ +return ipi_irq_base + (cpu * nr_ipi) + ipi; +} + +static int irq_to_ipi (int irq) +{ +return (irq - ipi_irq_base) % nr_ipi; +}arch/arm64/kernel/smp.c static void ipi_teardown(int cpu) · line 1145
Quoted 10 lines
arch/arm64/kernel/smp.c +9
-0+static void ipi_setup_lpi (int ipi,int ncpus) +{ +for (int cpu =0 ; cpu < ncpus; cpu++) { +int err, irq; + + irq =ipi_to_irq (ipi, cpu); + + err =irq_force_affinity (irq,cpumask_of (cpu)); +Trivial local consistency thing but maybe no blank line here or...
Quoted 6 lines
arch/arm64/kernel/smp.c static void ipi_teardown(int cpu) · line 1150
Quoted 5 lines
arch/arm64/kernel/smp.c +5
-0+WARN (err,"Could not force affinity IRQ %d, err=%d\n" , irq, err); + + err =request_irq (irq, ipi_handler,IRQF_NO_AUTOEN ,"IPI" , + &irq_stat); +here to match the style in
ipi_setup_ppi()
Done.
Thanks,
Lorenzo
Quoted 8 lines
Quoted 7 lines
arch/arm64/kernel/smp.c +7
-0+WARN (err,"Could not request IRQ %d, err=%d\n" , irq, err); + +irq_set_status_flags (irq, (IRQ_HIDDEN |IRQ_NO_BALANCING_MASK )); + +get_ipi_desc (cpu, ipi) =irq_to_desc (irq); + } +}
Lorenzo Pieralisi
maintainerPATCH v4 19/26 arm64: Add support for GICv5 GSB barriers
In reply to Lorenzo PieralisiThe 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
@@ -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
@@ -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
Re: [PATCH v4 19/26] arm64: Add support for GICv5 GSB barriers
Quoted 35 lines · On Tue, 13 May 2025 19:48:12 +0200 Lorenzo Pieralisi <[email protected]>…
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.
Suggested-by Marc Zyngier <[email protected]>Signed-off-by Lorenzo Pieralisi <[email protected]>Cc Will Deacon <[email protected]>Cc Catalin Marinas <[email protected]>Cc Marc Zyngier <[email protected]>--- 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@@ -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 +0
-0
arch/arm64/include/asm/sysreg.h line 118
Quoted 9 lines
arch/arm64/include/asm/sysreg.h +4
-2@@ -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))
Perhaps indent as something like the following for readbility?
#define __SYS_BARRIER_INSN(op0, op1, CRn, CRm, op2, Rt) \ __emit_inst(0xd5000000 | \ sys_insn((op0), (op1), (CRn), (CRm), (op2)) | \ ((Rt) & 0x1f))
Quoted 9 lines
arch/arm64/include/asm/sysreg.h +3
-1-#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)
Lorenzo Pieralisi
maintainerRe: [PATCH v4 19/26] arm64: Add support for GICv5 GSB barriers
Quoted 49 lines · Jonathan Cameron
Quoted 35 lines · On Tue, 13 May 2025 19:48:12 +0200 Lorenzo Pieralisi <[email protected]>…
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.
Suggested-by Marc Zyngier <[email protected]>Signed-off-by Lorenzo Pieralisi <[email protected]>Cc Will Deacon <[email protected]>Cc Catalin Marinas <[email protected]>Cc Marc Zyngier <[email protected]>--- 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@@ -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 +0
-0arch/arm64/include/asm/sysreg.h line 118
Quoted 9 lines
arch/arm64/include/asm/sysreg.h +4
-2@@ -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))Perhaps indent as something like the following for readbility?
Quoted 5 lines
#define __SYS_BARRIER_INSN(op0, op1, CRn, CRm, op2, Rt) \ __emit_inst(0xd5000000 | \ sys_insn((op0), (op1), (CRn), (CRm), (op2)) | \ ((Rt) & 0x1f))
I can do - even though readability is subjective, this looks nicer to me but if possible I'd avoid the churn required if I change it and then it is not readable for other people.
Noted.
Thanks,
Lorenzo
Quoted 10 lines
Quoted 9 lines
arch/arm64/include/asm/sysreg.h +3
-1-#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)
Lorenzo Pieralisi
maintainerPATCH v4 20/26 irqchip/gic-v5: Add GICv5 PPI support
In reply to Lorenzo PieralisiThe 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 | 19 ++ drivers/irqchip/Kconfig | 5 + drivers/irqchip/Makefile | 1 + drivers/irqchip/irq-gic-v5.c | 460 +++++++++++++++++++++++++++++++++++++ include/linux/irqchip/arm-gic-v5.h | 16 ++ 6 files changed, 503 insertions(+)
MAINTAINERS +2 -0
@@ -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 +19 -0
@@ -1079,6 +1079,25 @@#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_ID_MASK GENMASK_ULL(23, 0) + +/* 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_ID_MASK GENMASK_ULL(23, 0) + +#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
@@ -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
@@ -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 +460 -0
460 lines not on this page · raw message
include/linux/irqchip/arm-gic-v5.h new file +16 -0
@@ -0,0 +1,16 @@ +/* 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) + +#endif
Signature · 1 line
2.48.0
Re: [PATCH v4 20/26] irqchip/gic-v5: Add GICv5 PPI support
Quoted 22 lines · On Tue, 13 May 2025 19:48:13 +0200 Lorenzo Pieralisi <[email protected]>…
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 methodsPPI 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).
Quoted 9 lines
Co-developed-by Sascha Bischoff <[email protected]>Signed-off-by Sascha Bischoff <[email protected]>Co-developed-by Timothy Hayes <[email protected]>Signed-off-by Timothy Hayes <[email protected]>Signed-off-by Lorenzo Pieralisi <[email protected]>Cc Will Deacon <[email protected]>Cc Thomas Gleixner <[email protected]>Cc Catalin Marinas <[email protected]>Cc Marc Zyngier <[email protected]>
A few trivial things inline.
J
Quoted 21 lines
--- MAINTAINERS | 2 + arch/arm64/include/asm/sysreg.h | 19 ++ drivers/irqchip/Kconfig | 5 + drivers/irqchip/Makefile | 1 + drivers/irqchip/irq-gic-v5.c | 460 +++++++++++++++++++++++++++++++++++++ include/linux/irqchip/arm-gic-v5.h | 16 ++ 6 files changed, 503 insertions(+)MAINTAINERS +0
-0arch/arm64/include/asm/sysreg.h +0
-0@@ -1079,6 +1079,25 @@
arch/arm64/include/asm/sysreg.h line 1089
Quoted 10 lines
arch/arm64/include/asm/sysreg.h +8
-0#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 */
Technically just masks (which are shifted) but none the less I wouldn't expect the comment to say Shift and mask.
arch/arm64/include/asm/sysreg.h line 1093
Quoted 4 lines
arch/arm64/include/asm/sysreg.h +4
-0+#define GICV5_GIC_CDDI_TYPE_MASK GENMASK_ULL(31, 29) +#define GICV5_GIC_CDDI_ID_MASK GENMASK_ULL(23, 0) + +/* Shift and mask definitions for GICR CDIA */
Likewise.
arch/arm64/include/asm/sysreg.h line 1094
Quoted 1 line
arch/arm64/include/asm/sysreg.h +1
-0+#define GICV5_GIC_CDIA_VALID_MASK BIT_ULL(32)
MaybeGICV5_GICR_CDIA_VALID(r) etc given the instruction define name.
arch/arm64/include/asm/sysreg.h line 1095
Quoted 1 line
arch/arm64/include/asm/sysreg.h +1
-0+#define GICV5_GIC_CDIA_VALID (r) FIELD_GET(GICV5_GIC_CDIA_VALID_MASK, r)
Personally I rarely see benefit in wrapping FIELD_GET() in another macro The bare code is only a little shorter and the FIELD_GET() inline keeps things nice and clear. It's your code though so keep this if you really want to!
Quoted 70 lines
arch/arm64/include/asm/sysreg.h +5
-0+#define GICV5_GIC_CDIA_TYPE_MASK GENMASK_ULL(31, 29) +#define GICV5_GIC_CDIA_ID_MASK GENMASK_ULL(23, 0) + +#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 4drivers/irqchip/Kconfig +5
-0@@ -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_HIERARCHYdrivers/irqchip/Makefile +1
-0@@ -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.odrivers/irqchip/irq-gic-v5.c new file +26
-0@@ -0,0 +1,460 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* +* Copyright (C) 2024-2025 ARM Limited, All Rights Reserved. +*/ + +#define pr_fmt (fmt) "GICv5: " fmt + +#include <linux/irqdomain.h> +#include <linux/wordpart.h> + +#include <linux/irqchip.h> +#include <linux/irqchip/arm-gic-v5.h> + +#include <asm/cpufeature.h> +#include <asm/exception.h> + +static u8 pri_bits__ro_after_init =5 ; + +#define GICV5_IRQ_PRI_MASK 0x1f +#define GICV5_IRQ_PRI_MI (GICV5_IRQ_PRI_MASK & GENMASK(4, 5 - pri_bits)) +struct gicv5_chip_data { +struct fwnode_handle *fwnode; +struct irq_domain *ppi_domain; +}; + +static struct gicv5_chip_data gicv5_global_data__read_mostly ;
drivers/irqchip/irq-gic-v5.c
Quoted 10 lines
drivers/irqchip/irq-gic-v5.c new file +8
-0+enum { +PPI_PENDING , +PPI_ACTIVE , +PPI_HM +}; + +static __always_inline u64 read_ppi_sysreg_s(unsigned int irq, +const unsigned int which)
Name the enum and use that here rather than an unsigned int? Might as well give the compiler a hand.
Maybe I'm missing a later use of this that means we can't do that.
This is almost enough combinations to justify a look up table but I guess the compiler might not figure out how to optimize that.
Quoted 8 lines
drivers/irqchip/irq-gic-v5.c new file +8
-0+{ +switch (which) { +case PPI_PENDING : +return irq <64 ?read_sysreg_s (SYS_ICC_PPI_SPENDR0_EL1 ) : +read_sysreg_s (SYS_ICC_PPI_SPENDR1_EL1 ); +case PPI_ACTIVE : +return irq <64 ?read_sysreg_s (SYS_ICC_PPI_SACTIVER0_EL1 ) : +read_sysreg_s (SYS_ICC_PPI_SACTIVER1_EL1 );
drivers/irqchip/irq-gic-v5.c line 137
Quoted 10 lines
drivers/irqchip/irq-gic-v5.c new file +10
-0+case PPI_HM : +return irq <64 ?read_sysreg_s (SYS_ICC_PPI_HMR0_EL1 ) : +read_sysreg_s (SYS_ICC_PPI_HMR1_EL1 ); +default : +BUILD_BUG_ON (1 ); + } +} + +static __always_inline void write_ppi_sysreg_s(unsigned int irq, bool set, +const unsigned int which)
Likewise - nicer with enum perhaps.
Quoted 34 lines
drivers/irqchip/irq-gic-v5.c new file +34
-0+{ +u64 bit =BIT_ULL (irq %64 ); + +switch (which) { +case PPI_PENDING : +if (set) { +if (irq <64 ) +write_sysreg_s (bit,SYS_ICC_PPI_SPENDR0_EL1 ); +else +write_sysreg_s (bit,SYS_ICC_PPI_SPENDR1_EL1 ); + }else { +if (irq <64 ) +write_sysreg_s (bit,SYS_ICC_PPI_CPENDR0_EL1 ); +else +write_sysreg_s (bit,SYS_ICC_PPI_CPENDR1_EL1 ); + } +return ; +case PPI_ACTIVE : +if (set) { +if (irq <64 ) +write_sysreg_s (bit,SYS_ICC_PPI_SACTIVER0_EL1 ); +else +write_sysreg_s (bit,SYS_ICC_PPI_SACTIVER1_EL1 ); + }else { +if (irq <64 ) +write_sysreg_s (bit,SYS_ICC_PPI_CACTIVER0_EL1 ); +else +write_sysreg_s (bit,SYS_ICC_PPI_CACTIVER1_EL1 ); + } +return ; +default : +BUILD_BUG_ON (1 ); + } +}
drivers/irqchip/irq-gic-v5.c line 181
Quoted 10 lines
drivers/irqchip/irq-gic-v5.c new file +10
-0+ +static int gicv5_ppi_irq_get_irqchip_state (struct irq_data *d, +enum irqchip_irq_state which, +bool *val) +{ +u64 hwirq_id_bit =BIT_ULL (d->hwirq %64 ); + +switch (which) { +case IRQCHIP_STATE_PENDING : + *val = !!(read_ppi_sysreg_s (d->hwirq,PPI_PENDING ) & hwirq_id_bit);
The !! isn't needed AFAICS but maybe adds a small amount of documentation value if people don't notice that *val is a bool. I'd call it state as per the definition as that's kind of more obviously boolean than 'val'.
Quoted 27 lines
drivers/irqchip/irq-gic-v5.c new file +25
-0+return 0 ; +case IRQCHIP_STATE_ACTIVE : + *val = !!(read_ppi_sysreg_s (d->hwirq,PPI_ACTIVE ) & hwirq_id_bit); +return 0 ; +default : +pr_debug ("Unexpected PPI irqchip state\n" ); +return -EINVAL ; + } +} + +static void __exception_irq_entry gicv5_handle_irq(struct pt_regs *regs) +{ +bool valid; +u32 hwirq; +u64 ia; + + ia =gicr_insn (CDIA ); + valid =GICV5_GIC_CDIA_VALID (ia); + +if (!valid) +return ; + +/* +* Ensure that the CDIA instruction effects (ie IRQ activation) are +* completed before handling the interrupt.
drivers/irqchip/irq-gic-v5.c line 355
Quoted 10 lines
drivers/irqchip/irq-gic-v5.c new file +10
-0+*/ +gsb_ack (); + +/* +* Ensure instruction ordering between an acknowledgment and subsequent +* instructions in the IRQ handler using an ISB. +*/ +isb (); + + hwirq =FIELD_GET (GICV5_HWIRQ_INTID , ia);
As below - the GICV5_HWIRQ defines other than this one are going from hwirq to something the GIC cares about - this one is extracting the software managed hwirq from the CDIA register.
drivers/irqchip/irq-gic-v5.c line 365
Quoted 10 lines
drivers/irqchip/irq-gic-v5.c new file +10
-0+ +handle_irq_per_domain (hwirq); +} + +static void gicv5_cpu_disable_interrupts (void ) +{ +u64 cr0; + + cr0 =FIELD_PREP (ICC_CR0_EL1_EN ,0 ); +write_sysreg_s (cr0,SYS_ICC_CR0_EL1 );
This might get more complex later, but if not why not squash to one line? Given the register name is right there, there isn't a lot of documentation benefit in having cr0 as the variable name.
Quoted 6 lines
drivers/irqchip/irq-gic-v5.c new file +6
-0+} + +static void gicv5_cpu_enable_interrupts (void ) +{ +u64 cr0, pcr; +
drivers/irqchip/irq-gic-v5.c line 381
Quoted 10 lines
drivers/irqchip/irq-gic-v5.c new file +10
-0+write_sysreg_s (0 ,SYS_ICC_PPI_ENABLER0_EL1 ); +write_sysreg_s (0 ,SYS_ICC_PPI_ENABLER1_EL1 ); + +gicv5_ppi_priority_init (); + + pcr =FIELD_PREP (ICC_PCR_EL1_PRIORITY ,GICV5_IRQ_PRI_MI ); +write_sysreg_s (pcr,SYS_ICC_PCR_EL1 ); + + cr0 =FIELD_PREP (ICC_CR0_EL1_EN ,1 ); +write_sysreg_s (cr0,SYS_ICC_CR0_EL1 );
Similar to above, I'd squash into single line.
drivers/irqchip/irq-gic-v5.c line 387
Quoted 6 lines
drivers/irqchip/irq-gic-v5.c new file +6
-0+} + +static int gicv5_starting_cpu (unsigned int cpu) +{ +if (WARN (!gicv5_cpuif_has_gcie (), +"GICv5 system components present but CPU does not have FEAT_GCIE" ))
Alignment off to my eyes. Either a tab or align with !
Quoted 16 lines
drivers/irqchip/irq-gic-v5.c new file +7
-0+return -ENODEV ; + +gicv5_cpu_enable_interrupts (); + +return 0 ; +} +include/linux/irqchip/arm-gic-v5.h new file +2
-0@@ -0,0 +1,16 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/*
include/linux/irqchip/arm-gic-v5.h line 12
Quoted 10 lines
include/linux/irqchip/arm-gic-v5.h new file +10
-0+* 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)
Maybe some hint as to what these are in from their naming?
First two are from hwirq as defined in the irq domain stuff. Not the 3rd one if I follow this right.
Quoted 5 lines
include/linux/irqchip/arm-gic-v5.h new file +4
-0+ +#define GICV5_HWIRQ_TYPE_PPI UL(0x1) + +#endif
Lorenzo Pieralisi
maintainerRe: [PATCH v4 20/26] irqchip/gic-v5: Add GICv5 PPI support
On Wed, May 28, 2025 at 03:15:24PM +0100, Jonathan Cameron wrote:
[...]
Quoted 4 lines
Quoted 1 line
+/* Shift and mask definitions for GIC CDDI */
Technically just masks (which are shifted) but none the less I wouldn't expect the comment to say Shift and mask.
Fixed.
Quoted 8 lines
arch/arm64/include/asm/sysreg.h line 1093
Quoted 5 lines
arch/arm64/include/asm/sysreg.h +4
-0+#define GICV5_GIC_CDDI_TYPE_MASK GENMASK_ULL(31, 29) +#define GICV5_GIC_CDDI_ID_MASK GENMASK_ULL(23, 0) + +/* Shift and mask definitions for GICR CDIA */ Likewise.
Quoted 4 lines
Quoted 1 line
+#define
GICV5_GIC_CDIA_VALID_MASKBIT_ULL(32)Maybe
GICV5_GICR_CDIA_VALID(r)etc given the instruction define name.
Yes I can do that.
Quoted 5 lines
Quoted 1 line
+#define
GICV5_GIC_CDIA_VALID(r)FIELD_GET(GICV5_GIC_CDIA_VALID_MASK, r)Personally I rarely see benefit in wrapping
FIELD_GET()in another macro The bare code is only a little shorter and theFIELD_GET()inline keeps things nice and clear. It's your code though so keep this if you really want to!
For these things to be honest I am reluctant to change them, it is subjective - we may end up arguing forever.
Quoted 85 lines
Quoted 70 lines
arch/arm64/include/asm/sysreg.h +5
-0+#define GICV5_GIC_CDIA_TYPE_MASK GENMASK_ULL(31, 29) +#define GICV5_GIC_CDIA_ID_MASK GENMASK_ULL(23, 0) + +#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 4drivers/irqchip/Kconfig +5
-0@@ -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_HIERARCHYdrivers/irqchip/Makefile +1
-0@@ -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.odrivers/irqchip/irq-gic-v5.c new file +26
-0@@ -0,0 +1,460 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* +* Copyright (C) 2024-2025 ARM Limited, All Rights Reserved. +*/ + +#define pr_fmt (fmt) "GICv5: " fmt + +#include <linux/irqdomain.h> +#include <linux/wordpart.h> + +#include <linux/irqchip.h> +#include <linux/irqchip/arm-gic-v5.h> + +#include <asm/cpufeature.h> +#include <asm/exception.h> + +static u8 pri_bits__ro_after_init =5 ; + +#define GICV5_IRQ_PRI_MASK 0x1f +#define GICV5_IRQ_PRI_MI (GICV5_IRQ_PRI_MASK & GENMASK(4, 5 - pri_bits)) +struct gicv5_chip_data { +struct fwnode_handle *fwnode; +struct irq_domain *ppi_domain; +}; + +static struct gicv5_chip_data gicv5_global_data__read_mostly ;drivers/irqchip/irq-gic-v5.c
Quoted 10 lines
drivers/irqchip/irq-gic-v5.c new file +8
-0+enum { +PPI_PENDING , +PPI_ACTIVE , +PPI_HM +}; + +static __always_inline u64 read_ppi_sysreg_s(unsigned int irq, +const unsigned int which)Name the enum and use that here rather than an unsigned int? Might as well give the compiler a hand.
Maybe I'm missing a later use of this that means we can't do that.
Quoted 2 lines
This is almost enough combinations to justify a look up table but I guess the compiler might not figure out how to optimize that.
Yes, while writing it I initially used a named enum, then switched to this, does not change anything, function is always inline and either the compiler manages to remove switch cases or the build fails :) so at the end of the day a named enum does not change much, I will change it to that though.
Quoted 13 lines
Quoted 13 lines
drivers/irqchip/irq-gic-v5.c new file +12
-0+{ +switch (which) { +case PPI_PENDING : +return irq <64 ?read_sysreg_s (SYS_ICC_PPI_SPENDR0_EL1 ) : +read_sysreg_s (SYS_ICC_PPI_SPENDR1_EL1 ); +case PPI_ACTIVE : +return irq <64 ?read_sysreg_s (SYS_ICC_PPI_SACTIVER0_EL1 ) : +read_sysreg_s (SYS_ICC_PPI_SACTIVER1_EL1 ); +case PPI_HM : +return irq <64 ?read_sysreg_s (SYS_ICC_PPI_HMR0_EL1 ) : +read_sysreg_s (SYS_ICC_PPI_HMR1_EL1 ); +default :
Quoted 8 lines
drivers/irqchip/irq-gic-v5.c line 137
Quoted 6 lines
drivers/irqchip/irq-gic-v5.c new file +6
-0+BUILD_BUG_ON (1 ); + } +} + +static __always_inline void write_ppi_sysreg_s(unsigned int irq, bool set, +const unsigned int which)Likewise - nicer with enum perhaps.
Done.
Quoted 41 lines
Quoted 41 lines
drivers/irqchip/irq-gic-v5.c new file +40
-0+{ +u64 bit =BIT_ULL (irq %64 ); + +switch (which) { +case PPI_PENDING : +if (set) { +if (irq <64 ) +write_sysreg_s (bit,SYS_ICC_PPI_SPENDR0_EL1 ); +else +write_sysreg_s (bit,SYS_ICC_PPI_SPENDR1_EL1 ); + }else { +if (irq <64 ) +write_sysreg_s (bit,SYS_ICC_PPI_CPENDR0_EL1 ); +else +write_sysreg_s (bit,SYS_ICC_PPI_CPENDR1_EL1 ); + } +return ; +case PPI_ACTIVE : +if (set) { +if (irq <64 ) +write_sysreg_s (bit,SYS_ICC_PPI_SACTIVER0_EL1 ); +else +write_sysreg_s (bit,SYS_ICC_PPI_SACTIVER1_EL1 ); + }else { +if (irq <64 ) +write_sysreg_s (bit,SYS_ICC_PPI_CACTIVER0_EL1 ); +else +write_sysreg_s (bit,SYS_ICC_PPI_CACTIVER1_EL1 ); + } +return ; +default : +BUILD_BUG_ON (1 ); + } +} + +static int gicv5_ppi_irq_get_irqchip_state (struct irq_data *d, +enum irqchip_irq_state which, +bool *val) +{ +u64 hwirq_id_bit =BIT_ULL (d->hwirq %64 );
Quoted 8 lines
drivers/irqchip/irq-gic-v5.c line 181
Quoted 4 lines
drivers/irqchip/irq-gic-v5.c new file +4
-0+ +switch (which) { +case IRQCHIP_STATE_PENDING : + *val = !!(read_ppi_sysreg_s (d->hwirq,PPI_PENDING ) & hwirq_id_bit);The !! isn't needed AFAICS but maybe adds a small amount of documentation value if people don't notice that *val is a bool. I'd call it state as per the definition as that's kind of more obviously boolean than 'val'.
Ok for naming it 'state'.
Quoted 33 lines
Quoted 33 lines
drivers/irqchip/irq-gic-v5.c new file +31
-0+return 0 ; +case IRQCHIP_STATE_ACTIVE : + *val = !!(read_ppi_sysreg_s (d->hwirq,PPI_ACTIVE ) & hwirq_id_bit); +return 0 ; +default : +pr_debug ("Unexpected PPI irqchip state\n" ); +return -EINVAL ; + } +} + +static void __exception_irq_entry gicv5_handle_irq(struct pt_regs *regs) +{ +bool valid; +u32 hwirq; +u64 ia; + + ia =gicr_insn (CDIA ); + valid =GICV5_GIC_CDIA_VALID (ia); + +if (!valid) +return ; + +/* +* Ensure that the CDIA instruction effects (ie IRQ activation) are +* completed before handling the interrupt. +*/ +gsb_ack (); + +/* +* Ensure instruction ordering between an acknowledgment and subsequent +* instructions in the IRQ handler using an ISB.
Quoted 8 lines
drivers/irqchip/irq-gic-v5.c line 355
Quoted 4 lines
drivers/irqchip/irq-gic-v5.c new file +4
-0+*/ +isb (); + + hwirq =FIELD_GET (GICV5_HWIRQ_INTID , ia);As below - the
GICV5_HWIRQdefines other than this one are going from hwirq to something the GIC cares about - this one is extracting the software managed hwirq from the CDIA register.
I don't get what you mean. We are extracting the HW INTID from the value read with CDIA.
Quoted 16 lines
drivers/irqchip/irq-gic-v5.c line 365
Quoted 11 lines
drivers/irqchip/irq-gic-v5.c new file +10
-0+ +handle_irq_per_domain (hwirq); +} + +static void gicv5_cpu_disable_interrupts (void ) +{ +u64 cr0; + + cr0 =FIELD_PREP (ICC_CR0_EL1_EN ,0 ); +write_sysreg_s (cr0,SYS_ICC_CR0_EL1 );This might get more complex later, but if not why not squash to one line? Given the register name is right there, there isn't a lot of documentation benefit in having cr0 as the variable name.
See above. No rule on the matter - it is subjective so I am reluctant to change it.
Quoted 10 lines
Quoted 10 lines
drivers/irqchip/irq-gic-v5.c new file +10
-0+} + +static void gicv5_cpu_enable_interrupts (void ) +{ +u64 cr0, pcr; + +write_sysreg_s (0 ,SYS_ICC_PPI_ENABLER0_EL1 ); +write_sysreg_s (0 ,SYS_ICC_PPI_ENABLER1_EL1 ); + +gicv5_ppi_priority_init ();
Quoted 8 lines
drivers/irqchip/irq-gic-v5.c line 381
Quoted 6 lines
drivers/irqchip/irq-gic-v5.c new file +6
-0+ + pcr =FIELD_PREP (ICC_PCR_EL1_PRIORITY ,GICV5_IRQ_PRI_MI ); +write_sysreg_s (pcr,SYS_ICC_PCR_EL1 ); + + cr0 =FIELD_PREP (ICC_CR0_EL1_EN ,1 ); +write_sysreg_s (cr0,SYS_ICC_CR0_EL1 );Similar to above, I'd squash into single line.
Ditto.
Quoted 8 lines
drivers/irqchip/irq-gic-v5.c line 387
Quoted 6 lines
drivers/irqchip/irq-gic-v5.c new file +6
-0+} + +static int gicv5_starting_cpu (unsigned int cpu) +{ +if (WARN (!gicv5_cpuif_has_gcie (), +"GICv5 system components present but CPU does not have FEAT_GCIE" ))Alignment off to my eyes. Either a tab or align with !
Fixed it.
Quoted 29 lines
Quoted 16 lines
drivers/irqchip/irq-gic-v5.c new file +7
-0+return -ENODEV ; + +gicv5_cpu_enable_interrupts (); + +return 0 ; +} +include/linux/irqchip/arm-gic-v5.h new file +2
-0@@ -0,0 +1,16 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* include/linux/irqchip/arm-gic-v5.h line 12
Quoted 10 lines
include/linux/irqchip/arm-gic-v5.h new file +10
-0+* 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)Maybe some hint as to what these are in from their naming?
Quoted 2 lines
First two are from hwirq as defined in the irq domain stuff. Not the 3rd one if I follow this right.
The three of them are there to handle the HW GICv5 INTID and its related fields (Rule R_TJPHS), maybe I should add a comment highlighting this ?
Thanks,
Lorenzo
Quoted 6 lines
Quoted 5 lines
include/linux/irqchip/arm-gic-v5.h new file +4
-0+ +#define GICV5_HWIRQ_TYPE_PPI UL(0x1) + +#endif
Lorenzo Pieralisi
maintainerPATCH v4 21/26 irqchip/gic-v5: Add GICv5 IRS/SPI support
In reply to Lorenzo PieralisiThe 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 | 36 +++ drivers/irqchip/Makefile | 2 +- drivers/irqchip/irq-gic-v5-irs.c | 433 +++++++++++++++++++++++++++++++++++++ drivers/irqchip/irq-gic-v5.c | 341 +++++++++++++++++++++++++++-- include/linux/irqchip/arm-gic-v5.h | 130 +++++++++++ 5 files changed, 920 insertions(+), 22 deletions(-)
arch/arm64/include/asm/sysreg.h +36 -0
@@ -1082,14 +1082,50 @@/* * 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_TYPE_MASK GENMASK_ULL(31, 29) +#define GICV5_GIC_CDAFF_IRM_MASK BIT_ULL(28) +#define GICV5_GIC_CDAFF_ID_MASK GENMASK_ULL(23, 0) +/* Shift and mask definitions for GIC CDDI */ #define GICV5_GIC_CDDI_TYPE_MASK GENMASK_ULL(31, 29)#define GICV5_GIC_CDDI_ID_MASK GENMASK_ULL(23, 0) +/* 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_ID_MASK GENMASK_ULL(23, 0) + +/* Shift and mask definitions for GIC CDPEND */ +#define GICV5_GIC_CDPEND_PENDING_MASK BIT_ULL(32) +#define GICV5_GIC_CDPEND_TYPE_MASK GENMASK_ULL(31, 29) +#define GICV5_GIC_CDPEND_ID_MASK GENMASK_ULL(23, 0) + +/* Shift and mask definitions for GIC CDPRI */ +#define GICV5_GIC_CDPRI_PRIORITY_MASK GENMASK_ULL(39, 35) +#define GICV5_GIC_CDPRI_TYPE_MASK GENMASK_ULL(31, 29) +#define GICV5_GIC_CDPRI_ID_MASK GENMASK_ULL(23, 0) + +/* Shift and mask definitions for GIC CDRCFG */ +#define GICV5_GIC_CDRCFG_TYPE_MASK GENMASK_ULL(31, 29) +#define GICV5_GIC_CDRCFG_ID_MASK GENMASK_ULL(23, 0) +/* 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
@@ -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 +320 -21
467 lines not on this page · raw message
include/linux/irqchip/arm-gic-v5.h +130 -0
141 lines not on this page · raw message
Signature · 1 line
2.48.0
Re: [PATCH v4 21/26] irqchip/gic-v5: Add GICv5 IRS/SPI support
Quoted 40 lines · On Tue, 13 May 2025 19:48:14 +0200 Lorenzo Pieralisi <[email protected]>…
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 handlingSPIs 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.
Quoted 9 lines
Co-developed-by Sascha Bischoff <[email protected]>Signed-off-by Sascha Bischoff <[email protected]>Co-developed-by Timothy Hayes <[email protected]>Signed-off-by Timothy Hayes <[email protected]>Signed-off-by Lorenzo Pieralisi <[email protected]>Cc Will Deacon <[email protected]>Cc Thomas Gleixner <[email protected]>Cc Catalin Marinas <[email protected]>Cc Marc Zyngier <[email protected]>
A few comments inline. Mostly around of cpu phandle parsing. +CC Ali as there is a comment on his SMT DT patch set inline.
Quoted 13 lines
--- arch/arm64/include/asm/sysreg.h | 36 +++ drivers/irqchip/Makefile | 2 +- drivers/irqchip/irq-gic-v5-irs.c | 433 +++++++++++++++++++++++++++++++++++++ drivers/irqchip/irq-gic-v5.c | 341 +++++++++++++++++++++++++++-- include/linux/irqchip/arm-gic-v5.h | 130 +++++++++++ 5 files changed, 920 insertions(+), 22 deletions(-)arch/arm64/include/asm/sysreg.h +0
-0
arch/arm64/include/asm/sysreg.h line 1087
Quoted 6 lines
arch/arm64/include/asm/sysreg.h +1
-0@@ -1082,14 +1082,50 @@/* * Definitions for GICv5 instructions */ +/* Shift and mask definitions for GIC CDAFF */
Similar comment. Mask definitions seems more accurate to me.
arch/arm64/include/asm/sysreg.h line 1109
Quoted 5 lines
arch/arm64/include/asm/sysreg.h +5
-0+/* 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)
Similar to earlier comment. I'm not sure the shortened forms are worth the bother.
Quoted 47 lines
drivers/irqchip/irq-gic-v5-irs.c new file +38
-0@@ -0,0 +1,433 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* +* Copyright (C) 2024-2025 ARM Limited, All Rights Reserved. +*/ + +#define pr_fmt (fmt) "GICv5 IRS: " fmt + +#include <linux/of.h> +#include <linux/of_address.h> + +#include <linux/irqchip.h> +#include <linux/irqchip/arm-gic-v5.h> +int gicv5_spi_irq_set_type (struct irq_data *d,unsigned int type) +{ +struct gicv5_irs_chip_data *irs_data = d->chip_data; +u32 selr, cfgr; +bool level; +int ret; + +switch (type) { +case IRQ_TYPE_EDGE_RISING : +case IRQ_TYPE_EDGE_FALLING : + level = false; +break ; +case IRQ_TYPE_LEVEL_HIGH : +case IRQ_TYPE_LEVEL_LOW : + level = true; +break ; +default : +return -EINVAL ; + } + +guard (raw_spinlock)(&irs_data->spi_config_lock); + + selr =FIELD_PREP (GICV5_IRS_SPI_SELR_ID , d->hwirq); +irs_writel_relaxed (irs_data, selr,GICV5_IRS_SPI_SELR ); + ret =gicv5_irs_wait_for_spi_op (irs_data); +if (ret)
drivers/irqchip/irq-gic-v5-irs.c line 146
Quoted 10 lines
drivers/irqchip/irq-gic-v5-irs.c new file +10
-0+return ret; + + cfgr =FIELD_PREP (GICV5_IRS_SPI_CFGR_TM , level); + +irs_writel_relaxed (irs_data, cfgr,GICV5_IRS_SPI_CFGR ); + ret =gicv5_irs_wait_for_spi_op (irs_data); +if (ret) +return ret; + +return 0 ;
return gicv5_irq_wait_for_spi_op()
unless more code turns up here in a later patch.
Quoted 12 lines
drivers/irqchip/irq-gic-v5-irs.c new file +11
-0+} + +static void __init gicv5_irs_init_bases (struct gicv5_irs_chip_data *irs_data, +void __iomem *irs_base, +struct fwnode_handle *handle) +{ +struct device_node *np =to_of_node (handle); +u32 cr0, cr1; + + irs_data->fwnode = handle; + irs_data->irs_base = irs_base;
drivers/irqchip/irq-gic-v5-irs.c line 213
Quoted 10 lines
drivers/irqchip/irq-gic-v5-irs.c new file +10
-0+ +if (of_property_read_bool (np,"dma-noncoherent" )) { +/* +* A non-coherent IRS implies that some cache levels cannot be +* used coherently by the cores and GIC. Our only option is to mark +* memory attributes for the GIC as non-cacheable; by default, +* non-cacheable memory attributes imply outer-shareable +* shareability, the value written into IRS_CR1_SH is ignored. +*/ + cr1 = FIELD_PREP(GICV5_IRS_CR1_VPED_WA, GICV5_NO_WRITE_ALLOC) |
As per earlier comments is this less clear as:
cr1 = FIELD_PREP(GICV5_IRS_CR1_VPED_WA, 0) |
To me, seems fine but up to you.
Quoted 31 lines
drivers/irqchip/irq-gic-v5-irs.c new file +31
-0+FIELD_PREP (GICV5_IRS_CR1_VPED_RA ,GICV5_NO_READ_ALLOC ) | +FIELD_PREP (GICV5_IRS_CR1_VMD_WA ,GICV5_NO_WRITE_ALLOC ) | +FIELD_PREP (GICV5_IRS_CR1_VMD_RA ,GICV5_NO_READ_ALLOC ) | +FIELD_PREP (GICV5_IRS_CR1_VPET_RA ,GICV5_NO_READ_ALLOC ) | +FIELD_PREP (GICV5_IRS_CR1_VMT_RA ,GICV5_NO_READ_ALLOC ) | +FIELD_PREP (GICV5_IRS_CR1_IST_WA ,GICV5_NO_WRITE_ALLOC ) | +FIELD_PREP (GICV5_IRS_CR1_IST_RA ,GICV5_NO_READ_ALLOC ) | +FIELD_PREP (GICV5_IRS_CR1_IC ,GICV5_NON_CACHE ) | +FIELD_PREP (GICV5_IRS_CR1_OC ,GICV5_NON_CACHE ); + irs_data->flags |=IRS_FLAGS_NON_COHERENT ; + }else { + cr1 =FIELD_PREP (GICV5_IRS_CR1_VPED_WA ,GICV5_WRITE_ALLOC ) | +FIELD_PREP (GICV5_IRS_CR1_VPED_RA ,GICV5_READ_ALLOC ) | +FIELD_PREP (GICV5_IRS_CR1_VMD_WA ,GICV5_WRITE_ALLOC ) | +FIELD_PREP (GICV5_IRS_CR1_VMD_RA ,GICV5_READ_ALLOC ) | +FIELD_PREP (GICV5_IRS_CR1_VPET_RA ,GICV5_READ_ALLOC ) | +FIELD_PREP (GICV5_IRS_CR1_VMT_RA ,GICV5_READ_ALLOC ) | +FIELD_PREP (GICV5_IRS_CR1_IST_WA ,GICV5_WRITE_ALLOC ) | +FIELD_PREP (GICV5_IRS_CR1_IST_RA ,GICV5_READ_ALLOC ) | +FIELD_PREP (GICV5_IRS_CR1_IC ,GICV5_WB_CACHE ) | +FIELD_PREP (GICV5_IRS_CR1_OC ,GICV5_WB_CACHE ) | +FIELD_PREP (GICV5_IRS_CR1_SH ,GICV5_INNER_SHARE ); + } + +irs_writel_relaxed (irs_data, cr1,GICV5_IRS_CR1 ); + + cr0 =FIELD_PREP (GICV5_IRS_CR0_IRSEN ,0x1 ); +irs_writel_relaxed (irs_data, cr0,GICV5_IRS_CR0 ); +gicv5_irs_wait_for_idle (irs_data); +} +
drivers/irqchip/irq-gic-v5-irs.c line 254
Quoted 10 lines
drivers/irqchip/irq-gic-v5-irs.c new file +10
-0+static int __init gicv5_irs_of_init_affinity (struct device_node *node, +struct gicv5_irs_chip_data *irs_data, +u8 iaffid_bits) +{ +/* +* Detect IAFFID<->CPU mappings from the device tree and +* record IRS<->CPU topology information. +*/ +u16 iaffid_mask =GENMASK (iaffid_bits -1 ,0 ); + u16 *iaffids __free(kfree) = NULL;
See comments in cleanup.h. Linus has been fairly clear he doesn't like separating the constructor and destructor like this - just declare iaffids where you construct it.
drivers/irqchip/irq-gic-v5-irs.c line 257
Quoted 4 lines
drivers/irqchip/irq-gic-v5-irs.c new file +3
-0+int ret, i, ncpus, niaffids; + + ncpus =of_property_count_elems_of_size (node,"cpus" ,sizeof (u32));
cpus is a phandle? I think this is going to run into current discussion on what phandles to CPUs on an SMT system look like (Rob Herring and Mark Rutland have different views)
https://lore.kernel.org/linux-arm-kernel/[email protected]/
Anyhow this doesn't look right to me.
I think it should be of_count_phandle_with_args() Potentially with cpu-cells
as the argument depending on how that thread goes.
drivers/irqchip/irq-gic-v5-irs.c line 265
Quoted 8 lines
drivers/irqchip/irq-gic-v5-irs.c new file +8
-0+if (ncpus <0 ) +return -EINVAL ; + + niaffids =of_property_count_elems_of_size (node,"arm,iaffids" , +sizeof (u16)); +if (niaffids != ncpus) +return -EINVAL ; +
u16 *iaffids __free(kfree) = kcalloc(niaffids, sizeof(*iaffids), GFP_KERNEL);
Quoted 7 lines
drivers/irqchip/irq-gic-v5-irs.c new file +7
-0+ iaffids =kcalloc (niaffids,sizeof (*iaffids),GFP_KERNEL ); +if (!iaffids) +return -ENOMEM ; + + ret =of_property_read_u16_array (node,"arm,iaffids" , iaffids, niaffids); +if (ret) +return ret;
drivers/irqchip/irq-gic-v5-irs.c line 282
Quoted 10 lines
drivers/irqchip/irq-gic-v5-irs.c new file +10
-0+ +for (i =0 ; i < ncpus; i++) { +struct device_node *cpu_node; +u32 cpu_phandle; +int cpu; + +if (of_property_read_u32_index (node,"cpus" , i, &cpu_phandle)) +continue ; + + cpu_node =of_find_node_by_phandle (cpu_phandle);
cpu_node = of_parse_phandle(node, "cpus", i);
not work here?
drivers/irqchip/irq-gic-v5-irs.c line 286
Quoted 4 lines
drivers/irqchip/irq-gic-v5-irs.c new file +4
-0+if (WARN_ON (!cpu_node)) +continue ; + + cpu =of_cpu_node_to_id (cpu_node);
If this is all you want then Ali's series gives you a helper
cpu = of_cpu_phandle_to_id(node, &cpu_node, i);
Though even better to have a helper that allows
cpu = of_cpu_phandle_to_id(node, NULL, i); and handles
the node put as internally.
Ali, any reason we can't do that? Seems to be a fairly common pattern.
Quoted 24 lines
drivers/irqchip/irq-gic-v5-irs.c new file +19
-0+of_node_put (cpu_node); +if (WARN_ON (cpu <0 )) +continue ; + +if (iaffids[i] & ~iaffid_mask) { +pr_warn ("CPU %d iaffid 0x%x exceeds IRS iaffid bits\n" , + cpu, iaffids[i]); +continue ; + } + +per_cpu (cpu_iaffid, cpu).iaffid = iaffids[i]; +per_cpu (cpu_iaffid, cpu).valid = true; + +/* We also know that the CPU is connected to this IRS */ +per_cpu (per_cpu_irs_data, cpu) = irs_data; + } + +return ret; +}drivers/irqchip/irq-gic-v5.c +0
-0
drivers/irqchip/irq-gic-v5.c static int gicv5_ppi_irq_set_irqchip_state(struct irq_data *d, · line 367
Quoted 6 lines
drivers/irqchip/irq-gic-v5.c +5
-0+ +static int gicv5_spi_irq_set_irqchip_state (struct irq_data *d, +enum irqchip_irq_state which, +bool val) +{
Similar to previous, I'd call the state parameter state rather than val.
include/linux/irqchip/arm-gic-v5.h line 12
Quoted 13 lines
include/linux/irqchip/arm-gic-v5.h +4
-0@@ -5,6 +5,8 @@#ifndef __LINUX_IRQCHIP_ARM_GIC_V5_H#define __LINUX_IRQCHIP_ARM_GIC_V5_H +#define GICV5_NO_READ_ALLOC 0b0 +#define GICV5_READ_ALLOC 0b1 +#define GICV5_NO_WRITE_ALLOC 0b0 +#define GICV5_WRITE_ALLOC 0b1
Given these are being written to fields called _RA and _WA so the defines provide value over 0 and 1 in appropriate places? Maybe just about. Anyhow, your code so on this up to you.
Quoted 12 lines
include/linux/irqchip/arm-gic-v5.h +12
-0+ +#define GICV5_NON_CACHE 0b00 +#define GICV5_WB_CACHE 0b01 +#define GICV5_WT_CACHE 0b10 + +#define GICV5_NON_SHARE 0b00 +#define GICV5_OUTER_SHARE 0b10 +#define GICV5_INNER_SHARE 0b11 + +#define GICV5_IRS_IDR1 0x0004 +#define GICV5_IRS_IDR2 0x0008 +#define GICV5_IRS_IDR5 0x0014
include/linux/irqchip/arm-gic-v5.h line 44
Quoted 10 lines
include/linux/irqchip/arm-gic-v5.h +10
-0+#define GICV5_IRS_IDR6 0x0018 +#define GICV5_IRS_IDR7 0x001c +#define GICV5_IRS_CR0 0x0080 +#define GICV5_IRS_CR1 0x0084 +#define GICV5_IRS_SPI_SELR 0x0108 +#define GICV5_IRS_SPI_CFGR 0x0114 +#define GICV5_IRS_SPI_STATUSR 0x0118 +#define GICV5_IRS_PE_SELR 0x0140 +#define GICV5_IRS_PE_STATUSR 0x0144 +#define GICV5_IRS_PE_CR0 0x0148
Blank line here as this is end of register offsets.
Quoted 2 lines
include/linux/irqchip/arm-gic-v5.h +2
-0+#define GICV5_IRS_IDR1_PRIORITY_BITS GENMASK(22, 20) +#define GICV5_IRS_IDR1_IAFFID_BITS GENMASK(19, 16)
Lorenzo Pieralisi
maintainerRe: [PATCH v4 21/26] irqchip/gic-v5: Add GICv5 IRS/SPI support
Quoted 75 lines · Jonathan Cameron
Quoted 40 lines · On Tue, 13 May 2025 19:48:14 +0200 Lorenzo Pieralisi <[email protected]>…
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 handlingSPIs 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.
Quoted 9 lines
Co-developed-by Sascha Bischoff <[email protected]>Signed-off-by Sascha Bischoff <[email protected]>Co-developed-by Timothy Hayes <[email protected]>Signed-off-by Timothy Hayes <[email protected]>Signed-off-by Lorenzo Pieralisi <[email protected]>Cc Will Deacon <[email protected]>Cc Thomas Gleixner <[email protected]>Cc Catalin Marinas <[email protected]>Cc Marc Zyngier <[email protected]>A few comments inline. Mostly around of cpu phandle parsing. +CC Ali as there is a comment on his SMT DT patch set inline.
Quoted 18 lines
--- arch/arm64/include/asm/sysreg.h | 36 +++ drivers/irqchip/Makefile | 2 +- drivers/irqchip/irq-gic-v5-irs.c | 433 +++++++++++++++++++++++++++++++++++++ drivers/irqchip/irq-gic-v5.c | 341 +++++++++++++++++++++++++++-- include/linux/irqchip/arm-gic-v5.h | 130 +++++++++++ 5 files changed, 920 insertions(+), 22 deletions(-)arch/arm64/include/asm/sysreg.h +0
-0@@ -1082,14 +1082,50 @@/* * Definitions for GICv5 instructions */
Quoted 3 lines
arch/arm64/include/asm/sysreg.h line 1095
Quoted 1 line
arch/arm64/include/asm/sysreg.h +1
-0+/* Shift and mask definitions for GIC CDAFF */ Similar comment. Mask definitions seems more accurate to me.
Fixed.
Quoted 7 lines
arch/arm64/include/asm/sysreg.h line 1109
Quoted 5 lines
arch/arm64/include/asm/sysreg.h +5
-0+/* 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)Similar to earlier comment. I'm not sure the shortened forms are worth the bother.
Same as previous replies.
Quoted 59 lines
Quoted 47 lines
drivers/irqchip/irq-gic-v5-irs.c new file +38
-0@@ -0,0 +1,433 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* +* Copyright (C) 2024-2025 ARM Limited, All Rights Reserved. +*/ + +#define pr_fmt (fmt) "GICv5 IRS: " fmt + +#include <linux/of.h> +#include <linux/of_address.h> + +#include <linux/irqchip.h> +#include <linux/irqchip/arm-gic-v5.h> +int gicv5_spi_irq_set_type (struct irq_data *d,unsigned int type) +{ +struct gicv5_irs_chip_data *irs_data = d->chip_data; +u32 selr, cfgr; +bool level; +int ret; + +switch (type) { +case IRQ_TYPE_EDGE_RISING : +case IRQ_TYPE_EDGE_FALLING : + level = false; +break ; +case IRQ_TYPE_LEVEL_HIGH : +case IRQ_TYPE_LEVEL_LOW : + level = true; +break ; +default : +return -EINVAL ; + } + +guard (raw_spinlock)(&irs_data->spi_config_lock); + + selr =FIELD_PREP (GICV5_IRS_SPI_SELR_ID , d->hwirq); +irs_writel_relaxed (irs_data, selr,GICV5_IRS_SPI_SELR ); + ret =gicv5_irs_wait_for_spi_op (irs_data); +if (ret)drivers/irqchip/irq-gic-v5-irs.c line 146
Quoted 10 lines
drivers/irqchip/irq-gic-v5-irs.c new file +10
-0+return ret; + + cfgr =FIELD_PREP (GICV5_IRS_SPI_CFGR_TM , level); + +irs_writel_relaxed (irs_data, cfgr,GICV5_IRS_SPI_CFGR ); + ret =gicv5_irs_wait_for_spi_op (irs_data); +if (ret) +return ret; + +return 0 ;return
gicv5_irq_wait_for_spi_op()
Quoted 1 line
unless more code turns up here in a later patch.
Ok.
Quoted 65 lines
Quoted 13 lines
drivers/irqchip/irq-gic-v5-irs.c new file +11
-0+} + +static void __init gicv5_irs_init_bases (struct gicv5_irs_chip_data *irs_data, +void __iomem *irs_base, +struct fwnode_handle *handle) +{ +struct device_node *np =to_of_node (handle); +u32 cr0, cr1; + + irs_data->fwnode = handle; + irs_data->irs_base = irs_base;drivers/irqchip/irq-gic-v5-irs.c line 213
Quoted 10 lines
drivers/irqchip/irq-gic-v5-irs.c new file +10
-0+ +if (of_property_read_bool (np,"dma-noncoherent" )) { +/* +* A non-coherent IRS implies that some cache levels cannot be +* used coherently by the cores and GIC. Our only option is to mark +* memory attributes for the GIC as non-cacheable; by default, +* non-cacheable memory attributes imply outer-shareable +* shareability, the value written into IRS_CR1_SH is ignored. +*/ + cr1 = FIELD_PREP(GICV5_IRS_CR1_VPED_WA, GICV5_NO_WRITE_ALLOC) |As per earlier comments is this less clear as:
cr1 = FIELD_PREP(GICV5_IRS_CR1_VPED_WA, 0) |To me, seems fine but up to you.
Quoted 37 lines
drivers/irqchip/irq-gic-v5-irs.c new file +37
-0+FIELD_PREP (GICV5_IRS_CR1_VPED_RA ,GICV5_NO_READ_ALLOC ) | +FIELD_PREP (GICV5_IRS_CR1_VMD_WA ,GICV5_NO_WRITE_ALLOC ) | +FIELD_PREP (GICV5_IRS_CR1_VMD_RA ,GICV5_NO_READ_ALLOC ) | +FIELD_PREP (GICV5_IRS_CR1_VPET_RA ,GICV5_NO_READ_ALLOC ) | +FIELD_PREP (GICV5_IRS_CR1_VMT_RA ,GICV5_NO_READ_ALLOC ) | +FIELD_PREP (GICV5_IRS_CR1_IST_WA ,GICV5_NO_WRITE_ALLOC ) | +FIELD_PREP (GICV5_IRS_CR1_IST_RA ,GICV5_NO_READ_ALLOC ) | +FIELD_PREP (GICV5_IRS_CR1_IC ,GICV5_NON_CACHE ) | +FIELD_PREP (GICV5_IRS_CR1_OC ,GICV5_NON_CACHE ); + irs_data->flags |=IRS_FLAGS_NON_COHERENT ; + }else { + cr1 =FIELD_PREP (GICV5_IRS_CR1_VPED_WA ,GICV5_WRITE_ALLOC ) | +FIELD_PREP (GICV5_IRS_CR1_VPED_RA ,GICV5_READ_ALLOC ) | +FIELD_PREP (GICV5_IRS_CR1_VMD_WA ,GICV5_WRITE_ALLOC ) | +FIELD_PREP (GICV5_IRS_CR1_VMD_RA ,GICV5_READ_ALLOC ) | +FIELD_PREP (GICV5_IRS_CR1_VPET_RA ,GICV5_READ_ALLOC ) | +FIELD_PREP (GICV5_IRS_CR1_VMT_RA ,GICV5_READ_ALLOC ) | +FIELD_PREP (GICV5_IRS_CR1_IST_WA ,GICV5_WRITE_ALLOC ) | +FIELD_PREP (GICV5_IRS_CR1_IST_RA ,GICV5_READ_ALLOC ) | +FIELD_PREP (GICV5_IRS_CR1_IC ,GICV5_WB_CACHE ) | +FIELD_PREP (GICV5_IRS_CR1_OC ,GICV5_WB_CACHE ) | +FIELD_PREP (GICV5_IRS_CR1_SH ,GICV5_INNER_SHARE ); + } + +irs_writel_relaxed (irs_data, cr1,GICV5_IRS_CR1 ); + + cr0 =FIELD_PREP (GICV5_IRS_CR0_IRSEN ,0x1 ); +irs_writel_relaxed (irs_data, cr0,GICV5_IRS_CR0 ); +gicv5_irs_wait_for_idle (irs_data); +} + +static int __init gicv5_irs_of_init_affinity (struct device_node *node, +struct gicv5_irs_chip_data *irs_data, +u8 iaffid_bits) +{ +/* +* Detect IAFFID<->CPU mappings from the device tree and
Quoted 8 lines
drivers/irqchip/irq-gic-v5-irs.c line 254
Quoted 4 lines
drivers/irqchip/irq-gic-v5-irs.c new file +4
-0+* record IRS<->CPU topology information. +*/ +u16 iaffid_mask =GENMASK (iaffid_bits -1 ,0 ); + u16 *iaffids __free(kfree) = NULL;See comments in
cleanup.h. Linus has been fairly clear he doesn't like separating the constructor and destructor like this - just declare iaffids where you construct it.
Right.
Quoted 9 lines
drivers/irqchip/irq-gic-v5-irs.c line 257
Quoted 4 lines
drivers/irqchip/irq-gic-v5-irs.c new file +3
-0+int ret, i, ncpus, niaffids; + + ncpus =of_property_count_elems_of_size (node,"cpus" ,sizeof (u32));cpus is a phandle? I think this is going to run into current discussion on what phandles to CPUs on an SMT system look like (Rob Herring and Mark Rutland have different views)
https://lore.kernel.org/linux-arm-kernel/[email protected]/
I will make sure to steer clear of that then ;-), whatever the outcome the current "cpus" bindings should continue to work as-is, right ?
Quoted 2 lines
Anyhow this doesn't look right to me.
I think it should beof_count_phandle_with_args()
Aren't they equivalent in functionality if of_count_phandle_with_args() cells_name == NULL ?
I will update the code but if the functionality provided is not the same there is kernel code to fix (it is an example, there are others):
Quoted 13 lines
Potentially with cpu-cells as the argument depending on how that thread goes.
drivers/irqchip/irq-gic-v5-irs.c line 265
Quoted 8 lines
drivers/irqchip/irq-gic-v5-irs.c new file +8
-0+if (ncpus <0 ) +return -EINVAL ; + + niaffids =of_property_count_elems_of_size (node,"arm,iaffids" , +sizeof (u16)); +if (niaffids != ncpus) +return -EINVAL ; +u16 *iaffids __free(kfree) = kcalloc(niaffids, sizeof(*iaffids), GFP_KERNEL);
Maybe I should rewrite this in Rust :)
Quoted 20 lines
Quoted 7 lines
drivers/irqchip/irq-gic-v5-irs.c new file +7
-0+ iaffids =kcalloc (niaffids,sizeof (*iaffids),GFP_KERNEL ); +if (!iaffids) +return -ENOMEM ; + + ret =of_property_read_u16_array (node,"arm,iaffids" , iaffids, niaffids); +if (ret) +return ret;drivers/irqchip/irq-gic-v5-irs.c line 282
Quoted 10 lines
drivers/irqchip/irq-gic-v5-irs.c new file +10
-0+ +for (i =0 ; i < ncpus; i++) { +struct device_node *cpu_node; +u32 cpu_phandle; +int cpu; + +if (of_property_read_u32_index (node,"cpus" , i, &cpu_phandle)) +continue ; + + cpu_node =of_find_node_by_phandle (cpu_phandle);cpu_node = of_parse_phandle(node, "cpus", i);
Quoted 1 line
not work here?
I think it would.
Quoted 44 lines
drivers/irqchip/irq-gic-v5-irs.c line 286
Quoted 5 lines
drivers/irqchip/irq-gic-v5-irs.c new file +4
-0+if (WARN_ON (!cpu_node)) +continue ; + + cpu =of_cpu_node_to_id (cpu_node);If this is all you want then Ali's series gives you a helper
cpu = of_cpu_phandle_to_id(node, &cpu_node, i);Though even better to have a helper that allows
cpu =of_cpu_phandle_to_id(node, NULL, i); and handles
the node put as internally.Ali, any reason we can't do that? Seems to be a fairly common pattern.
Quoted 25 lines
drivers/irqchip/irq-gic-v5-irs.c new file +19
-0+of_node_put (cpu_node); +if (WARN_ON (cpu <0 )) +continue ; + +if (iaffids[i] & ~iaffid_mask) { +pr_warn ("CPU %d iaffid 0x%x exceeds IRS iaffid bits\n" , + cpu, iaffids[i]); +continue ; + } + +per_cpu (cpu_iaffid, cpu).iaffid = iaffids[i]; +per_cpu (cpu_iaffid, cpu).valid = true; + +/* We also know that the CPU is connected to this IRS */ +per_cpu (per_cpu_irs_data, cpu) = irs_data; + } + +return ret; +}drivers/irqchip/irq-gic-v5.c +0
-0
Quoted 7 lines
drivers/irqchip/irq-gic-v5.c static int gicv5_ppi_irq_set_irqchip_state(struct irq_data *d, · line 367
Quoted 5 lines
drivers/irqchip/irq-gic-v5.c +5
-0+ +static int gicv5_spi_irq_set_irqchip_state (struct irq_data *d, +enum irqchip_irq_state which, +bool val) +{Similar to previous, I'd call the state parameter state rather than val.
Right.
Quoted 34 lines
include/linux/irqchip/arm-gic-v5.h line 12
Quoted 13 lines
include/linux/irqchip/arm-gic-v5.h +4
-0@@ -5,6 +5,8 @@#ifndef __LINUX_IRQCHIP_ARM_GIC_V5_H#define __LINUX_IRQCHIP_ARM_GIC_V5_H +#define GICV5_NO_READ_ALLOC 0b0 +#define GICV5_READ_ALLOC 0b1 +#define GICV5_NO_WRITE_ALLOC 0b0 +#define GICV5_WRITE_ALLOC 0b1Given these are being written to fields called
_RAand_WAso the defines provide value over 0 and 1 in appropriate places? Maybe just about. Anyhow, your code so on this up to you.Quoted 16 lines
include/linux/irqchip/arm-gic-v5.h +16
-0+ +#define GICV5_NON_CACHE 0b00 +#define GICV5_WB_CACHE 0b01 +#define GICV5_WT_CACHE 0b10 + +#define GICV5_NON_SHARE 0b00 +#define GICV5_OUTER_SHARE 0b10 +#define GICV5_INNER_SHARE 0b11 + +#define GICV5_IRS_IDR1 0x0004 +#define GICV5_IRS_IDR2 0x0008 +#define GICV5_IRS_IDR5 0x0014 +#define GICV5_IRS_IDR6 0x0018 +#define GICV5_IRS_IDR7 0x001c +#define GICV5_IRS_CR0 0x0080 +#define GICV5_IRS_CR1 0x0084
Quoted 8 lines
include/linux/irqchip/arm-gic-v5.h line 44
Quoted 6 lines
include/linux/irqchip/arm-gic-v5.h +6
-0+#define GICV5_IRS_SPI_SELR 0x0108 +#define GICV5_IRS_SPI_CFGR 0x0114 +#define GICV5_IRS_SPI_STATUSR 0x0118 +#define GICV5_IRS_PE_SELR 0x0140 +#define GICV5_IRS_PE_STATUSR 0x0144 +#define GICV5_IRS_PE_CR0 0x0148Blank line here as this is end of register offsets.
Yep, fixed it.
Thanks for having a look !
Lorenzo
Quoted 5 lines
Quoted 2 lines
include/linux/irqchip/arm-gic-v5.h +2
-0+#define GICV5_IRS_IDR1_PRIORITY_BITS GENMASK(22, 20) +#define GICV5_IRS_IDR1_IAFFID_BITS GENMASK(19, 16)
Re: [PATCH v4 21/26] irqchip/gic-v5: Add GICv5 IRS/SPI support
Quoted 283 lines · On Thu, 29 May 2025 10:38:05 +0200 Lorenzo Pieralisi <[email protected]>…
Quoted 77 lines · Jonathan Cameron
Quoted 40 lines · On Tue, 13 May 2025 19:48:14 +0200 Lorenzo Pieralisi <[email protected]>…
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 handlingSPIs 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.
Quoted 9 lines
Co-developed-by Sascha Bischoff <[email protected]>Signed-off-by Sascha Bischoff <[email protected]>Co-developed-by Timothy Hayes <[email protected]>Signed-off-by Timothy Hayes <[email protected]>Signed-off-by Lorenzo Pieralisi <[email protected]>Cc Will Deacon <[email protected]>Cc Thomas Gleixner <[email protected]>Cc Catalin Marinas <[email protected]>Cc Marc Zyngier <[email protected]>A few comments inline. Mostly around of cpu phandle parsing. +CC Ali as there is a comment on his SMT DT patch set inline.
Quoted 20 lines
--- arch/arm64/include/asm/sysreg.h | 36 +++ drivers/irqchip/Makefile | 2 +- drivers/irqchip/irq-gic-v5-irs.c | 433+++++++++++++++++++++++++++++++++++++
drivers/irqchip/irq-gic-v5.c| 341
+++++++++++++++++++++++++++--include/linux/irqchip/arm-gic-v5.h| 130 +++++++++++ 5 files changed, 920 insertions(+), 22 deletions(-)(quoted diff) +0
-0
b/arch/arm64/include/asm/sysreg.hindex9d28d408f9c6df24526dd8ecbf3c7d920246b22d..fbac3b6f056ae6fafd64457600d45808e4904ae3100644 ---a/arch/arm64/include/asm/sysreg.h+++b/arch/arm64/include/asm/sysreg.h@@ -1082,14 +1082,50 @@
/*
* Definitions for GICv5 instructions
*/Quoted 3 lines
Quoted 1 line
+/* Shift and mask definitions for GIC CDAFF */
Similar comment. Mask definitions seems more accurate to me.
Fixed.
Quoted 10 lines
Quoted 7 lines
arch/arm64/include/asm/sysreg.h +3
-0+/* 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)+#defineGICV5_GIC_CDDIS_ID_MASKGENMASK_ULL(23, 0)
+#defineGICV5_GIC_CDDIS_ID(r)FIELD_GET(GICV5_GIC_CDDIS_ID_MASK, r)Similar to earlier comment. I'm not sure the shortened forms are worth the bother.
Same as previous replies.
Quoted 59 lines
Quoted 47 lines
(quoted diff) +0
-0
b/drivers/irqchip/irq-gic-v5-irs.cnew file mode 100644
index 0000000000000000000000000000000000000000..8c448487b909c7d3b4e1f95a5bc02b741ecc40b3 ---/dev/null+++b/drivers/irqchip/irq-gic-v5-irs.cdrivers/irqchip/irq-gic-v5-irs.c new file +38
-0@@ -0,0 +1,433 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* +* Copyright (C) 2024-2025 ARM Limited, All Rights Reserved. +*/ + +#define pr_fmt (fmt) "GICv5 IRS: " fmt + +#include <linux/of.h> +#include <linux/of_address.h> + +#include <linux/irqchip.h> +#include <linux/irqchip/arm-gic-v5.h> +int gicv5_spi_irq_set_type (struct irq_data *d,unsigned int type) +{ +struct gicv5_irs_chip_data *irs_data = d->chip_data; +u32 selr, cfgr; +bool level; +int ret; + +switch (type) { +case IRQ_TYPE_EDGE_RISING : +case IRQ_TYPE_EDGE_FALLING : + level = false; +break ; +case IRQ_TYPE_LEVEL_HIGH : +case IRQ_TYPE_LEVEL_LOW : + level = true; +break ; +default : +return -EINVAL ; + } + +guard (raw_spinlock)(&irs_data->spi_config_lock); + + selr =FIELD_PREP (GICV5_IRS_SPI_SELR_ID , d->hwirq); +irs_writel_relaxed (irs_data, selr,GICV5_IRS_SPI_SELR ); + ret =gicv5_irs_wait_for_spi_op (irs_data); +if (ret)drivers/irqchip/irq-gic-v5-irs.c line 146
Quoted 10 lines
drivers/irqchip/irq-gic-v5-irs.c new file +10
-0+return ret; + + cfgr =FIELD_PREP (GICV5_IRS_SPI_CFGR_TM , level); + +irs_writel_relaxed (irs_data, cfgr,GICV5_IRS_SPI_CFGR ); + ret =gicv5_irs_wait_for_spi_op (irs_data); +if (ret) +return ret; + +return 0 ;return
gicv5_irq_wait_for_spi_op()Quoted 1 line
unless more code turns up here in a later patch.
Ok.
Quoted 95 lines
Quoted 29 lines
drivers/irqchip/irq-gic-v5-irs.c new file +3
-0+} + +static void __init gicv5_irs_init_bases(struct
gicv5_irs_chip_data*irs_data,(quoted diff) +2
-0+ void __iomem *irs_base, + struct fwnode_handle*handle) +{
drivers/irqchip/irq-gic-v5-irs.c new file +9
-0+struct device_node *np =to_of_node (handle); +u32 cr0, cr1; + + irs_data->fwnode = handle; + irs_data->irs_base = irs_base; + +if (of_property_read_bool (np,"dma-noncoherent" )) { +/* +* A non-coherent IRS implies that some cache levels cannot be
(quoted diff) +1
-0+ * used coherently by the cores and GIC. Ouronly option is to mark
(quoted diff) +1
-0+ * memory attributes for the GIC asnon-cacheable; by default,
(quoted diff) +1
-0+ * non-cacheable memory attributes implyouter-shareable
(quoted diff) +1
-0+ * shareability, the value written into
IRS_CR1_SHis ignored.(quoted diff) +2
-0+ */ + cr1 = FIELD_PREP(GICV5_IRS_CR1_VPED_WA,Quoted 1 line
GICV5_NO_WRITE_ALLOC) |As per earlier comments is this less clear as:
cr1 = FIELD_PREP(GICV5_IRS_CR1_VPED_WA, 0) |To me, seems fine but up to you.
Quoted 60 lines
(quoted diff) +1
-0+ FIELD_PREP(GICV5_IRS_CR1_VPED_RA,
GICV5_NO_READ_ALLOC) |(quoted diff) +1
-0+ FIELD_PREP(GICV5_IRS_CR1_VMD_WA,
GICV5_NO_WRITE_ALLOC) |(quoted diff) +1
-0+ FIELD_PREP(GICV5_IRS_CR1_VMD_RA,
GICV5_NO_READ_ALLOC) |(quoted diff) +1
-0+ FIELD_PREP(GICV5_IRS_CR1_VPET_RA,
GICV5_NO_READ_ALLOC) |(quoted diff) +1
-0+ FIELD_PREP(GICV5_IRS_CR1_VMT_RA,
GICV5_NO_READ_ALLOC) |(quoted diff) +1
-0+ FIELD_PREP(GICV5_IRS_CR1_IST_WA,
GICV5_NO_WRITE_ALLOC) |(quoted diff) +1
-0+ FIELD_PREP(GICV5_IRS_CR1_IST_RA,
GICV5_NO_READ_ALLOC) |(quoted diff) +1
-0+ FIELD_PREP(GICV5_IRS_CR1_IC,
GICV5_NON_CACHE) |(quoted diff) +1
-0+ FIELD_PREP(GICV5_IRS_CR1_OC,
GICV5_NON_CACHE);(quoted diff) +1
-0+ irs_data->flags |=
IRS_FLAGS_NON_COHERENT;(quoted diff) +2
-0+ } else { + cr1 = FIELD_PREP(GICV5_IRS_CR1_VPED_WA,
GICV5_WRITE_ALLOC) |(quoted diff) +1
-0+ FIELD_PREP(GICV5_IRS_CR1_VPED_RA,
GICV5_READ_ALLOC) |(quoted diff) +1
-0+ FIELD_PREP(GICV5_IRS_CR1_VMD_WA,
GICV5_WRITE_ALLOC) |(quoted diff) +1
-0+ FIELD_PREP(GICV5_IRS_CR1_VMD_RA,
GICV5_READ_ALLOC) |(quoted diff) +1
-0+ FIELD_PREP(GICV5_IRS_CR1_VPET_RA,
GICV5_READ_ALLOC) |(quoted diff) +1
-0+ FIELD_PREP(GICV5_IRS_CR1_VMT_RA,
GICV5_READ_ALLOC) |(quoted diff) +1
-0+ FIELD_PREP(GICV5_IRS_CR1_IST_WA,
GICV5_WRITE_ALLOC) |(quoted diff) +1
-0+ FIELD_PREP(GICV5_IRS_CR1_IST_RA,
GICV5_READ_ALLOC) |(quoted diff) +1
-0+ FIELD_PREP(GICV5_IRS_CR1_IC,
GICV5_WB_CACHE) |(quoted diff) +1
-0+ FIELD_PREP(GICV5_IRS_CR1_OC,
GICV5_WB_CACHE) |(quoted diff) +1
-0+ FIELD_PREP(GICV5_IRS_CR1_SH,
GICV5_INNER_SHARE);drivers/irqchip/irq-gic-v5-irs.c new file +10
-0+ } + +irs_writel_relaxed (irs_data, cr1,GICV5_IRS_CR1 ); + + cr0 =FIELD_PREP (GICV5_IRS_CR0_IRSEN ,0x1 ); +irs_writel_relaxed (irs_data, cr0,GICV5_IRS_CR0 ); +gicv5_irs_wait_for_idle (irs_data); +} + +static int __init gicv5_irs_of_init_affinity(struct device_node*node,
(quoted diff) +1
-0+ struct
gicv5_irs_chip_data*irs_data,drivers/irqchip/irq-gic-v5-irs.c new file +4
-0+ u8 iaffid_bits) +{ +/* +* Detect IAFFID<->CPU mappings from the device tree and Quoted 8 lines
drivers/irqchip/irq-gic-v5-irs.c line 254
Quoted 4 lines
drivers/irqchip/irq-gic-v5-irs.c new file +4
-0+* record IRS<->CPU topology information. +*/ +u16 iaffid_mask =GENMASK (iaffid_bits -1 ,0 ); + u16 *iaffids __free(kfree) = NULL;See comments in
cleanup.h. Linus has been fairly clear he doesn't like separating the constructor and destructor like this - just declare iaffids where you construct it.Right.
Quoted 10 lines
Quoted 5 lines
drivers/irqchip/irq-gic-v5-irs.c new file +3
-0+int ret, i, ncpus, niaffids; + + ncpus = of_property_count_elems_of_size(node, "cpus",sizeof(u32));
cpus is a phandle? I think this is going to run into current discussion on what phandles to CPUs on an SMT system look like (Rob Herring and Mark Rutland have different views)
https://lore.kernel.org/linux-arm-kernel/[email protected]/I will make sure to steer clear of that then ;-), whatever the outcome the current "cpus" bindings should continue to work as-is, right ?
Quoted 2 lines
Anyhow this doesn't look right to me.
I think it should beof_count_phandle_with_args()
Quoted 7 lines
Aren't they equivalent in functionality if
of_count_phandle_with_args()cells_name== NULL ?I will update the code but if the functionality provided is not the same there is kernel code to fix (it is an example, there are others):
I think this is fine, as long as we have always len(reg) == 1 which is our current case in the dt.
Quoted 159 lines
Quoted 4 lines
Potentially with cpu-cells as the argument depending on how that thread goes.
Quoted 11 lines
drivers/irqchip/irq-gic-v5-irs.c line 265
Quoted 9 lines
drivers/irqchip/irq-gic-v5-irs.c new file +4
-0+if (ncpus <0 ) +return -EINVAL ; + + niaffids = of_property_count_elems_of_size(node,"arm,iaffids",
drivers/irqchip/irq-gic-v5-irs.c new file +4
-0+ sizeof(u16)); +if (niaffids != ncpus) +return -EINVAL ; +u16 *iaffids
__free(kfree)= kcalloc(niaffids,sizeof(*iaffids),GFP_KERNEL);Maybe I should rewrite this in Rust :)
Quoted 24 lines
Quoted 18 lines
(quoted diff) +1
-0+ iaffids = kcalloc(niaffids, sizeof(*iaffids),
GFP_KERNEL);drivers/irqchip/irq-gic-v5-irs.c new file +4
-0+if (!iaffids) +return -ENOMEM ; + + ret = of_property_read_u16_array(node, "arm,iaffids",iaffids, niaffids);
drivers/irqchip/irq-gic-v5-irs.c new file +9
-0+if (ret) +return ret; + +for (i =0 ; i < ncpus; i++) { +struct device_node *cpu_node; +u32 cpu_phandle; +int cpu; + + if (of_property_read_u32_index(node, "cpus", i,
&cpu_phandle))drivers/irqchip/irq-gic-v5-irs.c line 282
Quoted 3 lines
drivers/irqchip/irq-gic-v5-irs.c new file +3
-0+continue ; + + cpu_node =of_find_node_by_phandle (cpu_phandle);cpu_node = of_parse_phandle(node, "cpus", i);Quoted 1 line
not work here?
I think it would.
Quoted 47 lines
drivers/irqchip/irq-gic-v5-irs.c line 286
Quoted 5 lines
drivers/irqchip/irq-gic-v5-irs.c new file +4
-0+if (WARN_ON (!cpu_node)) +continue ; + + cpu =of_cpu_node_to_id (cpu_node);If this is all you want then Ali's series gives you a helper
cpu = of_cpu_phandle_to_id(node, &cpu_node, i);Though even better to have a helper that allows
cpu =of_cpu_phandle_to_id(node, NULL, i); and
handles the node put as internally.Ali, any reason we can't do that? Seems to be a fairly common pattern.
Quoted 28 lines
drivers/irqchip/irq-gic-v5-irs.c new file +6
-0+of_node_put (cpu_node); +if (WARN_ON (cpu <0 )) +continue ; + +if (iaffids[i] & ~iaffid_mask) { + pr_warn("CPU %d iaffid 0x%x exceeds IRSiaffid bits\n",
drivers/irqchip/irq-gic-v5-irs.c new file +8
-0+ cpu, iaffids[i]); +continue ; + } + +per_cpu (cpu_iaffid, cpu).iaffid = iaffids[i]; +per_cpu (cpu_iaffid, cpu).valid = true; + +/* We also know that the CPU is connected to this IRS */
drivers/irqchip/irq-gic-v5-irs.c new file +5
-0+per_cpu (per_cpu_irs_data, cpu) = irs_data; + } + +return ret; +}(quoted diff) +0
-0
b/drivers/irqchip/irq-gic-v5.cindexa50982e5d98816d88e4fca37cc0ac31684fb6c76..e58ff345dbfaf840b17ad63c4fdb6c227137cf4b100644 ---a/drivers/irqchip/irq-gic-v5.c+++b/drivers/irqchip/irq-gic-v5.cQuoted 9 lines
Review
Quoted 6 lines
drivers/irqchip/irq-gic-v5.c +3
-0+ +static int gicv5_spi_irq_set_irqchip_state(struct irq_data *d, + enum
irqchip_irq_statewhich,(quoted diff) +2
-0+ bool val) +{Similar to previous, I'd call the state parameter state rather than val.
Right.
Quoted 34 lines
include/linux/irqchip/arm-gic-v5.h line 22
Quoted 13 lines
(quoted diff) +0
-0
b/include/linux/irqchip/arm-gic-v5.hindex4ff0ba64d9840c3844671f7850bb3d81ba2eb1b6..187af307de9170d9569898cb1e50de376a38bd0a100644 ---a/include/linux/irqchip/arm-gic-v5.h+++b/include/linux/irqchip/arm-gic-v5.h@@ -5,6 +5,8 @@
#ifndef__LINUX_IRQCHIP_ARM_GIC_V5_H
#define__LINUX_IRQCHIP_ARM_GIC_V5_Hinclude/linux/irqchip/arm-gic-v5.h +4
-0+#define GICV5_NO_READ_ALLOC 0b0 +#define GICV5_READ_ALLOC 0b1 +#define GICV5_NO_WRITE_ALLOC 0b0 +#define GICV5_WRITE_ALLOC 0b1Given these are being written to fields called
_RAand_WAso the defines provide value over 0 and 1 in appropriate places? Maybe just about. Anyhow, your code so on this up to you.Quoted 16 lines
include/linux/irqchip/arm-gic-v5.h +16
-0+ +#define GICV5_NON_CACHE 0b00 +#define GICV5_WB_CACHE 0b01 +#define GICV5_WT_CACHE 0b10 + +#define GICV5_NON_SHARE 0b00 +#define GICV5_OUTER_SHARE 0b10 +#define GICV5_INNER_SHARE 0b11 + +#define GICV5_IRS_IDR1 0x0004 +#define GICV5_IRS_IDR2 0x0008 +#define GICV5_IRS_IDR5 0x0014 +#define GICV5_IRS_IDR6 0x0018 +#define GICV5_IRS_IDR7 0x001c +#define GICV5_IRS_CR0 0x0080 +#define GICV5_IRS_CR1 0x0084Quoted 8 lines
include/linux/irqchip/arm-gic-v5.h line 44
Quoted 6 lines
include/linux/irqchip/arm-gic-v5.h +6
-0+#define GICV5_IRS_SPI_SELR 0x0108 +#define GICV5_IRS_SPI_CFGR 0x0114 +#define GICV5_IRS_SPI_STATUSR 0x0118 +#define GICV5_IRS_PE_SELR 0x0140 +#define GICV5_IRS_PE_STATUSR 0x0144 +#define GICV5_IRS_PE_CR0 0x0148Blank line here as this is end of register offsets.
Yep, fixed it.
Thanks for having a look !
LorenzoQuoted 5 lines
Quoted 2 lines
include/linux/irqchip/arm-gic-v5.h +2
-0+#define GICV5_IRS_IDR1_PRIORITY_BITS GENMASK(22, 20) +#define GICV5_IRS_IDR1_IAFFID_BITS GENMASK(19, 16)
Lorenzo Pieralisi
maintainerRe: [PATCH v4 21/26] irqchip/gic-v5: Add GICv5 IRS/SPI support
On Thu, May 29, 2025 at 09:45:19AM +0100, Alireza Sanaee wrote:
[...]
Quoted 14 lines
Quoted 14 lines
Quoted 4 lines
cpus is a phandle? I think this is going to run into current discussion on what phandles to CPUs on an SMT system look like (Rob Herring and Mark Rutland have different views)
https://lore.kernel.org/linux-arm-kernel/[email protected]/I will make sure to steer clear of that then ;-), whatever the outcome the current "cpus" bindings should continue to work as-is, right ?
Quoted 2 lines
Anyhow this doesn't look right to me.
I think it should beof_count_phandle_with_args()Aren't they equivalent in functionality if
of_count_phandle_with_args()cells_name== NULL ?
Quoted 7 lines
Quoted 4 lines
I will update the code but if the functionality provided is not the same there is kernel code to fix (it is an example, there are others):
I think this is fine, as long as we have always len(reg) == 1 which is our current case in the dt.
I don't understand what you mean. "cpus" is a list of phandles, what has "reg" got to do with it ?
"reg" of which node ? "cpu" ? why should it be that len(reg) == 1 always ? It describes MPIDR_EL1, it depends on the "cpus" _node_ #address-cells.
I am missing something from the thread above probably.
Lorenzo
Quoted 160 lines
Quoted 159 lines
Quoted 4 lines
Potentially with cpu-cells as the argument depending on how that thread goes.
Quoted 11 lines
drivers/irqchip/irq-gic-v5-irs.c line 265
Quoted 9 lines
drivers/irqchip/irq-gic-v5-irs.c new file +4
-0+if (ncpus <0 ) +return -EINVAL ; + + niaffids = of_property_count_elems_of_size(node,"arm,iaffids",
drivers/irqchip/irq-gic-v5-irs.c new file +4
-0+ sizeof(u16)); +if (niaffids != ncpus) +return -EINVAL ; +u16 *iaffids
__free(kfree)= kcalloc(niaffids,sizeof(*iaffids),GFP_KERNEL);Maybe I should rewrite this in Rust :)
Quoted 24 lines
Quoted 18 lines
(quoted diff) +1
-0+ iaffids = kcalloc(niaffids, sizeof(*iaffids),
GFP_KERNEL);drivers/irqchip/irq-gic-v5-irs.c new file +4
-0+if (!iaffids) +return -ENOMEM ; + + ret = of_property_read_u16_array(node, "arm,iaffids",iaffids, niaffids);
drivers/irqchip/irq-gic-v5-irs.c new file +9
-0+if (ret) +return ret; + +for (i =0 ; i < ncpus; i++) { +struct device_node *cpu_node; +u32 cpu_phandle; +int cpu; + + if (of_property_read_u32_index(node, "cpus", i,
&cpu_phandle))drivers/irqchip/irq-gic-v5-irs.c line 282
Quoted 3 lines
drivers/irqchip/irq-gic-v5-irs.c new file +3
-0+continue ; + + cpu_node =of_find_node_by_phandle (cpu_phandle);cpu_node = of_parse_phandle(node, "cpus", i);Quoted 1 line
not work here?
I think it would.
Quoted 47 lines
drivers/irqchip/irq-gic-v5-irs.c line 286
Quoted 5 lines
drivers/irqchip/irq-gic-v5-irs.c new file +4
-0+if (WARN_ON (!cpu_node)) +continue ; + + cpu =of_cpu_node_to_id (cpu_node);If this is all you want then Ali's series gives you a helper
cpu = of_cpu_phandle_to_id(node, &cpu_node, i);Though even better to have a helper that allows
cpu =of_cpu_phandle_to_id(node, NULL, i); and
handles the node put as internally.Ali, any reason we can't do that? Seems to be a fairly common pattern.
Quoted 28 lines
drivers/irqchip/irq-gic-v5-irs.c new file +6
-0+of_node_put (cpu_node); +if (WARN_ON (cpu <0 )) +continue ; + +if (iaffids[i] & ~iaffid_mask) { + pr_warn("CPU %d iaffid 0x%x exceeds IRSiaffid bits\n",
drivers/irqchip/irq-gic-v5-irs.c new file +8
-0+ cpu, iaffids[i]); +continue ; + } + +per_cpu (cpu_iaffid, cpu).iaffid = iaffids[i]; +per_cpu (cpu_iaffid, cpu).valid = true; + +/* We also know that the CPU is connected to this IRS */
drivers/irqchip/irq-gic-v5-irs.c new file +5
-0+per_cpu (per_cpu_irs_data, cpu) = irs_data; + } + +return ret; +}(quoted diff) +0
-0
b/drivers/irqchip/irq-gic-v5.cindexa50982e5d98816d88e4fca37cc0ac31684fb6c76..e58ff345dbfaf840b17ad63c4fdb6c227137cf4b100644 ---a/drivers/irqchip/irq-gic-v5.c+++b/drivers/irqchip/irq-gic-v5.cQuoted 9 lines
Review
Quoted 6 lines
drivers/irqchip/irq-gic-v5.c +3
-0+ +static int gicv5_spi_irq_set_irqchip_state(struct irq_data *d, + enum
irqchip_irq_statewhich,(quoted diff) +2
-0+ bool val) +{Similar to previous, I'd call the state parameter state rather than val.
Right.
Quoted 34 lines
include/linux/irqchip/arm-gic-v5.h line 22
Quoted 13 lines
(quoted diff) +0
-0
b/include/linux/irqchip/arm-gic-v5.hindex4ff0ba64d9840c3844671f7850bb3d81ba2eb1b6..187af307de9170d9569898cb1e50de376a38bd0a100644 ---a/include/linux/irqchip/arm-gic-v5.h+++b/include/linux/irqchip/arm-gic-v5.h@@ -5,6 +5,8 @@
#ifndef__LINUX_IRQCHIP_ARM_GIC_V5_H
#define__LINUX_IRQCHIP_ARM_GIC_V5_Hinclude/linux/irqchip/arm-gic-v5.h +4
-0+#define GICV5_NO_READ_ALLOC 0b0 +#define GICV5_READ_ALLOC 0b1 +#define GICV5_NO_WRITE_ALLOC 0b0 +#define GICV5_WRITE_ALLOC 0b1Given these are being written to fields called
_RAand_WAso the defines provide value over 0 and 1 in appropriate places? Maybe just about. Anyhow, your code so on this up to you.Quoted 16 lines
include/linux/irqchip/arm-gic-v5.h +16
-0+ +#define GICV5_NON_CACHE 0b00 +#define GICV5_WB_CACHE 0b01 +#define GICV5_WT_CACHE 0b10 + +#define GICV5_NON_SHARE 0b00 +#define GICV5_OUTER_SHARE 0b10 +#define GICV5_INNER_SHARE 0b11 + +#define GICV5_IRS_IDR1 0x0004 +#define GICV5_IRS_IDR2 0x0008 +#define GICV5_IRS_IDR5 0x0014 +#define GICV5_IRS_IDR6 0x0018 +#define GICV5_IRS_IDR7 0x001c +#define GICV5_IRS_CR0 0x0080 +#define GICV5_IRS_CR1 0x0084Quoted 8 lines
include/linux/irqchip/arm-gic-v5.h line 44
Quoted 6 lines
include/linux/irqchip/arm-gic-v5.h +6
-0+#define GICV5_IRS_SPI_SELR 0x0108 +#define GICV5_IRS_SPI_CFGR 0x0114 +#define GICV5_IRS_SPI_STATUSR 0x0118 +#define GICV5_IRS_PE_SELR 0x0140 +#define GICV5_IRS_PE_STATUSR 0x0144 +#define GICV5_IRS_PE_CR0 0x0148Blank line here as this is end of register offsets.
Yep, fixed it.
Thanks for having a look !
LorenzoQuoted 5 lines
Quoted 2 lines
include/linux/irqchip/arm-gic-v5.h +2
-0+#define GICV5_IRS_IDR1_PRIORITY_BITS GENMASK(22, 20) +#define GICV5_IRS_IDR1_IAFFID_BITS GENMASK(19, 16)
Re: [PATCH v4 21/26] irqchip/gic-v5: Add GICv5 IRS/SPI support
Quoted 30 lines · On Thu, 29 May 2025 11:32:06 +0200 Lorenzo Pieralisi <[email protected]>…
On Thu, May 29, 2025 at 09:45:19AM +0100, Alireza Sanaee wrote:
[...]
Quoted 14 lines
Quoted 14 lines
Quoted 4 lines
cpus is a phandle? I think this is going to run into current discussion on what phandles to CPUs on an SMT system look like (Rob Herring and Mark Rutland have different views)
https://lore.kernel.org/linux-arm-kernel/[email protected]/I will make sure to steer clear of that then ;-), whatever the outcome the current "cpus" bindings should continue to work as-is, right ?
Quoted 2 lines
Anyhow this doesn't look right to me.
I think it should beof_count_phandle_with_args()Aren't they equivalent in functionality if
of_count_phandle_with_args()cells_name== NULL ?Quoted 8 lines
Quoted 5 lines
I will update the code but if the functionality provided is not the same there is kernel code to fix (it is an example, there are others):
I think this is fine, as long as we have always len(reg) == 1 which is our current case in the dt.
I don't understand what you mean. "cpus" is a list of phandles, what has "reg" got to do with it ?
Quoted 7 lines
"reg" of which node ? "cpu" ? why should it be that len(reg) == 1 always ? It describes
MPIDR_EL1, it depends on the "cpus" _node_ #address-cells.I am missing something from the thread above probably.
Lorenzo
Hi Lorenzo,
This goes back to the Rob and Mark discussion in regards to representing SMTs.
With SMTs if cpu-node reg property has
more than one entry, then you probably have to count them and also ref them differently.
But if every single SMT is a cpu-node in the DT (which is indeed how things are currently), it is fine.
Thanks,
Alireza
Quoted 165 lines
Quoted 163 lines
Quoted 162 lines
Quoted 5 lines
Potentially with cpu-cells as the argument depending on how that thread goes.
Quoted 12 lines
drivers/irqchip/irq-gic-v5-irs.c line 265
Quoted 10 lines
drivers/irqchip/irq-gic-v5-irs.c new file +4
-0+if (ncpus <0 ) +return -EINVAL ; + + niaffids = of_property_count_elems_of_size(node,"arm,iaffids",
+
sizeof(u16));drivers/irqchip/irq-gic-v5-irs.c new file +3
-0+if (niaffids != ncpus) +return -EINVAL ; +u16 *iaffids
__free(kfree)= kcalloc(niaffids,sizeof(*iaffids),GFP_KERNEL);Maybe I should rewrite this in Rust :)
Quoted 24 lines
Quoted 20 lines
(quoted diff) +1
-0+ iaffids = kcalloc(niaffids, sizeof(*iaffids),
GFP_KERNEL);drivers/irqchip/irq-gic-v5-irs.c new file +4
-0+if (!iaffids) +return -ENOMEM ; + + ret = of_property_read_u16_array(node, "arm,iaffids",iaffids, niaffids);
drivers/irqchip/irq-gic-v5-irs.c new file +9
-0+if (ret) +return ret; + +for (i =0 ; i < ncpus; i++) { +struct device_node *cpu_node; +u32 cpu_phandle; +int cpu; + + if (of_property_read_u32_index(node, "cpus",i,
&cpu_phandle))drivers/irqchip/irq-gic-v5-irs.c new file +3
-0+continue ; + + cpu_node =Quoted 1 line
of_find_node_by_phandle(cpu_phandle);cpu_node = of_parse_phandle(node, "cpus", i);Quoted 1 line
not work here?
I think it would.
Quoted 47 lines
drivers/irqchip/irq-gic-v5-irs.c line 286
Quoted 5 lines
drivers/irqchip/irq-gic-v5-irs.c new file +4
-0+if (WARN_ON (!cpu_node)) +continue ; + + cpu =of_cpu_node_to_id (cpu_node);If this is all you want then Ali's series gives you a helper
cpu = of_cpu_phandle_to_id(node, &cpu_node, i);Though even better to have a helper that allows
cpu =of_cpu_phandle_to_id(node, NULL, i); and
handles the node put as internally.Ali, any reason we can't do that? Seems to be a fairly common pattern.
Quoted 28 lines
drivers/irqchip/irq-gic-v5-irs.c new file +6
-0+of_node_put (cpu_node); +if (WARN_ON (cpu <0 )) +continue ; + +if (iaffids[i] & ~iaffid_mask) { + pr_warn("CPU %d iaffid 0x%x exceedsIRS iaffid bits\n",
drivers/irqchip/irq-gic-v5-irs.c new file +8
-0+ cpu, iaffids[i]); +continue ; + } + +per_cpu (cpu_iaffid, cpu).iaffid = iaffids[i]; +per_cpu (cpu_iaffid, cpu).valid = true; + +/* We also know that the CPU is connected to this IRS */
drivers/irqchip/irq-gic-v5-irs.c new file +5
-0+per_cpu (per_cpu_irs_data, cpu) = irs_data; + } + +return ret; +}(quoted diff) +0
-0
b/drivers/irqchip/irq-gic-v5.cindexa50982e5d98816d88e4fca37cc0ac31684fb6c76..e58ff345dbfaf840b17ad63c4fdb6c227137cf4b100644 ---a/drivers/irqchip/irq-gic-v5.c+++b/drivers/irqchip/irq-gic-v5.cQuoted 10 lines
Review
Quoted 7 lines
(quoted diff) +2
-0+ +static int gicv5_spi_irq_set_irqchip_state(struct irq_data*d,
(quoted diff) +1
-0+ enum
irqchip_irq_statewhich,(quoted diff) +2
-0+ bool val) +{Similar to previous, I'd call the state parameter state rather than val.
Right.
Quoted 34 lines
include/linux/irqchip/arm-gic-v5.h line 22
Quoted 13 lines
(quoted diff) +0
-0
b/include/linux/irqchip/arm-gic-v5.hindex4ff0ba64d9840c3844671f7850bb3d81ba2eb1b6..187af307de9170d9569898cb1e50de376a38bd0a100644 ---a/include/linux/irqchip/arm-gic-v5.h+++b/include/linux/irqchip/arm-gic-v5.h@@ -5,6 +5,8 @@
#ifndef__LINUX_IRQCHIP_ARM_GIC_V5_H
#define__LINUX_IRQCHIP_ARM_GIC_V5_Hinclude/linux/irqchip/arm-gic-v5.h +4
-0+#define GICV5_NO_READ_ALLOC 0b0 +#define GICV5_READ_ALLOC 0b1 +#define GICV5_NO_WRITE_ALLOC 0b0 +#define GICV5_WRITE_ALLOC 0b1Given these are being written to fields called
_RAand_WAso the defines provide value over 0 and 1 in appropriate places? Maybe just about. Anyhow, your code so on this up to you.Quoted 16 lines
include/linux/irqchip/arm-gic-v5.h +16
-0+ +#define GICV5_NON_CACHE 0b00 +#define GICV5_WB_CACHE 0b01 +#define GICV5_WT_CACHE 0b10 + +#define GICV5_NON_SHARE 0b00 +#define GICV5_OUTER_SHARE 0b10 +#define GICV5_INNER_SHARE 0b11 + +#define GICV5_IRS_IDR1 0x0004 +#define GICV5_IRS_IDR2 0x0008 +#define GICV5_IRS_IDR5 0x0014 +#define GICV5_IRS_IDR6 0x0018 +#define GICV5_IRS_IDR7 0x001c +#define GICV5_IRS_CR0 0x0080 +#define GICV5_IRS_CR1 0x0084Quoted 8 lines
include/linux/irqchip/arm-gic-v5.h line 44
Quoted 6 lines
include/linux/irqchip/arm-gic-v5.h +6
-0+#define GICV5_IRS_SPI_SELR 0x0108 +#define GICV5_IRS_SPI_CFGR 0x0114 +#define GICV5_IRS_SPI_STATUSR 0x0118 +#define GICV5_IRS_PE_SELR 0x0140 +#define GICV5_IRS_PE_STATUSR 0x0144 +#define GICV5_IRS_PE_CR0 0x0148Blank line here as this is end of register offsets.
Yep, fixed it.
Thanks for having a look !
LorenzoQuoted 5 lines
Quoted 2 lines
include/linux/irqchip/arm-gic-v5.h +2
-0+#define GICV5_IRS_IDR1_PRIORITY_BITS GENMASK(22, 20) +#define GICV5_IRS_IDR1_IAFFID_BITS GENMASK(19, 16)
Lorenzo Pieralisi
maintainerPATCH v4 22/26 irqchip/gic-v5: Add GICv5 LPI/IPI support
In reply to Lorenzo PieralisiAn 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/include/asm/sysreg.h | 6 + arch/arm64/kernel/smp.c | 17 -- drivers/irqchip/irq-gic-v5-irs.c | 360 +++++++++++++++++++++++++++++++++++++ drivers/irqchip/irq-gic-v5.c | 298 +++++++++++++++++++++++++++++- include/linux/irqchip/arm-gic-v5.h | 59 ++++++ 6 files changed, 738 insertions(+), 19 deletions(-)
arch/arm64/include/asm/smp.h +17 -0
@@ -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/include/asm/sysreg.h +6 -0
@@ -1085,6 +1085,7 @@#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_CDHM sys_insn(1, 0, 12, 2, 1)#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)
@@ -1108,6 +1109,11 @@#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 CDHM */ +#define GICV5_GIC_CDHM_HM_MASK BIT_ULL(32) +#define GICV5_GIC_CDHM_TYPE_MASK GENMASK_ULL(31, 29) +#define GICV5_GIC_CDHM_ID_MASK GENMASK_ULL(23, 0) +/* Shift and mask definitions for GIC CDEN */ #define GICV5_GIC_CDEN_TYPE_MASK GENMASK_ULL(31, 29)#define GICV5_GIC_CDEN_ID_MASK GENMASK_ULL(23, 0)
arch/arm64/kernel/smp.c +0 -17
@@ -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 +360 -0
396 lines not on this page · raw message
drivers/irqchip/irq-gic-v5.c +296 -2
422 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
Lorenzo Pieralisi
maintainerPATCH v4 23/26 irqchip/gic-v5: Enable GICv5 SMP booting
In reply to Lorenzo PieralisiSet 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
@@ -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>
@@ -908,6 +909,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(),
@@ -919,6 +922,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)
@@ -1040,6 +1059,8 @@ static int __init gicv5_of_init(struct device_node *node, struct device_node *paif (ret) goto out_int; +gicv5_smp_init (); +return 0 ; out_int:gicv5_cpu_disable_interrupts ();
Signature · 1 line
2.48.0
Lorenzo Pieralisi
maintainerPATCH v4 24/26 irqchip/gic-v5: Add GICv5 ITS support
In reply to Lorenzo PieralisiThe 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 | 1183 ++++++++++++++++++++ drivers/irqchip/irq-gic-v5.c | 6 +- include/linux/irqchip/arm-gic-v5.h | 177 +++ 11 files changed, 1416 insertions(+), 9 deletions(-)
MAINTAINERS +1 -0
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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 | \
@@ -199,7 +198,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
@@ -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
@@ -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)
@@ -5143,7 +5144,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 |IRQ_DOMAIN_FLAG_MSI_IMMUTABLE ;return 0 ;
drivers/irqchip/irq-gic-v5-irs.c +25 -0
@@ -481,6 +481,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;
@@ -775,6 +792,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 +1183 -0
1,183 lines not on this page · raw message
drivers/irqchip/irq-gic-v5.c +4 -2
@@ -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); }
@@ -1061,6 +1061,8 @@ static int __init gicv5_of_init(struct device_node *node, struct device_node *pagicv5_smp_init (); +gicv5_irs_its_probe (); +return 0 ; out_int:gicv5_cpu_disable_interrupts ();
include/linux/irqchip/arm-gic-v5.h +177 -0
216 lines not on this page · raw message
Signature · 1 line
2.48.0
Lorenzo Pieralisi
maintainerPATCH v4 25/26 irqchip/gic-v5: Add GICv5 IWB support
In reply to Lorenzo PieralisiThe GICv5 architecture implements the Interrupt Wire Bridge (IWB) in order to support wired interrupts that cannot be connected directly to an IRS and instead uses the ITS to translate a wire event into an IRQ signal.
Add the wired-to-MSI IWB driver to manage IWB wired interrupts.
An IWB is connected to an ITS and it has its own deviceID for all interrupt wires that it manages; the IWB input wire number must be exposed to the ITS as an eventID with a 1:1 mapping.
This eventID is not programmable and therefore requires a new msi_alloc_info_t flag to make sure the ITS driver does not allocate an eventid for the wire but rather it uses the msi_alloc_info_t.hwirq number to gather the ITS eventID.
--- drivers/irqchip/Makefile | 3 +- drivers/irqchip/irq-gic-v5-its.c | 40 ++++-- drivers/irqchip/irq-gic-v5-iwb.c | 285 +++++++++++++++++++++++++++++++++++++ include/asm-generic/msi.h | 1 + include/linux/irqchip/arm-gic-v5.h | 14 ++ 5 files changed, 333 insertions(+), 10 deletions(-)
drivers/irqchip/Makefile +2 -1
@@ -36,7 +36,8 @@ 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 irq-gic-v5-its.o +obj-$(CONFIG_ARM_GIC_V5) += irq-gic-v5.o irq-gic-v5-irs.o irq-gic-v5-its.o \ + irq-gic-v5-iwb.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-its.c +31 -9
@@ -863,19 +863,41 @@ static void gicv5_its_unmap_event(struct gicv5_its_dev *its_dev, u16 event_id)gicv5_its_itt_cache_inv (its, its_dev->device_id, event_id); } -static int gicv5_its_alloc_eventid (struct gicv5_its_dev *its_dev, +static int gicv5_its_alloc_eventid (struct gicv5_its_dev *its_dev,msi_alloc_info_t *info,unsigned int nr_irqs,u32 *eventid) { -int ret; +int event_id_base; - ret =bitmap_find_free_region (its_dev->event_map, - its_dev->num_events, -get_count_order (nr_irqs)); +if (!(info->flags &MSI_ALLOC_FLAGS_FIXED_MSG_DATA )) { + event_id_base =bitmap_find_free_region (its_dev->event_map, + its_dev->num_events, +get_count_order (nr_irqs)); +if (event_id_base <0 ) +return event_id_base; + }else { +/* +* We want to have a fixed EventID mapped for hardcoded +* message data allocations. +*/ +if (WARN_ON_ONCE (nr_irqs !=1 )) +return -EINVAL ; -if (ret <0 ) -return ret; + event_id_base = info->hwirq; - *eventid = ret; +if (event_id_base >= its_dev->num_events) { +pr_err ("EventID ouside of ITT range; cannot allocate an ITT entry!\n" ); + +return -EINVAL ; + } + +if (test_and_set_bit (event_id_base, its_dev->event_map)) { +pr_warn ("Can't reserve event_id bitmap\n" ); +return -EINVAL ; + + } + } + + *eventid = event_id_base;return 0 ; }
@@ -905,7 +927,7 @@ static int gicv5_its_irq_domain_alloc(struct irq_domain *domain, unsigned int vi msi_info =msi_get_domain_info (domain); its = msi_info->data; - ret =gicv5_its_alloc_eventid (its_dev, nr_irqs, &event_id_base); + ret =gicv5_its_alloc_eventid (its_dev, info, nr_irqs, &event_id_base);if (ret)return ret;
drivers/irqchip/irq-gic-v5-iwb.c new file +285 -0
285 lines not on this page · raw message
include/asm-generic/msi.h +1 -0
@@ -33,6 +33,7 @@ typedef struct msi_alloc_info {/* Device generating MSIs is proxying for another device */ #define MSI_ALLOC_FLAGS_PROXY_DEVICE (1UL << 0) +#define MSI_ALLOC_FLAGS_FIXED_MSG_DATA (1UL << 1)#define GENERIC_MSI_DOMAIN_OPS 1
include/linux/irqchip/arm-gic-v5.h +14 -0
@@ -236,6 +236,20 @@#define GICV5_ITS_HWIRQ_DEVICE_ID GENMASK_ULL(31, 0)#define GICV5_ITS_HWIRQ_EVENT_ID GENMASK_ULL(63, 32) +#define GICV5_IWB_IDR0 0x0000 +#define GICV5_IWB_CR0 0x0080 +#define GICV5_IWB_WENABLE_STATUSR 0x00c0 +#define GICV5_IWB_WENABLER 0x2000 +#define GICV5_IWB_WTMR 0x4000 + +#define GICV5_IWB_IDR0_INT_DOMS GENMASK(14, 11) +#define GICV5_IWB_IDR0_IW_RANGE GENMASK(10, 0) + +#define GICV5_IWB_CR0_IDLE BIT(1) +#define GICV5_IWB_CR0_IWBEN BIT(0) + +#define GICV5_IWB_WENABLE_STATUSR_IDLE BIT(0) +struct gicv5_chip_data {struct fwnode_handle *fwnode;struct irq_domain *ppi_domain;
Signature · 1 line
2.48.0
Lorenzo Pieralisi
maintainerPATCH v4 26/26 arm64: Kconfig: Enable GICv5
In reply to Lorenzo PieralisiEnable GICv5 driver code for the ARM64 architecture.
--- arch/arm64/Kconfig | 1 + 1 file changed, 1 insertion(+)
arch/arm64/Kconfig +1 -0
@@ -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