Skip to contentSkip to conversation

hw/pci-bridge: pci_expander_bridge: Fix wrong type and rework inheritance.

PATCH In review Jonathan Cameron via 4 participants 11 messages Apr 20, 2023 – Apr 22, 2023

lore
Share & tools
lore
#0 lore raw

cover hw/pci-bridge: pci_expander_bridge: Fix wrong type and rework inheritance.

Peter Maydell highlighted an incorrect conversion to TYPE_PXB_DEVICE from a device that didn't have that a an ancestor type. PXB_DEV() used instead of PXB_CXL_DEV()/

https://lore.kernel.org/qemu-devel/CAFEAcA-+de+eeLCE4YsAw1O-Qyd_4W1Ra05mGDsU_-3a6d92qw@mail.gmail.com/

During the discussion it became clear that the inheritance of the various TYPE_PXB*_DEVICE was unusual. This patchset first provides the minimal fix then cleans up the inheritance of types based on functionality.

There is also a rename to TYPE_PXB*_DEV to allow removal of some boilerplate.

Before this series
TYPE_PXB_DEVICE, TYPE_PXB_PCIE_DEVICE and TYPE_PXB_CXL_DEVICE all had TYPE_PCI_DEVICE as their direct parent though they shared a common struct PXBDev for their state. As a result this state contained some data that was irrelevant for some the types.

This series changes to
TYPE_PXB_CXL_DEV has a parent of TYPE_PXB_PCIE_DEV TYPE_PXB_PCIE_DEV has a parent of TYPE_PXB_DEV TYPE_PXB_DEV continues to have a parent of TYPE_PCI_DEVICE.

Each of the TYPE_PXB*_DEV has a state structure adding those elements to their parent that they need. This also allowed dropping a wrapping structure for the CXL state as the PXBCXLDev structure already provides the equivalent grouping.

Patches are similar to those posted in the thread but rebased on v8.0.0.

Jonathan Cameron (2):
hw/pci-bridge: pci_expander_bridge fix type in pxb_cxl_dev_reset() hw/pci-bridge: Make PCIe and CXL PXB Devices inherit from TYPE_PXB_DEV

 hw/acpi/cxl.c                       | 11 +++---
 hw/cxl/cxl-host.c                   |  4 +-
 hw/pci-bridge/pci_expander_bridge.c | 61 ++++++++++-------------------
 include/hw/cxl/cxl.h                |  4 +-
 include/hw/pci/pci_bridge.h         | 28 +++++++++----
 5 files changed, 50 insertions(+), 58 deletions(-)
Signature · 1 line
2.37.2
#1 lore raw

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

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")
---
 hw/pci-bridge/pci_expander_bridge.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/pci-bridge/pci_expander_bridge.c +1 -1
index ead33f0c05..a78327b5f2 100644
@@ -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 */
Signature · 1 line
2.37.2
Reviewed-by on v1 1/2
#2 lore raw

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

Quoted 26 lines · Jonathan Cameron via

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")
---
  hw/pci-bridge/pci_expander_bridge.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
hw/pci-bridge/pci_expander_bridge.c +0 -0
index ead33f0c05..a78327b5f2 100644

hw/pci-bridge/pci_expander_bridge.c static void pxb_cxl_dev_reset(DeviceState *dev) · line 317

Quoted 8 lines
hw/pci-bridge/pci_expander_bridge.c +1 -1
@@ -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

#3 lore raw

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

In reply to Jonathan Cameron via
Quoted 15 lines · Jonathan Cameron

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.

Quoted 4 lines
Fixes 154070eaf6 ("hw/pxb-cxl: Support passthrough HDM Decoders unless overridden")

--

We should add:
Cc: [email protected]

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

-- PMM

#4 lore raw

PATCH 2/2 hw/pci-bridge: Make PCIe and CXL PXB Devices inherit from TYPE_PXB_DEV

In reply to Jonathan Cameron via

Previously, PXB_CXL_DEVICE, PXB_PCIE_DEVICE and PXB_DEVICE all have PCI_DEVICE as their direct parent but share a common state struct PXBDev. convert_to_pxb() is used to get the PXBDev instance from which ever of these types it is called on.

