diff mbox series

[1/2] hw/pci-bridge: pci_expander_bridge fix type in pxb_cxl_dev_reset()

Message ID 20230420142750.6950-2-Jonathan.Cameron@huawei.com (mailing list archive)
State New, archived
Headers show
Series hw/pci-bridge: pci_expander_bridge: Fix wrong type and rework inheritance. | expand

Commit Message

Jonathan Cameron April 20, 2023, 2:27 p.m. UTC
Reproduce issue with

configure --enable-qom-cast-debug ...

qemu-system-x86_64 -display none -machine q35,cxl=on -device pxb-cxl,bus=pcie.0

  hw/pci-bridge/pci_expander_bridge.c:54:PXB_DEV: Object 0x5570e0b1ada0 is not an instance of type pxb
  Aborted

The type conversion results in the right state structure, but PXB_DEV is
not a parent of PXB_CXL_DEV hence the error. Rather than directly
cleaning up the inheritance, this is the minimal fix which will be
followed by the cleanup.

Fixes: 154070eaf6 ("hw/pxb-cxl: Support passthrough HDM Decoders unless overridden")
Reported-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
---
 hw/pci-bridge/pci_expander_bridge.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Thomas Huth April 21, 2023, 2:03 p.m. UTC | #1
On 20/04/2023 16.27, Jonathan Cameron via wrote:
> Reproduce issue with
> 
> configure --enable-qom-cast-debug ...
> 
> qemu-system-x86_64 -display none -machine q35,cxl=on -device pxb-cxl,bus=pcie.0
> 
>    hw/pci-bridge/pci_expander_bridge.c:54:PXB_DEV: Object 0x5570e0b1ada0 is not an instance of type pxb
>    Aborted
> 
> The type conversion results in the right state structure, but PXB_DEV is
> not a parent of PXB_CXL_DEV hence the error. Rather than directly
> cleaning up the inheritance, this is the minimal fix which will be
> followed by the cleanup.
> 
> Fixes: 154070eaf6 ("hw/pxb-cxl: Support passthrough HDM Decoders unless overridden")
> Reported-by: Peter Maydell <peter.maydell@linaro.org>
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> ---
>   hw/pci-bridge/pci_expander_bridge.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/hw/pci-bridge/pci_expander_bridge.c b/hw/pci-bridge/pci_expander_bridge.c
> index ead33f0c05..a78327b5f2 100644
> --- a/hw/pci-bridge/pci_expander_bridge.c
> +++ b/hw/pci-bridge/pci_expander_bridge.c
> @@ -311,7 +311,7 @@ static void pxb_cxl_dev_reset(DeviceState *dev)
>        * The CXL specification allows for host bridges with no HDM decoders
>        * if they only have a single root port.
>        */
> -    if (!PXB_DEV(dev)->hdm_for_passthrough) {
> +    if (!PXB_CXL_DEV(dev)->hdm_for_passthrough) {
>           dsp_count = pcie_count_ds_ports(hb->bus);
>       }
>       /* Initial reset will have 0 dsp so wait until > 0 */

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1586

Reviewed-by: Thomas Huth <thuth@redhat.com>
Peter Maydell April 21, 2023, 2:24 p.m. UTC | #2
On Thu, 20 Apr 2023 at 15:28, Jonathan Cameron
<Jonathan.Cameron@huawei.com> wrote:
>
> Reproduce issue with
>
> configure --enable-qom-cast-debug ...
>
> qemu-system-x86_64 -display none -machine q35,cxl=on -device pxb-cxl,bus=pcie.0
>
>   hw/pci-bridge/pci_expander_bridge.c:54:PXB_DEV: Object 0x5570e0b1ada0 is not an instance of type pxb
>   Aborted
>
> The type conversion results in the right state structure, but PXB_DEV is
> not a parent of PXB_CXL_DEV hence the error. Rather than directly
> cleaning up the inheritance, this is the minimal fix which will be
> followed by the cleanup.
>
> Fixes: 154070eaf6 ("hw/pxb-cxl: Support passthrough HDM Decoders unless overridden")
> Reported-by: Peter Maydell <peter.maydell@linaro.org>
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> --

We should add:
Cc: qemu-stable@nongnu.org

so downstreams don't have to disable the QOM cast asserts.

-- PMM
diff mbox series

Patch

diff --git a/hw/pci-bridge/pci_expander_bridge.c b/hw/pci-bridge/pci_expander_bridge.c
index ead33f0c05..a78327b5f2 100644
--- a/hw/pci-bridge/pci_expander_bridge.c
+++ b/hw/pci-bridge/pci_expander_bridge.c
@@ -311,7 +311,7 @@  static void pxb_cxl_dev_reset(DeviceState *dev)
      * The CXL specification allows for host bridges with no HDM decoders
      * if they only have a single root port.
      */
-    if (!PXB_DEV(dev)->hdm_for_passthrough) {
+    if (!PXB_CXL_DEV(dev)->hdm_for_passthrough) {
         dsp_count = pcie_count_ds_ports(hb->bus);
     }
     /* Initial reset will have 0 dsp so wait until > 0 */