Message ID | 20230109172347.1830-26-shentey@gmail.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Consolidate PIIX south bridges | expand |
On 9/1/23 18:23, Bernhard Beschow wrote: > Aligns the code with PIIX3 such that PIIXState can be used in PIIX4, > too. > > Signed-off-by: Bernhard Beschow <shentey@gmail.com> > Reviewed-by: Michael S. Tsirkin <mst@redhat.com> > Message-Id: <20221022150508.26830-33-shentey@gmail.com> > --- > hw/isa/piix4.c | 28 ++++++++++------------------ > hw/mips/malta.c | 11 +++++++++-- > hw/mips/Kconfig | 1 + > 3 files changed, 20 insertions(+), 20 deletions(-) > @@ -1459,7 +1461,12 @@ void mips_malta_init(MachineState *machine) > pci_ide_create_devs(PCI_DEVICE(dev)); > > /* Interrupt controller */ > - qdev_connect_gpio_out_named(DEVICE(piix4), "intr", 0, i8259_irq); > + dev = DEVICE(object_resolve_path_component(OBJECT(piix4), "pic")); > + i8259 = i8259_init(isa_bus, i8259_irq); > + for (i = 0; i < ISA_NUM_IRQS; i++) { > + qdev_connect_gpio_out(dev, i, i8259[i]); > + } > + g_free(i8259); > > /* generate SPD EEPROM data */ > dev = DEVICE(object_resolve_path_component(OBJECT(piix4), "pm")); > diff --git a/hw/mips/Kconfig b/hw/mips/Kconfig > index 4e7042f03d..d156de812c 100644 > --- a/hw/mips/Kconfig > +++ b/hw/mips/Kconfig > @@ -1,5 +1,6 @@ > config MALTA > bool > + select I8259 > select ISA_SUPERIO > select PIIX4 The PIIX4 owns / exposes the I8259, so we don't need to select it here. The Malta board only initializes it. Why did you have to add this?
Am 11. Januar 2023 17:08:28 UTC schrieb "Philippe Mathieu-Daudé" <philmd@linaro.org>: >On 9/1/23 18:23, Bernhard Beschow wrote: >> Aligns the code with PIIX3 such that PIIXState can be used in PIIX4, >> too. >> >> Signed-off-by: Bernhard Beschow <shentey@gmail.com> >> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> >> Message-Id: <20221022150508.26830-33-shentey@gmail.com> >> --- >> hw/isa/piix4.c | 28 ++++++++++------------------ >> hw/mips/malta.c | 11 +++++++++-- >> hw/mips/Kconfig | 1 + >> 3 files changed, 20 insertions(+), 20 deletions(-) > >> @@ -1459,7 +1461,12 @@ void mips_malta_init(MachineState *machine) >> pci_ide_create_devs(PCI_DEVICE(dev)); >> /* Interrupt controller */ >> - qdev_connect_gpio_out_named(DEVICE(piix4), "intr", 0, i8259_irq); >> + dev = DEVICE(object_resolve_path_component(OBJECT(piix4), "pic")); >> + i8259 = i8259_init(isa_bus, i8259_irq); >> + for (i = 0; i < ISA_NUM_IRQS; i++) { >> + qdev_connect_gpio_out(dev, i, i8259[i]); >> + } >> + g_free(i8259); >> /* generate SPD EEPROM data */ >> dev = DEVICE(object_resolve_path_component(OBJECT(piix4), "pm")); >> diff --git a/hw/mips/Kconfig b/hw/mips/Kconfig >> index 4e7042f03d..d156de812c 100644 >> --- a/hw/mips/Kconfig >> +++ b/hw/mips/Kconfig >> @@ -1,5 +1,6 @@ >> config MALTA >> bool >> + select I8259 >> select ISA_SUPERIO >> select PIIX4 > >The PIIX4 owns / exposes the I8259, so we don't need to select it here. >The Malta board only initializes it. Why did you have to add this? The Malta board instantiates a real I8259 while PIIX4 instantiates the TYPE_ISA_PIC proxy. Both are implemented pragmatically in the same source file, so both Malta and PIIX4 select it for different reasons. In previous iterations using the TYPE_PROXY_PIC this might have been clearer: PIIX4 would select PROXY_PIC (and not I8259) while Malta would select I8259. OK? Best regards, Bernhard
diff --git a/hw/isa/piix4.c b/hw/isa/piix4.c index 9edaa5de3e..eae4db0182 100644 --- a/hw/isa/piix4.c +++ b/hw/isa/piix4.c @@ -44,9 +44,8 @@ struct PIIX4State { PCIDevice dev; - qemu_irq cpu_intr; - qemu_irq *isa; + ISAPICState pic; RTCState rtc; PCIIDEState ide; UHCIState uhci; @@ -82,7 +81,7 @@ static void piix4_set_irq(void *opaque, int irq_num, int level) pic_level |= pci_bus_get_irq_level(bus, i); } } - qemu_set_irq(s->isa[pic_irq], pic_level); + qemu_set_irq(s->pic.in_irqs[pic_irq], pic_level); } } @@ -149,12 +148,6 @@ static const VMStateDescription vmstate_piix4 = { } }; -static void piix4_request_i8259_irq(void *opaque, int irq, int level) -{ - PIIX4State *s = opaque; - qemu_set_irq(s->cpu_intr, level); -} - static void piix4_rcr_write(void *opaque, hwaddr addr, uint64_t val, unsigned int len) { @@ -190,7 +183,6 @@ static void piix4_realize(PCIDevice *dev, Error **errp) PIIX4State *s = PIIX4_PCI_DEVICE(dev); PCIBus *pci_bus = pci_get_bus(dev); ISABus *isa_bus; - qemu_irq *i8259_out_irq; isa_bus = isa_bus_new(DEVICE(dev), pci_address_space(dev), pci_address_space_io(dev), errp); @@ -198,20 +190,18 @@ static void piix4_realize(PCIDevice *dev, Error **errp) return; } - qdev_init_gpio_out_named(DEVICE(dev), &s->cpu_intr, - "intr", 1); - memory_region_init_io(&s->rcr_mem, OBJECT(dev), &piix4_rcr_ops, s, "reset-control", 1); memory_region_add_subregion_overlap(pci_address_space_io(dev), PIIX_RCR_IOPORT, &s->rcr_mem, 1); /* initialize i8259 pic */ - i8259_out_irq = qemu_allocate_irqs(piix4_request_i8259_irq, s, 1); - s->isa = i8259_init(isa_bus, *i8259_out_irq); + if (!qdev_realize(DEVICE(&s->pic), NULL, errp)) { + return; + } /* initialize ISA irqs */ - isa_bus_irqs(isa_bus, s->isa); + isa_bus_irqs(isa_bus, s->pic.in_irqs); /* initialize pit */ i8254_pit_init(isa_bus, 0x40, 0, NULL); @@ -224,7 +214,7 @@ static void piix4_realize(PCIDevice *dev, Error **errp) if (!qdev_realize(DEVICE(&s->rtc), BUS(isa_bus), errp)) { return; } - s->rtc.irq = isa_get_irq(ISA_DEVICE(&s->rtc), s->rtc.isairq); + s->rtc.irq = qdev_get_gpio_in(DEVICE(&s->pic), s->rtc.isairq); /* IDE */ qdev_prop_set_int32(DEVICE(&s->ide), "addr", dev->devfn + 1); @@ -251,7 +241,8 @@ static void piix4_realize(PCIDevice *dev, Error **errp) if (!qdev_realize(DEVICE(&s->pm), BUS(pci_bus), errp)) { return; } - qdev_connect_gpio_out(DEVICE(&s->pm), 0, s->isa[9]); + qdev_connect_gpio_out(DEVICE(&s->pm), 0, + qdev_get_gpio_in(DEVICE(&s->pic), 9)); } pci_bus_irqs(pci_bus, piix4_set_irq, s, PIIX_NUM_PIRQS); @@ -261,6 +252,7 @@ static void piix4_init(Object *obj) { PIIX4State *s = PIIX4_PCI_DEVICE(obj); + object_initialize_child(obj, "pic", &s->pic, TYPE_ISA_PIC); object_initialize_child(obj, "rtc", &s->rtc, TYPE_MC146818_RTC); object_initialize_child(obj, "ide", &s->ide, TYPE_PIIX4_IDE); } diff --git a/hw/mips/malta.c b/hw/mips/malta.c index 4a2e0edd98..55f3e0c54a 100644 --- a/hw/mips/malta.c +++ b/hw/mips/malta.c @@ -29,6 +29,7 @@ #include "qemu/guest-random.h" #include "hw/clock.h" #include "hw/southbridge/piix.h" +#include "hw/intc/i8259.h" #include "hw/isa/superio.h" #include "hw/char/serial.h" #include "net/net.h" @@ -1280,10 +1281,11 @@ void mips_malta_init(MachineState *machine) PCIBus *pci_bus; ISABus *isa_bus; qemu_irq cbus_irq, i8259_irq; + qemu_irq *i8259; I2CBus *smbus; DriveInfo *dinfo; int fl_idx = 0; - int be; + int be, i; MaltaState *s; PCIDevice *piix4; DeviceState *dev; @@ -1459,7 +1461,12 @@ void mips_malta_init(MachineState *machine) pci_ide_create_devs(PCI_DEVICE(dev)); /* Interrupt controller */ - qdev_connect_gpio_out_named(DEVICE(piix4), "intr", 0, i8259_irq); + dev = DEVICE(object_resolve_path_component(OBJECT(piix4), "pic")); + i8259 = i8259_init(isa_bus, i8259_irq); + for (i = 0; i < ISA_NUM_IRQS; i++) { + qdev_connect_gpio_out(dev, i, i8259[i]); + } + g_free(i8259); /* generate SPD EEPROM data */ dev = DEVICE(object_resolve_path_component(OBJECT(piix4), "pm")); diff --git a/hw/mips/Kconfig b/hw/mips/Kconfig index 4e7042f03d..d156de812c 100644 --- a/hw/mips/Kconfig +++ b/hw/mips/Kconfig @@ -1,5 +1,6 @@ config MALTA bool + select I8259 select ISA_SUPERIO select PIIX4