Skip to contentSkip to conversation

ppc/pnv: Preliminary cleanups before user created PHBs

PATCH Applied Cédric Le Goater 2 participants 13 messages Dec 22, 2021 – Jan 4, 2022

lore
Share & tools
lore
#0 lore raw

cover ppc/pnv: Preliminary cleanups before user created PHBs

Hello,

There are the last cleanups preparing ground for PHBs created on the command line and possibly libvirt support.

Thanks,

C.

Cédric Le Goater (5):
ppc/pnv: Change the maximum of PHB3 devices for Power8NVL ppc/pnv: Remove PHB4 reset handler
ppc/pnv: Remove the PHB4 "device-id" property ppc/pnv: Attach PHB3 root port device when defaults are enabled ppc/pnv: Attach PHB4 root port device when defaults are enabled

 include/hw/pci-host/pnv_phb3.h |  2 --
 include/hw/pci-host/pnv_phb4.h |  4 ----
 hw/pci-host/pnv_phb3.c         |  8 --------
 hw/pci-host/pnv_phb4.c         | 25 -------------------------
 hw/pci-host/pnv_phb4_pec.c     |  3 ---
 hw/ppc/pnv.c                   | 25 +++++++++++++++++++++++--
 6 files changed, 23 insertions(+), 44 deletions(-)
Signature · 1 line
2.31.1
#1 lore raw

PATCH 1/5 ppc/pnv: Change the maximum of PHB3 devices for Power8NVL

The POWER8 processors with a NVLink logic unit have 4 PHB3 devices per chip.

---
 hw/ppc/pnv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/ppc/pnv.c +1 -1
index 29ee0d0f08b4..9de8b8353014 100644
@@ -1314,7 +1314,7 @@ static void pnv_chip_power8nvl_class_init(ObjectClass *klass, void *data)
 
     k->chip_cfam_id = 0x120d304980000000ull;  /* P8 Naples DD1.0 */
     k->cores_mask = POWER8_CORE_MASK;
-    k->num_phbs = 3;
+    k->num_phbs = 4;
     k->core_pir = pnv_chip_core_pir_p8;
     k->intc_create = pnv_chip_power8_intc_create;
     k->intc_reset = pnv_chip_power8_intc_reset;
Signature · 1 line
2.31.1
Reviewed-by on v1 1/5
#2 lore raw

Re: [PATCH 1/5] ppc/pnv: Change the maximum of PHB3 devices for Power8NVL

Quoted 5 lines · Cédric Le Goater

The POWER8 processors with a NVLink logic unit have 4 PHB3 devices per chip.

---

Quoted 17 lines
  hw/ppc/pnv.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
hw/ppc/pnv.c +1 -1
index 29ee0d0f08b4..9de8b8353014 100644
@@ -1314,7 +1314,7 @@ static void pnv_chip_power8nvl_class_init(ObjectClass *klass, void *data)
 
      k->chip_cfam_id = 0x120d304980000000ull;  /* P8 Naples DD1.0 */
      k->cores_mask = POWER8_CORE_MASK;
-    k->num_phbs = 3;
+    k->num_phbs = 4;
      k->core_pir = pnv_chip_core_pir_p8;
      k->intc_create = pnv_chip_power8_intc_create;
      k->intc_reset = pnv_chip_power8_intc_reset;
#3 lore raw

PATCH 2/5 ppc/pnv: Remove PHB4 reset handler

In reply to Cédric Le Goater

The PHB4 reset handler was preparing ground for PHB5 to set appropriately the device id. We don't need it for the PHB4 since the device id is already set in the root port complex. PH5 will introduce its own.

"device-id" property is now useless. It should be removed.

---
 hw/pci-host/pnv_phb4.c | 13 -------------
 1 file changed, 13 deletions(-)
hw/pci-host/pnv_phb4.c +0 -13
index 40b793201a34..4caf03310fab 100644
@@ -1229,18 +1229,6 @@ static void pnv_phb4_realize(DeviceState *dev, Error **errp)
     phb->qirqs = qemu_allocate_irqs(xive_source_set_irq, xsrc, xsrc->nr_irqs);
 }
 
