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

Jamin Lin posted 1 patch 1 month ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20261020033755.2618640-1-jamin._5Flin@aspeedtech.com
Maintainers: "Cédric Le Goater" <clg@kaod.org>, Peter Maydell <peter.maydell@linaro.org>, Jamin Lin <jamin_lin@aspeedtech.com>, Kane Chen <kane_chen@aspeedtech.com>
hw/pci-host/aspeed_pcie.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
[PATCH v2] hw/pci-host/aspeed_pcie: Fix global MSI setting during class initialization
Posted by Jamin Lin 1 month ago
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.

Reported-by: Marcelo Manzo <marcelomanzo@gmail.com>
Fixes: f002aa35f320 ("hw/pci-host/aspeed: Add AST2600 PCIe config space and host bridge")
Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Jamin Lin <jamin_lin@aspeedtech.com>
---
 hw/pci-host/aspeed_pcie.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/hw/pci-host/aspeed_pcie.c b/hw/pci-host/aspeed_pcie.c
index b46eb74234..ceb010f213 100644
--- a/hw/pci-host/aspeed_pcie.c
+++ b/hw/pci-host/aspeed_pcie.c
@@ -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;
 }
 
 /*
-- 
2.43.0
Re: [PATCH v2] hw/pci-host/aspeed_pcie: Fix global MSI setting during class initialization
Posted by Marcelo Manzo 1 month ago
Reviewed-by: Marcelo Manzo <marcelomanzo@gmail.com>
Tested-by: Marcelo Manzo <marcelomanzo@gmail.com>

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.

On Mon, Oct 19, 2026 11:38 PM, Jamin Lin <jamin_lin@aspeedtech.com> wrote:

> 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.
>
> Reported-by: Marcelo Manzo <marcelomanzo@gmail.com>
> Fixes: f002aa35f320 ("hw/pci-host/aspeed: Add AST2600 PCIe config space
> and host bridge")
> Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
> Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
> Signed-off-by: Jamin Lin <jamin_lin@aspeedtech.com>
> ---
>  hw/pci-host/aspeed_pcie.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/hw/pci-host/aspeed_pcie.c b/hw/pci-host/aspeed_pcie.c
> index b46eb74234..ceb010f213 100644
> --- a/hw/pci-host/aspeed_pcie.c
> +++ b/hw/pci-host/aspeed_pcie.c
> @@ -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;
>  }
>
>  /*
> --
> 2.43.0
>
Re: [PATCH v2] hw/pci-host/aspeed_pcie: Fix global MSI setting during class initialization
Posted by Peter Maydell 1 month ago
On Tue, 20 Oct 2026 at 04:38, Jamin Lin <jamin_lin@aspeedtech.com> wrote:
>
> 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.
>
> Reported-by: Marcelo Manzo <marcelomanzo@gmail.com>
> Fixes: f002aa35f320 ("hw/pci-host/aspeed: Add AST2600 PCIe config space and host bridge")
> Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
> Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
> Signed-off-by: Jamin Lin <jamin_lin@aspeedtech.com>
> ---
>  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: qemu-stable@nongnu.org

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

thanks
-- PMM
Re: [PATCH v2] hw/pci-host/aspeed_pcie: Fix global MSI setting during class initialization
Posted by Cédric Le Goater 4 weeks ago
On 10/20/26 12:12, Peter Maydell wrote:
> On Tue, 20 Oct 2026 at 04:38, Jamin Lin <jamin_lin@aspeedtech.com> wrote:
>>
>> 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.
>>
>> Reported-by: Marcelo Manzo <marcelomanzo@gmail.com>
>> Fixes: f002aa35f320 ("hw/pci-host/aspeed: Add AST2600 PCIe config space and host bridge")
>> Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
>> Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
>> Signed-off-by: Jamin Lin <jamin_lin@aspeedtech.com>
>> ---
>>   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: qemu-stable@nongnu.org
> 
> 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.