diff mbox series

[kvmtool,3/3] arm: pci: Generate "msi-parent" property only with a MSI controller

Message ID 20220214165830.69207-4-alexandru.elisei@arm.com (mailing list archive)
State New, archived
Headers show
Series Misc fixes | expand

Commit Message

Alexandru Elisei Feb. 14, 2022, 4:58 p.m. UTC
The "msi-parent" PCI root complex property describes the MSI parent of the
root complex. When the VM is created with a GICv2 or GICv3 irqchip
(--irqchip=gicv3 or --irqchip=gicv2), there is no MSI controller present on
the system and the corresponding phandle is not generated, leaving the
"msi-parent" property to point to a non-existing phandle. Skip creating the
"msi-parent" property when no MSI controller exists.

Reported-by: Pierre Gondois <pierre.gondois@arm.com>
Signed-off-by: Alexandru Elisei <alexandru.elisei@arm.com>
---
 arm/fdt.c                    | 2 +-
 arm/include/arm-common/pci.h | 3 ++-
 arm/pci.c                    | 8 ++++++--
 3 files changed, 9 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/arm/fdt.c b/arm/fdt.c
index 635de7f27fa5..286ccadf1311 100644
--- a/arm/fdt.c
+++ b/arm/fdt.c
@@ -190,7 +190,7 @@  static int setup_fdt(struct kvm *kvm)
 	}
 
 	/* PCI host controller */
-	pci__generate_fdt_nodes(fdt);
+	pci__generate_fdt_nodes(fdt, kvm);
 
 	/* PSCI firmware */
 	_FDT(fdt_begin_node(fdt, "psci"));
diff --git a/arm/include/arm-common/pci.h b/arm/include/arm-common/pci.h
index 9008a0ed072e..afa7f7f42bcb 100644
--- a/arm/include/arm-common/pci.h
+++ b/arm/include/arm-common/pci.h
@@ -1,6 +1,7 @@ 
 #ifndef ARM_COMMON__PCI_H
 #define ARM_COMMON__PCI_H
 
-void pci__generate_fdt_nodes(void *fdt);
+struct kvm;
+void pci__generate_fdt_nodes(void *fdt, struct kvm *kvm);
 
 #endif /* ARM_COMMON__PCI_H */
diff --git a/arm/pci.c b/arm/pci.c
index e44e45343c6a..5bd82d438807 100644
--- a/arm/pci.c
+++ b/arm/pci.c
@@ -6,6 +6,7 @@ 
 #include "kvm/util.h"
 
 #include "arm-common/pci.h"
+#include "arm-common/gic.h"
 
 /*
  * An entry in the interrupt-map table looks like:
@@ -24,8 +25,9 @@  struct of_interrupt_map_entry {
 	struct of_gic_irq		gic_irq;
 } __attribute__((packed));
 
-void pci__generate_fdt_nodes(void *fdt)
+void pci__generate_fdt_nodes(void *fdt, struct kvm *kvm)
 {
+	enum irqchip_type irqchip = kvm->cfg.arch.irqchip;
 	struct device_header *dev_hdr;
 	struct of_interrupt_map_entry irq_map[OF_PCI_IRQ_MAP_MAX];
 	unsigned nentries = 0;
@@ -68,7 +70,9 @@  void pci__generate_fdt_nodes(void *fdt)
 	_FDT(fdt_property(fdt, "bus-range", bus_range, sizeof(bus_range)));
 	_FDT(fdt_property(fdt, "reg", &cfg_reg_prop, sizeof(cfg_reg_prop)));
 	_FDT(fdt_property(fdt, "ranges", ranges, sizeof(ranges)));
-	_FDT(fdt_property_cell(fdt, "msi-parent", PHANDLE_MSI));
+
+	if (irqchip == IRQCHIP_GICV2M || irqchip == IRQCHIP_GICV3_ITS)
+		_FDT(fdt_property_cell(fdt, "msi-parent", PHANDLE_MSI));
 
 	/* Generate the interrupt map ... */
 	dev_hdr = device__first_dev(DEVICE_BUS_PCI);