-static void pnv_phb4_reset(DeviceState *dev)
-{
-    PnvPHB4 *phb = PNV_PHB4(dev);
-    PCIDevice *root_dev = PCI_DEVICE(&phb->root);
-
-    /*
-     * Configure PCI device id at reset using a property.
-     */
-    pci_config_set_vendor_id(root_dev->config, PCI_VENDOR_ID_IBM);
-    pci_config_set_device_id(root_dev->config, phb->device_id);
-}
-
 static const char *pnv_phb4_root_bus_path(PCIHostState *host_bridge,
                                           PCIBus *rootbus)
 {
@@ -1290,7 +1278,6 @@ static void pnv_phb4_class_init(ObjectClass *klass, void *data)
     device_class_set_props(dc, pnv_phb4_properties);
     set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
     dc->user_creatable  = false;
-    dc->reset           = pnv_phb4_reset;
 
     xfc->notify         = pnv_phb4_xive_notify;
 }
Signature · 1 line
2.31.1
Reviewed-by on v1 2/5
#4 lore raw

Re: [PATCH 2/5] ppc/pnv: Remove PHB4 reset handler

Quoted 9 lines · Cédric Le Goater

The PHB4 reset handler was preparing ground for PHB5 to set appropriately the device id. We don't need it for the PHB4 since the device id is already set in the root port complex. PH5 will introduce its own.

"device-id" property is now useless. It should be removed.

---

Quoted 35 lines
  hw/pci-host/pnv_phb4.c | 13 -------------
  1 file changed, 13 deletions(-)
hw/pci-host/pnv_phb4.c +0 -13
index 40b793201a34..4caf03310fab 100644
@@ -1229,18 +1229,6 @@ static void pnv_phb4_realize(DeviceState *dev, Error **errp)
      phb->qirqs = qemu_allocate_irqs(xive_source_set_irq, xsrc, xsrc->nr_irqs);
  }
 
-static void pnv_phb4_reset(DeviceState *dev)
-{
-    PnvPHB4 *phb = PNV_PHB4(dev);
-    PCIDevice *root_dev = PCI_DEVICE(&phb->root);
-
-    /*
-     * Configure PCI device id at reset using a property.
-     */
-    pci_config_set_vendor_id(root_dev->config, PCI_VENDOR_ID_IBM);
-    pci_config_set_device_id(root_dev->config, phb->device_id);
-}
-
  static const char *pnv_phb4_root_bus_path(PCIHostState *host_bridge,
                                            PCIBus *rootbus)
  {
@@ -1290,7 +1278,6 @@ static void pnv_phb4_class_init(ObjectClass *klass, void *data)
      device_class_set_props(dc, pnv_phb4_properties);
      set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
      dc->user_creatable  = false;
-    dc->reset           = pnv_phb4_reset;
 
      xfc->notify         = pnv_phb4_xive_notify;
  }
#5 lore raw

PATCH 3/5 ppc/pnv: Remove the PHB4 "device-id" property

In reply to Cédric Le Goater

It's unused.

---
 include/hw/pci-host/pnv_phb4.h | 2 --
 hw/pci-host/pnv_phb4.c         | 1 -
 hw/pci-host/pnv_phb4_pec.c     | 3 ---
 3 files changed, 6 deletions(-)
include/hw/pci-host/pnv_phb4.h +0 -2
index 60de3031a622..4a19338db35e 100644
@@ -84,7 +84,6 @@ struct PnvPHB4 {
     uint32_t phb_id;
 
     uint64_t version;
-    uint16_t device_id;
 
     char bus_path[8];
 
@@ -222,7 +221,6 @@ struct PnvPhb4PecClass {
     const char *stk_compat;
     int stk_compat_size;
     uint64_t version;
-    uint64_t device_id;
     const uint32_t *num_stacks;
 };
 
hw/pci-host/pnv_phb4.c +0 -1
index 4caf03310fab..3b50a22b97cd 100644
@@ -1261,7 +1261,6 @@ static Property pnv_phb4_properties[] = {
         DEFINE_PROP_UINT32("index", PnvPHB4, phb_id, 0),
         DEFINE_PROP_UINT32("chip-id", PnvPHB4, chip_id, 0),
         DEFINE_PROP_UINT64("version", PnvPHB4, version, 0),
-        DEFINE_PROP_UINT16("device-id", PnvPHB4, device_id, 0),
         DEFINE_PROP_LINK("stack", PnvPHB4, stack, TYPE_PNV_PHB4_PEC_STACK,
                          PnvPhb4PecStack *),
         DEFINE_PROP_END_OF_LIST(),
hw/pci-host/pnv_phb4_pec.c +0 -3
index 24a3adcae326..f3e4fa0c8297 100644
@@ -527,7 +527,6 @@ static void pnv_pec_class_init(ObjectClass *klass, void *data)
     pecc->stk_compat = stk_compat;
     pecc->stk_compat_size = sizeof(stk_compat);
     pecc->version = PNV_PHB4_VERSION;
-    pecc->device_id = PNV_PHB4_DEVICE_ID;
     pecc->num_stacks = pnv_pec_num_stacks;
 }
 
@@ -587,8 +586,6 @@ static void pnv_pec_stk_realize(DeviceState *dev, Error **errp)
                             &error_fatal);
     object_property_set_int(OBJECT(&stack->phb), "version", pecc->version,
                             &error_fatal);
