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 1/6] via-ide: Avoid expensive operations in irq handler
Date: Mon, 18 Oct 2021 15:27:32 +0200	[thread overview]
Message-ID: <2997b47710914a138223c7b4565dd49204b5b3f0.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 IDE device
has to use for IRQs) in the PCIIDEState and pass that as the opaque
data for the interrupt handler to eliminate both the need to look up
function 0 at every interrupt and also a QOM type cast of the opaque
pointer as that's also expensive (mainly due to qom-debug being
enabled by default).

Suggested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
---
 hw/ide/via.c         | 11 ++++++-----
 include/hw/ide/pci.h |  1 +
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/hw/ide/via.c b/hw/ide/via.c
index 82def819c4..30566bc409 100644
--- a/hw/ide/via.c
+++ b/hw/ide/via.c
@@ -104,15 +104,15 @@ static void bmdma_setup_bar(PCIIDEState *d)
 
 static void via_ide_set_irq(void *opaque, int n, int level)
 {
-    PCIDevice *d = PCI_DEVICE(opaque);
+    PCIIDEState *d = opaque;
 
     if (level) {
-        d->config[0x70 + n * 8] |= 0x80;
+        d->parent_obj.config[0x70 + n * 8] |= 0x80;
     } else {
-        d->config[0x70 + n * 8] &= ~0x80;
+        d->parent_obj.config[0x70 + n * 8] &= ~0x80;
     }
 
-    via_isa_set_irq(pci_get_function_0(d), 14 + n, level);
+    via_isa_set_irq(d->func0, 14 + n, level);
 }
 
 static void via_ide_reset(DeviceState *dev)
@@ -188,7 +188,8 @@ static void via_ide_realize(PCIDevice *dev, Error **errp)
     bmdma_setup_bar(d);
     pci_register_bar(dev, 4, PCI_BASE_ADDRESS_SPACE_IO, &d->bmdma_bar);
 
-    qdev_init_gpio_in(ds, via_ide_set_irq, 2);
+    d->func0 = pci_get_function_0(dev);
+    qdev_init_gpio_in_named_with_opaque(ds, via_ide_set_irq, d, NULL, 2);
     for (i = 0; i < 2; i++) {
         ide_bus_init(&d->bus[i], sizeof(d->bus[i]), ds, i, 2);
         ide_init2(&d->bus[i], qdev_get_gpio_in(ds, i));
diff --git a/include/hw/ide/pci.h b/include/hw/ide/pci.h
index d8384e1c42..89d14abf95 100644
--- a/include/hw/ide/pci.h
+++ b/include/hw/ide/pci.h
@@ -50,6 +50,7 @@ struct PCIIDEState {
     IDEBus bus[2];
     BMDMAState bmdma[2];
     uint32_t secondary; /* used only for cmd646 */
+    PCIDevice *func0; /* used only by IDE functions of superio chips */
     MemoryRegion bmdma_bar;
     MemoryRegion cmd_bar[2];
     MemoryRegion data_bar[2];
-- 
2.21.4



  reply	other threads:[~2021-10-18 13:55 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 ` BALATON Zoltan [this message]
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 ` [PATCH 6/6] hw/usb/vt82c686-uhci-pci: Optimise itq handler BALATON Zoltan
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=2997b47710914a138223c7b4565dd49204b5b3f0.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.