From nobody Mon Feb 9 20:32:47 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1574298314; cv=none; d=zoho.com; s=zohoarc; b=TDfUWN0MYJI6tVQvvFnYhLDkBz9vZnv5QQ+vCWBBkl54PF+uwIT3nfFpxBqSXecwUk99RM3Li8i/yUid1VT8pFHo1xQ65NkNSwJlFmFlzHr5K+5+MUBVGiORwkcdf3VaSHvPO+X42K0VBCJ3EwFwZp8VaIpPID+1Do27kPdcRYA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1574298314; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=FBZYN/wbpgsVd5oZ7uCfeEZaCY2sFxl1Yc06ruPGE4s=; b=Jtiz3gsdYw3AH+9qD40mV5SALPHgKqh7y/STVE8fOCaFiqHFh1ilBPHEYUgBam6/PDB42/PyrjMo4balnttK+rW+iPwW8o4+HYi4W/Ihn+dJSGY/LOuiRDHCY4HFCeP7yT+sjNgh1AKQrE/OwU57FJlUvX6oo08EvbrDPQzROfY= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1574298314182199.84376303300405; Wed, 20 Nov 2019 17:05:14 -0800 (PST) Received: from localhost ([::1]:35526 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iXauH-0007ME-4N for importer@patchew.org; Wed, 20 Nov 2019 20:05:13 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:33932) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iXao5-0001Qg-Js for qemu-devel@nongnu.org; Wed, 20 Nov 2019 19:58:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iXao4-0001s6-HE for qemu-devel@nongnu.org; Wed, 20 Nov 2019 19:58:49 -0500 Received: from bilbo.ozlabs.org ([2401:3900:2:1::2]:35443 helo=ozlabs.org) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iXao4-0001qz-6i; Wed, 20 Nov 2019 19:58:48 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 47JLm42L1Gz9sPW; Thu, 21 Nov 2019 11:58:44 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1574297924; bh=M0mcg5/1en/4FPfwraZYSINmLiks1lDcs9ZPZyf4HFY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IrCBuvydoJarKwc/AqXBCCfhRHgtOv2SIHcrg7RMzyu44qkv46jqKR1N3sGuqc4mh I9yv01OBJiKsd+pNQA58bD4EXpoXcEVNT14kxVqV0ZDbKeXx1WZqgw8B5syMI78vvk FKKxC/uAqg99z7l1n69qh3cmU4omIQGoacX/vSQ4= From: David Gibson To: Alex Williamson , clg@kaod.org Subject: [PATCH 2/5] vfio/pci: Split vfio_intx_update() Date: Thu, 21 Nov 2019 11:56:04 +1100 Message-Id: <20191121005607.274347-3-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191121005607.274347-1-david@gibson.dropbear.id.au> References: <20191121005607.274347-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2401:3900:2:1::2 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: kvm@vger.kernel.org, qemu-devel@nongnu.org, Jason Wang , Riku Voipio , Laurent Vivier , groug@kaod.org, Alexey Kardashevskiy , qemu-ppc@nongnu.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , philmd@redhat.com, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" This splits the vfio_intx_update() function into one part doing the actual reconnection with the KVM irqchip (vfio_intx_update(), now taking an argument with the new routing) and vfio_intx_routing_notifier() which handles calls to the pci device intx routing notifier and calling vfio_intx_update() when necessary. This will make adding support for the irqchip change notifier easier. Cc: Alex Williamson Cc: Alexey Kardashevskiy Signed-off-by: David Gibson --- hw/vfio/pci.c | 39 ++++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index 0c55883bba..521289aa7d 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -216,30 +216,18 @@ static void vfio_intx_disable_kvm(VFIOPCIDevice *vdev) #endif } =20 -static void vfio_intx_update(PCIDevice *pdev) +static void vfio_intx_update(VFIOPCIDevice *vdev, PCIINTxRoute *route) { - VFIOPCIDevice *vdev =3D PCI_VFIO(pdev); - PCIINTxRoute route; Error *err =3D NULL; =20 - if (vdev->interrupt !=3D VFIO_INT_INTx) { - return; - } - - route =3D pci_device_route_intx_to_irq(&vdev->pdev, vdev->intx.pin); - - if (!pci_intx_route_changed(&vdev->intx.route, &route)) { - return; /* Nothing changed */ - } - trace_vfio_intx_update(vdev->vbasedev.name, - vdev->intx.route.irq, route.irq); + vdev->intx.route.irq, route->irq); =20 vfio_intx_disable_kvm(vdev); =20 - vdev->intx.route =3D route; + vdev->intx.route =3D *route; =20 - if (route.mode !=3D PCI_INTX_ENABLED) { + if (route->mode !=3D PCI_INTX_ENABLED) { return; } =20 @@ -252,6 +240,22 @@ static void vfio_intx_update(PCIDevice *pdev) vfio_intx_eoi(&vdev->vbasedev); } =20 +static void vfio_intx_routing_notifier(PCIDevice *pdev) +{ + VFIOPCIDevice *vdev =3D PCI_VFIO(pdev); + PCIINTxRoute route; + + if (vdev->interrupt !=3D VFIO_INT_INTx) { + return; + } + + route =3D pci_device_route_intx_to_irq(&vdev->pdev, vdev->intx.pin); + + if (pci_intx_route_changed(&vdev->intx.route, &route)) { + vfio_intx_update(vdev, &route); + } +} + static int vfio_intx_enable(VFIOPCIDevice *vdev, Error **errp) { uint8_t pin =3D vfio_pci_read_config(&vdev->pdev, PCI_INTERRUPT_PIN, 1= ); @@ -2967,7 +2971,8 @@ static void vfio_realize(PCIDevice *pdev, Error **err= p) if (vfio_pci_read_config(&vdev->pdev, PCI_INTERRUPT_PIN, 1)) { vdev->intx.mmap_timer =3D timer_new_ms(QEMU_CLOCK_VIRTUAL, vfio_intx_mmap_enable, v= dev); - pci_device_set_intx_routing_notifier(&vdev->pdev, vfio_intx_update= ); + pci_device_set_intx_routing_notifier(&vdev->pdev, + vfio_intx_routing_notifier); ret =3D vfio_intx_enable(vdev, errp); if (ret) { goto out_teardown; --=20 2.23.0