This patch switches to an explicit heirarchy based on shared functionality. To allow use of OBJECT_DECLARE_SIMPLE_TYPE() whilst minimizing code changes, all types are renamed to have the postfix _DEV rather than _DEVICE. The new heirarchy has PXB_CXL_DEV with parent PXB_PCIE_DEV which in turn has parent PXB_DEV which continues to have parent PCI_DEVICE.

This allows simple use of PXB_DEV() etc rather than a custom function
+ removal of duplicated properties and moving the CXL specific elements out of struct PXBDev.

---
 hw/acpi/cxl.c                       | 11 +++---
 hw/cxl/cxl-host.c                   |  4 +-
 hw/pci-bridge/pci_expander_bridge.c | 59 ++++++++++-------------------
 include/hw/cxl/cxl.h                |  4 +-
 include/hw/pci/pci_bridge.h         | 28 ++++++++++----
 5 files changed, 49 insertions(+), 57 deletions(-)
hw/acpi/cxl.c +6 -5
index 2bf8c07993..92b46bc932 100644
@@ -30,9 +30,10 @@
 #include "qapi/error.h"
 #include "qemu/uuid.h"
 
-static void cedt_build_chbs(GArray *table_data, PXBDev *cxl)
+static void cedt_build_chbs(GArray *table_data, PXBCXLDev *cxl)
 {
-    SysBusDevice *sbd = SYS_BUS_DEVICE(cxl->cxl.cxl_host_bridge);
+    PXBDev *pxb = PXB_DEV(cxl);
+    SysBusDevice *sbd = SYS_BUS_DEVICE(cxl->cxl_host_bridge);
     struct MemoryRegion *mr = sbd->mmio[0].memory;
 
     /* Type */
@@ -45,7 +46,7 @@ static void cedt_build_chbs(GArray *table_data, PXBDev *cxl)
     build_append_int_noprefix(table_data, 32, 2);
 
     /* UID - currently equal to bus number */
-    build_append_int_noprefix(table_data, cxl->bus_nr, 4);
+    build_append_int_noprefix(table_data, pxb->bus_nr, 4);
 
     /* Version */
     build_append_int_noprefix(table_data, 1, 4);
@@ -112,7 +113,7 @@ static void cedt_build_cfmws(GArray *table_data, CXLState *cxls)
         /* Host Bridge List (list of UIDs - currently bus_nr) */
         for (i = 0; i < fw->num_targets; i++) {
             g_assert(fw->target_hbs[i]);
-            build_append_int_noprefix(table_data, fw->target_hbs[i]->bus_nr, 4);
+            build_append_int_noprefix(table_data, PXB_DEV(fw->target_hbs[i])->bus_nr, 4);
         }
     }
 }
