* [PATCH] hw/usb/vt82c686-uhci-pci: Use ISA instead of PCI interrupts
@ 2021-10-03 16:12 BALATON Zoltan
2021-10-03 16:24 ` Jiaxun Yang
2021-10-04 10:13 ` BALATON Zoltan
0 siblings, 2 replies; 3+ messages in thread
From: BALATON Zoltan @ 2021-10-03 16:12 UTC (permalink / raw)
To: qemu-devel; +Cc: Huacai Chen, Gerd Hoffmann, Philippe M-D
This device is part of a sperio/ISA bridge chip and IRQs from it are
routed to an ISA interrupt set by the Interrupt Line PCI config
register. Change uhci_update_irq() to allow this and use it from
vt82c686-uhci-pci.
Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
---
Maybe bit of a hack but fixes USB interrupts on pegasos2 until
somebody has a better idea. I'm not sure about fuloong2e but the
VT82C686B docs say it also does the same routing IRQs to ISA PIC like
VT8231 used on pegasos2.
hw/usb/hcd-uhci.c | 12 +++++++++---
hw/usb/hcd-uhci.h | 1 +
hw/usb/vt82c686-uhci-pci.c | 1 +
3 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/hw/usb/hcd-uhci.c b/hw/usb/hcd-uhci.c
index 0cb02a6432..8f28241f70 100644
--- a/hw/usb/hcd-uhci.c
+++ b/hw/usb/hcd-uhci.c
@@ -31,6 +31,7 @@
#include "hw/usb/uhci-regs.h"
#include "migration/vmstate.h"
#include "hw/pci/pci.h"
+#include "hw/irq.h"
#include "hw/qdev-properties.h"
#include "qapi/error.h"
#include "qemu/timer.h"
@@ -290,7 +291,7 @@ static UHCIAsync *uhci_async_find_td(UHCIState *s, uint32_t td_addr)
static void uhci_update_irq(UHCIState *s)
{
- int level;
+ int level = 0;
if (((s->status2 & 1) && (s->intr & (1 << 2))) ||
((s->status2 & 2) && (s->intr & (1 << 3))) ||
((s->status & UHCI_STS_USBERR) && (s->intr & (1 << 0))) ||
@@ -298,10 +299,15 @@ static void uhci_update_irq(UHCIState *s)
(s->status & UHCI_STS_HSERR) ||
(s->status & UHCI_STS_HCPERR)) {
level = 1;
+ }
+ if (s->isa_irqs) {
+ uint8_t irq = pci_get_byte(s->dev.config + PCI_INTERRUPT_LINE);
+ if (irq < ISA_NUM_IRQS) {
+ qemu_set_irq(isa_get_irq(NULL, irq), level);
+ }
} else {
- level = 0;
+ pci_set_irq(&s->dev, level);
}
- pci_set_irq(&s->dev, level);
}
static void uhci_reset(DeviceState *dev)
diff --git a/hw/usb/hcd-uhci.h b/hw/usb/hcd-uhci.h
index e61d8fcb19..c91805a65e 100644
--- a/hw/usb/hcd-uhci.h
+++ b/hw/usb/hcd-uhci.h
@@ -59,6 +59,7 @@ typedef struct UHCIState {
uint32_t frame_bytes;
uint32_t frame_bandwidth;
bool completions_only;
+ bool isa_irqs;
UHCIPort ports[NB_PORTS];
/* Interrupts that should be raised at the end of the current frame. */
diff --git a/hw/usb/vt82c686-uhci-pci.c b/hw/usb/vt82c686-uhci-pci.c
index b109c21603..5c79e293ef 100644
--- a/hw/usb/vt82c686-uhci-pci.c
+++ b/hw/usb/vt82c686-uhci-pci.c
@@ -13,6 +13,7 @@ static void usb_uhci_vt82c686b_realize(PCIDevice *dev, Error **errp)
/* USB legacy support */
pci_set_long(pci_conf + 0xc0, 0x00002000);
+ s->isa_irqs = true;
usb_uhci_common_realize(dev, errp);
}
--
2.21.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] hw/usb/vt82c686-uhci-pci: Use ISA instead of PCI interrupts
2021-10-03 16:12 [PATCH] hw/usb/vt82c686-uhci-pci: Use ISA instead of PCI interrupts BALATON Zoltan
@ 2021-10-03 16:24 ` Jiaxun Yang
2021-10-04 10:13 ` BALATON Zoltan
1 sibling, 0 replies; 3+ messages in thread
From: Jiaxun Yang @ 2021-10-03 16:24 UTC (permalink / raw)
To: BALATON Zoltan, qemu-devel; +Cc: Huacai Chen, Gerd Hoffmann, Philippe M-D
在 2021/10/3 17:12, BALATON Zoltan 写道:
> This device is part of a sperio/ISA bridge chip and IRQs from it are
> routed to an ISA interrupt set by the Interrupt Line PCI config
> register. Change uhci_update_irq() to allow this and use it from
> vt82c686-uhci-pci.
>
> Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
Reviewed-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
Just double checked kernel of fuloong2e which uses this bridge chip and
it's supposed to route UHCI IRQ to i8259.
Thanks.
- Jiaxun
> ---
> Maybe bit of a hack but fixes USB interrupts on pegasos2 until
> somebody has a better idea. I'm not sure about fuloong2e but the
> VT82C686B docs say it also does the same routing IRQs to ISA PIC like
> VT8231 used on pegasos2.
>
> hw/usb/hcd-uhci.c | 12 +++++++++---
> hw/usb/hcd-uhci.h | 1 +
> hw/usb/vt82c686-uhci-pci.c | 1 +
> 3 files changed, 11 insertions(+), 3 deletions(-)
>
> diff --git a/hw/usb/hcd-uhci.c b/hw/usb/hcd-uhci.c
> index 0cb02a6432..8f28241f70 100644
> --- a/hw/usb/hcd-uhci.c
> +++ b/hw/usb/hcd-uhci.c
> @@ -31,6 +31,7 @@
> #include "hw/usb/uhci-regs.h"
> #include "migration/vmstate.h"
> #include "hw/pci/pci.h"
> +#include "hw/irq.h"
> #include "hw/qdev-properties.h"
> #include "qapi/error.h"
> #include "qemu/timer.h"
> @@ -290,7 +291,7 @@ static UHCIAsync *uhci_async_find_td(UHCIState *s, uint32_t td_addr)
>
> static void uhci_update_irq(UHCIState *s)
> {
> - int level;
> + int level = 0;
> if (((s->status2 & 1) && (s->intr & (1 << 2))) ||
> ((s->status2 & 2) && (s->intr & (1 << 3))) ||
> ((s->status & UHCI_STS_USBERR) && (s->intr & (1 << 0))) ||
> @@ -298,10 +299,15 @@ static void uhci_update_irq(UHCIState *s)
> (s->status & UHCI_STS_HSERR) ||
> (s->status & UHCI_STS_HCPERR)) {
> level = 1;
> + }
> + if (s->isa_irqs) {
> + uint8_t irq = pci_get_byte(s->dev.config + PCI_INTERRUPT_LINE);
> + if (irq < ISA_NUM_IRQS) {
> + qemu_set_irq(isa_get_irq(NULL, irq), level);
> + }
> } else {
> - level = 0;
> + pci_set_irq(&s->dev, level);
> }
> - pci_set_irq(&s->dev, level);
> }
>
> static void uhci_reset(DeviceState *dev)
> diff --git a/hw/usb/hcd-uhci.h b/hw/usb/hcd-uhci.h
> index e61d8fcb19..c91805a65e 100644
> --- a/hw/usb/hcd-uhci.h
> +++ b/hw/usb/hcd-uhci.h
> @@ -59,6 +59,7 @@ typedef struct UHCIState {
> uint32_t frame_bytes;
> uint32_t frame_bandwidth;
> bool completions_only;
> + bool isa_irqs;
> UHCIPort ports[NB_PORTS];
>
> /* Interrupts that should be raised at the end of the current frame. */
> diff --git a/hw/usb/vt82c686-uhci-pci.c b/hw/usb/vt82c686-uhci-pci.c
> index b109c21603..5c79e293ef 100644
> --- a/hw/usb/vt82c686-uhci-pci.c
> +++ b/hw/usb/vt82c686-uhci-pci.c
> @@ -13,6 +13,7 @@ static void usb_uhci_vt82c686b_realize(PCIDevice *dev, Error **errp)
> /* USB legacy support */
> pci_set_long(pci_conf + 0xc0, 0x00002000);
>
> + s->isa_irqs = true;
> usb_uhci_common_realize(dev, errp);
> }
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] hw/usb/vt82c686-uhci-pci: Use ISA instead of PCI interrupts
2021-10-03 16:12 [PATCH] hw/usb/vt82c686-uhci-pci: Use ISA instead of PCI interrupts BALATON Zoltan
2021-10-03 16:24 ` Jiaxun Yang
@ 2021-10-04 10:13 ` BALATON Zoltan
1 sibling, 0 replies; 3+ messages in thread
From: BALATON Zoltan @ 2021-10-04 10:13 UTC (permalink / raw)
To: qemu-devel; +Cc: Huacai Chen, Gerd Hoffmann, Philippe M-D
On Sun, 3 Oct 2021, BALATON Zoltan wrote:
> This device is part of a sperio/ISA bridge chip and IRQs from it are
> routed to an ISA interrupt set by the Interrupt Line PCI config
> register. Change uhci_update_irq() to allow this and use it from
> vt82c686-uhci-pci.
>
> Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
> ---
> Maybe bit of a hack but fixes USB interrupts on pegasos2 until
> somebody has a better idea. I'm not sure about fuloong2e but the
> VT82C686B docs say it also does the same routing IRQs to ISA PIC like
> VT8231 used on pegasos2.
I've found this breaks compilation for machines that have UHCI but no ISA
so I'll have to cahnge it a bit to put a set_irq method in UHCIState
instead that subclasses can set then implement the ISA irq mapping in
vt82c686-uhci-pci.c which depends on VT82C686B which depends on ISA but
the idea is the same unless somebody comes up with a better one. I'll send
a v2 later.
Regards,
BALATON Zoltan
> hw/usb/hcd-uhci.c | 12 +++++++++---
> hw/usb/hcd-uhci.h | 1 +
> hw/usb/vt82c686-uhci-pci.c | 1 +
> 3 files changed, 11 insertions(+), 3 deletions(-)
>
> diff --git a/hw/usb/hcd-uhci.c b/hw/usb/hcd-uhci.c
> index 0cb02a6432..8f28241f70 100644
> --- a/hw/usb/hcd-uhci.c
> +++ b/hw/usb/hcd-uhci.c
> @@ -31,6 +31,7 @@
> #include "hw/usb/uhci-regs.h"
> #include "migration/vmstate.h"
> #include "hw/pci/pci.h"
> +#include "hw/irq.h"
> #include "hw/qdev-properties.h"
> #include "qapi/error.h"
> #include "qemu/timer.h"
> @@ -290,7 +291,7 @@ static UHCIAsync *uhci_async_find_td(UHCIState *s, uint32_t td_addr)
>
> static void uhci_update_irq(UHCIState *s)
> {
> - int level;
> + int level = 0;
> if (((s->status2 & 1) && (s->intr & (1 << 2))) ||
> ((s->status2 & 2) && (s->intr & (1 << 3))) ||
> ((s->status & UHCI_STS_USBERR) && (s->intr & (1 << 0))) ||
> @@ -298,10 +299,15 @@ static void uhci_update_irq(UHCIState *s)
> (s->status & UHCI_STS_HSERR) ||
> (s->status & UHCI_STS_HCPERR)) {
> level = 1;
> + }
> + if (s->isa_irqs) {
> + uint8_t irq = pci_get_byte(s->dev.config + PCI_INTERRUPT_LINE);
> + if (irq < ISA_NUM_IRQS) {
> + qemu_set_irq(isa_get_irq(NULL, irq), level);
> + }
> } else {
> - level = 0;
> + pci_set_irq(&s->dev, level);
> }
> - pci_set_irq(&s->dev, level);
> }
>
> static void uhci_reset(DeviceState *dev)
> diff --git a/hw/usb/hcd-uhci.h b/hw/usb/hcd-uhci.h
> index e61d8fcb19..c91805a65e 100644
> --- a/hw/usb/hcd-uhci.h
> +++ b/hw/usb/hcd-uhci.h
> @@ -59,6 +59,7 @@ typedef struct UHCIState {
> uint32_t frame_bytes;
> uint32_t frame_bandwidth;
> bool completions_only;
> + bool isa_irqs;
> UHCIPort ports[NB_PORTS];
>
> /* Interrupts that should be raised at the end of the current frame. */
> diff --git a/hw/usb/vt82c686-uhci-pci.c b/hw/usb/vt82c686-uhci-pci.c
> index b109c21603..5c79e293ef 100644
> --- a/hw/usb/vt82c686-uhci-pci.c
> +++ b/hw/usb/vt82c686-uhci-pci.c
> @@ -13,6 +13,7 @@ static void usb_uhci_vt82c686b_realize(PCIDevice *dev, Error **errp)
> /* USB legacy support */
> pci_set_long(pci_conf + 0xc0, 0x00002000);
>
> + s->isa_irqs = true;
> usb_uhci_common_realize(dev, errp);
> }
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-10-04 10:19 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-03 16:12 [PATCH] hw/usb/vt82c686-uhci-pci: Use ISA instead of PCI interrupts BALATON Zoltan
2021-10-03 16:24 ` Jiaxun Yang
2021-10-04 10:13 ` BALATON Zoltan
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.