qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 14/14] ppc/pnv: Introduce support for user created PHB4 devic


From: Daniel Henrique Barboza
Subject: Re: [PATCH 14/14] ppc/pnv: Introduce support for user created PHB4 devices
Date: Thu, 2 Dec 2021 14:49:42 -0300
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.3.0



On 12/2/21 11:42, Cédric Le Goater wrote:
PHB4 devices and PCI devices can now be added to the powernv9 machine
using:

   -device pnv-phb4-pec,chip-id=0,index=0
   -device nec-usb-xhci,bus=pci.0,addr=0x0

In case of user created devices, a lookup on 'chip-id' is required to
assign the owning chip.

To be noted, that the PEC PHB4 devices can add more than one PHB4
devices:

   * PEC0 provides 1 PHB  (PHB0)
   * PEC1 provides 2 PHBs (PHB1 and PHB2)
   * PEC2 provides 3 PHBs (PHB3, PHB4 and PHB5)

Signed-off-by: Cédric Le Goater <clg@kaod.org>
---

Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>

  hw/pci-host/pnv_phb4_pec.c | 19 ++++++++++++++++++-
  1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/hw/pci-host/pnv_phb4_pec.c b/hw/pci-host/pnv_phb4_pec.c
index 9b081d543057..4ee92f11945c 100644
--- a/hw/pci-host/pnv_phb4_pec.c
+++ b/hw/pci-host/pnv_phb4_pec.c
@@ -394,6 +394,17 @@ static void pnv_pec_realize(DeviceState *dev, Error **errp)
      char name[64];
      int i;
+ /* User created devices */
+    if (!pec->chip) {
+        PnvMachineState *pnv = PNV_MACHINE(qdev_get_machine());
+
+        pec->chip = pnv_get_chip(pnv, pec->chip_id);
+        if (!pec->chip) {
+            error_setg(errp, "invalid chip id: %d", pec->chip_id);
+            return;
+        }
+    }
+
      if (pec->index >= PNV_CHIP_GET_CLASS(pec->chip)->num_pecs) {
          error_setg(errp, "invalid PEC index: %d", pec->index);
          return;
@@ -401,6 +412,12 @@ static void pnv_pec_realize(DeviceState *dev, Error **errp)
pec->num_stacks = pecc->num_stacks[pec->index]; + /*
+     * Reparent user created devices to the chip to build correctly
+     * the device tree.
+     */
+    pnv_chip_parent_fixup(pec->chip, OBJECT(pec), pec->index);
+
      /* Create stacks */
      for (i = 0; i < pec->num_stacks; i++) {
          PnvPhb4PecStack *stack = &pec->stacks[i];
@@ -516,7 +533,7 @@ static void pnv_pec_class_init(ObjectClass *klass, void 
*data)
dc->realize = pnv_pec_realize;
      device_class_set_props(dc, pnv_pec_properties);
-    dc->user_creatable = false;
+    dc->user_creatable = true;
pecc->xscom_nest_base = pnv_pec_xscom_nest_base;
      pecc->xscom_pci_base  = pnv_pec_xscom_pci_base;




reply via email to

[Prev in Thread] Current Thread [Next in Thread]