From nobody Thu Apr 25 03:41:31 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; dkim=pass; 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=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1633356762; cv=none; d=zohomail.com; s=zohoarc; b=l1291nByJcMc545jNQyzstc6e8L9dgveZHZ3uo92X0mg/tkrdGQe4kOuRRz+WvHEi+AXKDEu+znQ8Cdjid/PNOFNl7mKu01gsKv8zh+CCScR66s60i6RncpG1xtHddu6E5eT1b90epHraXHsSxqcAnoduGC1kNVhlIg7uL6x4JY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1633356762; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=IBrpPALaHgEu2bRfUzTni2BaAuDBWtjiAy9s9dEtWuo=; b=JHO7W4sGBFH3CP55FKRKoSFbXv+WCHKurPmediD6MNiz9+fazT88DGEHQRZzLqEOJUIfTbkdoknpa9fUsPZCWxbAjm8La1PkPkuER7wZMZ2RxrJZdAD7DlF2rnwOR5i8Wj9zyKc5OF2fjpRup6M2wQDGty5G4NW7Xp7W411UcUc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1633356762247895.9873541656162; Mon, 4 Oct 2021 07:12:42 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.201470.356003 (Exim 4.92) (envelope-from ) id 1mXOhX-0001ON-Qq; Mon, 04 Oct 2021 14:12:19 +0000 Received: by outflank-mailman (output) from mailman id 201470.356003; Mon, 04 Oct 2021 14:12:19 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mXOhX-0001OC-Nb; Mon, 04 Oct 2021 14:12:19 +0000 Received: by outflank-mailman (input) for mailman id 201470; Mon, 04 Oct 2021 14:12:18 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mXOhW-0008QG-E8 for xen-devel@lists.xenproject.org; Mon, 04 Oct 2021 14:12:18 +0000 Received: from mail-lf1-x12a.google.com (unknown [2a00:1450:4864:20::12a]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 2b54face-c132-49cc-8c13-b830f68026ae; Mon, 04 Oct 2021 14:12:03 +0000 (UTC) Received: by mail-lf1-x12a.google.com with SMTP id m3so71513774lfu.2 for ; Mon, 04 Oct 2021 07:12:03 -0700 (PDT) Received: from localhost.localdomain (host-176-36-245-220.b024.la.net.ua. [176.36.245.220]) by smtp.gmail.com with ESMTPSA id n12sm1076809lfe.145.2021.10.04.07.11.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Oct 2021 07:11:54 -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: 2b54face-c132-49cc-8c13-b830f68026ae DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=IBrpPALaHgEu2bRfUzTni2BaAuDBWtjiAy9s9dEtWuo=; b=Ez3QUU4M+ZzyRJzYI7PxNH6KFybpw2X52IIyCfolA/goD64BD0H1ylyW/UjcmfXbQm T9LUfCMCd3cOx44P7lzDKzq6KTS04CXPeOjx3ExEBRD6chKSC8hwx+jzUciYnpJh+Q9x xJh0RPoWKHUuZGpX41d2p6iEbR4DbO6Yjd85Fk5ZRu7Dcj/sAXHyv5QZewIDyPOrbbWf Uj1298AJ46nwJev0K9WD/T4PsdnpR0B7Q32JIVWIs4+SOeN3ey1J1yEOxkEVddEpkjGw ADp+s6yhOEDIMVO4uG7g5QzmzXKwqkgE1JmHfTe+wak/eKZ3zBIoxyjR158UG5pHKTAL +EKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=IBrpPALaHgEu2bRfUzTni2BaAuDBWtjiAy9s9dEtWuo=; b=aa6fEVcu68NwYYn3aCywFJk7NwPSk8RorkdQPg9V6DdfCr/13jNoFrqllZkwMcA+/t 68gJFB9+HNk17IA0aOksf7wnSHrw/YQwTUuDpxfb97cd1v23qBey6sfty18mMiYUPdvH JQqeXYVmM/2t3h7OAuiM3KqznuzBoylmpAzzR5zR18BtFLgCtOa6hFWg1DOBdW54Yz28 CNsmWSeUsZmTnBYCQMYxnJlhgWFJFbJhsaTCYZIZp9SwpWIDWz6BjEG7n7pHyZj16eZo KDMLZe3dXytJALAqAacB2Yd9hbEopnM9fGSk5zHZ2nAeEd41nblNpmIJGbXYVDDLccmy 6Rpg== X-Gm-Message-State: AOAM532eE2z13AjRfdckATepEJ7RaTChM99IgTxPBX1b3uhgEugVbRrY APJUntPNmquJzMFjKdZl0/vIbkA73iQ= X-Google-Smtp-Source: ABdhPJz1SHMt2ZTDbeA6PPu/8DUsuEKadrrUL9iIVMY3wTj3Updc7wVxwvB7+bWha+S4A5GsivnE5A== X-Received: by 2002:a05:6512:3d86:: with SMTP id k6mr15180736lfv.120.1633356715255; Mon, 04 Oct 2021 07:11:55 -0700 (PDT) From: Oleksandr Andrushchenko To: xen-devel@lists.xenproject.org Cc: julien@xen.org, sstabellini@kernel.org, oleksandr_tyshchenko@epam.com, volodymyr_babchuk@epam.com, Artem_Mygaiev@epam.com, roger.pau@citrix.com, jbeulich@suse.com, andrew.cooper3@citrix.com, george.dunlap@citrix.com, paul@xen.org, bertrand.marquis@arm.com, rahul.singh@arm.com, Oleksandr Andrushchenko , Michal Orzel Subject: [PATCH v4 01/11] xen/arm: Fix dev_is_dt macro definition Date: Mon, 4 Oct 2021 17:11:41 +0300 Message-Id: <20211004141151.132231-2-andr2000@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211004141151.132231-1-andr2000@gmail.com> References: <20211004141151.132231-1-andr2000@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1633356763465100001 Content-Type: text/plain; charset="utf-8" From: Oleksandr Andrushchenko This macro is not currently used, but still has an error in it: a missing parenthesis. Fix this, so the macro is properly defined. Fixes: 6c5d3075d97e ("xen/arm: Introduce a generic way to describe device") Signed-off-by: Oleksandr Andrushchenko Reviewed-by: Stefano Stabellini Reviewed-by: Michal Orzel --- New in v2 --- xen/include/asm-arm/device.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xen/include/asm-arm/device.h b/xen/include/asm-arm/device.h index 5ecd5e7bd15e..ebe84ea853cd 100644 --- a/xen/include/asm-arm/device.h +++ b/xen/include/asm-arm/device.h @@ -27,7 +27,7 @@ typedef struct device device_t; =20 /* TODO: Correctly implement dev_is_pci when PCI is supported on ARM */ #define dev_is_pci(dev) ((void)(dev), 0) -#define dev_is_dt(dev) ((dev->type =3D=3D DEV_DT) +#define dev_is_dt(dev) ((dev)->type =3D=3D DEV_DT) =20 enum device_class { --=20 2.25.1 From nobody Thu Apr 25 03:41:31 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; dkim=pass; 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=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1633356757; cv=none; d=zohomail.com; s=zohoarc; b=Oz8UohvFtZMoDMqjlllJunwIRbhrcunBuiYl0gANk5M8kcMXuulhqizCvFeG7rBD3NkF2eliIrRMySUOnMCjPP1P/2S0CN9rCuaTkIxV+p0gIhHEUksE/eOGLhwBcFZdcAVP4UoRueJE0FgbbNRAJvDbhc3Vx3Dk1THrIbA+7OU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1633356757; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=mico79NSg1dTzXgY8IQRVxF4SlAfW6DJKkQE/et5l+E=; b=QcA8Kd66ss/eFh5iOxkfQbpcuXi5IXKprzMkcPYRkSIei0Rqs/AZ5+AF5SLEOfck+w9mocffChzWR5oHVGbvL39Nan6jkYvJwrBh7RVTL/6gWaa2Yb07jRWekX8rLSD6jskKPKQqSCBCYFIKzNxScDBPNMttAI40V6LwDSIz62c= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1633356757829502.0060056621991; Mon, 4 Oct 2021 07:12:37 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.201468.355982 (Exim 4.92) (envelope-from ) id 1mXOhO-0000ac-2A; Mon, 04 Oct 2021 14:12:10 +0000 Received: by outflank-mailman (output) from mailman id 201468.355982; Mon, 04 Oct 2021 14:12:10 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mXOhN-0000aT-Ul; Mon, 04 Oct 2021 14:12:09 +0000 Received: by outflank-mailman (input) for mailman id 201468; Mon, 04 Oct 2021 14:12:08 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mXOhM-0008QG-DX for xen-devel@lists.xenproject.org; Mon, 04 Oct 2021 14:12:08 +0000 Received: from mail-lf1-x136.google.com (unknown [2a00:1450:4864:20::136]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 2a84c4a3-d15a-4ce4-b8c6-68ed5b4f4ef1; Mon, 04 Oct 2021 14:11:59 +0000 (UTC) Received: by mail-lf1-x136.google.com with SMTP id x27so72243825lfu.5 for ; Mon, 04 Oct 2021 07:11:59 -0700 (PDT) Received: from localhost.localdomain (host-176-36-245-220.b024.la.net.ua. [176.36.245.220]) by smtp.gmail.com with ESMTPSA id n12sm1076809lfe.145.2021.10.04.07.11.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Oct 2021 07:11:56 -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: 2a84c4a3-d15a-4ce4-b8c6-68ed5b4f4ef1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=mico79NSg1dTzXgY8IQRVxF4SlAfW6DJKkQE/et5l+E=; b=ICTepnxsockaYNS6J7TvmXTgJKo44BlX5+Dwx/rzhbLH9pAOqtVErpd8UCPGo6wHei vDMr2/dAU8tinEvhYOkGYarLsqxSUu9fSU6vVD6oZrIZFLcx0cL8AQXeLk0RU233XNFY buy5VZZ137b3oTlIiiwmd+6SO72Pfe/8FI6EgG+YXljtjB2J8el+FU2tLYNEaSKyt5i5 6uwEzOunBNDhnCC3oDDg3cLkSRA5wxFTSTbLYZ/C9ybq607EV5l7tPzMKAi07PQEqrrV odMDsApervGjMsT8Dg93Nt4gbuXCMesvjhmBB5LH4vNceiuQjQ/H7wS88eqTJK5xme+s ExXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=mico79NSg1dTzXgY8IQRVxF4SlAfW6DJKkQE/et5l+E=; b=2L0eAwl9kOv1i2W/X6CC3FV5p7mHIlopnO5157zxA1fm1ZrjQ9neAJieC4vlU85uG+ 6bVIiUFuDL0q87t4UP4JoYg1Po98ycq5RnNFaiEAgnOgCjk6G40GeX+bV12JiONQFg8k 7VkliVHliZx7X2DIKquvkhOIw6LoZxZ9TvKFZKupnKLZhOOFv/LOlsBZC+NVbC5IYEMV evbTCDwJwUfNWzcFhqWQAl/2WEC1VM6jkhtwgSa2b5dQIrYjEK+07ZTqavoj6TSP6KrC 3MkKhZv1kuSRvvAVL/EN6rwK8Pd/sXAHywroPyHgtkndnUeJJro9V9M0e5TO/6Y0QXdF 9Auw== X-Gm-Message-State: AOAM530tHiOedjao5shnxnDp+xM9yMZoerJoi7hpcuDOUkNBRxwBf7ak EzUoc0ZajR+jbJ2/1mbDavAoRPwepqA= X-Google-Smtp-Source: ABdhPJx6BLkwzCWXnYzL8PCkpvh5BukwzmSkRNCjUNZQtrb5PtZlYg9g1G4HfyIGbc5giXQbXeZV3Q== X-Received: by 2002:ac2:5e31:: with SMTP id o17mr15074866lfg.36.1633356716497; Mon, 04 Oct 2021 07:11:56 -0700 (PDT) From: Oleksandr Andrushchenko To: xen-devel@lists.xenproject.org Cc: julien@xen.org, sstabellini@kernel.org, oleksandr_tyshchenko@epam.com, volodymyr_babchuk@epam.com, Artem_Mygaiev@epam.com, roger.pau@citrix.com, jbeulich@suse.com, andrew.cooper3@citrix.com, george.dunlap@citrix.com, paul@xen.org, bertrand.marquis@arm.com, rahul.singh@arm.com, Oleksandr Andrushchenko Subject: [PATCH v4 02/11] xen/arm: Add new device type for PCI Date: Mon, 4 Oct 2021 17:11:42 +0300 Message-Id: <20211004141151.132231-3-andr2000@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211004141151.132231-1-andr2000@gmail.com> References: <20211004141151.132231-1-andr2000@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1633356759732100003 Content-Type: text/plain; charset="utf-8" From: Oleksandr Andrushchenko Add new device type (DEV_PCI) to distinguish PCI devices from platform DT devices, so some drivers, like IOMMU, can handle PCI devices differently. Also add a helper which is when given a struct device returns the corresponding struct pci_dev which this device is a part of. Because of the header cross-dependencies, e.g. we need both struct pci_dev and struct arch_pci_dev at the same time, this cannot be done with an inline. Signed-off-by: Oleksandr Andrushchenko Reviewed-by: Stefano Stabellini Reviewed-by: Rahul Singh Tested-by: Rahul Singh --- Since v2: - !! dropped Stefano's r-b because of the changes - simplified dev_to_pci to use a single container_of(dev, struct pci_dev, arch.dev) (Jan) Since v1: - Folded new device type (DEV_PCI) into this patch. --- xen/arch/arm/pci/pci.c | 7 +++++++ xen/include/asm-arm/device.h | 4 ++-- xen/include/asm-arm/pci.h | 7 +++++++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/xen/arch/arm/pci/pci.c b/xen/arch/arm/pci/pci.c index 73540045d187..138da19284ab 100644 --- a/xen/arch/arm/pci/pci.c +++ b/xen/arch/arm/pci/pci.c @@ -27,6 +27,13 @@ int arch_pci_clean_pirqs(struct domain *d) return 0; } =20 +struct pci_dev *dev_to_pci(struct device *dev) +{ + ASSERT(dev->type =3D=3D DEV_PCI); + + return container_of(dev, struct pci_dev, arch.dev); +} + static int __init dt_pci_init(void) { struct dt_device_node *np; diff --git a/xen/include/asm-arm/device.h b/xen/include/asm-arm/device.h index ebe84ea853cd..7bf040560363 100644 --- a/xen/include/asm-arm/device.h +++ b/xen/include/asm-arm/device.h @@ -4,6 +4,7 @@ enum device_type { DEV_DT, + DEV_PCI, }; =20 struct dev_archdata { @@ -25,8 +26,7 @@ typedef struct device device_t; =20 #include =20 -/* TODO: Correctly implement dev_is_pci when PCI is supported on ARM */ -#define dev_is_pci(dev) ((void)(dev), 0) +#define dev_is_pci(dev) ((dev)->type =3D=3D DEV_PCI) #define dev_is_dt(dev) ((dev)->type =3D=3D DEV_DT) =20 enum device_class diff --git a/xen/include/asm-arm/pci.h b/xen/include/asm-arm/pci.h index 7cb2e2f1edaf..603a1fc072d1 100644 --- a/xen/include/asm-arm/pci.h +++ b/xen/include/asm-arm/pci.h @@ -26,6 +26,13 @@ struct arch_pci_dev { struct device dev; }; =20 +/* + * Because of the header cross-dependencies, e.g. we need both + * struct pci_dev and struct arch_pci_dev at the same time, this cannot be + * done with an inline here. Macro can be implemented, but looks scary. + */ +struct pci_dev *dev_to_pci(struct device *dev); + /* Arch-specific MSI data for vPCI. */ struct vpci_arch_msi { }; --=20 2.25.1 From nobody Thu Apr 25 03:41:31 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; dkim=pass; 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=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1633356756; cv=none; d=zohomail.com; s=zohoarc; b=Bppm9bvsOBzAUbmflRbEN5E48nkQFITbh6IMbOLQkbNfIDORLZ5pESUPtNjPTVVrOMJgaP0+GzVjMyqFIVozxFops6JkLyXecng1M1sFjqvayw16q5gAmQaIBHemb3NAWHg/9MiF/u/821bUCkm9pvewtGEyFNIutLs18fcYQ4k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1633356756; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=6SnkOg3n8e3cKJ07G/rY49f9q+Znw0T7C7j0b8OToUE=; b=HBN47ev8s3LDZ0nDsG8Gt6tICLqMM/iL2tugVGuoNa68QLwb4+6TQusQzaL5sgYIn2xb8qkiaz/K173tt7ofz+2Qt9x3ty3mU2bMy7bQXOCPlulD6TQ4OtRKr4hZI8voXDtXIdntneTevvcmkYXZ5PG3vNYNZQGPyxjupPig51U= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1633356756679116.90544079320898; Mon, 4 Oct 2021 07:12:36 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.201467.355970 (Exim 4.92) (envelope-from ) id 1mXOhI-0000G2-NA; Mon, 04 Oct 2021 14:12:04 +0000 Received: by outflank-mailman (output) from mailman id 201467.355970; Mon, 04 Oct 2021 14:12:04 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mXOhI-0000Fq-K5; Mon, 04 Oct 2021 14:12:04 +0000 Received: by outflank-mailman (input) for mailman id 201467; Mon, 04 Oct 2021 14:12:03 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mXOhH-0008QG-DL for xen-devel@lists.xenproject.org; Mon, 04 Oct 2021 14:12:03 +0000 Received: from mail-lf1-x130.google.com (unknown [2a00:1450:4864:20::130]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 6d1dcbb3-cf72-42f4-b41d-3dccba6c6d2d; Mon, 04 Oct 2021 14:11:59 +0000 (UTC) Received: by mail-lf1-x130.google.com with SMTP id b20so72639255lfv.3 for ; Mon, 04 Oct 2021 07:11:59 -0700 (PDT) Received: from localhost.localdomain (host-176-36-245-220.b024.la.net.ua. [176.36.245.220]) by smtp.gmail.com with ESMTPSA id n12sm1076809lfe.145.2021.10.04.07.11.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Oct 2021 07:11:57 -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: 6d1dcbb3-cf72-42f4-b41d-3dccba6c6d2d DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=6SnkOg3n8e3cKJ07G/rY49f9q+Znw0T7C7j0b8OToUE=; b=cG3bTjz1jG08qYOXTlqDkOVKK6Tg673becU6zGcsV/7A2cAwe7yX+KGh9RDSf3gYpq Kz0RCQi9yqcM2Zwsb257xGhctCVFRdpcQsF4Q+KEMyYQIhnyyC2/aYIOYtVwDJeAoQL3 4kfFLdH20LTN2Gj4DoTAMB/dQO9EWm5x+GO5X3XTgheRLMMseqaTHTVE7AhZedsiQnO1 7SkNLG+45kk6n8ws49Du7rmm6Gzf7moLsJCxMWgcpHUhm3HPojpIOihojoCtUH5Id6Qs gu5vqXMmVPkWYRaitGnOJIPy3BB46drDrXe+ierlC/yl/Qwo/2/AlRqCkoFd98fFIORz G/zQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=6SnkOg3n8e3cKJ07G/rY49f9q+Znw0T7C7j0b8OToUE=; b=mbNYvbCXX96n2XtVo3KapwZD7QfaCBRrpyCbKagBzTiaSfZN2FXx3EFAUd/GMxDy2Z HQXe3l0Hei4Idq+cbpnFOMsOkyMB1oLG8fj92JjJajwjrgKS6xokifrrwWv3YHkFfu8b UTFEK9xZCwl9tfE2lceMxJw8m5j02TQpeV6K3HuYhli/Zd6hUmaPVbK9bTvI5zf7KNej PB55kXZLZHWh+llTAQqnO81lujnBmkh34HOr8nbAT9RfYUgyxqUTcB3EJ89op9/qsiaN xOHCJuGeXx/+vTQicEhQzwKQ+Sn1Xr3IjuOc8QPjz50231gPOg8QWmSGq8CG1JeVPkoU 9IGA== X-Gm-Message-State: AOAM5330ddfyC3DM1/3sZFmCcCwUbCxP5BZg3MHFiWZu4o+q0j3r9QjY lvM0rJlLGtamp6QT0wJg4NX8tyXfJbA= X-Google-Smtp-Source: ABdhPJzpujgVo0AAnDsvX0/mO7rPD9uSovOIu8r7ciZeOT0kK7o5OIiRJSqZhSSxGquwC3JhyagoMg== X-Received: by 2002:a2e:7d15:: with SMTP id y21mr15846457ljc.70.1633356717899; Mon, 04 Oct 2021 07:11:57 -0700 (PDT) From: Oleksandr Andrushchenko To: xen-devel@lists.xenproject.org Cc: julien@xen.org, sstabellini@kernel.org, oleksandr_tyshchenko@epam.com, volodymyr_babchuk@epam.com, Artem_Mygaiev@epam.com, roger.pau@citrix.com, jbeulich@suse.com, andrew.cooper3@citrix.com, george.dunlap@citrix.com, paul@xen.org, bertrand.marquis@arm.com, rahul.singh@arm.com, Oleksandr Andrushchenko Subject: [PATCH v4 03/11] xen/arm: Introduce pci_find_host_bridge_node helper Date: Mon, 4 Oct 2021 17:11:43 +0300 Message-Id: <20211004141151.132231-4-andr2000@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211004141151.132231-1-andr2000@gmail.com> References: <20211004141151.132231-1-andr2000@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1633356759729100002 Content-Type: text/plain; charset="utf-8" From: Oleksandr Andrushchenko Get host bridge node given a PCI device attached to it. This helper will be re-used for adding PCI devices by the subsequent patches. Signed-off-by: Oleksandr Andrushchenko Signed-off-by: Oleksandr Tyshchenko Reviewed-by: Stefano Stabellini Reviewed-by: Rahul Singh Tested-by: Rahul Singh --- Since v2: - !! dropped Stefano's r-b because of the changes - s/PRI_pci/%pp after rebase onto Arm series --- xen/arch/arm/pci/pci-host-common.c | 16 ++++++++++++++++ xen/include/asm-arm/pci.h | 1 + 2 files changed, 17 insertions(+) diff --git a/xen/arch/arm/pci/pci-host-common.c b/xen/arch/arm/pci/pci-host= -common.c index 593beeb48ce4..592c01aae5bb 100644 --- a/xen/arch/arm/pci/pci-host-common.c +++ b/xen/arch/arm/pci/pci-host-common.c @@ -276,6 +276,22 @@ int pci_get_host_bridge_segment(const struct dt_device= _node *node, return -EINVAL; } =20 +/* + * Get host bridge node given a device attached to it. + */ +struct dt_device_node *pci_find_host_bridge_node(struct device *dev) +{ + struct pci_host_bridge *bridge; + struct pci_dev *pdev =3D dev_to_pci(dev); + + bridge =3D pci_find_host_bridge(pdev->seg, pdev->bus); + if ( unlikely(!bridge) ) + { + printk(XENLOG_ERR "Unable to find PCI bridge for %pp\n", &pdev->sb= df); + return NULL; + } + return bridge->dt_node; +} /* * Local variables: * mode: C diff --git a/xen/include/asm-arm/pci.h b/xen/include/asm-arm/pci.h index 603a1fc072d1..e6d4000e2ac8 100644 --- a/xen/include/asm-arm/pci.h +++ b/xen/include/asm-arm/pci.h @@ -99,6 +99,7 @@ void __iomem *pci_ecam_map_bus(struct pci_host_bridge *br= idge, struct pci_host_bridge *pci_find_host_bridge(uint16_t segment, uint8_t bus= ); int pci_get_host_bridge_segment(const struct dt_device_node *node, uint16_t *segment); +struct dt_device_node *pci_find_host_bridge_node(struct device *dev); =20 static always_inline bool is_pci_passthrough_enabled(void) { --=20 2.25.1 From nobody Thu Apr 25 03:41:31 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; dkim=pass; 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=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1633356757; cv=none; d=zohomail.com; s=zohoarc; b=ZY7s/0/k/kRs5CtE82aKSc/Gr3FdGq1frHwTH7QAOFNCicW/5AH8Ygzy0nNDYpOm6QLzGtU16G+GGOZf7yMLiX3ajE+pOp/wSLn9L8MLYfPmCY0iPGWZeZOw5CBQMJl+nYJaGxrtlTfTgclOcNLYGmwccE1bb2X+mn5qzE++kSo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1633356757; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=SW5l0COaWEZ5SQENULoKJ23OIO+t8l75C/PAXs3yYFM=; b=IWbvCf5DkICX7Zg9P18B7NJC/YLzDswzflFaOEqA5+yISTd00liew/57fBTv7bJ0+7NJnML46tpKcM18fNE6ECjlCuq+9E1IDVkwcAo3enWduI9AAq6I3NEpu+KU82MA+Je8pi7Z3qzrvZYbNY8M9JDr9mWwG/YAdxQY+wT1vRo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1633356757415398.4849807375823; Mon, 4 Oct 2021 07:12:37 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.201469.355993 (Exim 4.92) (envelope-from ) id 1mXOhS-0000w2-Hf; Mon, 04 Oct 2021 14:12:14 +0000 Received: by outflank-mailman (output) from mailman id 201469.355993; Mon, 04 Oct 2021 14:12:14 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mXOhS-0000vv-Db; Mon, 04 Oct 2021 14:12:14 +0000 Received: by outflank-mailman (input) for mailman id 201469; Mon, 04 Oct 2021 14:12:13 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mXOhR-0008QG-Do for xen-devel@lists.xenproject.org; Mon, 04 Oct 2021 14:12:13 +0000 Received: from mail-lf1-x134.google.com (unknown [2a00:1450:4864:20::134]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 0caa8cc2-efeb-4b20-b8a3-ef921042cb49; Mon, 04 Oct 2021 14:12:02 +0000 (UTC) Received: by mail-lf1-x134.google.com with SMTP id e15so72226530lfr.10 for ; Mon, 04 Oct 2021 07:12:02 -0700 (PDT) Received: from localhost.localdomain (host-176-36-245-220.b024.la.net.ua. [176.36.245.220]) by smtp.gmail.com with ESMTPSA id n12sm1076809lfe.145.2021.10.04.07.11.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Oct 2021 07:11:58 -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: 0caa8cc2-efeb-4b20-b8a3-ef921042cb49 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=SW5l0COaWEZ5SQENULoKJ23OIO+t8l75C/PAXs3yYFM=; b=ntx/K3knoi+iSrMn9p7uItv9/iGeeiMOipiMNZeTVU5nuNZ81z0AVPCeDVNH6fFtXj n4FD7JaU0nV+5PfWFuErnZCLpfEGURbI5pWJ8pdUjEWUCEG5tIoS3GHEep1WgXBw9DI6 reXVG2AwzazcS8x51rUKNBCpWtXXpuTD2hy5qg2TirkzLqK+HpYfJCO0maaOvqIFJIJd 64CyohDiVBjsHgKJvrjFqwRLJ7OguMNaRRdZXnnsVTRUVl/HSWGqUMc2bVXrQbAiPgyw X8TKrtziWgyknLX3aLJouNNqrAVC72J8mtXnjzMY6gbZhVVtR+O9yrNPJLxd4ik0UcI1 frRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=SW5l0COaWEZ5SQENULoKJ23OIO+t8l75C/PAXs3yYFM=; b=yaB5SkjynifH43GaVYOJXW9S2nnBeokShVQC7o1HV00fUblIlFsxqqk5s2HcBsAC2Y qP9tQW+d2Dzk6nH2zbAWPfZzU2Bfsw/ZNS7eveNmkITzlZjSuCrACI0uJ7CIrlPoHFoI epIOfoljEcHHhnz8chdKg3Y5eibFgYG17GCditvz8Ezm6uTCJT7zh2Z1pnLIN5cSu9QY MA3yml5jo3oPjhsyUMbgKEmYeRfX/haPoy7PKdZW/5bimkdeIPimMd2bwlxwK6D/BfS3 5iDckt+8dcR6aGAO2TAiNLwJsZxGJW1Qxq2LLSVROUhLpvRlEjd0jQ9YrjnAnNLh4kEh m8XQ== X-Gm-Message-State: AOAM533cC6M5ZZG70Q7UwrBx/s7awn7nZtq73RoboFkr2YggJ1fgCI4A lYMZDWyNp1EMVAvnrLdMtzm4G8J2zx4= X-Google-Smtp-Source: ABdhPJyavFO/o6GxpHltCcx8E2ZFYORwrVAopkK4TzGlo178OgdWxxMtjW60ncVsqyVALdP4IhHpKA== X-Received: by 2002:a05:6512:114d:: with SMTP id m13mr2588483lfg.382.1633356719174; Mon, 04 Oct 2021 07:11:59 -0700 (PDT) From: Oleksandr Andrushchenko To: xen-devel@lists.xenproject.org Cc: julien@xen.org, sstabellini@kernel.org, oleksandr_tyshchenko@epam.com, volodymyr_babchuk@epam.com, Artem_Mygaiev@epam.com, roger.pau@citrix.com, jbeulich@suse.com, andrew.cooper3@citrix.com, george.dunlap@citrix.com, paul@xen.org, bertrand.marquis@arm.com, rahul.singh@arm.com, Oleksandr Andrushchenko Subject: [PATCH v4 04/11] xen/device-tree: Make dt_find_node_by_phandle global Date: Mon, 4 Oct 2021 17:11:44 +0300 Message-Id: <20211004141151.132231-5-andr2000@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211004141151.132231-1-andr2000@gmail.com> References: <20211004141151.132231-1-andr2000@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1633356759726100001 Content-Type: text/plain; charset="utf-8" From: Oleksandr Andrushchenko Make dt_find_node_by_phandle globally visible, so it can be re-used by other frameworks. Signed-off-by: Oleksandr Andrushchenko Reviewed-by: Stefano Stabellini Reviewed-by: Rahul Singh Tested-by: Rahul Singh --- xen/common/device_tree.c | 2 +- xen/include/xen/device_tree.h | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/xen/common/device_tree.c b/xen/common/device_tree.c index ea93da1725f6..4aae281e89bf 100644 --- a/xen/common/device_tree.c +++ b/xen/common/device_tree.c @@ -1047,7 +1047,7 @@ int dt_for_each_range(const struct dt_device_node *de= v, * * Returns a node pointer. */ -static struct dt_device_node *dt_find_node_by_phandle(dt_phandle handle) +struct dt_device_node *dt_find_node_by_phandle(dt_phandle handle) { struct dt_device_node *np; =20 diff --git a/xen/include/xen/device_tree.h b/xen/include/xen/device_tree.h index 2297c59ce66d..fd6cd00b433a 100644 --- a/xen/include/xen/device_tree.h +++ b/xen/include/xen/device_tree.h @@ -849,6 +849,8 @@ int dt_count_phandle_with_args(const struct dt_device_n= ode *np, */ int dt_get_pci_domain_nr(struct dt_device_node *node); =20 +struct dt_device_node *dt_find_node_by_phandle(dt_phandle handle); + #ifdef CONFIG_DEVICE_TREE_DEBUG #define dt_dprintk(fmt, args...) \ printk(XENLOG_DEBUG fmt, ## args) --=20 2.25.1 From nobody Thu Apr 25 03:41:31 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; dkim=pass; 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=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1633356773; cv=none; d=zohomail.com; s=zohoarc; b=TB7cLHrkrbYPF9vcDK9NcShi5y1UGQcv7WmN8MrE1fi+L8e9UKE43d7tCiHLagWn8S4TwrHdHPajJiAkYrjNS59F++R8/H3oEtksPO6U8Q6IB7E5fSo1ZE+UU/3qAo7TrUMfKO+yKHxzrH+NnZQGeACDZnGYCXHs95t+RY7Lj0o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1633356773; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Nrv8Q7YNNTYEmccS6yS28+CJYz+9hljBpl00ZO95JOI=; b=LOwRe4pUaUOZoAW7l1DZt8XUH2OxPSwFs1CxxVuQ8Ud3lZcUPOddkQnG1Sjp2N4zRxOyKBc9DsR3n8mB/fk1FYKxRPSjSmlQXgAA5Jn3YNiV05gJjRBvpsLUzI68qZdm4Z3WWeKxBHnsQjJF8YD7DLO1HyM6Zx/Eb0j9/lG+Tmo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1633356773961637.6956780786743; Mon, 4 Oct 2021 07:12:53 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.201475.356026 (Exim 4.92) (envelope-from ) id 1mXOhh-0002Qc-Iq; Mon, 04 Oct 2021 14:12:29 +0000 Received: by outflank-mailman (output) from mailman id 201475.356026; Mon, 04 Oct 2021 14:12:29 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mXOhh-0002QP-DG; Mon, 04 Oct 2021 14:12:29 +0000 Received: by outflank-mailman (input) for mailman id 201475; Mon, 04 Oct 2021 14:12:28 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mXOhg-0008QG-EO for xen-devel@lists.xenproject.org; Mon, 04 Oct 2021 14:12:28 +0000 Received: from mail-lf1-x132.google.com (unknown [2a00:1450:4864:20::132]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id e72701a1-b62e-4ec6-ab73-34ca2ca8a6d9; Mon, 04 Oct 2021 14:12:04 +0000 (UTC) Received: by mail-lf1-x132.google.com with SMTP id e15so72226937lfr.10 for ; Mon, 04 Oct 2021 07:12:04 -0700 (PDT) Received: from localhost.localdomain (host-176-36-245-220.b024.la.net.ua. [176.36.245.220]) by smtp.gmail.com with ESMTPSA id n12sm1076809lfe.145.2021.10.04.07.11.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Oct 2021 07:12:00 -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: e72701a1-b62e-4ec6-ab73-34ca2ca8a6d9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Nrv8Q7YNNTYEmccS6yS28+CJYz+9hljBpl00ZO95JOI=; b=nHuD21akS1FNyvIKBPdF6k+GqRtBWoOQJqggbF4XIO3yURxuakjo8JjEARjNGJ/4Mg WfTvVAT5I5o6ZU+MbvJb3Tj/KcCPI6VoaqiJ05HXRRTiBm6t34rg3/m85WvcLmfrowJ/ R+UZsE1C8easZFmv5iXiFnTWuyAcJmxcsF/+zx8ga1h717rcjGaa3rXtvoUXWepavkEB xMbCejYM6qEP67QHbHlDsoLkV02Bs/+PHQs1KeNnVEsc5tziliRzG9hXNw/SQZJdbJpU 7FqiFK2kY1BHxmUJ0gGQEzHT52jM8K8KbD8pNBWW82B46ohRvq9PRq8wRq4xIqY3NGL7 wZsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Nrv8Q7YNNTYEmccS6yS28+CJYz+9hljBpl00ZO95JOI=; b=QkDa5yPT6MEIkGHtzxSfHoY9oQ5yDxQYOlKlcKImX2oXCjqhNNBa0fJGCyIJjJrBWG jgnzn5nj3zmQfrlhibpG5ZS5lGQzvlxy53rvjW2oL2EJ6ZXfyLlJPhnS0Y/tEvvq44yg c0GhH+MT0LhM9QaQa/pUaurmuojJX+UfUgHBayJYUJauIg1YedzX5y3ytvrSwZ+Pohbg cg4iiXG4hzCJF3rrMBlbXNnABUCNlE/fUHofRCM/PntR0PCBTRi/vinM8GHTKz4Uumw2 uRt6dt9tsGO4yFoNVFjiGTkBURYFXA0ZVPoZ9O3iJRe3BUgKI7xw26q3TbOZvFMyiJPD lBKg== X-Gm-Message-State: AOAM5314s+tBHfc6+nFKEqzGMNnwvEjX9HO1odES1Emx1DEns/zQfNnK hR2EMJcrxWuzjVwbxKbdqaj+dx46bWQ= X-Google-Smtp-Source: ABdhPJx9kKhnJbCVxMMJxRpcRGYsGoLBXte/mgqMMAh+YYTdLQh7eBnZZ9pPdA0Flx+hyPuS8jf1JQ== X-Received: by 2002:a2e:9cd:: with SMTP id 196mr16213782ljj.434.1633356720823; Mon, 04 Oct 2021 07:12:00 -0700 (PDT) From: Oleksandr Andrushchenko To: xen-devel@lists.xenproject.org Cc: julien@xen.org, sstabellini@kernel.org, oleksandr_tyshchenko@epam.com, volodymyr_babchuk@epam.com, Artem_Mygaiev@epam.com, roger.pau@citrix.com, jbeulich@suse.com, andrew.cooper3@citrix.com, george.dunlap@citrix.com, paul@xen.org, bertrand.marquis@arm.com, rahul.singh@arm.com, Oleksandr Andrushchenko Subject: [PATCH v4 05/11] xen/arm: Mark device as PCI while creating one Date: Mon, 4 Oct 2021 17:11:45 +0300 Message-Id: <20211004141151.132231-6-andr2000@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211004141151.132231-1-andr2000@gmail.com> References: <20211004141151.132231-1-andr2000@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1633356776045100001 Content-Type: text/plain; charset="utf-8" From: Oleksandr Andrushchenko While adding a PCI device mark it as such, so other frameworks can distinguish it from DT devices. For that introduce an architecture defined helper which may perform additional initialization of the newly created PCI device. Cc: Andrew Cooper Cc: Paul Durrant Signed-off-by: Oleksandr Andrushchenko [applicable parts] Acked-by: Jan Beulich Reviewed-by: Rahul Singh Tested-by: Rahul Singh --- Since v3: - fixed Arm build without CONFIG_HAS_PCI Since v2: - !! dropped Stefano's r-b because of the changes - introduced arch_pci_init_pdev (Jan) Since v1: - moved the assignment from iommu_add_device to alloc_pdev --- xen/arch/arm/pci/pci.c | 5 +++++ xen/drivers/passthrough/pci.c | 2 ++ xen/include/asm-arm/pci.h | 7 +++++++ xen/include/asm-x86/pci.h | 2 ++ 4 files changed, 16 insertions(+) diff --git a/xen/arch/arm/pci/pci.c b/xen/arch/arm/pci/pci.c index 138da19284ab..082c14e127a8 100644 --- a/xen/arch/arm/pci/pci.c +++ b/xen/arch/arm/pci/pci.c @@ -34,6 +34,11 @@ struct pci_dev *dev_to_pci(struct device *dev) return container_of(dev, struct pci_dev, arch.dev); } =20 +void arch_pci_init_pdev(struct pci_dev *pdev) +{ + pci_to_dev(pdev)->type =3D DEV_PCI; +} + static int __init dt_pci_init(void) { struct dt_device_node *np; diff --git a/xen/drivers/passthrough/pci.c b/xen/drivers/passthrough/pci.c index b36d5a481162..9e6246afeef5 100644 --- a/xen/drivers/passthrough/pci.c +++ b/xen/drivers/passthrough/pci.c @@ -329,6 +329,8 @@ static struct pci_dev *alloc_pdev(struct pci_seg *pseg,= u8 bus, u8 devfn) *((u8*) &pdev->devfn) =3D devfn; pdev->domain =3D NULL; =20 + arch_pci_init_pdev(pdev); + rc =3D pdev_msi_init(pdev); if ( rc ) { diff --git a/xen/include/asm-arm/pci.h b/xen/include/asm-arm/pci.h index e6d4000e2ac8..ea87ec6006fc 100644 --- a/xen/include/asm-arm/pci.h +++ b/xen/include/asm-arm/pci.h @@ -105,6 +105,9 @@ static always_inline bool is_pci_passthrough_enabled(vo= id) { return pci_passthrough_enabled; } + +void arch_pci_init_pdev(struct pci_dev *pdev); + #else /*!CONFIG_HAS_PCI*/ =20 struct arch_pci_dev { }; @@ -121,5 +124,9 @@ static inline int pci_get_host_bridge_segment(const str= uct dt_device_node *node, return -EINVAL; } =20 +struct pci_dev; + +static inline void arch_pci_init_pdev(struct pci_dev *pdev) {} + #endif /*!CONFIG_HAS_PCI*/ #endif /* __ARM_PCI_H__ */ diff --git a/xen/include/asm-x86/pci.h b/xen/include/asm-x86/pci.h index c4a4fdcbc239..443f25347d08 100644 --- a/xen/include/asm-x86/pci.h +++ b/xen/include/asm-x86/pci.h @@ -36,4 +36,6 @@ static always_inline bool is_pci_passthrough_enabled(void) return true; } =20 +static inline void arch_pci_init_pdev(struct pci_dev *pdev) {} + #endif /* __X86_PCI_H__ */ --=20 2.25.1 From nobody Thu Apr 25 03:41:31 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; dkim=pass; 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=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1633356768; cv=none; d=zohomail.com; s=zohoarc; b=EUyh2sqSPsncxeRuTptoIO35RAsbnL31BKx/mD/REFL+ojhdU3yJR2bqHatP8amfnfF0JhWaaieX30zI/Npj2aAJgs8/pgfWc+Opt+6HV1sPboLzUp/6UrvE3Wvu2OOHDgVPbRklkUf+pmZTJBl8ID7Z1WIR1zumpI7KV4kMHXM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1633356768; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=+Ihu8WIsBNrrd/XYg45D3f8fvmiiGUNqVLLkujQ3kSQ=; b=ON7M6rYykkrXY5busUDjIkEWj6tVIDp6Nqb2omUe8qG3EtHzNdX1BjaD57tuIGzqEQ+Wo0nlL1iucJ13h8NTN/g9dPv81jEU0JuS0ajk4Og+oQ0smfk4Jtgk5U7rvAxFv6b6EIZmEia0x8eIrByUzp9n4Icn7iWGG1YcGMc55V4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1633356768237852.189503321093; Mon, 4 Oct 2021 07:12:48 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.201472.356015 (Exim 4.92) (envelope-from ) id 1mXOhd-0001sH-6O; Mon, 04 Oct 2021 14:12:25 +0000 Received: by outflank-mailman (output) from mailman id 201472.356015; Mon, 04 Oct 2021 14:12:25 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mXOhd-0001rx-1k; Mon, 04 Oct 2021 14:12:25 +0000 Received: by outflank-mailman (input) for mailman id 201472; Mon, 04 Oct 2021 14:12:23 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mXOhb-0008QG-EE for xen-devel@lists.xenproject.org; Mon, 04 Oct 2021 14:12:23 +0000 Received: from mail-lf1-x12a.google.com (unknown [2a00:1450:4864:20::12a]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 2fadc80f-0717-4551-9792-16413c61196a; Mon, 04 Oct 2021 14:12:04 +0000 (UTC) Received: by mail-lf1-x12a.google.com with SMTP id y26so72533785lfa.11 for ; Mon, 04 Oct 2021 07:12:04 -0700 (PDT) Received: from localhost.localdomain (host-176-36-245-220.b024.la.net.ua. [176.36.245.220]) by smtp.gmail.com with ESMTPSA id n12sm1076809lfe.145.2021.10.04.07.12.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Oct 2021 07:12:01 -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: 2fadc80f-0717-4551-9792-16413c61196a DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=+Ihu8WIsBNrrd/XYg45D3f8fvmiiGUNqVLLkujQ3kSQ=; b=P7FVi5NuBKlmOjDovaxcHsNZRDofWPqtuFCfvvhbn0xNCa0CQGm89iQ9ZsvGJHba3W s0f5tFt5ltgrt9gCI/v0qEQ4tWx46I7yfrTBL5+LjQgHSvExeS7i8YHyIEk+uITRBdYl xQKpm3kBFS0rrUNOia93qQaHI/rgNOPYn0A+L+EdmwQ1PF4sY9k0BAm/ITZBA8ukHi57 zegm3KJSAhzxH1euJoHijWltm001sKQZLIgyTPVTQ7Kcqx22lxIdPkH5WirvXb/B3H3k t/jHyx/x+IBolejEuaeFJQPty82Xg1nmIAfwiAxBQcMOXJzBMeIyooNJ421SRnxcMr8L 5SwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=+Ihu8WIsBNrrd/XYg45D3f8fvmiiGUNqVLLkujQ3kSQ=; b=fOd3X2cdTrQKewA6Hg0czKql6yQocTYUg53F+hE3UMYicwdw5f8s/9nVoiVXOQjUXZ o2Yf0LWjpiqHlj25eWBX4MpqaPa5RykHQSkoMXh4+fheOiZiq1V+z2ApcSw8v3Tqp9Sb k9YE91JgJPsMoxFM32KO7WYLnxxuUCQ3NU+oZJ83MoQZCi9eWg8EiWJXOijMQ/sjehkn oq1Id5FoOJQXoABV3gFDAUxV0NW4AkaKW0cILrfYTiug121wEfdOPvr8h0AP2rTrYV6Q qbD5NAsRx/3DoXJVnfwzitf0+LwGJzWvdM0LajPXxyTVfI2cSdpPLAU95I6Dw32CmlM6 GL2Q== X-Gm-Message-State: AOAM533a0ftl8/KWO5twyE23aoZhzK0dRtTgNe+MDD5u76SnTUk8fIGZ yTyzdvDq7kNuekYzn8j0MJi8jlUOua0= X-Google-Smtp-Source: ABdhPJyHpK9g16BM2BPUWlUCc1BuvoSI7jQvDCN3PstgDPofILOIH1rVzq6oomDhq2WyFkeAx9W9kg== X-Received: by 2002:a05:6512:3e1e:: with SMTP id i30mr14503161lfv.273.1633356722040; Mon, 04 Oct 2021 07:12:02 -0700 (PDT) From: Oleksandr Andrushchenko To: xen-devel@lists.xenproject.org Cc: julien@xen.org, sstabellini@kernel.org, oleksandr_tyshchenko@epam.com, volodymyr_babchuk@epam.com, Artem_Mygaiev@epam.com, roger.pau@citrix.com, jbeulich@suse.com, andrew.cooper3@citrix.com, george.dunlap@citrix.com, paul@xen.org, bertrand.marquis@arm.com, rahul.singh@arm.com, Oleksandr Andrushchenko Subject: [PATCH v4 06/11] xen/domain: Call pci_release_devices() when releasing domain resources Date: Mon, 4 Oct 2021 17:11:46 +0300 Message-Id: <20211004141151.132231-7-andr2000@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211004141151.132231-1-andr2000@gmail.com> References: <20211004141151.132231-1-andr2000@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1633356769234100001 Content-Type: text/plain; charset="utf-8" From: Oleksandr Tyshchenko This is the very same that we already do for DT devices. Moreover, x86 already calls pci_release_devices(). Signed-off-by: Oleksandr Tyshchenko Signed-off-by: Oleksandr Andrushchenko Reviewed-by: Stefano Stabellini Reviewed-by: Rahul Singh Tested-by: Rahul Singh --- Since v1: - re-wording in the commit message --- xen/arch/arm/domain.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c index fbb52f78f1a6..79012bf77757 100644 --- a/xen/arch/arm/domain.c +++ b/xen/arch/arm/domain.c @@ -985,7 +985,8 @@ static int relinquish_memory(struct domain *d, struct p= age_list_head *list) * function which may return -ERESTART. */ enum { - PROG_tee =3D 1, + PROG_pci =3D 1, + PROG_tee, PROG_xen, PROG_page, PROG_mapping, @@ -1022,6 +1023,12 @@ int domain_relinquish_resources(struct domain *d) #ifdef CONFIG_IOREQ_SERVER ioreq_server_destroy_all(d); #endif +#ifdef CONFIG_HAS_PCI + PROGRESS(pci): + ret =3D pci_release_devices(d); + if ( ret ) + return ret; +#endif =20 PROGRESS(tee): ret =3D tee_relinquish_resources(d); --=20 2.25.1 From nobody Thu Apr 25 03:41:31 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; dkim=pass; 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=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1633356777; cv=none; d=zohomail.com; s=zohoarc; b=ZUdYusxToHpWiy0Uk8NtLcKTjA69S9lMxwWYeQpzF73cfsefEPtpLWg9q6b1NKBfv+W4SBr+kp+olNFU28rNSxH2Alnqkfjq2mz9F2dXmBSqZz5weBxmi8DwD7EoF9MoYlwpykTpJhtlO7mkfhaNIYWOEaSvRvxbXPYwAZM9Dro= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1633356777; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=WDh679uaxt3D3xG8n+dCNUszLzt3im/1WQOSXJPkVhE=; b=RHIecqpkrL/h9+jBlk5SPmdQRYPFmoBnySyYBHGJ0vpkg0duUh1HpVdP+NRQFeov0Mf8dI/e0NKw5t5zk0DdeRbz0Qn1T/7qvP8q9V7E4VN7sOHyrrxPa28Us52K+/79HSdeeKRJhaVKXHNNfKEFbWoPhgDKdAtxSjdpsD9QTJw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1633356777412805.3465997580911; Mon, 4 Oct 2021 07:12:57 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.201478.356036 (Exim 4.92) (envelope-from ) id 1mXOhm-00037I-SV; Mon, 04 Oct 2021 14:12:34 +0000 Received: by outflank-mailman (output) from mailman id 201478.356036; Mon, 04 Oct 2021 14:12:34 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mXOhm-000373-Nc; Mon, 04 Oct 2021 14:12:34 +0000 Received: by outflank-mailman (input) for mailman id 201478; Mon, 04 Oct 2021 14:12:33 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mXOhl-0008QG-ER for xen-devel@lists.xenproject.org; Mon, 04 Oct 2021 14:12:33 +0000 Received: from mail-lf1-x12d.google.com (unknown [2a00:1450:4864:20::12d]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 7e868626-1a8c-4afb-a1b9-319849fb2127; Mon, 04 Oct 2021 14:12:05 +0000 (UTC) Received: by mail-lf1-x12d.google.com with SMTP id y26so72533951lfa.11 for ; Mon, 04 Oct 2021 07:12:05 -0700 (PDT) Received: from localhost.localdomain (host-176-36-245-220.b024.la.net.ua. [176.36.245.220]) by smtp.gmail.com with ESMTPSA id n12sm1076809lfe.145.2021.10.04.07.12.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Oct 2021 07:12:02 -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: 7e868626-1a8c-4afb-a1b9-319849fb2127 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=WDh679uaxt3D3xG8n+dCNUszLzt3im/1WQOSXJPkVhE=; b=HIvpuPPvTQxm3OTLHvl+Tw3Oj3SBy3az2jhK/UzxV42Oc9je52k9hFyz6y33ZEuQSX WzcUKPT99S0mmEQUwgbSIXjgTzQ/yY586VLPk2uvwSr3rpCyVlUrTppqznKhsN5E2/YB UldBiS9bJ/fs4Tm+CzQDybmbQCMQJvX43OR8cy+SWzUD6lNAzcEVHYznJ4U47WrLi5t9 W0iaARnFPLag0YC+LhHxM10iyfTdPkEfon74PSjA05kLmtrdgry+vjRJ8PHsKMCo9EZ8 paDkuXb69ZcUT8Vhy85wLax9E3bpHx6FCiuR6ATpH9r8kwiHO+2ZO6sugk1s+S3dWlZA Un/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=WDh679uaxt3D3xG8n+dCNUszLzt3im/1WQOSXJPkVhE=; b=0LpYe6gN9R44hRo2SPLtZwQD7w2QvT/bSGJqyW1Wb0Apj735JTgdHQa2ISLq3hPEaw yQQ53eRMtB00KUY4iTl7YMFBlAIDbqXYqfhjUpOd9wkFLvNFoHWVwd/eAKG04TTATYoW cNBv1VNH2MFUFHmF2LGuV+6JQzoH/BojL8XSJbr1FWA/Z23ERKo6CfB65JcAJWW2OMQM Hx8H3tgQ6m6xZ4iEjRvGH7hW/xGhuDR7fRvMSFXdafpJb3lgTybgLKZUDn5FnR65bP2+ HczLoeGtR7Ns5XJCAeYhrFabmIGc64nrP+UR1lwjTpqjm3n2+0cmATFUMUritRvTGvsA qQQQ== X-Gm-Message-State: AOAM531C2lLWnd7WS2fQ21eDBYp7FAvV366bTCd3i3jskZYQ08+BczSV X24zsjEVmKlV/sHGoai/hFcROoHnSgmzBw== X-Google-Smtp-Source: ABdhPJxAec2PEhmXVf/JTyEZPASdhB7S68QQTKy/dhI+wiEenp0e1SIg5plQ7m+2kt83+jHKWv7Dsg== X-Received: by 2002:a2e:70a:: with SMTP id 10mr16039162ljh.89.1633356723577; Mon, 04 Oct 2021 07:12:03 -0700 (PDT) From: Oleksandr Andrushchenko To: xen-devel@lists.xenproject.org Cc: julien@xen.org, sstabellini@kernel.org, oleksandr_tyshchenko@epam.com, volodymyr_babchuk@epam.com, Artem_Mygaiev@epam.com, roger.pau@citrix.com, jbeulich@suse.com, andrew.cooper3@citrix.com, george.dunlap@citrix.com, paul@xen.org, bertrand.marquis@arm.com, rahul.singh@arm.com, Oleksandr Andrushchenko , Ian Jackson , Juergen Gross Subject: [PATCH v4 07/11] libxl: Allow removing PCI devices for all types of domains Date: Mon, 4 Oct 2021 17:11:47 +0300 Message-Id: <20211004141151.132231-8-andr2000@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211004141151.132231-1-andr2000@gmail.com> References: <20211004141151.132231-1-andr2000@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1633356778537100001 Content-Type: text/plain; charset="utf-8" From: Oleksandr Andrushchenko The PCI device remove path may now be used by PVH on ARM, so the assert is no longer valid. Cc: Ian Jackson Cc: Juergen Gross Signed-off-by: Oleksandr Andrushchenko Acked-by: Stefano Stabellini Reviewed-by: Rahul Singh Tested-by: Rahul Singh --- tools/libs/light/libxl_pci.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/tools/libs/light/libxl_pci.c b/tools/libs/light/libxl_pci.c index 1a1c2630803b..59f3686fc85e 100644 --- a/tools/libs/light/libxl_pci.c +++ b/tools/libs/light/libxl_pci.c @@ -1947,8 +1947,6 @@ static void do_pci_remove(libxl__egc *egc, pci_remove= _state *prs) goto out_fail; } } else { - assert(type =3D=3D LIBXL_DOMAIN_TYPE_PV); - char *sysfs_path =3D GCSPRINTF(SYSFS_PCI_DEV"/"PCI_BDF"/resource",= pci->domain, pci->bus, pci->dev, pci->func); FILE *f =3D fopen(sysfs_path, "r"); --=20 2.25.1 From nobody Thu Apr 25 03:41:31 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; dkim=pass; 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=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1633356788; cv=none; d=zohomail.com; s=zohoarc; b=QkTsCn2Yw4oH6mSbsDUfmdNc3wLEDN5BMoyhoYXwqInQusL7LD8GpSp2M0ZBvaRpAV/azOE50iOjg5xN0yQ8gAkw0ROwns1AHZ8YyPgcMDbw0LYM8+0Dj3XCp/TDb/zKMlQpy98aNuFIanRta0WZgkye1cR5w+PkJ6FT7oLjRh8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1633356788; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=WtoV9kcozcsPgkYbTZ9sQ3MmnsSfH8oWiuIZRPzZ8Ac=; b=fK3DU+JNgoSh8bk6Yo60OXw2LYV9Otkcb8Xj+V8zHx2rvc0Q1sZUWs9h3ZZthZHgMbvhLYCVTd30+EEEAiE1Tsxi7X7WBzqwm6EKbuezfM3nV/TL5o4wGGag+66fxTMFCSFFngNQkgEGTQ8tXKyXby5h6WXqnxldwb2qFlWI50g= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1633356788358244.7823054719048; Mon, 4 Oct 2021 07:13:08 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.201485.356048 (Exim 4.92) (envelope-from ) id 1mXOhx-0003xn-5h; Mon, 04 Oct 2021 14:12:45 +0000 Received: by outflank-mailman (output) from mailman id 201485.356048; Mon, 04 Oct 2021 14:12:45 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mXOhx-0003xS-1J; Mon, 04 Oct 2021 14:12:45 +0000 Received: by outflank-mailman (input) for mailman id 201485; Mon, 04 Oct 2021 14:12:43 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mXOhv-0008QG-ET for xen-devel@lists.xenproject.org; Mon, 04 Oct 2021 14:12:43 +0000 Received: from mail-lf1-x12b.google.com (unknown [2a00:1450:4864:20::12b]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 184555a2-32a8-4530-a7e4-70f36408f919; Mon, 04 Oct 2021 14:12:09 +0000 (UTC) Received: by mail-lf1-x12b.google.com with SMTP id j5so67294813lfg.8 for ; Mon, 04 Oct 2021 07:12:09 -0700 (PDT) Received: from localhost.localdomain (host-176-36-245-220.b024.la.net.ua. [176.36.245.220]) by smtp.gmail.com with ESMTPSA id n12sm1076809lfe.145.2021.10.04.07.12.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Oct 2021 07:12:04 -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: 184555a2-32a8-4530-a7e4-70f36408f919 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=WtoV9kcozcsPgkYbTZ9sQ3MmnsSfH8oWiuIZRPzZ8Ac=; b=AZ+cyo6GcrFP4hY/gE6hDkzOR9T02GILiuinadnUzET4hfCR1Srfx/E6RgvAfWIsa9 bOBBw36L/JXpoXRYFTZfST5OU9O/ZvWkROEQV1EDN9Fg5Hh0qKTUgclN/86LumqYrGh+ d8oJZUnRALtfC/3d9KlBg9W0gofCLJtG/e94oiI2xezAxfCFME0HLP0IGsEjZ4qqU5O0 xo6c5yOSz8p9zKMK39OwMYQ7KerZe0xpGbLWH0dJFmyqPOLDnbh1h9Yvj7EkkcIydy0b zzVpfDeq15pPw2oVD9CMCHKz7qG4zlF1QBSUu8vKTUMukFUoqL+JL30pEka2uvB8161b 87fA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=WtoV9kcozcsPgkYbTZ9sQ3MmnsSfH8oWiuIZRPzZ8Ac=; b=g76AWiFkunYJpGkh9LvTH2CM+ICema9Q/9bdXuqmiicfGkHs+YaGAyURDFMnY8peqp IvwD1Zmko30jBQM5KJU2acIWHfESy/SPBel+hAEHW0KehaVbcfWfi4NEgodjXMCPrK1N de5MzRIJ3TxoJ9/ZkzMR6e6HHbQfPyrq9Q4pPiTVUo4Mi3oNFgaijHF2ROLl+DedFe1y D3Ptqn79UgDnd7EuR+H3BA3wR+DgWMY98fREu4UheRIHBA3yH3HR4Yg3BvuMZ3yVRVMC ovYr5fMd7+IdZ+iKKujInT+dhBJmEJFnl0kVM7XU6Wk0hiJB4ZVhtEuwewrKl9KAVFUa vRRA== X-Gm-Message-State: AOAM532LzBWOCwRO0Tqru80vBtfRNMqZ+Quv8hafIozh2Ii5BGn4DLwz TDNCWCWN87GfH+B+oj6dc2sfD0g6arQvGw== X-Google-Smtp-Source: ABdhPJx7yYnDt/IPOUn/fYX+ZAr0w8Wz5KXnxNDbO6A4Jyp69+rQKY5NEvMdRFUBepGVdWzeBMqIUg== X-Received: by 2002:a05:6512:1053:: with SMTP id c19mr14669899lfb.283.1633356725200; Mon, 04 Oct 2021 07:12:05 -0700 (PDT) From: Oleksandr Andrushchenko To: xen-devel@lists.xenproject.org Cc: julien@xen.org, sstabellini@kernel.org, oleksandr_tyshchenko@epam.com, volodymyr_babchuk@epam.com, Artem_Mygaiev@epam.com, roger.pau@citrix.com, jbeulich@suse.com, andrew.cooper3@citrix.com, george.dunlap@citrix.com, paul@xen.org, bertrand.marquis@arm.com, rahul.singh@arm.com, Oleksandr Andrushchenko , Ian Jackson , Juergen Gross Subject: [PATCH v4 08/11] libxl: Only map legacy PCI IRQs if they are supported Date: Mon, 4 Oct 2021 17:11:48 +0300 Message-Id: <20211004141151.132231-9-andr2000@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211004141151.132231-1-andr2000@gmail.com> References: <20211004141151.132231-1-andr2000@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1633356789648100001 Content-Type: text/plain; charset="utf-8" From: Oleksandr Andrushchenko Arm's PCI passthrough implementation doesn't support legacy interrupts, but MSI/MSI-X. This can be the case for other platforms too. For that reason introduce a new CONFIG_PCI_SUPP_LEGACY_IRQ and add it to the CFLAGS and compile the relevant code in the toolstack only if applicable. Cc: Ian Jackson Cc: Juergen Gross Signed-off-by: Oleksandr Andrushchenko Reviewed-by: Stefano Stabellini Reviewed-by: Rahul Singh Tested-by: Rahul Singh --- Since v1: - Minimized #idefery by introducing pci_supp_legacy_irq function for relevant checks --- tools/libs/light/Makefile | 4 ++++ tools/libs/light/libxl_pci.c | 13 +++++++++++++ 2 files changed, 17 insertions(+) diff --git a/tools/libs/light/Makefile b/tools/libs/light/Makefile index 7d8c51d49242..bd3f6be2a183 100644 --- a/tools/libs/light/Makefile +++ b/tools/libs/light/Makefile @@ -46,6 +46,10 @@ CFLAGS +=3D -Wno-format-zero-length -Wmissing-declaratio= ns \ -Wno-declaration-after-statement -Wformat-nonliteral CFLAGS +=3D -I. =20 +ifeq ($(CONFIG_X86),y) +CFLAGS +=3D -DCONFIG_PCI_SUPP_LEGACY_IRQ +endif + SRCS-$(CONFIG_X86) +=3D libxl_cpuid.c SRCS-$(CONFIG_X86) +=3D libxl_x86.c SRCS-$(CONFIG_X86) +=3D libxl_psr.c diff --git a/tools/libs/light/libxl_pci.c b/tools/libs/light/libxl_pci.c index 59f3686fc85e..4c2d7aeefbb2 100644 --- a/tools/libs/light/libxl_pci.c +++ b/tools/libs/light/libxl_pci.c @@ -1364,6 +1364,15 @@ static void pci_add_timeout(libxl__egc *egc, libxl__= ev_time *ev, pci_add_dm_done(egc, pas, rc); } =20 +static bool pci_supp_legacy_irq(void) +{ +#ifdef CONFIG_PCI_SUPP_LEGACY_IRQ + return true; +#else + return false; +#endif +} + static void pci_add_dm_done(libxl__egc *egc, pci_add_state *pas, int rc) @@ -1434,6 +1443,8 @@ static void pci_add_dm_done(libxl__egc *egc, } } fclose(f); + if (!pci_supp_legacy_irq()) + goto out_no_irq; sysfs_path =3D GCSPRINTF(SYSFS_PCI_DEV"/"PCI_BDF"/irq", pci->domain, pci->bus, pci->dev, pci->func); f =3D fopen(sysfs_path, "r"); @@ -1983,6 +1994,8 @@ static void do_pci_remove(libxl__egc *egc, pci_remove= _state *prs) } fclose(f); skip1: + if (!pci_supp_legacy_irq()) + goto skip_irq; sysfs_path =3D GCSPRINTF(SYSFS_PCI_DEV"/"PCI_BDF"/irq", pci->domai= n, pci->bus, pci->dev, pci->func); f =3D fopen(sysfs_path, "r"); --=20 2.25.1 From nobody Thu Apr 25 03:41:31 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; dkim=pass; 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=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1633357070; cv=none; d=zohomail.com; s=zohoarc; b=hXOe/PS/Ek9ht0lTPQcvTll6g1DOm0U8OceiPsbDTL5I5MjgsxtGXL5nSVgL7J6ZbQPp+UwK61XTekc3Y7KpVU6vF2RG1cKMKP44Xg3oBPXKvti+m1hsv3LxD7Wax1Mn/23PZXShEFwtmSC4vvDjQOhaSqCZKNLhqBTRWWza0l4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1633357070; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=yH0ib0fYHnpnXYuN0yIUp+P4aLOSl8TIjVaiKqqDoME=; b=OR0lOiGEaNWv45JBmRJcSVSmbESJb3S58x4YpF90IGHnBU4YXKRhqRhuOWxrHfaZKSblwOuAT5Jcr47T7UZ6tYAPCPOC1E+/9GPUpVvwEom/ezhfZedLIZ8rSLB9cv7zzv5l0nA7u1/c9Jsf9bfuXGzRyfhBxuJmgS6ZzL5Xg9U= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1633357069938106.13285751266051; Mon, 4 Oct 2021 07:17:49 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.201519.356081 (Exim 4.92) (envelope-from ) id 1mXOmf-0006Ta-Dv; Mon, 04 Oct 2021 14:17:37 +0000 Received: by outflank-mailman (output) from mailman id 201519.356081; Mon, 04 Oct 2021 14:17:37 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mXOmf-0006TN-Ay; Mon, 04 Oct 2021 14:17:37 +0000 Received: by outflank-mailman (input) for mailman id 201519; Mon, 04 Oct 2021 14:17:36 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mXOi0-0008QG-Ea for xen-devel@lists.xenproject.org; Mon, 04 Oct 2021 14:12:48 +0000 Received: from mail-lf1-x12a.google.com (unknown [2a00:1450:4864:20::12a]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 9ba3d850-b21d-4a3c-8497-b91f56f96571; Mon, 04 Oct 2021 14:12:09 +0000 (UTC) Received: by mail-lf1-x12a.google.com with SMTP id y15so6465418lfk.7 for ; Mon, 04 Oct 2021 07:12:09 -0700 (PDT) Received: from localhost.localdomain (host-176-36-245-220.b024.la.net.ua. [176.36.245.220]) by smtp.gmail.com with ESMTPSA id n12sm1076809lfe.145.2021.10.04.07.12.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Oct 2021 07:12:06 -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: 9ba3d850-b21d-4a3c-8497-b91f56f96571 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=yH0ib0fYHnpnXYuN0yIUp+P4aLOSl8TIjVaiKqqDoME=; b=FTHD1NrKz0elS/22hvRlyOVDFIaBeZCOjaYcvaH/NI4fV0l5+mCWELmxleSwhfqgA2 IxkBWtN5/1FBPLoqIGvY/7fUhsV57sWlA23IANz+DNsYGoTwbGuQSVK/PH6YWoTs3U4a nIA5oSI7sPmuAH7xgyMVjnx+k+kbZZWWfXzGzz1pZXAbFJ9aHEZ7rAcjwv6rkk6nITr3 KF5VKOnWFC0a4dYcXo0Bacz8X8NC8Wp1JjhUMy5WfwTCVhCHi0fZBDCk4RXg7lfoqK0Y h4HB1VKDZ+y/L4yb+fAqFnmEs9LuR+VfuUR60QXcR95hzIYd4zKENoUw4cq13IBDpEJB jxZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=yH0ib0fYHnpnXYuN0yIUp+P4aLOSl8TIjVaiKqqDoME=; b=NeMGuai8SsEBHvE62YEb3+es/Twwzrut10j47YZoq3GA/BVjkUwjOW77rXQCURYn9b 6L5gT55wF8xv20FXZoOINjC6lxAXnPOo/ZWfTgD30yGBlBXy4QZK1Y1D1DOWwPW1PCky g45+JwRTVUjL2FTkhUBxLCCkmEk/lAIMBflGR/OobVgw2nBsvTDX0497Y+bbSGSyifAL h2aZnjLlE9xG57fs70x0MpRRhSfIXW8DkAJU5g1VtA6QkycsrFkck3Qu6Xqeb7WMvtxS DOaLkxgaCReGIg2ktN2ZfyiXfSQAQzfpSU0WwC1G5hxYpfQpa1HR9MJmQ4l2cn/XyvTG WqjQ== X-Gm-Message-State: AOAM533HidWK0EAvTYf6MzegQgEjXHueJHKMMhw0C+RhDlRcG9bHTNRr RQ4sCGpwzGWVQS3onu79nXbkYdnMQmmFmQ== X-Google-Smtp-Source: ABdhPJxVEGVDIYMCWDv/jI0j9PHqrZZVAaBwU09bl5gdNZ5UX5C9BDoC8SDNudI2U3hzaJ41m+FXaw== X-Received: by 2002:a05:6512:acd:: with SMTP id n13mr14617608lfu.247.1633356726402; Mon, 04 Oct 2021 07:12:06 -0700 (PDT) From: Oleksandr Andrushchenko To: xen-devel@lists.xenproject.org Cc: julien@xen.org, sstabellini@kernel.org, oleksandr_tyshchenko@epam.com, volodymyr_babchuk@epam.com, Artem_Mygaiev@epam.com, roger.pau@citrix.com, jbeulich@suse.com, andrew.cooper3@citrix.com, george.dunlap@citrix.com, paul@xen.org, bertrand.marquis@arm.com, rahul.singh@arm.com, Oleksandr Andrushchenko Subject: [PATCH v4 09/11] xen/arm: Setup MMIO range trap handlers for hardware domain Date: Mon, 4 Oct 2021 17:11:49 +0300 Message-Id: <20211004141151.132231-10-andr2000@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211004141151.132231-1-andr2000@gmail.com> References: <20211004141151.132231-1-andr2000@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1633357072357100001 Content-Type: text/plain; charset="utf-8" From: Oleksandr Andrushchenko In order for vPCI to work it needs to maintain guest and hardware domain's views of the configuration space. For example, BARs and COMMAND registers require emulation for guests and the guest view of the registers needs to be in sync with the real contents of the relevant registers. For that ECAM address space needs to also be trapped for the hardware domain, so we need to implement PCI host bridge specific callbacks to properly setup MMIO handlers for those ranges depending on particular host bridge implementation. Signed-off-by: Oleksandr Andrushchenko Reviewed-by: Stefano Stabellini Reviewed-by: Rahul Singh Tested-by: Rahul Singh --- Since v3: - fixed comment formatting Since v2: - removed unneeded assignment (count =3D 0) - removed unneeded header inclusion - update commit message Since v1: - Dynamically calculate the number of MMIO handlers required for vPCI and update the total number accordingly - s/clb/cb - Do not introduce a new callback for MMIO handler setup --- xen/arch/arm/domain.c | 2 ++ xen/arch/arm/pci/pci-host-common.c | 28 ++++++++++++++++++++++++ xen/arch/arm/vpci.c | 34 ++++++++++++++++++++++++++++++ xen/arch/arm/vpci.h | 6 ++++++ xen/include/asm-arm/pci.h | 5 +++++ 5 files changed, 75 insertions(+) diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c index 79012bf77757..fa6fcc5e467c 100644 --- a/xen/arch/arm/domain.c +++ b/xen/arch/arm/domain.c @@ -733,6 +733,8 @@ int arch_domain_create(struct domain *d, if ( (rc =3D domain_vgic_register(d, &count)) !=3D 0 ) goto fail; =20 + count +=3D domain_vpci_get_num_mmio_handlers(d); + if ( (rc =3D domain_io_init(d, count + MAX_IO_HANDLER)) !=3D 0 ) goto fail; =20 diff --git a/xen/arch/arm/pci/pci-host-common.c b/xen/arch/arm/pci/pci-host= -common.c index 592c01aae5bb..1eb4daa87365 100644 --- a/xen/arch/arm/pci/pci-host-common.c +++ b/xen/arch/arm/pci/pci-host-common.c @@ -292,6 +292,34 @@ struct dt_device_node *pci_find_host_bridge_node(struc= t device *dev) } return bridge->dt_node; } + +int pci_host_iterate_bridges(struct domain *d, + int (*cb)(struct domain *d, + struct pci_host_bridge *bridge)) +{ + struct pci_host_bridge *bridge; + int err; + + list_for_each_entry( bridge, &pci_host_bridges, node ) + { + err =3D cb(d, bridge); + if ( err ) + return err; + } + return 0; +} + +int pci_host_get_num_bridges(void) +{ + struct pci_host_bridge *bridge; + int count =3D 0; + + list_for_each_entry( bridge, &pci_host_bridges, node ) + count++; + + return count; +} + /* * Local variables: * mode: C diff --git a/xen/arch/arm/vpci.c b/xen/arch/arm/vpci.c index 76c12b92814f..6e179cd3010b 100644 --- a/xen/arch/arm/vpci.c +++ b/xen/arch/arm/vpci.c @@ -80,17 +80,51 @@ static const struct mmio_handler_ops vpci_mmio_handler = =3D { .write =3D vpci_mmio_write, }; =20 +static int vpci_setup_mmio_handler(struct domain *d, + struct pci_host_bridge *bridge) +{ + struct pci_config_window *cfg =3D bridge->cfg; + + register_mmio_handler(d, &vpci_mmio_handler, + cfg->phys_addr, cfg->size, NULL); + return 0; +} + int domain_vpci_init(struct domain *d) { if ( !has_vpci(d) ) return 0; =20 + if ( is_hardware_domain(d) ) + return pci_host_iterate_bridges(d, vpci_setup_mmio_handler); + + /* Guest domains use what is programmed in their device tree. */ register_mmio_handler(d, &vpci_mmio_handler, GUEST_VPCI_ECAM_BASE, GUEST_VPCI_ECAM_SIZE, NULL= ); =20 return 0; } =20 +int domain_vpci_get_num_mmio_handlers(struct domain *d) +{ + int count; + + if ( is_hardware_domain(d) ) + /* For each PCI host bridge's configuration space. */ + count =3D pci_host_get_num_bridges(); + else + /* + * VPCI_MSIX_MEM_NUM handlers for MSI-X tables per each PCI device + * being passed through. Maximum number of supported devices + * is 32 as virtual bus topology emulates the devices as embedded + * endpoints. + * +1 for a single emulated host bridge's configuration space. + */ + count =3D VPCI_MSIX_MEM_NUM * 32 + 1; + + return count; +} + /* * Local variables: * mode: C diff --git a/xen/arch/arm/vpci.h b/xen/arch/arm/vpci.h index d8a7b0e3e802..27a2b069abd2 100644 --- a/xen/arch/arm/vpci.h +++ b/xen/arch/arm/vpci.h @@ -17,11 +17,17 @@ =20 #ifdef CONFIG_HAS_VPCI int domain_vpci_init(struct domain *d); +int domain_vpci_get_num_mmio_handlers(struct domain *d); #else static inline int domain_vpci_init(struct domain *d) { return 0; } + +static inline int domain_vpci_get_num_mmio_handlers(struct domain *d) +{ + return 0; +} #endif =20 #endif /* __ARCH_ARM_VPCI_H__ */ diff --git a/xen/include/asm-arm/pci.h b/xen/include/asm-arm/pci.h index ea87ec6006fc..a62d8bc60086 100644 --- a/xen/include/asm-arm/pci.h +++ b/xen/include/asm-arm/pci.h @@ -108,6 +108,11 @@ static always_inline bool is_pci_passthrough_enabled(v= oid) =20 void arch_pci_init_pdev(struct pci_dev *pdev); =20 +int pci_host_iterate_bridges(struct domain *d, + int (*clb)(struct domain *d, + struct pci_host_bridge *bridge)); +int pci_host_get_num_bridges(void); + #else /*!CONFIG_HAS_PCI*/ =20 struct arch_pci_dev { }; --=20 2.25.1 From nobody Thu Apr 25 03:41:31 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; dkim=pass; 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=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1633357064; cv=none; d=zohomail.com; s=zohoarc; b=QYDbf1kmdy2iK41EKeoO4jBrofjjNs8Vmf8mDqYt+7Mto6k32Q3NAqWn6xVwDgu/hp2qMvM0NeBoHW39wiffPNZTOTcv95J8NTEEktbh17YfWUetw2ADqoO3dLUhe0yeW/p33ZE+9r883ccKRXSiG3IIO95gwrHfNvqjpgKh8AY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1633357064; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=zoz1k75+2CYj6hEa3rYdIM6cYztNjgw6hV+gMEf3DZ0=; b=K69jE3KvIdsPsa1owhhypg6pdlqFMamcRQt2MrxaW6KG+SxR46OCyu2dbnt0tnedHyEQzPVTG2T+eDnzWh4MGdkBVbySYa0xMizgbyiMstLY/V6HrActsNNANxaIsiH1kb55vnzOvN7QqjJY6sgTRWoZYP21ZUEBft/kOVyTeEI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1633357064231386.8032514808782; Mon, 4 Oct 2021 07:17:44 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.201511.356070 (Exim 4.92) (envelope-from ) id 1mXOmR-0005uX-6H; Mon, 04 Oct 2021 14:17:23 +0000 Received: by outflank-mailman (output) from mailman id 201511.356070; Mon, 04 Oct 2021 14:17:23 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mXOmR-0005uO-1O; Mon, 04 Oct 2021 14:17:23 +0000 Received: by outflank-mailman (input) for mailman id 201511; Mon, 04 Oct 2021 14:17:21 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mXOiA-0008QG-En for xen-devel@lists.xenproject.org; Mon, 04 Oct 2021 14:12:58 +0000 Received: from mail-lf1-x132.google.com (unknown [2a00:1450:4864:20::132]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 4bf38a16-77d4-4f1a-ab9a-067fdb94d0a6; Mon, 04 Oct 2021 14:12:11 +0000 (UTC) Received: by mail-lf1-x132.google.com with SMTP id x27so72247055lfu.5 for ; Mon, 04 Oct 2021 07:12:10 -0700 (PDT) Received: from localhost.localdomain (host-176-36-245-220.b024.la.net.ua. [176.36.245.220]) by smtp.gmail.com with ESMTPSA id n12sm1076809lfe.145.2021.10.04.07.12.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Oct 2021 07:12:07 -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: 4bf38a16-77d4-4f1a-ab9a-067fdb94d0a6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=zoz1k75+2CYj6hEa3rYdIM6cYztNjgw6hV+gMEf3DZ0=; b=BDtgP8HFUjTqP7ZCzOT6MCtyPD//wmbU4pPY/JP0l0aURIKImh8Jx6oxinnj7KcCm2 U1ZvAuOs6MWxz/Lw7idNx5QkHRdahJcUVQl6/y1tzx7TgyFIzENYl0TG1EjNl2LYSOiB RF0bn1A7j60tDQ5B/Oa+muir6Rmc+rtqA0Zn8R4Z8ILqiZ5vl5kglDGzajKu8R0Q3P8V d1AV3PZIF5KivLcMyG4TwCZN3egJ4b3YSsUwvrZevhlS7yH1vTRZMNCS43fhcpkw52dr cWN9UQzZG9b2pkN6/qaFLqDDHVrsKPnbx9ADuBP2BU2kPCUAAUrLCYEiFoJOYEV3mE/H WJEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=zoz1k75+2CYj6hEa3rYdIM6cYztNjgw6hV+gMEf3DZ0=; b=tZ+l6inPXJTHXK6pe1SWYxV0WHfIuIUhrCTqPL0/8cS7sr1zJhVFKv4ln9Va3wV2XT Dhq1GmVMIvnGbQqrBIMztcbWm8oT2KvNTL9ApdEjhHHTPMVfFo0Zyx7eAjapsv52p72t SMEyJTDmvzOkx7anSG8kFPNgwM7p4agmKU+wTW38X9T5ewE4oFXOWoeWUsC+2P1dfmeL 7MExs7KtMrrKSZ/Xja9GSz4AKqBtimQvc065CoyAgomzNURZSl9JiKg+5m572zFWTPUU RteO7/ng2gLXEqhle8LorQk59HQqHwAID/NeSVchIklFwSzU8JQ8CJRsWUxI9l6x9IkP sP/g== X-Gm-Message-State: AOAM533sbsJJD/9tnEbcMHvlVKgwypnVRRlmaRnEnmJsBKzySccHA3Ii FIiwCHunDZX5FWZHr5Jyi6gPephQTbtclA== X-Google-Smtp-Source: ABdhPJyOEdsyl3+0ouniYrimebBFO5KD+mDsA2TST5Lp3VkTQZjVgrKjs5/mxecpwSrSR76K0Fbdbw== X-Received: by 2002:a05:6512:118a:: with SMTP id g10mr14437388lfr.580.1633356727740; Mon, 04 Oct 2021 07:12:07 -0700 (PDT) From: Oleksandr Andrushchenko To: xen-devel@lists.xenproject.org Cc: julien@xen.org, sstabellini@kernel.org, oleksandr_tyshchenko@epam.com, volodymyr_babchuk@epam.com, Artem_Mygaiev@epam.com, roger.pau@citrix.com, jbeulich@suse.com, andrew.cooper3@citrix.com, george.dunlap@citrix.com, paul@xen.org, bertrand.marquis@arm.com, rahul.singh@arm.com, Oleksandr Andrushchenko Subject: [PATCH v4 10/11] xen/arm: Do not map PCI ECAM and MMIO space to Domain-0's p2m Date: Mon, 4 Oct 2021 17:11:50 +0300 Message-Id: <20211004141151.132231-11-andr2000@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211004141151.132231-1-andr2000@gmail.com> References: <20211004141151.132231-1-andr2000@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1633357064951100001 Content-Type: text/plain; charset="utf-8" From: Oleksandr Andrushchenko PCI host bridges are special devices in terms of implementing PCI passthrough. According to [1] the current implementation depends on Domain-0 to perform the initialization of the relevant PCI host bridge hardware and perform PCI device enumeration. In order to achieve that one of the required changes is to not map all the memory ranges in map_range_to_domain as we traverse the device tree on startup and perform some additional checks if the range needs to be mapped to Domain-0. The generic PCI host controller device tree binding says [2]: - ranges: As described in IEEE Std 1275-1994, but must provide at least a definition of non-prefetchable memory. One or both of prefetchable Memory and IO Space may also be provided. - reg : The Configuration Space base address and size, as accessed from the parent bus. The base address corresponds to the first bus in the "bus-range" property. If no "bus-range" is specified, this will be bus 0 (the default). From the above none of the memory ranges from the "ranges" property needs to be mapped to Domain-0 at startup as MMIO mapping is going to be handled dynamically by vPCI as we assign PCI devices, e.g. each device assigned to Domain-0/guest will have its MMIOs mapped/unmapped as needed by Xen. The "reg" property covers not only ECAM space, but may also have other then the configuration memory ranges described, for example [3]: - reg: Should contain rc_dbi, config registers location and length. - reg-names: Must include the following entries: "rc_dbi": controller configuration registers; "config": PCIe configuration space registers. This patch makes it possible to not map all the ranges from the "ranges" property and also ECAM from the "reg". All the rest from the "reg" property still needs to be mapped to Domain-0, so the PCI host bridge remains functional in Domain-0. [1] https://lists.xenproject.org/archives/html/xen-devel/2020-07/msg00777.h= tml [2] https://www.kernel.org/doc/Documentation/devicetree/bindings/pci/host-g= eneric-pci.txt [3] https://www.kernel.org/doc/Documentation/devicetree/bindings/pci/hisili= con-pcie.txt Signed-off-by: Oleksandr Andrushchenko --- Since v3: - pass struct map_range_data to map_dt_irq_to_domain - remove redundant check from map_range_to_domain - fix handle_device's .skip_mapping Since v2: - removed check in map_range_to_domain for PCI_DEV and moved it to handle_device, so the code is simpler - s/map_pci_bridge/skip_mapping - extended comment in pci_host_bridge_mappings - minor code restructure in construct_dom0 - s/.need_p2m_mapping/.need_p2m_hwdom_mapping and related callbacks - unsigned int i; in pci_host_bridge_mappings Since v1: - Added better description of why and what needs to be mapped into Domain-0's p2m and what doesn't - Do not do any mappings for PCI devices while traversing the DT - Walk all the bridges and make required mappings in one go --- xen/arch/arm/domain_build.c | 50 ++++++++++++++++-------------- xen/arch/arm/pci/ecam.c | 14 +++++++++ xen/arch/arm/pci/pci-host-common.c | 49 +++++++++++++++++++++++++++++ xen/arch/arm/pci/pci-host-zynqmp.c | 1 + xen/include/asm-arm/pci.h | 10 ++++++ xen/include/asm-arm/setup.h | 13 ++++++++ 6 files changed, 114 insertions(+), 23 deletions(-) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index 8739e3285ef4..2a3c641476bd 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -10,7 +10,6 @@ #include #include #include -#include #include #include #include @@ -51,12 +50,6 @@ static int __init parse_dom0_mem(const char *s) } custom_param("dom0_mem", parse_dom0_mem); =20 -struct map_range_data -{ - struct domain *d; - p2m_type_t p2mt; -}; - /* Override macros from asm/page.h to make them work with mfn_t */ #undef virt_to_mfn #define virt_to_mfn(va) _mfn(__virt_to_mfn(va)) @@ -1641,10 +1634,11 @@ static int __init map_dt_irq_to_domain(const struct= dt_device_node *dev, const struct dt_irq *dt_irq, void *data) { - struct domain *d =3D data; + struct map_range_data *mr_data =3D data; + struct domain *d =3D mr_data->d; unsigned int irq =3D dt_irq->irq; int res; - bool need_mapping =3D !dt_device_for_passthrough(dev); + bool need_mapping =3D !mr_data->skip_mapping; =20 if ( irq < NR_LOCAL_IRQS ) { @@ -1668,13 +1662,12 @@ static int __init map_dt_irq_to_domain(const struct= dt_device_node *dev, return 0; } =20 -static int __init map_range_to_domain(const struct dt_device_node *dev, - u64 addr, u64 len, - void *data) +int __init map_range_to_domain(const struct dt_device_node *dev, + u64 addr, u64 len, void *data) { struct map_range_data *mr_data =3D data; struct domain *d =3D mr_data->d; - bool need_mapping =3D !dt_device_for_passthrough(dev); + bool need_mapping =3D !mr_data->skip_mapping; int res; =20 /* @@ -1726,23 +1719,21 @@ static int __init map_range_to_domain(const struct = dt_device_node *dev, * then we may need to perform additional mappings in order to make * the child resources available to domain 0. */ -static int __init map_device_children(struct domain *d, - const struct dt_device_node *dev, - p2m_type_t p2mt) +static int __init map_device_children(const struct dt_device_node *dev, + struct map_range_data *mr_data) { - struct map_range_data mr_data =3D { .d =3D d, .p2mt =3D p2mt }; - int ret; - if ( dt_device_type_is_equal(dev, "pci") ) { + int ret; + dt_dprintk("Mapping children of %s to guest\n", dt_node_full_name(dev)); =20 - ret =3D dt_for_each_irq_map(dev, &map_dt_irq_to_domain, d); + ret =3D dt_for_each_irq_map(dev, &map_dt_irq_to_domain, mr_data); if ( ret < 0 ) return ret; =20 - ret =3D dt_for_each_range(dev, &map_range_to_domain, &mr_data); + ret =3D dt_for_each_range(dev, &map_range_to_domain, mr_data); if ( ret < 0 ) return ret; } @@ -1823,6 +1814,13 @@ static int __init handle_device(struct domain *d, st= ruct dt_device_node *dev, int res; u64 addr, size; bool need_mapping =3D !dt_device_for_passthrough(dev); + struct map_range_data mr_data =3D { + .d =3D d, + .p2mt =3D p2mt, + .skip_mapping =3D !need_mapping || + (is_pci_passthrough_enabled() && + (device_get_class(dev) =3D=3D DEVICE_PCI)) + }; =20 naddr =3D dt_number_of_address(dev); =20 @@ -1862,7 +1860,6 @@ static int __init handle_device(struct domain *d, str= uct dt_device_node *dev, /* Give permission and map MMIOs */ for ( i =3D 0; i < naddr; i++ ) { - struct map_range_data mr_data =3D { .d =3D d, .p2mt =3D p2mt }; res =3D dt_device_get_address(dev, i, &addr, &size); if ( res ) { @@ -1876,7 +1873,7 @@ static int __init handle_device(struct domain *d, str= uct dt_device_node *dev, return res; } =20 - res =3D map_device_children(d, dev, p2mt); + res =3D map_device_children(dev, &mr_data); if ( res ) return res; =20 @@ -3034,7 +3031,14 @@ static int __init construct_dom0(struct domain *d) return rc; =20 if ( acpi_disabled ) + { rc =3D prepare_dtb_hwdom(d, &kinfo); + if ( rc < 0 ) + return rc; +#ifdef CONFIG_HAS_PCI + rc =3D pci_host_bridge_mappings(d, p2m_mmio_direct_c); +#endif + } else rc =3D prepare_acpi(d, &kinfo); =20 diff --git a/xen/arch/arm/pci/ecam.c b/xen/arch/arm/pci/ecam.c index 602d00799c8d..b81620074a91 100644 --- a/xen/arch/arm/pci/ecam.c +++ b/xen/arch/arm/pci/ecam.c @@ -40,6 +40,19 @@ void __iomem *pci_ecam_map_bus(struct pci_host_bridge *b= ridge, return base + (PCI_DEVFN2(sbdf.bdf) << devfn_shift) + where; } =20 +bool pci_ecam_need_p2m_hwdom_mapping(struct domain *d, + struct pci_host_bridge *bridge, + uint64_t addr) +{ + struct pci_config_window *cfg =3D bridge->cfg; + + /* + * We do not want ECAM address space to be mapped in Domain-0's p2m, + * so we can trap access to it. + */ + return cfg->phys_addr !=3D addr; +} + /* ECAM ops */ const struct pci_ecam_ops pci_generic_ecam_ops =3D { .bus_shift =3D 20, @@ -47,6 +60,7 @@ const struct pci_ecam_ops pci_generic_ecam_ops =3D { .map_bus =3D pci_ecam_map_bus, .read =3D pci_generic_config_read, .write =3D pci_generic_config_write, + .need_p2m_hwdom_mapping =3D pci_ecam_need_p2m_hwdom_mapping, } }; =20 diff --git a/xen/arch/arm/pci/pci-host-common.c b/xen/arch/arm/pci/pci-host= -common.c index 1eb4daa87365..085f08e23e0c 100644 --- a/xen/arch/arm/pci/pci-host-common.c +++ b/xen/arch/arm/pci/pci-host-common.c @@ -18,6 +18,7 @@ =20 #include #include +#include #include #include #include @@ -320,6 +321,54 @@ int pci_host_get_num_bridges(void) return count; } =20 +int __init pci_host_bridge_mappings(struct domain *d, p2m_type_t p2mt) +{ + struct pci_host_bridge *bridge; + struct map_range_data mr_data =3D { + .d =3D d, + .p2mt =3D p2mt, + .skip_mapping =3D false + }; + + /* + * For each PCI host bridge we need to only map those ranges + * which are used by Domain-0 to properly initialize the bridge, + * e.g. we do not want to map ECAM configuration space which lives in + * "reg" or "assigned-addresses" device tree property, but we want to + * map other regions of the host bridge. The PCI aperture defined by + * the "ranges" device tree property should also be skipped. + */ + list_for_each_entry( bridge, &pci_host_bridges, node ) + { + const struct dt_device_node *dev =3D bridge->dt_node; + unsigned int i; + + for ( i =3D 0; i < dt_number_of_address(dev); i++ ) + { + uint64_t addr, size; + int err; + + err =3D dt_device_get_address(dev, i, &addr, &size); + if ( err ) + { + printk(XENLOG_ERR + "Unable to retrieve address range index=3D%u for %s= \n", + i, dt_node_full_name(dev)); + return err; + } + + if ( bridge->ops->need_p2m_hwdom_mapping(d, bridge, addr) ) + { + err =3D map_range_to_domain(dev, addr, size, &mr_data); + if ( err ) + return err; + } + } + } + + return 0; +} + /* * Local variables: * mode: C diff --git a/xen/arch/arm/pci/pci-host-zynqmp.c b/xen/arch/arm/pci/pci-host= -zynqmp.c index 61a9807d3d58..6ad2b31e810d 100644 --- a/xen/arch/arm/pci/pci-host-zynqmp.c +++ b/xen/arch/arm/pci/pci-host-zynqmp.c @@ -34,6 +34,7 @@ const struct pci_ecam_ops nwl_pcie_ops =3D { .map_bus =3D pci_ecam_map_bus, .read =3D pci_generic_config_read, .write =3D pci_generic_config_write, + .need_p2m_hwdom_mapping =3D pci_ecam_need_p2m_hwdom_mapping, } }; =20 diff --git a/xen/include/asm-arm/pci.h b/xen/include/asm-arm/pci.h index a62d8bc60086..d9a3c2a4f3b3 100644 --- a/xen/include/asm-arm/pci.h +++ b/xen/include/asm-arm/pci.h @@ -17,6 +17,8 @@ =20 #ifdef CONFIG_HAS_PCI =20 +#include + #define pci_to_dev(pcidev) (&(pcidev)->arch.dev) =20 extern bool_t pci_passthrough_enabled; @@ -73,6 +75,9 @@ struct pci_ops { uint32_t reg, uint32_t len, uint32_t *value); int (*write)(struct pci_host_bridge *bridge, pci_sbdf_t sbdf, uint32_t reg, uint32_t len, uint32_t value); + bool (*need_p2m_hwdom_mapping)(struct domain *d, + struct pci_host_bridge *bridge, + uint64_t addr); }; =20 /* @@ -96,6 +101,9 @@ int pci_generic_config_write(struct pci_host_bridge *bri= dge, pci_sbdf_t sbdf, uint32_t reg, uint32_t len, uint32_t value); void __iomem *pci_ecam_map_bus(struct pci_host_bridge *bridge, pci_sbdf_t sbdf, uint32_t where); +bool pci_ecam_need_p2m_hwdom_mapping(struct domain *d, + struct pci_host_bridge *bridge, + uint64_t addr); struct pci_host_bridge *pci_find_host_bridge(uint16_t segment, uint8_t bus= ); int pci_get_host_bridge_segment(const struct dt_device_node *node, uint16_t *segment); @@ -113,6 +121,8 @@ int pci_host_iterate_bridges(struct domain *d, struct pci_host_bridge *bridge)); int pci_host_get_num_bridges(void); =20 +int pci_host_bridge_mappings(struct domain *d, p2m_type_t p2mt); + #else /*!CONFIG_HAS_PCI*/ =20 struct arch_pci_dev { }; diff --git a/xen/include/asm-arm/setup.h b/xen/include/asm-arm/setup.h index 95da0b7ab9cd..5b30135fda38 100644 --- a/xen/include/asm-arm/setup.h +++ b/xen/include/asm-arm/setup.h @@ -2,6 +2,8 @@ #define __ARM_SETUP_H_ =20 #include +#include +#include =20 #define MIN_FDT_ALIGN 8 #define MAX_FDT_SIZE SZ_2M @@ -77,6 +79,14 @@ struct bootinfo { #endif }; =20 +struct map_range_data +{ + struct domain *d; + p2m_type_t p2mt; + /* Set if mappings for PCI host bridges must not be skipped. */ + bool skip_mapping; +}; + extern struct bootinfo bootinfo; =20 extern domid_t max_init_domid; @@ -124,6 +134,9 @@ void device_tree_get_reg(const __be32 **cell, u32 addre= ss_cells, u32 device_tree_get_u32(const void *fdt, int node, const char *prop_name, u32 dflt); =20 +int map_range_to_domain(const struct dt_device_node *dev, + u64 addr, u64 len, void *data); + #endif /* * Local variables: --=20 2.25.1 From nobody Thu Apr 25 03:41:31 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; dkim=pass; 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=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1633357048; cv=none; d=zohomail.com; s=zohoarc; b=S3ar6APNMJc/WALqCL4KgM3uPeQFWWDOy5g+vEVMbXYbI0O4OUwkFIIDELHAdOBTxh3NLKMKuuEkzSB7loaHLb3b62IfPYbfGygRW8Aft8b+jQ+Gc1N86lgMtTbLpWMZU67YGVnrPXa/i/2FapzPBI6NyM+QJ4t+iLleTWeAKg0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1633357048; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Mt9OWBAhbT//DIBCaDBPG1KX4to8WfBEU/gi6Ti13xs=; b=dcgR5R6zNwYjIdz8C7hKJIQZniaE8B452G57zwvE4o4Ek8eCpm3VdyrD1X9pe449LcMBUl9C8Sje5FfdJ66ecSTNHjlU8MLYlvYcbT1dpEGJqLGf+f2Zo/w7PuiBq5iqzS6ZJ6eGz5vQTkwVcHdyPXrTiuSNgsgYRj20fYey4/Q= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1633357048735127.68582993255836; Mon, 4 Oct 2021 07:17:28 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.201509.356059 (Exim 4.92) (envelope-from ) id 1mXOmG-0005ZI-Rw; Mon, 04 Oct 2021 14:17:12 +0000 Received: by outflank-mailman (output) from mailman id 201509.356059; Mon, 04 Oct 2021 14:17:12 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mXOmG-0005ZB-P2; Mon, 04 Oct 2021 14:17:12 +0000 Received: by outflank-mailman (input) for mailman id 201509; Mon, 04 Oct 2021 14:17:11 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mXOiP-0008QG-F1 for xen-devel@lists.xenproject.org; Mon, 04 Oct 2021 14:13:13 +0000 Received: from mail-lf1-x12f.google.com (unknown [2a00:1450:4864:20::12f]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id e6cbbff4-ca33-483a-85a9-6b924cb03d70; Mon, 04 Oct 2021 14:12:17 +0000 (UTC) Received: by mail-lf1-x12f.google.com with SMTP id m3so71516962lfu.2 for ; Mon, 04 Oct 2021 07:12:17 -0700 (PDT) Received: from localhost.localdomain (host-176-36-245-220.b024.la.net.ua. [176.36.245.220]) by smtp.gmail.com with ESMTPSA id n12sm1076809lfe.145.2021.10.04.07.12.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Oct 2021 07:12:08 -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: e6cbbff4-ca33-483a-85a9-6b924cb03d70 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Mt9OWBAhbT//DIBCaDBPG1KX4to8WfBEU/gi6Ti13xs=; b=Zo/VaiBmlmMtZhzxzoT0AEknQqXI/pGqOzRD37w9kRaNWip0ilJ9I+DTC3inQe6gVQ ydV9F4HqQ30/x1fOg98A3JjKM2O7FrIkUAeD0wv5cZMB/ImlkT+BAuVcfbhCWxl2DFAY HxBGYFA2Qn7ny2406U5W8QCXYG/Shb4sBOY1NB/7pEYErmiOf8F63oJ2QdUJTGGcaDam tEEIvpAZrj3RSEnuuqJuiyECYW0wKCvtxOcFj8dt7vMkPGPWp4uI91oB3PDW0TwvkD8x fMcLaTDHUaFOT+zEjPEa4d9OZZ7HmD/VlTn4vRmYfwOqH2iA52GAsuRGi1iu/m182ufW EASA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Mt9OWBAhbT//DIBCaDBPG1KX4to8WfBEU/gi6Ti13xs=; b=PyLJwHno8xFfiRGzx+Z/ZDFc6oRzLDEdHMPuyl8ftnCMpLrELoQvuWIA0A+NWwb8gV 1Y0etFCsTV1iGCcJpQ3UqveTpiCCNHtjoY3vM3Vri+GeAXdSinkwf/et/cM7v0hqLsym 4QiDpBdPSt/M1nVMm6IBWZfJkCSTvDb5/+BDgu9jOGzXi/TzR0rvsNzweSCSsHbOIemB dpL/cIQZWV5AZEv8ORZxqqY3N2q+G+fadR3UYeOqZJnZqXExW0U6GBogVxknIEDF6RGB h5oLPhNSk3LzjdNM1W0L9OizOJgAPdlzeLN8RuNKeDE4h3qk/oNfRpcwDDvLMiL9R52h xOag== X-Gm-Message-State: AOAM53095FaXYS/wQR5EUVDu5dSqB6jAbajQGQx36EaPNg5y50ZdAeVy F0lzb3SPjm92sSs56rQO6Si/IXOIBBrlOA== X-Google-Smtp-Source: ABdhPJzVgJE4NpanPPuA1m9xh0vQ+K01UWveq9p7UsP19uF85d6cp+WkxfT9exshD+EyIpsPzcM74A== X-Received: by 2002:ac2:5c51:: with SMTP id s17mr7230247lfp.32.1633356728996; Mon, 04 Oct 2021 07:12:08 -0700 (PDT) From: Oleksandr Andrushchenko To: xen-devel@lists.xenproject.org Cc: julien@xen.org, sstabellini@kernel.org, oleksandr_tyshchenko@epam.com, volodymyr_babchuk@epam.com, Artem_Mygaiev@epam.com, roger.pau@citrix.com, jbeulich@suse.com, andrew.cooper3@citrix.com, george.dunlap@citrix.com, paul@xen.org, bertrand.marquis@arm.com, rahul.singh@arm.com, Oleksandr Andrushchenko Subject: [PATCH v4 11/11] xen/arm: Process pending vPCI map/unmap operations Date: Mon, 4 Oct 2021 17:11:51 +0300 Message-Id: <20211004141151.132231-12-andr2000@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211004141151.132231-1-andr2000@gmail.com> References: <20211004141151.132231-1-andr2000@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1633357049733100001 Content-Type: text/plain; charset="utf-8" From: Oleksandr Andrushchenko vPCI may map and unmap PCI device memory (BARs) being passed through which may take a lot of time. For this those operations may be deferred to be performed later, so that they can be safely preempted. Currently this deferred processing is happening in common IOREQ code which doesn't seem to be the right place for x86 and is even more doubtful because IOREQ may not be enabled for Arm at all. So, for Arm the pending vPCI work may have no chance to be executed if the processing is left as is in the common IOREQ code only. For that reason make vPCI processing happen in arch specific code. Please be aware that there are a few outstanding TODOs affecting this code path, see xen/drivers/vpci/header.c:map_range and xen/drivers/vpci/header.c:vpci_process_pending. Cc: Andrew Cooper Cc: Paul Durrant Signed-off-by: Oleksandr Andrushchenko [x86 changes] Acked-by: Jan Beulich Reviewed-by: Stefano Stabellini Reviewed-by: Rahul Singh Tested-by: Rahul Singh --- Since v2: - update commit message with more insight on x86, IOREQ and Arm - restored order of invocation for IOREQ and vPCI processing (Jan) Since v1: - Moved the check for pending vpci work from the common IOREQ code to hvm_do_resume on x86 - Re-worked the code for Arm to ensure we don't miss pending vPCI work --- xen/arch/arm/traps.c | 13 +++++++++++++ xen/arch/x86/hvm/hvm.c | 6 ++++++ xen/common/ioreq.c | 9 --------- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c index 219ab3c3fbde..b246f51086e3 100644 --- a/xen/arch/arm/traps.c +++ b/xen/arch/arm/traps.c @@ -34,6 +34,7 @@ #include #include #include +#include =20 #include #include @@ -2304,6 +2305,18 @@ static bool check_for_vcpu_work(void) } #endif =20 + if ( has_vpci(v->domain) ) + { + bool pending; + + local_irq_enable(); + pending =3D vpci_process_pending(v); + local_irq_disable(); + + if ( pending ) + return true; + } + if ( likely(!v->arch.need_flush_to_ram) ) return false; =20 diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c index aa418a3ca1b7..c491242e4b8b 100644 --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -546,6 +546,12 @@ void hvm_do_resume(struct vcpu *v) =20 pt_restore_timer(v); =20 + if ( has_vpci(v->domain) && vpci_process_pending(v) ) + { + raise_softirq(SCHEDULE_SOFTIRQ); + return; + } + if ( !vcpu_ioreq_handle_completion(v) ) return; =20 diff --git a/xen/common/ioreq.c b/xen/common/ioreq.c index d732dc045df9..689d256544c8 100644 --- a/xen/common/ioreq.c +++ b/xen/common/ioreq.c @@ -25,9 +25,7 @@ #include #include #include -#include #include -#include =20 #include #include @@ -212,19 +210,12 @@ static bool wait_for_io(struct ioreq_vcpu *sv, ioreq_= t *p) =20 bool vcpu_ioreq_handle_completion(struct vcpu *v) { - struct domain *d =3D v->domain; struct vcpu_io *vio =3D &v->io; struct ioreq_server *s; struct ioreq_vcpu *sv; enum vio_completion completion; bool res =3D true; =20 - if ( has_vpci(d) && vpci_process_pending(v) ) - { - raise_softirq(SCHEDULE_SOFTIRQ); - return false; - } - while ( (sv =3D get_pending_vcpu(v, &s)) !=3D NULL ) if ( !wait_for_io(sv, get_ioreq(s, v)) ) return false; --=20 2.25.1