VT82xx PCI IRQ routing fixes
v3 cover VT82xx PCI IRQ routing fixes
This series makes PCI interrupt routing in the VIA south bridges more compliant to the PCI specification. It aims to help bringing audio output support to the ppc/pegasos2 machine [1].
v3:
* Remove superfluous if statement in patch 2 (Phil)
v2:
* Remove audio patches which were included for proof of concept
Testing done with via-ac97 audio patches on top:
* make check
* qemu-system-ppc -M pegasos2 -rtc base=localtime -device ati-vga,guest_hwcursor=true,romfile="" -cdrom morphos-3.17.iso -kernel morphos-3.17/boot.img
-> There is a nice sound when the Desktop becomes visible.
* qemu-system-ppc -M pegasos2 -bios pegasos2.rom -rtc base=localtime -device ati-vga,guest_hwcursor=true,romfile="" -cdrom morphos-3.17.iso -> There is a nice sound when the Desktop becomes visible.
* qemu-system-ppc -M pegasos2 -bios pegasos2.rom -rtc base=localtime -device ati-vga,guest_hwcursor=true,romfile="" -cdrom morphos-3.17.iso -device usb-mouse -device usb-kbd
-> The machine hangs when audio is supposed to play while the mouse is moved.
This behavior can also be reproduced in v1.
[1] https://patchew.org/QEMU/[email protected]/
Bernhard Beschow (3):
hw/ppc/pegasos2: Initialize VT8231 PCI IRQ router hw/isa/vt82c686: Implement PCI IRQ routing hw/usb/vt82c686-uhci-pci: Use PCI IRQ routing
hw/isa/vt82c686.c | 41 ++++++++++++++++++++++++++++++++++++++ hw/ppc/pegasos2.c | 6 ++++++ hw/usb/vt82c686-uhci-pci.c | 12 ----------- 3 files changed, 47 insertions(+), 12 deletions(-)
Signature · 1 line
2.39.2
PATCH v3 1/3 hw/ppc/pegasos2: Initialize VT8231 PCI IRQ router
The firmware of the real PegasosII board routes all PIRQx to IRQ9, so do the same in QEMU. The PCI_INTERRUPT_LINE registers of the respective internal PCI functions are already initialized with IRQ9 which are currently used for routing.
Note that the PCI interrupt router isn't implemented yet in the VIA south bridges. This change has therefore no effect until this happens.
Inspired-by:
<c046d77c20875c8cd8bfdc79b4619a98ffd0bf33.1677004415.git.balaton@eik.bme.hu> ("hw/ppc/pegasos2: Fix PCI interrupt routing")
--- hw/ppc/pegasos2.c | 6 ++++++ 1 file changed, 6 insertions(+)
hw/ppc/pegasos2.c +6 -0
@@ -268,6 +268,12 @@ static void pegasos2_machine_reset(MachineState *machine, ShutdownCause reason) PCI_INTERRUPT_LINE, 2, 0x9);pegasos2_pci_config_write (pm,1 , (PCI_DEVFN (12 ,0 ) <<8 ) |0x50 ,1 ,0x2 ); +pegasos2_pci_config_write (pm,1 , (PCI_DEVFN (12 ,0 ) <<8 ) | +0x55 ,1 ,0x90 ); +pegasos2_pci_config_write (pm,1 , (PCI_DEVFN (12 ,0 ) <<8 ) | +0x56 ,1 ,0x99 ); +pegasos2_pci_config_write (pm,1 , (PCI_DEVFN (12 ,0 ) <<8 ) | +0x57 ,1 ,0x90 );pegasos2_pci_config_write (pm,1 , (PCI_DEVFN (12 ,1 ) <<8 ) |PCI_INTERRUPT_LINE ,2 ,0x109 );
Signature · 1 line
2.39.2
PATCH v3 2/3 hw/isa/vt82c686: Implement PCI IRQ routing
In reply to Bernhard BeschowThe real VIA south bridges implement a PCI IRQ router which is configured by the BIOS or the OS. In order to respect these configurations, QEMU needs to implement it as well.
--- hw/isa/vt82c686.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+)
hw/isa/vt82c686.c +41 -0
@@ -604,6 +604,45 @@ static void via_isa_request_i8259_irq(void *opaque, int irq, int level)qemu_set_irq (s->cpu_intr, level); } +static unsigned via_isa_get_pci_irq (const ViaISAState *s,int irq_num) +{ +switch (irq_num) { +case 0 : +return s->dev.config[0x55 ] >>4 ; + +case 1 : +return s->dev.config[0x56 ] &0xf ; + +case 2 : +return s->dev.config[0x56 ] >>4 ; + +case 3 : +return s->dev.config[0x57 ] >>4 ; + } + +return 0 ; +} + +static void via_isa_set_pci_irq (void *opaque,int irq_num,int level) +{ +ViaISAState *s = opaque; +PCIBus *bus =pci_get_bus (&s->dev); +unsigned pic_irq =via_isa_get_pci_irq (s, irq_num); +int i, pic_level =0 ; + +assert (pic_irq <ISA_NUM_IRQS ); + +/* The PIC level is the logical OR of all the PCI irqs mapped to it. */ +for (i =0 ; i <PCI_NUM_PINS ; i++) { +if (pic_irq ==via_isa_get_pci_irq (s, i)) { + pic_level |=pci_bus_get_irq_level (bus, i); + } + } + +/* Now we change the pic irq level according to the via irq mappings. */ +qemu_set_irq (s->isa_irqs[pic_irq], pic_level); +} +static void via_isa_realize (PCIDevice *d,Error **errp) {ViaISAState *s =VIA_ISA (d);
@@ -676,6 +715,8 @@ static void via_isa_realize(PCIDevice *d, Error **errp)if (!qdev_realize (DEVICE (&s->mc97),BUS (pci_bus), errp)) {return ; } + +pci_bus_irqs (pci_bus, via_isa_set_pci_irq, s,PCI_NUM_PINS ); }/* TYPE_VT82C686B_ISA */
Signature · 1 line
2.39.2
PATCH v3 3/3 hw/usb/vt82c686-uhci-pci: Use PCI IRQ routing
In reply to Bernhard BeschowAccording to the PCI specification, PCI_INTERRUPT_LINE shall have no effect on hardware operations. Now that the VIA south bridges implement the internal PCI interrupt router let's be more conformant to the PCI specification.
--- hw/usb/vt82c686-uhci-pci.c | 12 ------------ 1 file changed, 12 deletions(-)
hw/usb/vt82c686-uhci-pci.c +0 -12
@@ -1,17 +1,7 @@#include "qemu/osdep.h" -#include "hw/irq.h" #include "hw/isa/vt82c686.h" #include "hcd-uhci.h" -static void uhci_isa_set_irq (void *opaque,int irq_num,int level) -{ -UHCIState *s = opaque; -uint8_t irq =pci_get_byte (s->dev.config +PCI_INTERRUPT_LINE ); -if (irq >0 && irq <15 ) { -via_isa_set_irq (pci_get_function_0 (&s->dev), irq, level); - } -} -static void usb_uhci_vt82c686b_realize (PCIDevice *dev,Error **errp) {UHCIState *s =UHCI (dev);
@@ -25,8 +15,6 @@ static void usb_uhci_vt82c686b_realize(PCIDevice *dev, Error **errp)pci_set_long (pci_conf +0xc0 ,0x00002000 );usb_uhci_common_realize (dev, errp); -object_unref (s->irq); - s->irq =qemu_allocate_irq (uhci_isa_set_irq, s,0 ); }static UHCIInfo uhci_info[] = {
Signature · 1 line
2.39.2
Quoted 6 lines · Bernhard Beschow
This series makes PCI interrupt routing in the VIA south bridges more compliant to the PCI specification. It aims to help bringing audio output support to the ppc/pegasos2 machine [1].
v3:
* Remove superfluous if statement in patch 2 (Phil)
Thanks but to help my work could you please do this in patch 4 in my series and send a v4 to that one patch also not reverting my changes just changing what the review asked for, so I don't have to manually apply changes from this series to mine which is what supposed to be committed as it has all needed patches as aked by the PPC maintainer to make it easy to follow its status? Also replace the assert with a comment as I've asked. If you don't want to do that way I'll fold this in in the next version after waiting for some more review comments so I can do a respin with all needed chaages but doing it this way is not very helpful of you.
Regards,
BALATON Zoltan
Quoted 35 lines
v2:
* Remove audio patches which were included for proof of conceptTesting done with via-ac97 audio patches on top:
*make check
*qemu-system-ppc -M pegasos2 -rtc base=localtime -device ati-vga,guest_hwcursor=true,romfile="" -cdrom morphos-3.17.iso -kernel morphos-3.17/boot.img
-> There is a nice sound when the Desktop becomes visible.
*qemu-system-ppc -M pegasos2 -bios pegasos2.rom -rtc base=localtime -device ati-vga,guest_hwcursor=true,romfile="" -cdrom morphos-3.17.iso-> There is a nice sound when the Desktop becomes visible.
*qemu-system-ppc -M pegasos2 -bios pegasos2.rom -rtc base=localtime -device ati-vga,guest_hwcursor=true,romfile="" -cdrom morphos-3.17.iso -device usb-mouse -device usb-kbd
-> The machine hangs when audio is supposed to play while the mouse is moved.
This behavior can also be reproduced in v1.[1] https://patchew.org/QEMU/[email protected]/
Bernhard Beschow (3):
hw/ppc/pegasos2: Initialize VT8231 PCI IRQ router hw/isa/vt82c686: Implement PCI IRQ routing hw/usb/vt82c686-uhci-pci: Use PCI IRQ routinghw/isa/vt82c686.c | 41 ++++++++++++++++++++++++++++++++++++++ hw/ppc/pegasos2.c | 6 ++++++ hw/usb/vt82c686-uhci-pci.c | 12 ----------- 3 files changed, 47 insertions(+), 12 deletions(-)--
2.39.2