[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 16/18] hw/pci-host/bonito: Create TYPE_PCI_BONITO in bonito_host_
From: |
Philippe Mathieu-Daudé |
Subject: |
[PATCH 16/18] hw/pci-host/bonito: Create TYPE_PCI_BONITO in bonito_host_realize() |
Date: |
Thu, 31 Dec 2020 23:49:09 +0100 |
As it doesn't make sens to create the TYPE_BONITO_PCI_HOST_BRIDGE
PCI function device without its host side, create it in the host
realize(). This will allow to inline bonito_init() in few commits.
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
hw/pci-host/bonito.c | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/hw/pci-host/bonito.c b/hw/pci-host/bonito.c
index 099bb737c77..5a8a85ae443 100644
--- a/hw/pci-host/bonito.c
+++ b/hw/pci-host/bonito.c
@@ -622,6 +622,7 @@ static void bonito_host_realize(DeviceState *dev, Error
**errp)
PCIHostState *phb = PCI_HOST_BRIDGE(dev);
BonitoState *bs = BONITO_PCI_HOST_BRIDGE(dev);
MemoryRegion *pcimem_alias = g_new(MemoryRegion, 1);
+ PCIDevice *pci_dev;
memory_region_init(&bs->pci_mem, OBJECT(dev), "pci.mem",
BONITO_PCIHI_SIZE);
phb->bus = pci_register_root_bus(dev, "pci",
@@ -645,6 +646,11 @@ static void bonito_host_realize(DeviceState *dev, Error
**errp)
"north-bridge-pci-config", BONITO_PCICONFIG_SIZE);
memory_region_add_subregion(get_system_memory(), BONITO_PCICONFIG_BASE,
&phb->conf_mem);
+
+ pci_dev = pci_new(PCI_DEVFN(0, 0), TYPE_PCI_BONITO);
+ PCI_BONITO(pci_dev)->pcihost = bs;
+ bs->pci_dev = PCI_BONITO(pci_dev);
+ pci_realize_and_unref(pci_dev, phb->bus, &error_fatal);
}
static void bonito_pci_realize(PCIDevice *dev, Error **errp)
@@ -727,8 +733,6 @@ PCIBus *bonito_init(qemu_irq *pic)
DeviceState *dev;
BonitoState *pcihost;
PCIHostState *phb;
- BonitoPciState *s;
- PCIDevice *d;
dev = qdev_new(TYPE_BONITO_PCI_HOST_BRIDGE);
phb = PCI_HOST_BRIDGE(dev);
@@ -736,12 +740,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);
- s = PCI_BONITO(d);
- s->pcihost = pcihost;
- pcihost->pci_dev = s;
- pci_realize_and_unref(d, phb->bus, &error_fatal);
-
return phb->bus;
}
--
2.26.2
- [RFC PATCH 06/18] hw/pci-host/bonito: Do not allow big-endian targets, (continued)
- [RFC PATCH 06/18] hw/pci-host/bonito: Do not allow big-endian targets, Philippe Mathieu-Daudé, 2020/12/31
- [PATCH 07/18] hw/pci-host/bonito: Make BONPONCFG register read-only, Philippe Mathieu-Daudé, 2020/12/31
- [RFC PATCH 08/18] hw/pci-host/bonito: Remap PCI "lo" regions when PCIMAP reg is modified, Philippe Mathieu-Daudé, 2020/12/31
- [PATCH 09/18] hw/pci-host/bonito: Rename north bridge helpers, Philippe Mathieu-Daudé, 2020/12/31
- [PATCH 10/18] hw/pci-host/bonito: Rename PCI host helpers, Philippe Mathieu-Daudé, 2020/12/31
- [PATCH 11/18] hw/pci-host/bonito: Rename PCI function helpers, Philippe Mathieu-Daudé, 2020/12/31
- [PATCH 12/18] hw/pci-host/bonito: Rename PCIBonitoState -> BonitoPciState, Philippe Mathieu-Daudé, 2020/12/31
- [PATCH 13/18] hw/pci-host/bonito: Create PCI regions in bonito_host_realize(), Philippe Mathieu-Daudé, 2020/12/31
- [RFC PATCH 14/18] hw/pci-host/bonito: Simplify using pci_host_conf_le_ops MemoryRegionOps, Philippe Mathieu-Daudé, 2020/12/31
- [PATCH 15/18] hw/pci-host/bonito: Map north bridge region in bonito_host_realize(), Philippe Mathieu-Daudé, 2020/12/31
- [PATCH 16/18] hw/pci-host/bonito: Create TYPE_PCI_BONITO in bonito_host_realize(),
Philippe Mathieu-Daudé <=
- [PATCH 17/18] hw/pci-host/bonito: Declare TYPE_BONITO_PCI_HOST_BRIDGE in include/, Philippe Mathieu-Daudé, 2020/12/31
- [RFC PATCH 18/18] hw/mips/fuloong2e: Inline bonito_init(), Philippe Mathieu-Daudé, 2020/12/31