hw/pci-host/bonito: Housekeeping
cover hw/pci-host/bonito: Housekeeping
Minor housekeeping while reviewing PCI host bridge models.
- Convert to 3-phase reset
- Set reference using object_property_add_const_link
- Sysbus'ify IRQ
- Open code bonito_init()
Philippe Mathieu-Daudé (8):
hw/pci-host/bonito: Convert to 3-phase reset hw/pci-host/bonito: Use 'bonito_host' for PCI host bridge code hw/pci-host/bonito: Use 'bonito_pci' for PCI function #0 code hw/pci-host/bonito: Set reference using
object_property_add_const_link()
hw/pci-host/bonito: Create PCI function #0 in bridge realize() handler hw/pci-host/bonito: Sysbus'ify outgoing IRQ hw/pci-host/bonito: Declare TYPE_BONITO_PCI_HOST_BRIDGE in header hw/mips/fuloong2e: Open code bonito_init()
MAINTAINERS | 1 + hw/mips/fuloong2e.c | 6 ++- hw/pci-host/bonito.c | 93 +++++++++++++++--------------------- include/hw/mips/mips.h | 3 -- include/hw/pci-host/bonito.h | 18 +++++++ 5 files changed, 63 insertions(+), 58 deletions(-) create mode 100644 include/hw/pci-host/bonito.h
Signature · 1 line
2.38.1
PATCH 1/8 hw/pci-host/bonito: Convert to 3-phase reset
From: Philippe Mathieu-Daudé <[email protected]>
Convert the TYPE_PCI_BONITO class to use 3-phase reset.
--- hw/pci-host/bonito.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
hw/pci-host/bonito.c +4 -5
@@ -47,7 +47,6 @@#include "hw/mips/mips.h" #include "hw/pci/pci_host.h" #include "migration/vmstate.h" -#include "sysemu/reset.h" #include "sysemu/runstate.h" #include "hw/misc/unimp.h" #include "hw/registerfields.h"
@@ -593,9 +592,9 @@ static int pci_bonito_map_irq(PCIDevice *pci_dev, int irq_num) } } -static void bonito_reset (void *opaque) +static void bonito_reset_hold (Object *obj) { -PCIBonitoState *s = opaque; +PCIBonitoState *s =PCI_BONITO (obj);uint32_t val =0 ;/* set the default value of north bridge registers */
@@ -739,8 +738,6 @@ static void bonito_realize(PCIDevice *dev, Error **errp)pci_set_byte (dev->config +PCI_MIN_GNT ,0x3c );pci_set_byte (dev->config +PCI_MAX_LAT ,0x00 ); - -qemu_register_reset (bonito_reset, s); }PCIBus *bonito_init (qemu_irq *pic)
@@ -770,7 +767,9 @@ static void bonito_class_init(ObjectClass *klass, void *data) {DeviceClass *dc =DEVICE_CLASS (klass);PCIDeviceClass *k =PCI_DEVICE_CLASS (klass); +ResettableClass *rc =RESETTABLE_CLASS (klass); + rc->phases.hold = bonito_reset_hold; k->realize = bonito_realize; k->vendor_id =0xdf53 ; k->device_id =0x00d5 ;
Signature · 1 line
2.38.1
Re: [PATCH 1/8] hw/pci-host/bonito: Convert to 3-phase reset
Quoted 8 lines · Philippe Mathieu-Daudé
From: Philippe Mathieu-Daudé<[email protected]>
Convert the
TYPE_PCI_BONITOclass to use 3-phase reset.Signed-off-by Philippe Mathieu-Daudé<[email protected]>--- hw/pci-host/bonito.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
r~
PATCH 2/8 hw/pci-host/bonito: Use 'bonito_host' for PCI host bridge code
In reply to Philippe Mathieu-DaudéTo make it easier to differentiate between the Host Bridge object and its PCI function #0, rename bonito_pcihost* as bonito_host*.
--- hw/pci-host/bonito.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
hw/pci-host/bonito.c +6 -6
@@ -627,7 +627,7 @@ static const VMStateDescription vmstate_bonito = { } }; -static void bonito_pcihost_realize (DeviceState *dev,Error **errp) +static void bonito_host_realize (DeviceState *dev,Error **errp) {PCIHostState *phb =PCI_HOST_BRIDGE (dev);BonitoState *bs =BONITO_PCI_HOST_BRIDGE (dev);
@@ -795,23 +795,23 @@ static const TypeInfo bonito_info = { }, }; -static void bonito_pcihost_class_init (ObjectClass *klass,void *data) +static void bonito_host_class_init (ObjectClass *klass,void *data) {DeviceClass *dc =DEVICE_CLASS (klass); - dc->realize = bonito_pcihost_realize; + dc->realize = bonito_host_realize; } -static const TypeInfo bonito_pcihost_info = { +static const TypeInfo bonito_host_info = { .name =TYPE_BONITO_PCI_HOST_BRIDGE , .parent =TYPE_PCI_HOST_BRIDGE , .instance_size =sizeof (BonitoState), - .class_init = bonito_pcihost_class_init, + .class_init = bonito_host_class_init, };static void bonito_register_types (void ) { -type_register_static (&bonito_pcihost_info); +type_register_static (&bonito_host_info);type_register_static (&bonito_info); }
Signature · 1 line
2.38.1
Re: [PATCH 2/8] hw/pci-host/bonito: Use 'bonito_host' for PCI host bridge code
Quoted 8 lines · Philippe Mathieu-Daudé
To make it easier to differentiate between the Host Bridge object and its PCI function #0, rename bonito_pcihost* as bonito_host*.
Signed-off-by Philippe Mathieu-Daudé<[email protected]>--- hw/pci-host/bonito.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
r~
PATCH 3/8 hw/pci-host/bonito: Use 'bonito_pci' for PCI function #0 code
In reply to Philippe Mathieu-DaudéTo make it easier to differentiate between the Host Bridge object and its PCI function #0, rename bonito* as bonito_pci*.
--- hw/pci-host/bonito.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
hw/pci-host/bonito.c +8 -8
@@ -617,7 +617,7 @@ static void bonito_reset_hold(Object *obj) s->regs[BONITO_PCIMAP ] =0x6140 ; } -static const VMStateDescription vmstate_bonito = { +static const VMStateDescription vmstate_bonito_pci = { .name ="Bonito" , .version_id =1 , .minimum_version_id =1 ,
@@ -653,7 +653,7 @@ static void bonito_host_realize(DeviceState *dev, Error **errp)create_unimplemented_device ("pci.io" ,BONITO_PCIIO_BASE ,1 * MiB); } -static void bonito_realize (PCIDevice *dev,Error **errp) +static void bonito_pci_realize (PCIDevice *dev,Error **errp) {PCIBonitoState *s =PCI_BONITO (dev);SysBusDevice *sysbus =SYS_BUS_DEVICE (s->pcihost);
@@ -763,20 +763,20 @@ PCIBus *bonito_init(qemu_irq *pic)return phb->bus; } -static void bonito_class_init (ObjectClass *klass,void *data) +static void bonito_pci_class_init (ObjectClass *klass,void *data) {DeviceClass *dc =DEVICE_CLASS (klass);PCIDeviceClass *k =PCI_DEVICE_CLASS (klass);ResettableClass *rc =RESETTABLE_CLASS (klass); rc->phases.hold = bonito_reset_hold; - k->realize = bonito_realize; + k->realize = bonito_pci_realize; k->vendor_id =0xdf53 ; k->device_id =0x00d5 ; k->revision =0x01 ; k->class_id =PCI_CLASS_BRIDGE_HOST ; dc->desc ="Host bridge" ; - dc->vmsd = &vmstate_bonito; + dc->vmsd = &vmstate_bonito_pci;/* * PCI-facing part of the host bridge, not usable without the * host-facing part, which can't be device_add'ed, yet.
@@ -784,11 +784,11 @@ static void bonito_class_init(ObjectClass *klass, void *data) dc->user_creatable = false; } -static const TypeInfo bonito_info = { +static const TypeInfo bonito_pci_info = { .name =TYPE_PCI_BONITO , .parent =TYPE_PCI_DEVICE , .instance_size =sizeof (PCIBonitoState), - .class_init = bonito_class_init, + .class_init = bonito_pci_class_init, .interfaces = (InterfaceInfo []) { {INTERFACE_CONVENTIONAL_PCI_DEVICE }, { },
@@ -812,7 +812,7 @@ static const TypeInfo bonito_host_info = {static void bonito_register_types (void ) {type_register_static (&bonito_host_info); -type_register_static (&bonito_info); +type_register_static (&bonito_pci_info); }type_init (bonito_register_types)
Signature · 1 line
2.38.1
Re: [PATCH 3/8] hw/pci-host/bonito: Use 'bonito_pci' for PCI function #0 code
Quoted 7 lines · Philippe Mathieu-Daudé
To make it easier to differentiate between the Host Bridge object and its PCI function #0, rename bonito* as bonito_pci*.
Signed-off-by Philippe Mathieu-Daudé<[email protected]>--- hw/pci-host/bonito.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
r~
PATCH 4/8 hw/pci-host/bonito: Set reference using object_property_add_const_link()
In reply to Philippe Mathieu-DaudéA QOM object shouldn't poke at another object internals.
Here the PCI host bridge instantiates its PCI function #0 and sets a reference to itself (so the function can access the bridge fields).
Pass this reference with object_property_add_const_link(), since the reference won't change during the object lifetime.
--- hw/pci-host/bonito.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-)
hw/pci-host/bonito.c +12 -7
@@ -656,10 +656,17 @@ static void bonito_host_realize(DeviceState *dev, Error **errp)static void bonito_pci_realize (PCIDevice *dev,Error **errp) {PCIBonitoState *s =PCI_BONITO (dev); -SysBusDevice *sysbus =SYS_BUS_DEVICE (s->pcihost); -PCIHostState *phb =PCI_HOST_BRIDGE (s->pcihost); -BonitoState *bs =BONITO_PCI_HOST_BRIDGE (s->pcihost);MemoryRegion *pcimem_alias =g_new (MemoryRegion,1 ); +SysBusDevice *sysbus; +PCIHostState *phb; +BonitoState *bs; +Object *obj; + + obj =object_property_get_link (OBJECT (dev),"host-bridge" , &error_abort); + s->pcihost =BONITO_PCI_HOST_BRIDGE (obj); + sysbus =SYS_BUS_DEVICE (obj); + phb =PCI_HOST_BRIDGE (obj); + bs =BONITO_PCI_HOST_BRIDGE (obj);/* * Bonito North Bridge, built on FPGA,
@@ -745,7 +752,6 @@ PCIBus *bonito_init(qemu_irq *pic)DeviceState *dev;BonitoState *pcihost;PCIHostState *phb; -PCIBonitoState *s;PCIDevice *d; dev =qdev_new (TYPE_BONITO_PCI_HOST_BRIDGE );
@@ -755,10 +761,9 @@ PCIBus *bonito_init(qemu_irq *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; +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; }
Signature · 1 line
2.38.1
Re: [PATCH 4/8] hw/pci-host/bonito: Set reference using object_property_add_const_link()
Quoted 26 lines · Philippe Mathieu-Daudé
A QOM object shouldn't poke at another object internals.
Here the PCI host bridge instantiates its PCI function #0 and sets a reference to itself (so the function can access the bridge fields).
Pass this reference with
object_property_add_const_link(), since the reference won't change during the object lifetime.Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- hw/pci-host/bonito.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-)hw/pci-host/bonito.c +0
-3@@ -656,10 +656,17 @@ static void bonito_host_realize(DeviceState *dev, Error **errp)static void bonito_pci_realize (PCIDevice *dev,Error **errp) {PCIBonitoState *s =PCI_BONITO (dev); -SysBusDevice *sysbus =SYS_BUS_DEVICE (s->pcihost); -PCIHostState *phb =PCI_HOST_BRIDGE (s->pcihost); -BonitoState *bs =BONITO_PCI_HOST_BRIDGE (s->pcihost);MemoryRegion *pcimem_alias =g_new (MemoryRegion,1 );
hw/pci-host/bonito.c static void bonito_host_realize(DeviceState *dev, Error **errp) · line 669
Quoted 10 lines
hw/pci-host/bonito.c +10
-0+SysBusDevice *sysbus; +PCIHostState *phb; +BonitoState *bs; +Object *obj; + + obj =object_property_get_link (OBJECT (dev),"host-bridge" , &error_abort); + s->pcihost =BONITO_PCI_HOST_BRIDGE (obj); + sysbus =SYS_BUS_DEVICE (obj); + phb =PCI_HOST_BRIDGE (obj); + bs =BONITO_PCI_HOST_BRIDGE (obj);
It would be nice to re-order these so that you only perform the dynamic cast once:
s->pcihost = bs;
Regardless,
r~
PATCH 5/8 hw/pci-host/bonito: Create PCI function #0 in bridge realize() handler
In reply to Philippe Mathieu-DaudéThe PCI function #0 is an integral part of the PCI bridge, instantiate it internally during the bridge creation.
--- hw/pci-host/bonito.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
hw/pci-host/bonito.c +5 -6
@@ -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; }
Signature · 1 line
2.38.1
Re: [PATCH 5/8] hw/pci-host/bonito: Create PCI function #0 in bridge realize() handler
Quoted 13 lines · Philippe Mathieu-Daudé
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é <[email protected]>--- hw/pci-host/bonito.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)hw/pci-host/bonito.c +0
-0
hw/pci-host/bonito.c static void bonito_host_realize(DeviceState *dev, Error **errp) · line 658
Quoted 8 lines
hw/pci-host/bonito.c +5
-0@@ -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,
r~
PATCH 6/8 hw/pci-host/bonito: Sysbus'ify outgoing IRQ
In reply to Philippe Mathieu-DaudéSince TYPE_BONITO_PCI_HOST_BRIDGE inherits the TYPE_SYSBUS interface, use its API the manage the outgoing IRQ.
--- hw/pci-host/bonito.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-)
hw/pci-host/bonito.c +7 -8
@@ -233,7 +233,7 @@ typedef struct PCIBonitoState PCIBonitoState;struct BonitoState {PCIHostState parent_obj; -qemu_irq *pic; +qemu_irq irq;PCIBonitoState *pci_dev;MemoryRegion pci_mem; };
@@ -556,17 +556,16 @@ static const MemoryRegionOps bonito_spciconf_ops = {static void pci_bonito_set_irq (void *opaque,int irq_num,int level) {BonitoState *s = opaque; -qemu_irq *pic = s->pic;PCIBonitoState *bonito_state = s->pci_dev;int internal_irq = irq_num -BONITO_IRQ_BASE ;if (bonito_state->regs[BONITO_INTEDGE ] & (1 << internal_irq)) { -qemu_irq_pulse (*pic); +qemu_irq_pulse (s->irq); }else {/* level triggered */ if (bonito_state->regs[BONITO_INTPOL ] & (1 << internal_irq)) { -qemu_irq_raise (*pic); +qemu_irq_raise (s->irq); }else { -qemu_irq_lower (*pic); +qemu_irq_lower (s->irq); } } }
@@ -633,6 +632,7 @@ static void bonito_host_realize(DeviceState *dev, Error **errp)BonitoState *bs =BONITO_PCI_HOST_BRIDGE (dev);MemoryRegion *pcimem_lo_alias =g_new (MemoryRegion,3 ); +sysbus_init_irq (SYS_BUS_DEVICE (dev), &bs->irq);memory_region_init (&bs->pci_mem,OBJECT (dev),"pci.mem" ,BONITO_PCIHI_SIZE ); phb->bus = pci_register_root_bus(dev, "pci", pci_bonito_set_irq, pci_bonito_map_irq,
@@ -755,15 +755,14 @@ static void bonito_pci_realize(PCIDevice *dev, Error **errp)PCIBus *bonito_init (qemu_irq *pic) {DeviceState *dev; -BonitoState *pcihost;PCIHostState *phb; dev =qdev_new (TYPE_BONITO_PCI_HOST_BRIDGE ); phb =PCI_HOST_BRIDGE (dev); - pcihost =BONITO_PCI_HOST_BRIDGE (dev); - pcihost->pic = pic;sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal); +sysbus_connect_irq (SYS_BUS_DEVICE (dev),0 , *pic); +return phb->bus; }
Signature · 1 line
2.38.1
Re: [PATCH 6/8] hw/pci-host/bonito: Sysbus'ify outgoing IRQ
Quoted 7 lines · Philippe Mathieu-Daudé
Since
TYPE_BONITO_PCI_HOST_BRIDGEinherits theTYPE_SYSBUSinterface, use its API the manage the outgoing IRQ.Signed-off-by Philippe Mathieu-Daudé<[email protected]>--- hw/pci-host/bonito.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-)
r~
PATCH 7/8 hw/pci-host/bonito: Declare TYPE_BONITO_PCI_HOST_BRIDGE in header
In reply to Philippe Mathieu-DaudéDeclare the TYPE_BONITO_PCI_HOST_BRIDGE QOM type in a header to be able to access it from board code.
--- MAINTAINERS | 1 + hw/pci-host/bonito.c | 4 +--- include/hw/pci-host/bonito.h | 18 ++++++++++++++++++ 3 files changed, 20 insertions(+), 3 deletions(-) create mode 100644 include/hw/pci-host/bonito.h
MAINTAINERS +1 -0
@@ -1260,6 +1260,7 @@ F: hw/isa/vt82c686.c F: hw/pci-host/bonito.c F: hw/usb/vt82c686-uhci-pci.c F: include/hw/isa/vt82c686.h +F: include/hw/pci-host/bonito.h F: tests/avocado/machine_mips_fuloong2e.py Loongson-3 virtual platforms
hw/pci-host/bonito.c +1 -3
@@ -45,6 +45,7 @@#include "hw/pci/pci.h" #include "hw/irq.h" #include "hw/mips/mips.h" +#include "hw/pci-host/bonito.h" #include "hw/pci/pci_host.h" #include "migration/vmstate.h" #include "sysemu/runstate.h"
@@ -238,9 +239,6 @@ struct BonitoState {MemoryRegion pci_mem; }; -#define TYPE_BONITO_PCI_HOST_BRIDGE "Bonito-pcihost" -OBJECT_DECLARE_SIMPLE_TYPE(BonitoState, BONITO_PCI_HOST_BRIDGE) -#define TYPE_PCI_BONITO "Bonito"OBJECT_DECLARE_SIMPLE_TYPE (PCIBonitoState,PCI_BONITO )
include/hw/pci-host/bonito.h new file +18 -0
@@ -0,0 +1,18 @@ +/* +* QEMU Bonito64 north bridge support +* +* Copyright (c) 2008 yajin ([email protected]) +* Copyright (c) 2010 Huacai Chen ([email protected]) +* +* SPDX-License-Identifier: GPL-2.0-or-later +*/ + +#ifndef HW_PCI_HOST_BONITO_H +#define HW_PCI_HOST_BONITO_H + +#include "qom/object.h" + +#define TYPE_BONITO_PCI_HOST_BRIDGE "Bonito-pcihost" +OBJECT_DECLARE_SIMPLE_TYPE(BonitoState, BONITO_PCI_HOST_BRIDGE) + +#endif
Signature · 1 line
2.38.1
Re: [PATCH 7/8] hw/pci-host/bonito: Declare TYPE_BONITO_PCI_HOST_BRIDGE in header
Quoted 10 lines · Philippe Mathieu-Daudé
Declare the
TYPE_BONITO_PCI_HOST_BRIDGEQOM type in a header to be able to access it from board code.Signed-off-by Philippe Mathieu-Daudé<[email protected]>--- MAINTAINERS | 1 + hw/pci-host/bonito.c | 4 +--- include/hw/pci-host/bonito.h | 18 ++++++++++++++++++ 3 files changed, 20 insertions(+), 3 deletions(-)create mode 100644
include/hw/pci-host/bonito.h
r~
PATCH 8/8 hw/mips/fuloong2e: Open code bonito_init()
In reply to Philippe Mathieu-DaudéThis helper is trivial and is called once, directly open-code it.
--- hw/mips/fuloong2e.c | 6 +++++- hw/pci-host/bonito.c | 15 --------------- include/hw/mips/mips.h | 3 --- 3 files changed, 5 insertions(+), 19 deletions(-)
hw/mips/fuloong2e.c +5 -1
@@ -32,6 +32,7 @@#include "hw/mips/bootloader.h" #include "hw/mips/cpudevs.h" #include "hw/pci/pci.h" +#include "hw/pci-host/bonito.h" #include "hw/loader.h" #include "hw/ide/pci.h" #include "hw/qdev-properties.h"
@@ -292,7 +293,10 @@ static void mips_fuloong2e_init(MachineState *machine)cpu_mips_clock_init (cpu);/* North bridge, Bonito --> IP2 */ - pci_bus =bonito_init ((qemu_irq *)&(env->irq[2 ])); + dev =qdev_new (TYPE_BONITO_PCI_HOST_BRIDGE ); +sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal); +sysbus_connect_irq (SYS_BUS_DEVICE (dev),0 , env->irq[2 ]); + pci_bus =PCI_BUS (qdev_get_child_bus (dev,"pci" ));/* South bridge -> IP5 */ pci_dev = pci_create_simple_multifunction(pci_bus,
hw/pci-host/bonito.c +0 -15
@@ -44,7 +44,6 @@#include "qemu/error-report.h" #include "hw/pci/pci.h" #include "hw/irq.h" -#include "hw/mips/mips.h" #include "hw/pci-host/bonito.h" #include "hw/pci/pci_host.h" #include "migration/vmstate.h"
@@ -750,20 +749,6 @@ static void bonito_pci_realize(PCIDevice *dev, Error **errp)pci_set_byte (dev->config +PCI_MAX_LAT ,0x00 ); } -PCIBus *bonito_init (qemu_irq *pic) -{ -DeviceState *dev; -PCIHostState *phb; - - dev =qdev_new (TYPE_BONITO_PCI_HOST_BRIDGE ); - phb =PCI_HOST_BRIDGE (dev); -sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal); - -sysbus_connect_irq (SYS_BUS_DEVICE (dev),0 , *pic); - -return phb->bus; -} -static void bonito_pci_class_init (ObjectClass *klass,void *data) {DeviceClass *dc =DEVICE_CLASS (klass);
include/hw/mips/mips.h +0 -3
@@ -9,9 +9,6 @@#include "exec/memory.h" -/* bonito.c */ -PCIBus *bonito_init (qemu_irq *pic); -/* rc4030.c */ typedef struct rc4030DMAState *rc4030_dma ;void rc4030_dma_read (void *dma,uint8_t *buf,int len);
Signature · 1 line
2.38.1
Re: [PATCH 8/8] hw/mips/fuloong2e: Open code bonito_init()
Quoted 8 lines · Philippe Mathieu-Daudé
This helper is trivial and is called once, directly open-code it.
Signed-off-by Philippe Mathieu-Daudé<[email protected]>--- hw/mips/fuloong2e.c | 6 +++++- hw/pci-host/bonito.c | 15 --------------- include/hw/mips/mips.h | 3 --- 3 files changed, 5 insertions(+), 19 deletions(-)
r~
Quoted 8 lines · Philippe Mathieu-Daudé
Minor housekeeping while reviewing PCI host bridge models.
Philippe Mathieu-Daudé (8):
hw/pci-host/bonito: Convert to 3-phase reset hw/pci-host/bonito: Use 'bonito_host' for PCI host bridge code hw/pci-host/bonito: Use 'bonito_pci' for PCI function #0 codehw/pci-host/bonito: Declare
TYPE_BONITO_PCI_HOST_BRIDGEin header
Patches 1-3 & 7 queued to mips-next.