-    object_property_set_int(OBJECT(&stack->phb), "device-id", pecc->device_id,
-                            &error_fatal);
     object_property_set_link(OBJECT(&stack->phb), "stack", OBJECT(stack),
                              &error_abort);
     if (!sysbus_realize(SYS_BUS_DEVICE(&stack->phb), errp)) {
Signature · 1 line
2.31.1
Reviewed-by on v1 3/5
#6 lore raw

Re: [PATCH 3/5] ppc/pnv: Remove the PHB4 "device-id" property

Quoted 4 lines · Cédric Le Goater

It's unused.

---

Quoted 59 lines
  include/hw/pci-host/pnv_phb4.h | 2 --
  hw/pci-host/pnv_phb4.c         | 1 -
  hw/pci-host/pnv_phb4_pec.c     | 3 ---
  3 files changed, 6 deletions(-)
include/hw/pci-host/pnv_phb4.h +0 -2
index 60de3031a622..4a19338db35e 100644
@@ -84,7 +84,6 @@ struct PnvPHB4 {
      uint32_t phb_id;
 
      uint64_t version;
-    uint16_t device_id;
 
      char bus_path[8];
 
@@ -222,7 +221,6 @@ struct PnvPhb4PecClass {
      const char *stk_compat;
      int stk_compat_size;
      uint64_t version;
-    uint64_t device_id;
      const uint32_t *num_stacks;
  };
 
hw/pci-host/pnv_phb4.c +0 -1
index 4caf03310fab..3b50a22b97cd 100644
@@ -1261,7 +1261,6 @@ static Property pnv_phb4_properties[] = {
          DEFINE_PROP_UINT32("index", PnvPHB4, phb_id, 0),
          DEFINE_PROP_UINT32("chip-id", PnvPHB4, chip_id, 0),
          DEFINE_PROP_UINT64("version", PnvPHB4, version, 0),
-        DEFINE_PROP_UINT16("device-id", PnvPHB4, device_id, 0),
          DEFINE_PROP_LINK("stack", PnvPHB4, stack, TYPE_PNV_PHB4_PEC_STACK,
                           PnvPhb4PecStack *),
          DEFINE_PROP_END_OF_LIST(),
hw/pci-host/pnv_phb4_pec.c +0 -3
index 24a3adcae326..f3e4fa0c8297 100644
@@ -527,7 +527,6 @@ static void pnv_pec_class_init(ObjectClass *klass, void *data)
      pecc->stk_compat = stk_compat;
      pecc->stk_compat_size = sizeof(stk_compat);
      pecc->version = PNV_PHB4_VERSION;
-    pecc->device_id = PNV_PHB4_DEVICE_ID;
      pecc->num_stacks = pnv_pec_num_stacks;
  }
 
@@ -587,8 +586,6 @@ static void pnv_pec_stk_realize(DeviceState *dev, Error **errp)
                              &error_fatal);
      object_property_set_int(OBJECT(&stack->phb), "version", pecc->version,
                              &error_fatal);
-    object_property_set_int(OBJECT(&stack->phb), "device-id", pecc->device_id,
-                            &error_fatal);
      object_property_set_link(OBJECT(&stack->phb), "stack", OBJECT(stack),
                               &error_abort);
      if (!sysbus_realize(SYS_BUS_DEVICE(&stack->phb), errp)) {
#7 lore raw

PATCH 4/5 ppc/pnv: Attach PHB3 root port device when defaults are enabled

In reply to Cédric Le Goater

This cleanups the PHB3 model a bit more since the root port is an independent device and it will ease our task when adding user created PHB3s.

---
 include/hw/pci-host/pnv_phb3.h |  2 --
 hw/pci-host/pnv_phb3.c         |  8 --------
 hw/ppc/pnv.c                   | 14 ++++++++++++++
 3 files changed, 14 insertions(+), 10 deletions(-)
include/hw/pci-host/pnv_phb3.h +0 -2
index e9c13e6bd821..2e423c3890bc 100644
@@ -155,8 +155,6 @@ struct PnvPHB3 {
 
     PnvPBCQState pbcq;
 
-    PnvPHB3RootPort root;
-
     QLIST_HEAD(, PnvPhb3DMASpace) dma_spaces;
 
     PnvChip *chip;
hw/pci-host/pnv_phb3.c +0 -8
index 9c4451ca0d1c..39f03bd256d0 100644
@@ -980,10 +980,6 @@ static void pnv_phb3_instance_init(Object *obj)
     /* Power Bus Common Queue */
     object_initialize_child(obj, "pbcq", &phb->pbcq, TYPE_PNV_PBCQ);
 
-    /* Root Port */
-    object_initialize_child(obj, "root", &phb->root, TYPE_PNV_PHB3_ROOT_PORT);
-    qdev_prop_set_int32(DEVICE(&phb->root), "addr", PCI_DEVFN(0, 0));
-    qdev_prop_set_bit(DEVICE(&phb->root), "multifunction", false);
 }
 
 static void pnv_phb3_realize(DeviceState *dev, Error **errp)
@@ -1051,10 +1047,6 @@ static void pnv_phb3_realize(DeviceState *dev, Error **errp)
 
     pci_setup_iommu(pci->bus, pnv_phb3_dma_iommu, phb);
 
-    /* Add a single Root port */
-    qdev_prop_set_uint8(DEVICE(&phb->root), "chassis", phb->chip_id);
-    qdev_prop_set_uint16(DEVICE(&phb->root), "slot", phb->phb_id);
-    qdev_realize(DEVICE(&phb->root), BUS(pci->bus), &error_fatal);
 }
 
 void pnv_phb3_update_regions(PnvPHB3 *phb)
hw/ppc/pnv.c +14 -0
index 9de8b8353014..6edfd6876fd0 100644
@@ -1156,6 +1156,17 @@ static void pnv_chip_icp_realize(Pnv8Chip *chip8, Error **errp)
     }
 }
 
