Skip to contentSkip to conversation

hw/pci-host/aspeed_pcie: Fix global MSI setting during class initialization

PATCH In review Jamin Lin 4 participants 4 messages Oct 20 – Oct 25 Arm/Aspeed machine support

lore
Share & tools
lore

Jamin Lin

author
#0 lore raw

PATCH v2 1/1 hw/pci-host/aspeed_pcie: Fix global MSI setting during class initialization

The ASPEED PCIe class may be registered for machines that do not instantiate a PCIe root complex. Updating the global msi_nonbroken flag from class_init() therefore affects unrelated machines.

Defer the update to the per-device realize handler, so the flag changes only when an ASPEED PCIe root complex is actually instantiated.

Fixes f002aa35f320 ("hw/pci-host/aspeed: Add AST2600 PCIe config space and host bridge")
---
 hw/pci-host/aspeed_pcie.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
hw/pci-host/aspeed_pcie.c +2 -2
index b46eb74234..ceb010f213 100644
@@ -181,6 +181,8 @@ static void aspeed_pcie_rc_realize(DeviceState *dev, Error **errp)
     g_autofree char *dram_alias_name = NULL;
     g_autofree char *root_bus_name = NULL;
 
+    msi_nonbroken = true;
+
     /* PCI configuration space */
     pcie_host_mmcfg_init(pex, PCIE_MMCFG_SIZE_MAX);
     sysbus_init_mmio(sbd, &pex->mmio);
@@ -294,8 +296,6 @@ static void aspeed_pcie_rc_class_init(ObjectClass *klass, const void *data)
 
     hc->root_bus_path = aspeed_pcie_rc_root_bus_path;
     device_class_set_props(dc, aspeed_pcie_rc_props);
-
-    msi_nonbroken = true;
 }
 
 /*
Signature · 1 line
2.43.0
#1 lore raw
Quoted 9 lines · Jamin Lin

The ASPEED PCIe class may be registered for machines that do not instantiate a PCIe root complex. Updating the global msi_nonbroken flag from class_init() therefore affects unrelated machines.

Defer the update to the per-device realize handler, so the flag changes only when an ASPEED PCIe root complex is actually instantiated.

Quoted 8 lines
Fixes f002aa35f320 ("hw/pci-host/aspeed: Add AST2600 PCIe config space and host bridge")
---
 hw/pci-host/aspeed_pcie.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

As reminder for whoever picks this patch up, they should add
Cc: [email protected]

Cédric, I assume you'll be taking this as an aspeed patch.

thanks
-- PMM

#2 lore raw
Quoted 19 lines · Peter Maydell
Quoted 9 lines · Jamin Lin

The ASPEED PCIe class may be registered for machines that do not instantiate a PCIe root complex. Updating the global msi_nonbroken flag from class_init() therefore affects unrelated machines.

Defer the update to the per-device realize handler, so the flag changes only when an ASPEED PCIe root complex is actually instantiated.

Quoted 8 lines
Fixes f002aa35f320 ("hw/pci-host/aspeed: Add AST2600 PCIe config space and host bridge")
---
  hw/pci-host/aspeed_pcie.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
Quoted 4 lines

As reminder for whoever picks this patch up, they should add
Cc: [email protected]

Cédric, I assume you'll be taking this as an aspeed patch.

Yep,

Applied to

https://github.com/legoater/qemu aspeed-next

Thanks,

C.

Reviewed-by Tested-by on v2 1/1
#3 lore raw
In reply to Jamin Lin

Looks right to me: it sets the flag where designware.c does, once an Aspeed RC is actually realized.

I tested it. On raspi4b a qemu-xhci on pcie.1 now ends up with msix=off, so it falls back to INTx; without the patch it is msix=auto and MSI-X is wrongly enabled. On ast2700-evb a qemu-xhci on each of its PCIe buses (pcie.0-2, pcie.rc0-2) still gets msix=auto, so MSI-X is still available where an Aspeed RC is present. I have not run the ast2700 functional tests.

Thanks for the quick fix.

Quoted 45 lines · Jamin Lin

The ASPEED PCIe class may be registered for machines that do not instantiate a PCIe root complex. Updating the global msi_nonbroken flag from class_init() therefore affects unrelated machines.

Defer the update to the per-device realize handler, so the flag changes only when an ASPEED PCIe root complex is actually instantiated.

Fixes f002aa35f320 ("hw/pci-host/aspeed: Add AST2600 PCIe config space

and host bridge")

---
 hw/pci-host/aspeed_pcie.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
hw/pci-host/aspeed_pcie.c +2 -0
index b46eb74234..ceb010f213 100644
@@ -181,6 +181,8 @@ static void aspeed_pcie_rc_realize(DeviceState *dev,
 Error **errp)
     g_autofree char *dram_alias_name = NULL;
     g_autofree char *root_bus_name = NULL;
 
+    msi_nonbroken = true;
+
     /* PCI configuration space */
     pcie_host_mmcfg_init(pex, PCIE_MMCFG_SIZE_MAX);
     sysbus_init_mmio(sbd, &pex->mmio);
hw/pci-host/aspeed_pcie.c +0 -2
@@ -294,8 +296,6 @@ static void aspeed_pcie_rc_class_init(ObjectClass
 *klass, const void *data)
 
     hc->root_bus_path = aspeed_pcie_rc_root_bus_path;
     device_class_set_props(dc, aspeed_pcie_rc_props);
-
-    msi_nonbroken = true;
 }
 

/*
--
2.43.0