From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4B5CAC433FE for ; Mon, 18 Oct 2021 13:57:56 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E6ACB60FDA for ; Mon, 18 Oct 2021 13:57:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org E6ACB60FDA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=eik.bme.hu Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:43710 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mcT9G-00077X-Rq for qemu-devel@archiver.kernel.org; Mon, 18 Oct 2021 09:57:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55304) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mcT3Z-0004qX-Lc for qemu-devel@nongnu.org; Mon, 18 Oct 2021 09:52:01 -0400 Received: from zero.eik.bme.hu ([2001:738:2001:2001::2001]:40698) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mcT3W-00045o-Ux for qemu-devel@nongnu.org; Mon, 18 Oct 2021 09:52:01 -0400 Received: from zero.eik.bme.hu (blah.eik.bme.hu [152.66.115.182]) by localhost (Postfix) with SMTP id CE92A748F54; Mon, 18 Oct 2021 15:51:57 +0200 (CEST) Received: by zero.eik.bme.hu (Postfix, from userid 432) id AF56F748F52; Mon, 18 Oct 2021 15:51:57 +0200 (CEST) Message-Id: <3d15335e5b6a6e9603fe1f96e1c0bba7a1e2e540.1634563652.git.balaton@eik.bme.hu> In-Reply-To: References: From: BALATON Zoltan Subject: [PATCH 6/6] hw/usb/vt82c686-uhci-pci: Optimise itq handler Date: Mon, 18 Oct 2021 15:27:32 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit To: qemu-devel@nongnu.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: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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 --- 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