From nobody Mon Feb 9 19:10:58 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=eik.bme.hu Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1634565318567358.8819989033907; Mon, 18 Oct 2021 06:55:18 -0700 (PDT) Received: from localhost ([::1]:38312 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mcT6j-0003Pc-Ju for importer@patchew.org; Mon, 18 Oct 2021 09:55:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55258) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mcT3W-0004kR-6n for qemu-devel@nongnu.org; Mon, 18 Oct 2021 09:51:59 -0400 Received: from zero.eik.bme.hu ([2001:738:2001:2001::2001]:40667) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mcT3T-00041K-Nc for qemu-devel@nongnu.org; Mon, 18 Oct 2021 09:51:57 -0400 Received: from zero.eik.bme.hu (blah.eik.bme.hu [152.66.115.182]) by localhost (Postfix) with SMTP id 8F387748F53; Mon, 18 Oct 2021 15:51:52 +0200 (CEST) Received: by zero.eik.bme.hu (Postfix, from userid 432) id 6DFEF748F52; Mon, 18 Oct 2021 15:51:52 +0200 (CEST) Message-Id: <2997b47710914a138223c7b4565dd49204b5b3f0.1634563652.git.balaton@eik.bme.hu> In-Reply-To: References: From: BALATON Zoltan Subject: [PATCH 1/6] via-ide: Avoid expensive operations in irq handler Date: Mon, 18 Oct 2021 15:27:32 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable To: qemu-devel@nongnu.org X-Spam-Probability: 8% Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2001:738:2001:2001::2001; envelope-from=balaton@eik.bme.hu; helo=zero.eik.bme.hu X-Spam_score_int: 0 X-Spam_score: 0.0 X-Spam_bar: / X-Spam_report: (0.0 / 5.0 requ) SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Huacai Chen , Gerd Hoffmann , Philippe M-D Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZM-MESSAGEID: 1634565319981100001 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=C3=A9 Signed-off-by: BALATON Zoltan --- 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) =20 static void via_ide_set_irq(void *opaque, int n, int level) { - PCIDevice *d =3D PCI_DEVICE(opaque); + PCIIDEState *d =3D opaque; =20 if (level) { - d->config[0x70 + n * 8] |=3D 0x80; + d->parent_obj.config[0x70 + n * 8] |=3D 0x80; } else { - d->config[0x70 + n * 8] &=3D ~0x80; + d->parent_obj.config[0x70 + n * 8] &=3D ~0x80; } =20 - via_isa_set_irq(pci_get_function_0(d), 14 + n, level); + via_isa_set_irq(d->func0, 14 + n, level); } =20 static void via_ide_reset(DeviceState *dev) @@ -188,7 +188,8 @@ static void via_ide_realize(PCIDevice *dev, Error **err= p) bmdma_setup_bar(d); pci_register_bar(dev, 4, PCI_BASE_ADDRESS_SPACE_IO, &d->bmdma_bar); =20 - qdev_init_gpio_in(ds, via_ide_set_irq, 2); + d->func0 =3D pci_get_function_0(dev); + qdev_init_gpio_in_named_with_opaque(ds, via_ide_set_irq, d, NULL, 2); for (i =3D 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]; --=20 2.21.4