qemu-devel
[Top][All Lists]
Advanced

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

[PATCH 5/8] hw/pci-host/bonito: Create PCI function #0 in bridge realize


From: Philippe Mathieu-Daudé
Subject: [PATCH 5/8] hw/pci-host/bonito: Create PCI function #0 in bridge realize() handler
Date: Thu, 5 Jan 2023 14:07:07 +0100

The PCI function #0 is an integral part of the PCI bridge,
instantiate it internally during the bridge creation.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 hw/pci-host/bonito.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/hw/pci-host/bonito.c b/hw/pci-host/bonito.c
index d881c85509..7722636e9e 100644
--- a/hw/pci-host/bonito.c
+++ b/hw/pci-host/bonito.c
@@ -651,6 +651,11 @@ static void bonito_host_realize(DeviceState *dev, Error 
**errp)
     }
 
     create_unimplemented_device("pci.io", BONITO_PCIIO_BASE, 1 * MiB);
+
+    bs->pci_dev = PCI_BONITO(pci_new(PCI_DEVFN(0, 0), TYPE_PCI_BONITO));
+    object_property_add_const_link(OBJECT(bs->pci_dev), "host-bridge",
+                                   OBJECT(bs));
+    pci_realize_and_unref(PCI_DEVICE(bs->pci_dev), phb->bus, &error_fatal);
 }
 
 static void bonito_pci_realize(PCIDevice *dev, Error **errp)
@@ -752,7 +757,6 @@ PCIBus *bonito_init(qemu_irq *pic)
     DeviceState *dev;
     BonitoState *pcihost;
     PCIHostState *phb;
-    PCIDevice *d;
 
     dev = qdev_new(TYPE_BONITO_PCI_HOST_BRIDGE);
     phb = PCI_HOST_BRIDGE(dev);
@@ -760,11 +764,6 @@ PCIBus *bonito_init(qemu_irq *pic)
     pcihost->pic = pic;
     sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
 
-    d = pci_new(PCI_DEVFN(0, 0), TYPE_PCI_BONITO);
-    object_property_add_const_link(OBJECT(d), "host-bridge", OBJECT(dev));
-    pci_realize_and_unref(d, phb->bus, &error_fatal);
-    pcihost->pci_dev = PCI_BONITO(d);
-
     return phb->bus;
 }
 
-- 
2.38.1




reply via email to

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