+/* Attach a root port device */
+static void pnv_phb_attach_root_port(PCIHostState *pci, int id,
+                                     const char *name)
+{
+    PCIDevice *root = pci_new(PCI_DEVFN(0, 0), name);
+
+    qdev_prop_set_uint8(&root->qdev, "chassis", id);
+    qdev_prop_set_uint16(&root->qdev, "slot", id);
+    pci_realize_and_unref(root, pci->bus, &error_fatal);
+}
+
 static void pnv_chip_power8_realize(DeviceState *dev, Error **errp)
 {
     PnvChipClass *pcc = PNV_CHIP_GET_CLASS(dev);
@@ -1250,6 +1261,9 @@ static void pnv_chip_power8_realize(DeviceState *dev, Error **errp)
         if (!sysbus_realize(SYS_BUS_DEVICE(phb), errp)) {
             return;
         }
+
+        pnv_phb_attach_root_port(PCI_HOST_BRIDGE(phb), phb->phb_id,
+                                 TYPE_PNV_PHB3_ROOT_PORT);
     }
 }
 
Signature · 1 line
2.31.1
Reviewed-by on v1 4/5
#8 lore raw

Re: [PATCH 4/5] ppc/pnv: Attach PHB3 root port device when defaults are enabled

Quoted 6 lines · Cédric Le Goater

This cleanups the PHB3 model a bit more since the root port is an independent device and it will ease our task when adding user created PHB3s.

---

Quoted 77 lines
  include/hw/pci-host/pnv_phb3.h |  2 --
  hw/pci-host/pnv_phb3.c         |  8 --------
  hw/ppc/pnv.c                   | 14 ++++++++++++++
  3 files changed, 14 insertions(+), 10 deletions(-)
