Skip to contentSkip to conversation

arm: gic-v3: Scan for subnodes

PATCH In review Patrick Rudolph 2 participants 4 messages Mar 20, 2025 – Apr 10, 2025 Arm (32-bit)

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 arm: gic-v3: Scan for subnodes

According to the binding [1] the ITS node should be a subnode of the GICv3 node. Since the ITS node has it's own driver, manually probe for possible subnodes after binding since dm_scan_fdt() is not recursive.

1: https://www.kernel.org/doc/Documentation/devicetree/bindings/interrupt-controller/arm%2Cgic-v3.txt

---
 arch/arm/lib/gic-v3-its.c | 3 +++
 1 file changed, 3 insertions(+)
arch/arm/lib/gic-v3-its.c +3 -0
index 51cc2397768..34f05e94672 100644
@@ -232,6 +232,9 @@ U_BOOT_DRIVER(arm_gic_v3) = {
 	.id		= UCLASS_IRQ,
 	.of_match	= gic_v3_ids,
 	.ops		= &arm_gic_v3_ops,
+#if CONFIG_IS_ENABLED(OF_REAL)
+	.bind		= dm_scan_fdt_dev,
+#endif
 	ACPI_OPS_PTR(&gic_v3_acpi_ops)
 };
 
Signature · 1 line
2.48.1
#1 lore raw

PATCH 2/3 emulation: qemu-sbsa: Move ITS node into GICv3 node

According to the binding [1] the ITS node should be a subnode of the GICv3 node. Thus move it now that the driver binds subnodes as well.

1: https://www.kernel.org/doc/Documentation/devicetree/bindings/interrupt-controller/arm%2Cgic-v3.txt

---
 arch/arm/dts/qemu-sbsa.dts            | 10 ++++++----
 board/emulation/qemu-sbsa/qemu-sbsa.c |  2 +-
 2 files changed, 7 insertions(+), 5 deletions(-)
arch/arm/dts/qemu-sbsa.dts +6 -4
index ed00e501366..099b51b927f 100644
@@ -97,11 +97,13 @@
 		      /bits/ 64 <0 0>,
 		      /bits/ 64 <SBSA_GIC_HBASE_ADDR SBSA_GIC_HBASE_LENGTH>,
 		      /bits/ 64 <SBSA_GIC_VBASE_ADDR SBSA_GIC_VBASE_LENGTH>;
-	};
 
-	its {
-		compatible = "arm,gic-v3-its";
-		status = "disabled";
+		its: msi-controller {
+			compatible = "arm,gic-v3-its";
+			msi-controller;
+			#msi-cells = <1>;
+			status = "disabled";
+		};
 	};
 };
 
board/emulation/qemu-sbsa/qemu-sbsa.c +1 -1
index 3943c924320..cf1d5acf5cb 100644
@@ -202,7 +202,7 @@ static int fdtdec_fix_gic(void *fdt)
 	smc_get_gic_its_base(&gic_its_base);
 
 	if (gic_its_base != 0) {
-		offs = fdt_path_offset(fdt, "/its");
+		offs = fdt_path_offset(fdt, "/interrupt-controller/msi-controller");
 		if (offs < 0)
 			return offs;
 
Signature · 1 line
2.48.1
#2 lore raw

PATCH 3/3 emulation: qemu-sbsa: Fill in correct ITS ID

In reply to Patrick Rudolph

The ACPI IORT and ACPI MADT needs to use the same IDs when referencing GIC ITS. The GIC-v3 ITS driver uses dev_seq(dev) to generate a unique ID for the MADT, but qemu sbsa-ref hardcodes it.
Currently it's not the same ID, breaking interrupt routing on the OS.

Don't assume it's 0 and fetch it from the device instead.

TEST: Fixes non working IRQs in QEMU sbsa-ref.

---
 board/emulation/qemu-sbsa/acpi.c | 21 +++++++++++++--------
 1 file changed, 13 insertions(+), 8 deletions(-)
board/emulation/qemu-sbsa/acpi.c +13 -8
index ba85e08fc7d..2e518f2f03f 100644
@@ -10,9 +10,9 @@
 #include <asm/acpi_table.h>
 #include <asm/armv8/sec_firmware.h>
 #include <configs/qemu-sbsa.h>
-#include <dm/uclass.h>
 #include <dm/device.h>
-#include "qemu-sbsa.h"
+#include <dm/read.h>
+#include <dm/uclass.h>
 
 #define SBSAQEMU_MADT_GIC_VBASE          0x2c020000
 #define SBSAQEMU_MADT_GIC_HBASE          0x2c010000
@@ -45,13 +45,18 @@
 int acpi_fill_iort(struct acpi_ctx *ctx)
 {
 	u32 its_offset, smmu_offset;
-	u64 gic_its_base = 0;
-
-	smc_get_gic_its_base(&gic_its_base);
-	if (gic_its_base == 0)
-		return 0;
+	struct udevice *dev;
+	int ret;
+
+	ret = uclass_get_device_by_driver(UCLASS_IRQ,
+					  DM_DRIVER_GET(arm_gic_v3_its), &dev);
+	if (ret) {
+		pr_err("%s: failed to get %s irq device\n", __func__,
+		       DM_DRIVER_GET(arm_gic_v3_its)->name);
+		return ret;
+	}
 
-	u32 identifiers[] = { 0 };
+	u32 identifiers[] = { dev_seq(dev) };
 
 	its_offset = acpi_iort_add_its_group(ctx, ARRAY_SIZE(identifiers),
 					     identifiers);
Signature · 1 line
2.48.1
#3 lore raw
In reply to Patrick Rudolph
Quoted 8 lines · Patrick Rudolph

According to the binding [1] the ITS node should be a subnode of the GICv3 node. Since the ITS node has it's own driver, manually probe for possible subnodes after binding since dm_scan_fdt() is not recursive.

1: https://www.kernel.org/doc/Documentation/devicetree/bindings/interrupt-controller/arm%2Cgic-v3.txt

[...]

Applied to u-boot/master, thanks!

[1/3] arm: gic-v3: Scan for subnodes

      commit: 6554cb460bfc0d1a21406da49bf44f029b5aa185
[2/3] emulation: qemu-sbsa: Move ITS node into GICv3 node
      commit: d5a060b01b322231725dfc38090d8dc5e080cd33
[3/3] emulation: qemu-sbsa: Fill in correct ITS ID
      commit: 65504478fe44f6dd8b61907efa4eaeba5b79cbf5
Signature · 1 line
Tom