* [PATCH v3 0/3] VT82xx PCI IRQ routing fixes
@ 2023-02-27 12:33 Bernhard Beschow
2023-02-27 12:33 ` [PATCH v3 1/3] hw/ppc/pegasos2: Initialize VT8231 PCI IRQ router Bernhard Beschow
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Bernhard Beschow @ 2023-02-27 12:33 UTC (permalink / raw)
To: qemu-devel
Cc: Huacai Chen, Gerd Hoffmann, qemu-ppc, Jiaxun Yang, BALATON Zoltan,
Philippe Mathieu-Daudé, 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)
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/cover.1677004414.git.balaton@eik.bme.hu/
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(-)
--
2.39.2
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v3 1/3] hw/ppc/pegasos2: Initialize VT8231 PCI IRQ router
2023-02-27 12:33 [PATCH v3 0/3] VT82xx PCI IRQ routing fixes Bernhard Beschow
@ 2023-02-27 12:33 ` Bernhard Beschow
2023-02-27 12:33 ` [PATCH v3 2/3] hw/isa/vt82c686: Implement PCI IRQ routing Bernhard Beschow
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Bernhard Beschow @ 2023-02-27 12:33 UTC (permalink / raw)
To: qemu-devel
Cc: Huacai Chen, Gerd Hoffmann, qemu-ppc, Jiaxun Yang, BALATON Zoltan,
Philippe Mathieu-Daudé, Bernhard Beschow
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")
Signed-off-by: Bernhard Beschow <shentey@gmail.com>
---
hw/ppc/pegasos2.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/hw/ppc/pegasos2.c b/hw/ppc/pegasos2.c
index a9563f4fb2..41688699eb 100644
--- a/hw/ppc/pegasos2.c
+++ b/hw/ppc/pegasos2.c
@@ -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);
--
2.39.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v3 2/3] hw/isa/vt82c686: Implement PCI IRQ routing
2023-02-27 12:33 [PATCH v3 0/3] VT82xx PCI IRQ routing fixes Bernhard Beschow
2023-02-27 12:33 ` [PATCH v3 1/3] hw/ppc/pegasos2: Initialize VT8231 PCI IRQ router Bernhard Beschow
@ 2023-02-27 12:33 ` Bernhard Beschow
2023-02-27 12:33 ` [PATCH v3 3/3] hw/usb/vt82c686-uhci-pci: Use " Bernhard Beschow
2023-02-27 12:40 ` [PATCH v3 0/3] VT82xx PCI IRQ routing fixes BALATON Zoltan
3 siblings, 0 replies; 5+ messages in thread
From: Bernhard Beschow @ 2023-02-27 12:33 UTC (permalink / raw)
To: qemu-devel
Cc: Huacai Chen, Gerd Hoffmann, qemu-ppc, Jiaxun Yang, BALATON Zoltan,
Philippe Mathieu-Daudé, Bernhard Beschow
The 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.
Signed-off-by: Bernhard Beschow <shentey@gmail.com>
---
hw/isa/vt82c686.c | 41 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 41 insertions(+)
diff --git a/hw/isa/vt82c686.c b/hw/isa/vt82c686.c
index 3f9bd0c04d..7aea97365f 100644
--- a/hw/isa/vt82c686.c
+++ b/hw/isa/vt82c686.c
@@ -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 */
--
2.39.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v3 3/3] hw/usb/vt82c686-uhci-pci: Use PCI IRQ routing
2023-02-27 12:33 [PATCH v3 0/3] VT82xx PCI IRQ routing fixes Bernhard Beschow
2023-02-27 12:33 ` [PATCH v3 1/3] hw/ppc/pegasos2: Initialize VT8231 PCI IRQ router Bernhard Beschow
2023-02-27 12:33 ` [PATCH v3 2/3] hw/isa/vt82c686: Implement PCI IRQ routing Bernhard Beschow
@ 2023-02-27 12:33 ` Bernhard Beschow
2023-02-27 12:40 ` [PATCH v3 0/3] VT82xx PCI IRQ routing fixes BALATON Zoltan
3 siblings, 0 replies; 5+ messages in thread
From: Bernhard Beschow @ 2023-02-27 12:33 UTC (permalink / raw)
To: qemu-devel
Cc: Huacai Chen, Gerd Hoffmann, qemu-ppc, Jiaxun Yang, BALATON Zoltan,
Philippe Mathieu-Daudé, Bernhard Beschow, Rene Engel
According 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.
Signed-off-by: Bernhard Beschow <shentey@gmail.com>
Tested-by: Rene Engel <ReneEngel80@emailn.de>
---
hw/usb/vt82c686-uhci-pci.c | 12 ------------
1 file changed, 12 deletions(-)
diff --git a/hw/usb/vt82c686-uhci-pci.c b/hw/usb/vt82c686-uhci-pci.c
index 46a901f56f..b4884c9011 100644
--- a/hw/usb/vt82c686-uhci-pci.c
+++ b/hw/usb/vt82c686-uhci-pci.c
@@ -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[] = {
--
2.39.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v3 0/3] VT82xx PCI IRQ routing fixes
2023-02-27 12:33 [PATCH v3 0/3] VT82xx PCI IRQ routing fixes Bernhard Beschow
` (2 preceding siblings ...)
2023-02-27 12:33 ` [PATCH v3 3/3] hw/usb/vt82c686-uhci-pci: Use " Bernhard Beschow
@ 2023-02-27 12:40 ` BALATON Zoltan
3 siblings, 0 replies; 5+ messages in thread
From: BALATON Zoltan @ 2023-02-27 12:40 UTC (permalink / raw)
To: Bernhard Beschow
Cc: qemu-devel, Huacai Chen, Gerd Hoffmann, qemu-ppc, Jiaxun Yang,
Philippe Mathieu-Daudé
On Mon, 27 Feb 2023, Bernhard Beschow wrote:
> 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
> 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/cover.1677004414.git.balaton@eik.bme.hu/
>
> 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(-)
>
> --
> 2.39.2
>
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-02-27 12:42 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-27 12:33 [PATCH v3 0/3] VT82xx PCI IRQ routing fixes Bernhard Beschow
2023-02-27 12:33 ` [PATCH v3 1/3] hw/ppc/pegasos2: Initialize VT8231 PCI IRQ router Bernhard Beschow
2023-02-27 12:33 ` [PATCH v3 2/3] hw/isa/vt82c686: Implement PCI IRQ routing Bernhard Beschow
2023-02-27 12:33 ` [PATCH v3 3/3] hw/usb/vt82c686-uhci-pci: Use " Bernhard Beschow
2023-02-27 12:40 ` [PATCH v3 0/3] VT82xx PCI IRQ routing fixes BALATON Zoltan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).