include/hw/pci-host/pnv_phb3.h +0 -2
index e9c13e6bd821..2e423c3890bc 100644
@@ -155,8 +155,6 @@ struct PnvPHB3 {
 
      PnvPBCQState pbcq;
 
-    PnvPHB3RootPort root;
-
      QLIST_HEAD(, PnvPhb3DMASpace) dma_spaces;
 
      PnvChip *chip;
hw/pci-host/pnv_phb3.c +0 -8
index 9c4451ca0d1c..39f03bd256d0 100644
@@ -980,10 +980,6 @@ static void pnv_phb3_instance_init(Object *obj)
      /* Power Bus Common Queue */
      object_initialize_child(obj, "pbcq", &phb->pbcq, TYPE_PNV_PBCQ);
 
-    /* Root Port */
-    object_initialize_child(obj, "root", &phb->root, TYPE_PNV_PHB3_ROOT_PORT);
-    qdev_prop_set_int32(DEVICE(&phb->root), "addr", PCI_DEVFN(0, 0));
-    qdev_prop_set_bit(DEVICE(&phb->root), "multifunction", false);
  }
 
  static void pnv_phb3_realize(DeviceState *dev, Error **errp)
@@ -1051,10 +1047,6 @@ static void pnv_phb3_realize(DeviceState *dev, Error **errp)
 
      pci_setup_iommu(pci->bus, pnv_phb3_dma_iommu, phb);
 
-    /* Add a single Root port */
-    qdev_prop_set_uint8(DEVICE(&phb->root), "chassis", phb->chip_id);
-    qdev_prop_set_uint16(DEVICE(&phb->root), "slot", phb->phb_id);
-    qdev_realize(DEVICE(&phb->root), BUS(pci->bus), &error_fatal);
  }
 
  void pnv_phb3_update_regions(PnvPHB3 *phb)
hw/ppc/pnv.c +14 -0
index 9de8b8353014..6edfd6876fd0 100644
@@ -1156,6 +1156,17 @@ static void pnv_chip_icp_realize(Pnv8Chip *chip8, Error **errp)
      }
  }
 
+/* Attach a root port device */
+static void pnv_phb_attach_root_port(PCIHostState *pci, int id,
+                                     const char *name)
+{
+    PCIDevice *root = pci_new(PCI_DEVFN(0, 0), name);
+
+    qdev_prop_set_uint8(&root->qdev, "chassis", id);
+    qdev_prop_set_uint16(&root->qdev, "slot", id);
+    pci_realize_and_unref(root, pci->bus, &error_fatal);
+}
+
  static void pnv_chip_power8_realize(DeviceState *dev, Error **errp)
  {
      PnvChipClass *pcc = PNV_CHIP_GET_CLASS(dev);
@@ -1250,6 +1261,9 @@ static void pnv_chip_power8_realize(DeviceState *dev, Error **errp)
          if (!sysbus_realize(SYS_BUS_DEVICE(phb), errp)) {
              return;
          }
+
+        pnv_phb_attach_root_port(PCI_HOST_BRIDGE(phb), phb->phb_id,
+                                 TYPE_PNV_PHB3_ROOT_PORT);
      }
  }
 
#9 lore raw

PATCH 5/5 ppc/pnv: Attach PHB4 root port device when defaults are enabled

In reply to Cédric Le Goater

This cleanups the PHB4 model a bit more since the root port is an independent device and it will ease our task when adding user created PHB4s.

---
 include/hw/pci-host/pnv_phb4.h |  2 --
 hw/pci-host/pnv_phb4.c         | 11 -----------
 hw/ppc/pnv.c                   |  9 ++++++++-
 3 files changed, 8 insertions(+), 14 deletions(-)