@@ -121,7 +122,7 @@ static int cxl_foreach_pxb_hb(Object *obj, void *opaque)
 {
     Aml *cedt = opaque;
 
-    if (object_dynamic_cast(obj, TYPE_PXB_CXL_DEVICE)) {
+    if (object_dynamic_cast(obj, TYPE_PXB_CXL_DEV)) {
         cedt_build_chbs(cedt->buf, PXB_CXL_DEV(obj));
     }
 
hw/cxl/cxl-host.c +2 -2
index 6e923ceeaf..034c7805b3 100644
@@ -84,7 +84,7 @@ void cxl_fmws_link_targets(CXLState *cxl_state, Error **errp)
                 bool ambig;
 
                 o = object_resolve_path_type(fw->targets[i],
-                                             TYPE_PXB_CXL_DEVICE,
+                                             TYPE_PXB_CXL_DEV,
                                              &ambig);
                 if (!o) {
                     error_setg(errp, "Could not resolve CXLFM target %s",
@@ -141,7 +141,7 @@ static PCIDevice *cxl_cfmws_find_device(CXLFixedWindow *fw, hwaddr addr)
     addr += fw->base;
 
     rb_index = (addr / cxl_decode_ig(fw->enc_int_gran)) % fw->num_targets;
-    hb = PCI_HOST_BRIDGE(fw->target_hbs[rb_index]->cxl.cxl_host_bridge);
+    hb = PCI_HOST_BRIDGE(fw->target_hbs[rb_index]->cxl_host_bridge);
     if (!hb || !hb->bus || !pci_bus_is_cxl(hb->bus)) {
         return NULL;
     }
hw/pci-bridge/pci_expander_bridge.c +19 -40

142 lines not on this page · raw message

include/hw/cxl/cxl.h +2 -2
index b2cffbb364..c453983e83 100644
@@ -23,12 +23,12 @@
 
 #define CXL_WINDOW_MAX 10
 
-typedef struct PXBDev PXBDev;
+typedef struct PXBCXLDev PXBCXLDev;
 
 typedef struct CXLFixedWindow {
     uint64_t size;
     char **targets;
-    PXBDev *target_hbs[8];
+    PXBCXLDev *target_hbs[8];
     uint8_t num_targets;
     uint8_t enc_int_ways;
     uint8_t enc_int_gran;
include/hw/pci/pci_bridge.h +20 -8
index 1677176b2a..01670e9e65 100644
@@ -84,7 +84,7 @@ struct PCIBridge {
 #define PCI_BRIDGE_DEV_PROP_SHPC       "shpc"
 typedef struct CXLHost CXLHost;
 
-struct PXBDev {
+typedef struct PXBDev {
     /*< private >*/
     PCIDevice parent_obj;
     /*< public >*/
@@ -92,15 +92,27 @@ struct PXBDev {
     uint8_t bus_nr;
     uint16_t numa_node;
     bool bypass_iommu;
+} PXBDev;
+
+typedef struct PXBPCIEDev {
+    /*< private >*/
+    PXBDev parent_obj;
+} PXBPCIEDev;
+
+#define TYPE_PXB_DEV "pxb"
+OBJECT_DECLARE_SIMPLE_TYPE(PXBDev, PXB_DEV)
+
+typedef struct PXBCXLDev {
+    /*< private >*/
+    PXBPCIEDev parent_obj;
+    /*< public >*/
+
     bool hdm_for_passthrough;
-    struct cxl_dev {
-        CXLHost *cxl_host_bridge; /* Pointer to a CXLHost */
-    } cxl;
-};
+    CXLHost *cxl_host_bridge; /* Pointer to a CXLHost */
+} PXBCXLDev;
 
-#define TYPE_PXB_CXL_DEVICE "pxb-cxl"
-DECLARE_INSTANCE_CHECKER(PXBDev, PXB_CXL_DEV,
-                         TYPE_PXB_CXL_DEVICE)
+#define TYPE_PXB_CXL_DEV "pxb-cxl"
+OBJECT_DECLARE_SIMPLE_TYPE(PXBCXLDev, PXB_CXL_DEV)
 
 int pci_bridge_ssvid_init(PCIDevice *dev, uint8_t offset,
                           uint16_t svid, uint16_t ssid,
Signature · 1 line
2.37.2
Reviewed-by on v1 2/2
#5 lore raw

Re: [PATCH 2/2] hw/pci-bridge: Make PCIe and CXL PXB Devices inherit from TYPE_PXB_DEV

Quoted 9 lines · Jonathan Cameron via

Previously, PXB_CXL_DEVICE, PXB_PCIE_DEVICE and PXB_DEVICE all have PCI_DEVICE as their direct parent but share a common state struct PXBDev. convert_to_pxb() is used to get the PXBDev instance from which ever of these types it is called on.

This patch switches to an explicit heirarchy based on shared functionality. To allow use of OBJECT_DECLARE_SIMPLE_TYPE() whilst minimizing code changes, all types are renamed to have the postfix _DEV rather than _DEVICE. The new heirarchy

s/heirarchy/hierarchy/

Quoted 7 lines

has PXB_CXL_DEV with parent PXB_PCIE_DEV which in turn has parent PXB_DEV which continues to have parent PCI_DEVICE.

This allows simple use of PXB_DEV() etc rather than a custom function
+ removal of duplicated properties and moving the CXL specific elements out of struct PXBDev.

Quoted 8 lines
---
  hw/acpi/cxl.c                       | 11 +++---
  hw/cxl/cxl-host.c                   |  4 +-
  hw/pci-bridge/pci_expander_bridge.c | 59 ++++++++++-------------------
  include/hw/cxl/cxl.h                |  4 +-
  include/hw/pci/pci_bridge.h         | 28 ++++++++++----
  5 files changed, 49 insertions(+), 57 deletions(-)
#6 lore raw
In reply to Jonathan Cameron via
Quoted 23 lines · Jonathan Cameron

Peter Maydell highlighted an incorrect conversion to TYPE_PXB_DEVICE from a device that didn't have that a an ancestor type. PXB_DEV() used instead of PXB_CXL_DEV()/

https://lore.kernel.org/qemu-devel/CAFEAcA-+de+eeLCE4YsAw1O-Qyd_4W1Ra05mGDsU_-3a6d92qw@mail.gmail.com/

During the discussion it became clear that the inheritance of the various TYPE_PXB*_DEVICE was unusual. This patchset first provides the minimal fix then cleans up the inheritance of types based on functionality.

There is also a rename to TYPE_PXB*_DEV to allow removal of some boilerplate.

Before this series
TYPE_PXB_DEVICE, TYPE_PXB_PCIE_DEVICE and TYPE_PXB_CXL_DEVICE all had TYPE_PCI_DEVICE as their direct parent though they shared a common struct PXBDev for their state. As a result this state contained some data that was irrelevant for some the types.

This series changes to
TYPE_PXB_CXL_DEV has a parent of TYPE_PXB_PCIE_DEV TYPE_PXB_PCIE_DEV has a parent of TYPE_PXB_DEV TYPE_PXB_DEV continues to have a parent of TYPE_PCI_DEVICE.

Quoted 6 lines

Each of the TYPE_PXB*_DEV has a state structure adding those elements to their parent that they need. This also allowed dropping a wrapping structure for the CXL state as the PXBCXLDev structure already provides the equivalent grouping.

Patches are similar to those posted in the thread but rebased on v8.0.0.

this conflicts with
Revert "hw/pxb-cxl: Support passthrough HDM Decoders unless overridden"

I think you acked that one?

Quoted 13 lines

Jonathan Cameron (2):
hw/pci-bridge: pci_expander_bridge fix type in pxb_cxl_dev_reset() hw/pci-bridge: Make PCIe and CXL PXB Devices inherit from TYPE_PXB_DEV

 hw/acpi/cxl.c                       | 11 +++---
 hw/cxl/cxl-host.c                   |  4 +-
 hw/pci-bridge/pci_expander_bridge.c | 61 ++++++++++-------------------
 include/hw/cxl/cxl.h                |  4 +-
 include/hw/pci/pci_bridge.h         | 28 +++++++++----
 5 files changed, 50 insertions(+), 58 deletions(-)
Signature · 1 line
2.37.2
#7 lore raw
Quoted 30 lines · Michael S. Tsirkin
Quoted 28 lines · Jonathan Cameron

Peter Maydell highlighted an incorrect conversion to TYPE_PXB_DEVICE from a device that didn't have that a an ancestor type. PXB_DEV() used instead of PXB_CXL_DEV()/

https://lore.kernel.org/qemu-devel/CAFEAcA-+de+eeLCE4YsAw1O-Qyd_4W1Ra05mGDsU_-3a6d92qw@mail.gmail.com/

During the discussion it became clear that the inheritance of the various TYPE_PXB*_DEVICE was unusual. This patchset first provides the minimal fix then cleans up the inheritance of types based on functionality.

There is also a rename to TYPE_PXB*_DEV to allow removal of some boilerplate.

Before this series
TYPE_PXB_DEVICE, TYPE_PXB_PCIE_DEVICE and TYPE_PXB_CXL_DEVICE all had TYPE_PCI_DEVICE as their direct parent though they shared a common struct PXBDev for their state. As a result this state contained some data that was irrelevant for some the types.

This series changes to
TYPE_PXB_CXL_DEV has a parent of TYPE_PXB_PCIE_DEV TYPE_PXB_PCIE_DEV has a parent of TYPE_PXB_DEV TYPE_PXB_DEV continues to have a parent of TYPE_PCI_DEVICE.

Each of the TYPE_PXB*_DEV has a state structure adding those elements to their parent that they need. This also allowed dropping a wrapping structure for the CXL state as the PXBCXLDev structure already provides the equivalent grouping.

Quoted 6 lines
Quoted 1 line

Patches are similar to those posted in the thread but rebased on v8.0.0.

this conflicts with
Revert "hw/pxb-cxl: Support passthrough HDM Decoders unless overridden"

I think you acked that one?

We should take one or the other, but not both. If this patchset is good then it's probably better to fix the bug rather than revert the feature, I think.

-- PMM

#8 lore raw
Quoted 33 lines · On Fri, 21 Apr 2023 09:59:57 +0100 Peter Maydell <[email protected]>…
Quoted 32 lines · Michael S. Tsirkin
Quoted 29 lines · Jonathan Cameron

Peter Maydell highlighted an incorrect conversion to TYPE_PXB_DEVICE from a device that didn't have that a an ancestor type. PXB_DEV() used instead of PXB_CXL_DEV()/

https://lore.kernel.org/qemu-devel/CAFEAcA-+de+eeLCE4YsAw1O-Qyd_4W1Ra05mGDsU_-3a6d92qw@mail.gmail.com/

During the discussion it became clear that the inheritance of the various TYPE_PXB*_DEVICE was unusual. This patchset first provides the minimal fix then cleans up the inheritance of types based on functionality.

There is also a rename to TYPE_PXB*_DEV to allow removal of some boilerplate.

Before this series
TYPE_PXB_DEVICE, TYPE_PXB_PCIE_DEVICE and TYPE_PXB_CXL_DEVICE all had TYPE_PCI_DEVICE as their direct parent though they shared a common struct PXBDev for their state. As a result this state contained some data that was irrelevant for some the types.

This series changes to
TYPE_PXB_CXL_DEV has a parent of TYPE_PXB_PCIE_DEV TYPE_PXB_PCIE_DEV has a parent of TYPE_PXB_DEV TYPE_PXB_DEV continues to have a parent of TYPE_PCI_DEVICE.

Each of the TYPE_PXB*_DEV has a state structure adding those elements to their parent that they need. This also allowed dropping a wrapping structure for the CXL state as the PXBCXLDev structure already provides the equivalent grouping.

Patches are similar to those posted in the thread but rebased on v8.0.0.

Quoted 8 lines
Quoted 4 lines

this conflicts with
Revert "hw/pxb-cxl: Support passthrough HDM Decoders unless overridden"

I think you acked that one?

We should take one or the other, but not both. If this patchset is good then it's probably better to fix the bug rather than revert the feature, I think.

If it's easy to drop the revert that would be my preference.

If not, then I'm fine spinning a new version of that patch without the bug (so with patch 1 of this squashed in). Patch 2 is somewhat related refactoring. Not necessary to fix the issue even though it was motivated by that bug.

Jonathan

Quoted 2 lines

-- PMM

#9 lore raw
Quoted 39 lines · Jonathan Cameron via
Quoted 36 lines · On Fri, 21 Apr 2023 09:59:57 +0100 Peter Maydell <[email protected]>…
Quoted 35 lines · Michael S. Tsirkin
Quoted 23 lines · Jonathan Cameron

Peter Maydell highlighted an incorrect conversion to TYPE_PXB_DEVICE from a device that didn't have that a an ancestor type. PXB_DEV() used instead of PXB_CXL_DEV()/

https://lore.kernel.org/qemu-devel/CAFEAcA-+de+eeLCE4YsAw1O-Qyd_4W1Ra05mGDsU_-3a6d92qw@mail.gmail.com/

During the discussion it became clear that the inheritance of the various TYPE_PXB*_DEVICE was unusual. This patchset first provides the minimal fix then cleans up the inheritance of types based on functionality.

There is also a rename to TYPE_PXB*_DEV to allow removal of some boilerplate.

Before this series
TYPE_PXB_DEVICE, TYPE_PXB_PCIE_DEVICE and TYPE_PXB_CXL_DEVICE all had TYPE_PCI_DEVICE as their direct parent though they shared a common struct PXBDev for their state. As a result this state contained some data that was irrelevant for some the types.

This series changes to
TYPE_PXB_CXL_DEV has a parent of TYPE_PXB_PCIE_DEV TYPE_PXB_PCIE_DEV has a parent of TYPE_PXB_DEV TYPE_PXB_DEV continues to have a parent of TYPE_PCI_DEVICE.

Quoted 6 lines

Each of the TYPE_PXB*_DEV has a state structure adding those elements to their parent that they need. This also allowed dropping a wrapping structure for the CXL state as the PXBCXLDev structure already provides the equivalent grouping.

Patches are similar to those posted in the thread but rebased on v8.0.0.

this conflicts with
Revert "hw/pxb-cxl: Support passthrough HDM Decoders unless overridden"

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

I think you acked that one?

We should take one or the other, but not both. If this patchset is good then it's probably better to fix the bug rather than revert the feature, I think.

If it's easy to drop the revert that would be my preference.

Yes, the patch has not been picked up yet, so we can simply forget about the revert.

Thomas

#10 lore raw
In reply to Jonathan Cameron via
Quoted 39 lines · Jonathan Cameron
Quoted 36 lines · On Fri, 21 Apr 2023 09:59:57 +0100 Peter Maydell <[email protected]>…
Quoted 35 lines · Michael S. Tsirkin
Quoted 23 lines · Jonathan Cameron

Peter Maydell highlighted an incorrect conversion to TYPE_PXB_DEVICE from a device that didn't have that a an ancestor type. PXB_DEV() used instead of PXB_CXL_DEV()/

https://lore.kernel.org/qemu-devel/CAFEAcA-+de+eeLCE4YsAw1O-Qyd_4W1Ra05mGDsU_-3a6d92qw@mail.gmail.com/

During the discussion it became clear that the inheritance of the various TYPE_PXB*_DEVICE was unusual. This patchset first provides the minimal fix then cleans up the inheritance of types based on functionality.

There is also a rename to TYPE_PXB*_DEV to allow removal of some boilerplate.

Before this series
TYPE_PXB_DEVICE, TYPE_PXB_PCIE_DEVICE and TYPE_PXB_CXL_DEVICE all had TYPE_PCI_DEVICE as their direct parent though they shared a common struct PXBDev for their state. As a result this state contained some data that was irrelevant for some the types.

This series changes to
TYPE_PXB_CXL_DEV has a parent of TYPE_PXB_PCIE_DEV TYPE_PXB_PCIE_DEV has a parent of TYPE_PXB_DEV TYPE_PXB_DEV continues to have a parent of TYPE_PCI_DEVICE.

Quoted 6 lines

Each of the TYPE_PXB*_DEV has a state structure adding those elements to their parent that they need. This also allowed dropping a wrapping structure for the CXL state as the PXBCXLDev structure already provides the equivalent grouping.

Patches are similar to those posted in the thread but rebased on v8.0.0.

this conflicts with
Revert "hw/pxb-cxl: Support passthrough HDM Decoders unless overridden"

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

I think you acked that one?

We should take one or the other, but not both. If this patchset is good then it's probably better to fix the bug rather than revert the feature, I think.

If it's easy to drop the revert that would be my preference.

OK, I'll do that. Thanks!

Quoted 9 lines

If not, then I'm fine spinning a new version of that patch without the bug (so with patch 1 of this squashed in). Patch 2 is somewhat related refactoring. Not necessary to fix the issue even though it was motivated by that bug.

Jonathan

Quoted 2 lines

-- PMM