Message ID | 20230105130710.49264-6-philmd@linaro.org |
---|---|
State | New |
Headers | show |
Series | hw/pci-host/bonito: Housekeeping | expand |
On 1/5/23 05:07, Philippe Mathieu-Daudé wrote: > 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); You can avoid this final dynamic cast by saving the result of pci_new. Otherwise, Reviewed-by: Richard Henderson <richard.henderson@linaro.org> r~
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; }
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(-)