All of lore.kernel.org
 help / color / mirror / Atom feed
From: BALATON Zoltan <balaton@eik.bme.hu>
To: qemu-devel@nongnu.org
Cc: Huacai Chen <chenhuacai@kernel.org>,
	Gerd Hoffmann <kraxel@redhat.com>, Philippe M-D <f4bug@amsat.org>
Subject: [PATCH 6/6] hw/usb/vt82c686-uhci-pci: Optimise itq handler
Date: Mon, 18 Oct 2021 15:27:32 +0200	[thread overview]
Message-ID: <3d15335e5b6a6e9603fe1f96e1c0bba7a1e2e540.1634563652.git.balaton@eik.bme.hu> (raw)
In-Reply-To: <cover.1634563652.git.balaton@eik.bme.hu>

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 --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);
 }
-- 
2.21.4



  parent reply	other threads:[~2021-10-18 13:57 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-18 13:27 [PATCH 0/6] hw/usb/vt82c686-uhci-pci: Use ISA instead of PCI interrupts BALATON Zoltan
2021-10-18 13:27 ` [PATCH 1/6] via-ide: Avoid expensive operations in irq handler BALATON Zoltan
2021-10-18 13:27 ` [PATCH 4/6] usb/uhci: Replace pci_set_irq with qemu_set_irq BALATON Zoltan
2021-10-18 13:27 ` [PATCH 3/6] usb/uhci: Disallow user creating a vt82c686-uhci-pci device BALATON Zoltan
2021-10-18 13:27 ` [PATCH 5/6] hw/usb/vt82c686-uhci-pci: Use ISA instead of PCI interrupts BALATON Zoltan
2021-10-18 13:27 ` BALATON Zoltan [this message]
2021-10-18 13:27 ` [PATCH 2/6] usb/uhci: Misc clean up BALATON Zoltan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3d15335e5b6a6e9603fe1f96e1c0bba7a1e2e540.1634563652.git.balaton@eik.bme.hu \
    --to=balaton@eik.bme.hu \
    --cc=chenhuacai@kernel.org \
    --cc=f4bug@amsat.org \
    --cc=kraxel@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.