From nobody Mon Apr 29 00:40:22 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=arm.com Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1634640105925399.9860876153099; Tue, 19 Oct 2021 03:41:45 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.212953.371014 (Exim 4.92) (envelope-from ) id 1mcmYl-0008To-T2; Tue, 19 Oct 2021 10:41:31 +0000 Received: by outflank-mailman (output) from mailman id 212953.371014; Tue, 19 Oct 2021 10:41:31 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mcmYl-0008Th-Q0; Tue, 19 Oct 2021 10:41:31 +0000 Received: by outflank-mailman (input) for mailman id 212953; Tue, 19 Oct 2021 10:41:29 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mcmYj-0008TS-ON for xen-devel@lists.xenproject.org; Tue, 19 Oct 2021 10:41:29 +0000 Received: from foss.arm.com (unknown [217.140.110.172]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTP id 1e14144a-30c9-11ec-830c-12813bfff9fa; Tue, 19 Oct 2021 10:41:29 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id EF208ED1; Tue, 19 Oct 2021 03:41:28 -0700 (PDT) Received: from e109506.cambridge.arm.com (e109506.cambridge.arm.com [10.1.199.62]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E00A33F70D; Tue, 19 Oct 2021 03:41:27 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 1e14144a-30c9-11ec-830c-12813bfff9fa From: Bertrand Marquis To: xen-devel@lists.xenproject.org Cc: iwj@xenproject.org, sstabellini@kernel.org, Oleksandr_Andrushchenko@epam.com, jbeulich@suse.com, Paul Durrant Subject: [PATCH 1/3] xen/arm: call vpci_add_handlers on x86 Date: Tue, 19 Oct 2021 11:40:33 +0100 Message-Id: <24f88973257b7038511a0ca49a992d38b295c26f.1634639117.git.bertrand.marquis@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1634640107394100001 Content-Type: text/plain; charset="utf-8" Xen might not be able to discover at boot time all devices or some devices might appear after specific actions from dom0. In this case dom0 can use the PHYSDEVOP_pci_device_add to signal some PCI devices to Xen. As those devices where not known from Xen before, the vpci handlers must be properly installed during pci_device_add for x86 PVH Dom0, in the same way as what is done currently on arm (where Xen does not detect PCI devices but relies on Dom0 to declare them all the time). So this patch is removing the ifdef protecting the call to vpci_add_handlers and the comment which was arm specific. Suggested-by: Jan Beulich Signed-off-by: Bertrand Marquis --- xen/drivers/passthrough/pci.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/xen/drivers/passthrough/pci.c b/xen/drivers/passthrough/pci.c index 35e0190796..d7e09448d1 100644 --- a/xen/drivers/passthrough/pci.c +++ b/xen/drivers/passthrough/pci.c @@ -756,11 +756,6 @@ int pci_add_device(u16 seg, u8 bus, u8 devfn, if ( !pdev->domain ) { pdev->domain =3D hardware_domain; -#ifdef CONFIG_ARM - /* - * On ARM PCI devices discovery will be done by Dom0. Add vpci han= dler - * when Dom0 inform XEN to add the PCI devices in XEN. - */ ret =3D vpci_add_handlers(pdev); if ( ret ) { @@ -768,7 +763,6 @@ int pci_add_device(u16 seg, u8 bus, u8 devfn, pdev->domain =3D NULL; goto out; } -#endif ret =3D iommu_add_device(pdev); if ( ret ) { --=20 2.25.1 From nobody Mon Apr 29 00:40:22 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=arm.com Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1634640109672723.8849995218131; Tue, 19 Oct 2021 03:41:49 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.212955.371037 (Exim 4.92) (envelope-from ) id 1mcmYq-0000cv-DE; Tue, 19 Oct 2021 10:41:36 +0000 Received: by outflank-mailman (output) from mailman id 212955.371037; Tue, 19 Oct 2021 10:41:36 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mcmYq-0000ch-9u; Tue, 19 Oct 2021 10:41:36 +0000 Received: by outflank-mailman (input) for mailman id 212955; Tue, 19 Oct 2021 10:41:34 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mcmYo-0008TS-Mw for xen-devel@lists.xenproject.org; Tue, 19 Oct 2021 10:41:34 +0000 Received: from foss.arm.com (unknown [217.140.110.172]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTP id 1e14144b-30c9-11ec-830c-12813bfff9fa; Tue, 19 Oct 2021 10:41:30 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 78C26D6E; Tue, 19 Oct 2021 03:41:30 -0700 (PDT) Received: from e109506.cambridge.arm.com (e109506.cambridge.arm.com [10.1.199.62]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 3FF343F70D; Tue, 19 Oct 2021 03:41:29 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 1e14144b-30c9-11ec-830c-12813bfff9fa From: Bertrand Marquis To: xen-devel@lists.xenproject.org Cc: iwj@xenproject.org, sstabellini@kernel.org, Oleksandr_Andrushchenko@epam.com, jbeulich@suse.com, =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Subject: [PATCH 2/3] xen/vpci: Remove __hwdom_init for vpci_add_handlers Date: Tue, 19 Oct 2021 11:40:34 +0100 Message-Id: <33b03be7eeea521953790542eb31d5a1386d2b81.1634639117.git.bertrand.marquis@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1634640111379100001 Content-Type: text/plain; charset="utf-8" vpci_add_handlers is called on during pci_device_add which can be called at runtime through hypercall physdev_op. Remove __hwdom_init as the call is not limited anymore to hardware domain init. Fixes: d59168dc05 ("xen/arm: Enable the existing x86 virtual PCI support for ARM") Signed-off-by: Bertrand Marquis --- xen/drivers/vpci/vpci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xen/drivers/vpci/vpci.c b/xen/drivers/vpci/vpci.c index decf7d87a1..74894bcbac 100644 --- a/xen/drivers/vpci/vpci.c +++ b/xen/drivers/vpci/vpci.c @@ -54,7 +54,7 @@ void vpci_remove_device(struct pci_dev *pdev) pdev->vpci =3D NULL; } =20 -int __hwdom_init vpci_add_handlers(struct pci_dev *pdev) +int vpci_add_handlers(struct pci_dev *pdev) { unsigned int i; int rc =3D 0; --=20 2.25.1 From nobody Mon Apr 29 00:40:22 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=arm.com Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1634640113492921.1532819910648; Tue, 19 Oct 2021 03:41:53 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.212956.371048 (Exim 4.92) (envelope-from ) id 1mcmYv-00011w-OA; Tue, 19 Oct 2021 10:41:41 +0000 Received: by outflank-mailman (output) from mailman id 212956.371048; Tue, 19 Oct 2021 10:41:41 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mcmYv-00011m-Im; Tue, 19 Oct 2021 10:41:41 +0000 Received: by outflank-mailman (input) for mailman id 212956; Tue, 19 Oct 2021 10:41:39 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mcmYt-0008TS-ND for xen-devel@lists.xenproject.org; Tue, 19 Oct 2021 10:41:39 +0000 Received: from foss.arm.com (unknown [217.140.110.172]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTP id 200a4a94-30c9-11ec-830c-12813bfff9fa; Tue, 19 Oct 2021 10:41:32 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 65923D6E; Tue, 19 Oct 2021 03:41:32 -0700 (PDT) Received: from e109506.cambridge.arm.com (e109506.cambridge.arm.com [10.1.199.62]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id C80463F70D; Tue, 19 Oct 2021 03:41:30 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 200a4a94-30c9-11ec-830c-12813bfff9fa From: Bertrand Marquis To: xen-devel@lists.xenproject.org Cc: iwj@xenproject.org, sstabellini@kernel.org, Oleksandr_Andrushchenko@epam.com, jbeulich@suse.com, Paul Durrant , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Subject: [PATCH 3/3] xen/pci: Add missing vpci handler cleanup Date: Tue, 19 Oct 2021 11:40:35 +0100 Message-Id: <77e42e006ec7824e9d531cf488f746c2d7545f08.1634639117.git.bertrand.marquis@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1634640115727100001 Content-Type: text/plain; charset="utf-8" Add missing vpci handlers cleanup during pci_device_remove and in case of error with iommu during pci_device_add. Add empty static inline for vpci_remove_device when CONFIG_VPCI is not defined. Fixes: d59168dc05 ("xen/arm: Enable the existing x86 virtual PCI support for ARM") Signed-off-by: Bertrand Marquis --- xen/drivers/passthrough/pci.c | 2 ++ xen/include/xen/vpci.h | 2 ++ 2 files changed, 4 insertions(+) diff --git a/xen/drivers/passthrough/pci.c b/xen/drivers/passthrough/pci.c index d7e09448d1..ddf08a3fae 100644 --- a/xen/drivers/passthrough/pci.c +++ b/xen/drivers/passthrough/pci.c @@ -766,6 +766,7 @@ int pci_add_device(u16 seg, u8 bus, u8 devfn, ret =3D iommu_add_device(pdev); if ( ret ) { + vpci_remove_device(pdev); pdev->domain =3D NULL; goto out; } @@ -813,6 +814,7 @@ int pci_remove_device(u16 seg, u8 bus, u8 devfn) list_for_each_entry ( pdev, &pseg->alldevs_list, alldevs_list ) if ( pdev->bus =3D=3D bus && pdev->devfn =3D=3D devfn ) { + vpci_remove_device(pdev); pci_cleanup_msi(pdev); ret =3D iommu_remove_device(pdev); if ( pdev->domain ) diff --git a/xen/include/xen/vpci.h b/xen/include/xen/vpci.h index 6746c2589a..9ea66e033f 100644 --- a/xen/include/xen/vpci.h +++ b/xen/include/xen/vpci.h @@ -230,6 +230,8 @@ static inline int vpci_add_handlers(struct pci_dev *pde= v) return 0; } =20 +static inline void vpci_remove_device(struct pci_dev *pdev) { } + static inline void vpci_dump_msi(void) { } =20 static inline uint32_t vpci_read(pci_sbdf_t sbdf, unsigned int reg, --=20 2.25.1