include/hw/pci-host/pnv_phb4.h +0 -2
index 4a19338db35e..ea63df967678 100644
@@ -78,8 +78,6 @@ OBJECT_DECLARE_SIMPLE_TYPE(PnvPHB4, PNV_PHB4)
 struct PnvPHB4 {
     PCIExpressHost parent_obj;
 
-    PnvPHB4RootPort root;
-
     uint32_t chip_id;
     uint32_t phb_id;
 
hw/pci-host/pnv_phb4.c +0 -11
index 3b50a22b97cd..3b4758c42e26 100644
@@ -1158,12 +1158,6 @@ static void pnv_phb4_instance_init(Object *obj)
 
     /* XIVE interrupt source object */
     object_initialize_child(obj, "source", &phb->xsrc, TYPE_XIVE_SOURCE);
-
-    /* Root Port */
-    object_initialize_child(obj, "root", &phb->root, TYPE_PNV_PHB4_ROOT_PORT);
-
-    qdev_prop_set_int32(DEVICE(&phb->root), "addr", PCI_DEVFN(0, 0));
-    qdev_prop_set_bit(DEVICE(&phb->root), "multifunction", false);
 }
 
 static void pnv_phb4_realize(DeviceState *dev, Error **errp)
@@ -1207,11 +1201,6 @@ static void pnv_phb4_realize(DeviceState *dev, Error **errp)
     pci_setup_iommu(pci->bus, pnv_phb4_dma_iommu, phb);
     pci->bus->flags |= PCI_BUS_EXTENDED_CONFIG_SPACE;
 
