diff mbox series

[6/6] hw/usb/vt82c686-uhci-pci: Optimise itq handler

Message ID 3d15335e5b6a6e9603fe1f96e1c0bba7a1e2e540.1634563652.git.balaton@eik.bme.hu
State New
Headers show
Series hw/usb/vt82c686-uhci-pci: Use ISA instead of PCI interrupts | expand

Commit Message

BALATON Zoltan Oct. 18, 2021, 1:27 p.m. UTC
Cache the pointer to PCI function 0 (ISA bridge, that this device has
to use for IRQs) in the state struct and use that in the interrupt
handler to avoid needing to look up function 0 at every interrupt
which can be expensive.

Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
---
 hw/usb/hcd-uhci.h          | 1 +
 hw/usb/vt82c686-uhci-pci.c | 3 ++-
 2 files changed, 3 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/hw/usb/hcd-uhci.h b/hw/usb/hcd-uhci.h
index c85ab7868e..ac4e912a3f 100644
--- a/hw/usb/hcd-uhci.h
+++ b/hw/usb/hcd-uhci.h
@@ -44,6 +44,7 @@  typedef struct UHCIPort {
 
 typedef struct UHCIState {
     PCIDevice dev;
+    PCIDevice *func0; /* used when part of a superio chip */
     MemoryRegion io_bar;
     USBBus bus; /* Note unused when we're a companion controller */
     uint16_t cmd; /* cmd register */
diff --git a/hw/usb/vt82c686-uhci-pci.c b/hw/usb/vt82c686-uhci-pci.c
index 0bf2b72ff0..c500936af9 100644
--- a/hw/usb/vt82c686-uhci-pci.c
+++ b/hw/usb/vt82c686-uhci-pci.c
@@ -8,7 +8,7 @@  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);
+        via_isa_set_irq(s->func0, irq, level);
     }
 }
 
@@ -25,6 +25,7 @@  static void usb_uhci_vt82c686b_realize(PCIDevice *dev, Error **errp)
     pci_set_long(pci_conf + 0xc0, 0x00002000);
 
     usb_uhci_common_realize(dev, errp);
+    s->func0 = pci_get_function_0(&s->dev);
     object_unref(s->irq);
     s->irq = qemu_allocate_irq(uhci_isa_set_irq, s, 0);
 }