-    /* Add a single Root port */
-    qdev_prop_set_uint8(DEVICE(&phb->root), "chassis", phb->chip_id);
-    qdev_prop_set_uint16(DEVICE(&phb->root), "slot", phb->phb_id);
-    qdev_realize(DEVICE(&phb->root), BUS(pci->bus), &error_fatal);
-
     /* Setup XIVE Source */
     if (phb->big_phb) {
         nr_irqs = PNV_PHB4_MAX_INTs;
hw/ppc/pnv.c +8 -1
index 6edfd6876fd0..7a397698e984 100644
@@ -1403,7 +1403,7 @@ static void pnv_chip_quad_realize(Pnv9Chip *chip9, Error **errp)
 static void pnv_chip_power9_pec_realize(PnvChip *chip, Error **errp)
 {
     Pnv9Chip *chip9 = PNV9_CHIP(chip);
-    int i;
+    int i, j;
 
     for (i = 0; i < chip->num_pecs; i++) {
         PnvPhb4PecState *pec = &chip9->pecs[i];
@@ -1425,6 +1425,13 @@ static void pnv_chip_power9_pec_realize(PnvChip *chip, Error **errp)
 
         pnv_xscom_add_subregion(chip, pec_nest_base, &pec->nest_regs_mr);
         pnv_xscom_add_subregion(chip, pec_pci_base, &pec->pci_regs_mr);
+
+        for (j = 0; j < pec->num_stacks; j++) {
+            PnvPHB4 *phb = &pec->stacks[j].phb;
+
+            pnv_phb_attach_root_port(PCI_HOST_BRIDGE(phb), phb->phb_id,
+                                     TYPE_PNV_PHB4_ROOT_PORT);
+        }
     }
 }
 
Signature · 1 line
2.31.1
Reviewed-by on v1 5/5
#10 lore raw

Re: [PATCH 5/5] ppc/pnv: Attach PHB4 root port device when defaults are enabled

Quoted 6 lines · Cédric Le Goater

This cleanups the PHB4 model a bit more since the root port is an independent device and it will ease our task when adding user created PHB4s.

---

Quoted 75 lines
  include/hw/pci-host/pnv_phb4.h |  2 --
  hw/pci-host/pnv_phb4.c         | 11 -----------
  hw/ppc/pnv.c                   |  9 ++++++++-
  3 files changed, 8 insertions(+), 14 deletions(-)
include/hw/pci-host/pnv_phb4.h +0 -2
index 4a19338db35e..ea63df967678 100644
@@ -78,8 +78,6 @@ OBJECT_DECLARE_SIMPLE_TYPE(PnvPHB4, PNV_PHB4)
  struct PnvPHB4 {
      PCIExpressHost parent_obj;
 
-    PnvPHB4RootPort root;
-
      uint32_t chip_id;
      uint32_t phb_id;
 
hw/pci-host/pnv_phb4.c +0 -11
index 3b50a22b97cd..3b4758c42e26 100644
@@ -1158,12 +1158,6 @@ static void pnv_phb4_instance_init(Object *obj)
 
      /* XIVE interrupt source object */
      object_initialize_child(obj, "source", &phb->xsrc, TYPE_XIVE_SOURCE);
-
-    /* Root Port */
-    object_initialize_child(obj, "root", &phb->root, TYPE_PNV_PHB4_ROOT_PORT);
-
-    qdev_prop_set_int32(DEVICE(&phb->root), "addr", PCI_DEVFN(0, 0));
-    qdev_prop_set_bit(DEVICE(&phb->root), "multifunction", false);
  }
 
  static void pnv_phb4_realize(DeviceState *dev, Error **errp)
@@ -1207,11 +1201,6 @@ static void pnv_phb4_realize(DeviceState *dev, Error **errp)
      pci_setup_iommu(pci->bus, pnv_phb4_dma_iommu, phb);
      pci->bus->flags |= PCI_BUS_EXTENDED_CONFIG_SPACE;
 
-    /* Add a single Root port */
-    qdev_prop_set_uint8(DEVICE(&phb->root), "chassis", phb->chip_id);
-    qdev_prop_set_uint16(DEVICE(&phb->root), "slot", phb->phb_id);
-    qdev_realize(DEVICE(&phb->root), BUS(pci->bus), &error_fatal);
-
      /* Setup XIVE Source */
      if (phb->big_phb) {
          nr_irqs = PNV_PHB4_MAX_INTs;
hw/ppc/pnv.c +8 -1
index 6edfd6876fd0..7a397698e984 100644
@@ -1403,7 +1403,7 @@ static void pnv_chip_quad_realize(Pnv9Chip *chip9, Error **errp)
  static void pnv_chip_power9_pec_realize(PnvChip *chip, Error **errp)
  {
      Pnv9Chip *chip9 = PNV9_CHIP(chip);
-    int i;
+    int i, j;
 
      for (i = 0; i < chip->num_pecs; i++) {
          PnvPhb4PecState *pec = &chip9->pecs[i];
@@ -1425,6 +1425,13 @@ static void pnv_chip_power9_pec_realize(PnvChip *chip, Error **errp)
 
          pnv_xscom_add_subregion(chip, pec_nest_base, &pec->nest_regs_mr);
          pnv_xscom_add_subregion(chip, pec_pci_base, &pec->pci_regs_mr);
+
+        for (j = 0; j < pec->num_stacks; j++) {
+            PnvPHB4 *phb = &pec->stacks[j].phb;
+
+            pnv_phb_attach_root_port(PCI_HOST_BRIDGE(phb), phb->phb_id,
+                                     TYPE_PNV_PHB4_ROOT_PORT);
+        }
      }
  }
 
#11 lore raw
In reply to Cédric Le Goater
Quoted 4 lines · Cédric Le Goater

Hello,

There are the last cleanups preparing ground for PHBs created on the command line and possibly libvirt support.

As a note to whoever wants to give this series a go: I'm working in more fixes and cleanups on top of these patches. I'm planning to post what I have in the next few days.

Thanks,

Daniel

Quoted 20 lines

Thanks,

C.

Cédric Le Goater (5):
ppc/pnv: Change the maximum of PHB3 devices for Power8NVL ppc/pnv: Remove PHB4 reset handler
ppc/pnv: Remove the PHB4 "device-id" property ppc/pnv: Attach PHB3 root port device when defaults are enabled ppc/pnv: Attach PHB4 root port device when defaults are enabled

  include/hw/pci-host/pnv_phb3.h |  2 --
  include/hw/pci-host/pnv_phb4.h |  4 ----
  hw/pci-host/pnv_phb3.c         |  8 --------
  hw/pci-host/pnv_phb4.c         | 25 -------------------------
  hw/pci-host/pnv_phb4_pec.c     |  3 ---
  hw/ppc/pnv.c                   | 25 +++++++++++++++++++++++--
  6 files changed, 23 insertions(+), 44 deletions(-)
author Applied
#12 lore raw
In reply to Cédric Le Goater
Quoted 7 lines · Cédric Le Goater

Hello,

There are the last cleanups preparing ground for PHBs created on the command line and possibly libvirt support.

Thanks,

Quoted 8 lines

C.

Cédric Le Goater (5):
ppc/pnv: Change the maximum of PHB3 devices for Power8NVL ppc/pnv: Remove PHB4 reset handler
ppc/pnv: Remove the PHB4 "device-id" property ppc/pnv: Attach PHB3 root port device when defaults are enabled ppc/pnv: Attach PHB4 root port device when defaults are enabled

Applied patches 1-3 in ppc-next.

Thanks,

C.