From nobody Fri Nov 29 16:36:00 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=1632986030; cv=none; d=zohomail.com; s=zohoarc; b=lPbCDmwdBbcUwz5bMaZOxL83c2fUl/wEwTRZ0A1NmfaO0BqOnI6/WXUWHxNpLRVqXkI+cwUBU6TxKsx3iG4Hu61QqYWZ1RZ58TRC7YYQJ8V03+diSKNZIRJH4GJ2n6wf/o1eYBTwqpb4HEio5Zp4Fpskpb5vb6FuH41QBe7sg9U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1632986030; 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=XoFIgZVIb/mldOPu/YrxQoS5INXvifmOyWrKqRo2fLsN+x1vtVRJqXOk37XJ2eLTLegigWGSmZYNF94NG3+iIW3Er1Ub6Jyl83467xrieR+69aoU91mi4KNefziMn0uXIcAqqS36fwbioQaDwyQraSHJH3kCWBAZUqzswsye2/0= 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 1632986029842444.09757130311584; Thu, 30 Sep 2021 00:13:49 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.199394.353427 (Exim 4.92) (envelope-from ) id 1mVqG8-0004Uk-KL; Thu, 30 Sep 2021 07:13:36 +0000 Received: by outflank-mailman (output) from mailman id 199394.353427; Thu, 30 Sep 2021 07:13:36 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mVqG8-0004Ud-HA; Thu, 30 Sep 2021 07:13:36 +0000 Received: by outflank-mailman (input) for mailman id 199394; Thu, 30 Sep 2021 07:13:35 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mVqG7-0004B3-9N for xen-devel@lists.xenproject.org; Thu, 30 Sep 2021 07:13:35 +0000 Received: from mail-lf1-x129.google.com (unknown [2a00:1450:4864:20::129]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id f515294a-3ed3-4353-bcc5-859044fbd7cf; Thu, 30 Sep 2021 07:13:30 +0000 (UTC) Received: by mail-lf1-x129.google.com with SMTP id y26so21268579lfa.11 for ; Thu, 30 Sep 2021 00:13:30 -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 y3sm267835lfh.132.2021.09.30.00.13.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Sep 2021 00:13:28 -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: f515294a-3ed3-4353-bcc5-859044fbd7cf 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=Z9yyFXZsdmLsyD6irTOnBZJ4a2peO0DlcILrViPlOtCLbHHHPBQvfm+XXagPHBIesr /pMhLzjvAAIanKEVPa8Nq6293vtqZeg+RlKdHr7BiqpGn0SkK482Hgfb/0zRUBhEM4Aq Z/uWQEElIz3RBoFJ7n7ofrKD6c4WI6kQFEvukBKkEyhhvJxTadzdB1iprMtH4BC65DgT HyhURu3MK0YDM/lJBSpXuiD4mh1zxkztDBY4QCzblQdW+WCFuChcPQfIOq8sWMerf3oH vGX5MGSvIxz8vjzHuhIcTZJbKsrTlROnMMmB6uSVl7imLVoAZZMh8CzzJa9BVJG+JCbo qcoA== 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=zF/JAyoV7Bu9psGwPnOyO2q9IucMUm18En0TvcneoT2oaEn6Ujs8/xAlFmE6RMY85N r0ZYnswjcxR6cz/YgPR6wz6yrAk/cmRRr35aN78uRHChK6d5m8RRJTFkYH7+yCnBthNA UrjGj9mwtl1Xz3B2s9tfhXRO5WfWTJL0aIOlN1pMJx/XI5oov1jMz9fj6C4SkaFUbgHi 9a6NEN2H11v7FjX1AFe2j+REgpYPlgLs0y/XJ2JbOsf7ap3SUiw2g3+S6QJ5mENy7NSs bnbKw/Ukrji8/ESwicbnz1eih4GjkBcQ00+F236KLuc24uTjaTtfKlYS+/xA3oJKEvZu wgGA== X-Gm-Message-State: AOAM532lnOumxz99bkfRp102hznTPgEuAzcEQk8ia+uTJMjMboGgPaaS 31jvtXDCfbChItrJLQqSxFNkhKvgDaY= X-Google-Smtp-Source: ABdhPJxz3EzEY2bcM09sXyYuyw/lkXDJlm3JlawU2ox4wsarBkIa6FBNzfi8GwOhhMMM4VKX3TL9JA== X-Received: by 2002:a2e:9591:: with SMTP id w17mr4250036ljh.40.1632986008850; Thu, 30 Sep 2021 00:13:28 -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, bertrand.marquis@arm.com, rahul.singh@arm.com, Oleksandr Andrushchenko , Michal Orzel Subject: [PATCH v3 01/11] xen/arm: Fix dev_is_dt macro definition Date: Thu, 30 Sep 2021 10:13:16 +0300 Message-Id: <20210930071326.857390-2-andr2000@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210930071326.857390-1-andr2000@gmail.com> References: <20210930071326.857390-1-andr2000@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1632986030549100003 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 Fri Nov 29 16:36:00 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=1632986034; cv=none; d=zohomail.com; s=zohoarc; b=Wlbw6BIEOFaj/58NJncxC+bV3etUOv993nb/24uar+H303AilDHeK038JdCw9CHScnMgl2WNOFa0Jr/K3KfRiIt837C0KseKtHwUjo984KIZofGUKgAWf0rIcHutGmgzKe0CRnEg+lrpNP8XP7iXs1V9ylZYIB8l0a1OkLx5mnI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1632986034; 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=IQOqq0vw5ObAcax4b2zzMkwlZl3+eElA9Can/zWllgQ=; b=Za1Vsvm22mSQ2gDoJIqEpTMn7SxSBcva8iPKLB2ctxlime1oaUuJ8Pezy+qAAOPGYkHUgTmD3KJJso8r8jLHXApb8UwT03KIg8gm5Hu9xD+hF1Vf7xKME00pDoOs2Y9E8qw2syLqGBsUwVrRsyo/jPDffk4NHKfZT2/Q2bhGIiM= 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 1632986034212147.1842116941641; Thu, 30 Sep 2021 00:13:54 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.199395.353438 (Exim 4.92) (envelope-from ) id 1mVqGC-0004pG-VO; Thu, 30 Sep 2021 07:13:40 +0000 Received: by outflank-mailman (output) from mailman id 199395.353438; Thu, 30 Sep 2021 07:13:40 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mVqGC-0004p9-QA; Thu, 30 Sep 2021 07:13:40 +0000 Received: by outflank-mailman (input) for mailman id 199395; Thu, 30 Sep 2021 07:13:40 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mVqGC-0004B3-9X for xen-devel@lists.xenproject.org; Thu, 30 Sep 2021 07:13:40 +0000 Received: from mail-lf1-x12e.google.com (unknown [2a00:1450:4864:20::12e]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 345376d7-90bf-4731-be1f-4e150d108e43; Thu, 30 Sep 2021 07:13:31 +0000 (UTC) Received: by mail-lf1-x12e.google.com with SMTP id b15so21120329lfe.7 for ; Thu, 30 Sep 2021 00:13:30 -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 y3sm267835lfh.132.2021.09.30.00.13.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Sep 2021 00:13:29 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 345376d7-90bf-4731-be1f-4e150d108e43 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=IQOqq0vw5ObAcax4b2zzMkwlZl3+eElA9Can/zWllgQ=; b=brzQZIxPuUAGA3eUAp2p9S981LqvoqpmB6dwDkdSo9Kf3r52uaiKUKcScK3jLExAy8 xndRqxG+TGKHKvETguZ94WipFL+oPPSt6C2e7P0IaL/+/l4GUSRPt+wL7KnAYm9vhPxm aG4/3SkDXTINYSHVBLyPRqzBSnxaay4EEvfO/JlFttZlrB5g4H5I6Aa7c8tEPajhVdFD cTppFYUIGzf5uEjXhSlfRP3y71vRKIXyZO+KqjU0SeLdBhHguE5HPsjMdqkvzuUNj5Va lztysJxyr4t5Yb+UBMmlUDJbO/fY2EtKIo8aug7l8baAIPLnRfOfFkVHOTYckBIJZGyv KHdA== 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=IQOqq0vw5ObAcax4b2zzMkwlZl3+eElA9Can/zWllgQ=; b=LArj/pXZv7Crm6lUmXPmSWJ+JurAQqkh/zVy4EZY0KoWgwKad8fkZ3V317obfDRi5q KRxT1VFyupGZtZFoA6T28PseDe93C322NgVAha7Mc6NGcubSk+4M+v+jNTKgwMCDFVpp /GWEATKOWJg8w3mnjkaZ80sn1W+ajtem43y/+DoZHZke87XbVJKyd7DPAKBgrVlL5/Za GbXKeYirTzpf1vHB4OWNVoXy+iTEyFgh77wFJ9gV+QHwFfGRjVYSndtkmSghftE8PtSu CYrCmpky5vRPvYB7uNDINc2k+PjdGi1iabD9iLRMHJcs4aMv37PxlWvcgkikIhu+3sKo IADg== X-Gm-Message-State: AOAM532DXHY16qfx9rtBPYD4rpuaBdaec3Aadswe0MG3v4vupnAHS7xF ewfgW/F02aeNp62sYxr9+zw2WYb1KBc= X-Google-Smtp-Source: ABdhPJzyPgBi1m/E6vkHHJqtg/a9OyNjPIlynE53PEkapio7Yjdxyz7UXZ78Qo64Pb94Pvl771CKrw== X-Received: by 2002:a2e:5709:: with SMTP id l9mr4101790ljb.315.1632986009754; Thu, 30 Sep 2021 00:13:29 -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, bertrand.marquis@arm.com, rahul.singh@arm.com, Oleksandr Andrushchenko Subject: [PATCH v3 02/11] xen/arm: Add new device type for PCI Date: Thu, 30 Sep 2021 10:13:17 +0300 Message-Id: <20210930071326.857390-3-andr2000@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210930071326.857390-1-andr2000@gmail.com> References: <20210930071326.857390-1-andr2000@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1632986035091100001 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 --- 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 84d8f0d63430..9fc522e566a9 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 Fri Nov 29 16:36:00 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=1632986041; cv=none; d=zohomail.com; s=zohoarc; b=YIq09JwZn+0xYtDsA+c2AlY2PdFM2yR5x0X5Z1d8KEGgsnyCWnGM3AHtdMrEVX+1siYg+CoGXkmjzdRUgCZz3D7mntVvryhWLnEj1ggfuxYi35A6BMYVv8h5V/gPpGNwn+hOf8JGkwMdp7Da5DbPuJ/stfQsz9BB0b2iP0DRJlA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1632986041; 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=paCjRVnjfgtH4vjqWfPka1UDhVQcLz7hY/mZa1EMk18=; b=irBTgwzl6aZobO3dlyRm3lClCa5r8WRaE1eK1ULZ1Mk9RU2CJtHdIB+vUF5ggPhaUB5unAV8VVAetFErufWOgcZ60OyzHnEAKYec0a6WjmfDBrM65CtSLvO/8VVrJWA+RigAgv8Tyovjf35JE/yf9tYzBUtX6zncRsGwZcwbqgg= 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 1632986041004848.9908204942237; Thu, 30 Sep 2021 00:14:01 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.199397.353449 (Exim 4.92) (envelope-from ) id 1mVqGI-0005H5-99; Thu, 30 Sep 2021 07:13:46 +0000 Received: by outflank-mailman (output) from mailman id 199397.353449; Thu, 30 Sep 2021 07:13:46 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mVqGI-0005Gv-3e; Thu, 30 Sep 2021 07:13:46 +0000 Received: by outflank-mailman (input) for mailman id 199397; Thu, 30 Sep 2021 07:13:45 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mVqGH-0004B3-9a for xen-devel@lists.xenproject.org; Thu, 30 Sep 2021 07:13:45 +0000 Received: from mail-lf1-x12d.google.com (unknown [2a00:1450:4864:20::12d]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id af20419a-75c2-4a4e-b952-e5462fa26285; Thu, 30 Sep 2021 07:13:31 +0000 (UTC) Received: by mail-lf1-x12d.google.com with SMTP id z24so21166047lfu.13 for ; Thu, 30 Sep 2021 00:13:31 -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 y3sm267835lfh.132.2021.09.30.00.13.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Sep 2021 00:13:30 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: af20419a-75c2-4a4e-b952-e5462fa26285 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=paCjRVnjfgtH4vjqWfPka1UDhVQcLz7hY/mZa1EMk18=; b=h7fp1+CvHJx6R/9JuM6y/TneeLsVMxymOjdZCMKjKOrN4f68MqO4HbcUGdUtFE++gN 2XyAxRyUDPqM2WAsPBcSbovRYUUP3VfVyo42DO9MNjkFAX/Jcs22p3gVh9CLEDRY4qNl ettiWdKMaAcojj9OQ74LO6KTfqw/atujdDB9A3dy1Qq4e77bWYkD2tSehTsOP3csmw/t 47NvVimcjUAslLm0SzErCZOOFj/TfvPWIy1EfVW+aXvOb+hyz0sQm56ATOLAvz1QTb5s oFbGiGwXtzSkQHssxqZpFA0jDvCU+mAKp7Gs9xIlHQSxuosfJl3Ro6b9l7IH9pqryUO3 3DjQ== 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=paCjRVnjfgtH4vjqWfPka1UDhVQcLz7hY/mZa1EMk18=; b=Snb1M8+6DlhIf3niQ4tJP+0WDsde2vnWeKB1GeW9nmBYaAzjtjwL/qeGEpr7sVnyhI Np0j95dCvHfou07Wrk1QIst9BbT0ogowG9WrA89YcigImcl1pm7QL5KcBIAazaawvhFU KQ98TpKOjtz9+wznLWkYZYeHsN6QWIYfD/8ItY8szJkSYItdpSy1v3e7CnficlpGoj1A 7SaXXFnfIhoakiPEscRNOTgsRPqTvRO2TduJ9olOFbk5VWXVlJcPJbkZ6Jel33CABfn9 bOR6ZTH1aR9cj+MOqNtZMeDJpvoMY/3TDTX1KxRI6K0K0qp+axFju3c/nRO/H7ayjYQB VW+w== X-Gm-Message-State: AOAM530rPsujvVe9lelfb8GZ9kTA0Ir9KZn1ASKkF9tBT43oyYgdnMI0 YzpKl3eDvOLBECBFdZf6ZOQYNBBYWj0= X-Google-Smtp-Source: ABdhPJzgK6zEPNoC1RoV6e4MX4dvw0DYh6rJCjA+Ht48/hAjTz1ybEuyJuIEVwZDhLE1L7NXtVbgsg== X-Received: by 2002:a2e:5354:: with SMTP id t20mr4195057ljd.204.1632986010685; Thu, 30 Sep 2021 00:13:30 -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, bertrand.marquis@arm.com, rahul.singh@arm.com, Oleksandr Andrushchenko Subject: [PATCH v3 03/11] xen/arm: Introduce pci_find_host_bridge_node helper Date: Thu, 30 Sep 2021 10:13:18 +0300 Message-Id: <20210930071326.857390-4-andr2000@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210930071326.857390-1-andr2000@gmail.com> References: <20210930071326.857390-1-andr2000@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1632986041525100001 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 --- 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 Fri Nov 29 16:36:00 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=1632986044; cv=none; d=zohomail.com; s=zohoarc; b=iXg9+LmJn2P2ApHG9XZ44RpI9qsezYG/qWVD50iSQl2CKJjBQsBXoFutqQieOUKGX7w0jiZoaYGsUuwe2R2GTvrfGl8+09p2gQMNKZo6rrbnUAb4l1uNWz8l6UPc5GWGJij47bad2Ec7o1Olvpy6DvPJTyD2JeZ+qOcBARcpbGM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1632986044; 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=nbYsEm17HqgJO5/cYWrIyFppqwBAbdSyuFUOH4VkNALvXzqbYtOIIX+kc0HzdZN8B+XA/i4aTEv8d4TZJmUUjrWmw+ss9EXuIfnC/5G9/hkTOFUfHd60NiFg+KN9hRpx4xIU2Xi8fwpZ4FyHEzAhERO7GelMhBnWeETdVAkuKeg= 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 1632986044193112.25704107618571; Thu, 30 Sep 2021 00:14:04 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.199399.353460 (Exim 4.92) (envelope-from ) id 1mVqGN-0005na-Gn; Thu, 30 Sep 2021 07:13:51 +0000 Received: by outflank-mailman (output) from mailman id 199399.353460; Thu, 30 Sep 2021 07:13:51 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mVqGN-0005nT-DG; Thu, 30 Sep 2021 07:13:51 +0000 Received: by outflank-mailman (input) for mailman id 199399; Thu, 30 Sep 2021 07:13:50 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mVqGM-0004B3-9m for xen-devel@lists.xenproject.org; Thu, 30 Sep 2021 07:13:50 +0000 Received: from mail-lf1-x12a.google.com (unknown [2a00:1450:4864:20::12a]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id fa0297e2-f1ca-4583-8ec1-5ceb5ab925c1; Thu, 30 Sep 2021 07:13:32 +0000 (UTC) Received: by mail-lf1-x12a.google.com with SMTP id g41so21251914lfv.1 for ; Thu, 30 Sep 2021 00:13:32 -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 y3sm267835lfh.132.2021.09.30.00.13.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Sep 2021 00:13:31 -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: fa0297e2-f1ca-4583-8ec1-5ceb5ab925c1 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=IbIUqXrhJTRPq6lhYGZqZrFXaKdmScTrbfzt7COuq+xkWXbioejqNA/Y81bZGni0mz 98aJ1/kDEQYY1t9G1uY4Vn/Mpm4lKTGKEyd0B1IJsN0oJcZ0n5KFDQSo68GdWPoSxQ65 L70hoLDq8j/gb+pmvkEe7e+xHxvf6sX/LsKV3cACJeJ/jjOQzJU+OoWYgn7xu8bLsB8N NjrMiJZ5t6oIU8CWOCFQkJIO0TbtO+dvxmZ3rVc7fX6m+1CZ5qdH8hVP01cZfQYvkld9 6wiJ9zs61SYCV8jFTtBCKU3PZ8eTqxcrIabpWKfr8eAD914vLrDflYY4GrW952B8nvZA IegA== 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=tz+x2rEDvWaXtWaXfA/vjCpyBXHzULcRQNLM2K2qwj0sNIUZW0NQVSd5FyveREU75U EWhV5lXJkJ618tqG/S1A2vkYgLCW2evxp56HDB7AvUy7Tug9nml4k+bkxR7KqBnGiDKm SNJ8yfufL922bDQGLdC3XB8M8bAL02DnspgoV0dUfRSBL5M+WMFN+J/NlItIN1pm3JO7 rPDs8b2zGzYtc7X81+jqgMM+ubrzK4w8iFVmisl3TWDAb91wqBdf30nPvW7KnUm5f2rh rANh1yDCag338Ko19ZY35+mWKZ2zcuPcy2rxITE8uxavL1NAGQBPH+yII/0lFe1yHG17 rg8w== X-Gm-Message-State: AOAM5326USpvQscraBt7p88QsFsv1LBjBv1zhpneSQ1R7c6DYIzHxdns IC5Nki+uaA2gDmyphM0NbNb0TiqRb6M= X-Google-Smtp-Source: ABdhPJwauDS6x9R7+bWvRGCmKDDA9RWkLxAH63+3ofu4OaajWPa6y1TqRujWamY2ecr6eMk5JJHDuA== X-Received: by 2002:a2e:974b:: with SMTP id f11mr4336756ljj.385.1632986011655; Thu, 30 Sep 2021 00:13:31 -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, bertrand.marquis@arm.com, rahul.singh@arm.com, Oleksandr Andrushchenko Subject: [PATCH v3 04/11] xen/device-tree: Make dt_find_node_by_phandle global Date: Thu, 30 Sep 2021 10:13:19 +0300 Message-Id: <20210930071326.857390-5-andr2000@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210930071326.857390-1-andr2000@gmail.com> References: <20210930071326.857390-1-andr2000@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1632986045684100001 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 --- 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 Fri Nov 29 16:36:00 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=1632986053; cv=none; d=zohomail.com; s=zohoarc; b=fHDBAeJEpzGc2eqgMu55+bXRDgxvpnm3LcKQaHFR91/By0MfpO63hnGyju/XUzWrLPId1ouPwYNf/9/Tqku7gi/xJOUizQRpRBPJN2XXaCEvyr+D0A8JYxgTp4bSKh+P2/2wiZoyIq7uJu1XTm/uwKAyxlJyFR+PiQQ8nnw1l90= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1632986053; 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=hrW151Pn3PyP3za7zVLCbht2FcxzTewAzo6dwWGEqVU=; b=UPQ8xMCIDQSwMnhDHoc0sjEnqVeKmV7/fiCFLnghyHFDKh2r0kyy4aB6UPehCuwRGDrPmoHM7VVpe7cA7ySN+z6abhKhjWNIQK/0rCdI69mgf20t9fPLUA5Z0jEWIP06N7ziS+vWq9ysoswRKM/cB9xtUYQmKUYdLa2u+GAFQ48= 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 163298605370764.38944729552213; Thu, 30 Sep 2021 00:14:13 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.199403.353471 (Exim 4.92) (envelope-from ) id 1mVqGS-0006Fa-Pg; Thu, 30 Sep 2021 07:13:56 +0000 Received: by outflank-mailman (output) from mailman id 199403.353471; Thu, 30 Sep 2021 07:13:56 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mVqGS-0006FJ-Lx; Thu, 30 Sep 2021 07:13:56 +0000 Received: by outflank-mailman (input) for mailman id 199403; Thu, 30 Sep 2021 07:13:55 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mVqGR-0004B3-A1 for xen-devel@lists.xenproject.org; Thu, 30 Sep 2021 07:13:55 +0000 Received: from mail-lf1-x131.google.com (unknown [2a00:1450:4864:20::131]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 217905a7-2aad-4d67-baac-a2ec09057c84; Thu, 30 Sep 2021 07:13:33 +0000 (UTC) Received: by mail-lf1-x131.google.com with SMTP id y26so21269232lfa.11 for ; Thu, 30 Sep 2021 00:13:33 -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 y3sm267835lfh.132.2021.09.30.00.13.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Sep 2021 00:13:32 -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: 217905a7-2aad-4d67-baac-a2ec09057c84 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=hrW151Pn3PyP3za7zVLCbht2FcxzTewAzo6dwWGEqVU=; b=KyfuI8SonaSWtz6zuzp494aO7A2NeB2DFx5t5TBA7HLhBzmr0zEhamJF8rtXINz02Z g7xwVq2gx1xENguCWdaZgT02OwqEMKR2hAYJyR5m7BAD4TdoQyQ0IHW7QyeFrniw9C+L JgjGmpfvodDgYdTg4KrllQ5NlrOlx3qJmPCcyo0Kd1NEvdetdWK4lpllURpPP5K776wD vWo/Yf6W6UHHyTFrlXrB773n5JK+LZchpgueXLVT1EFMqt6C8zBntZDl/osxmcjNtbv4 weFFl2qpX6aHOjjd2FZ7RIB8UblXwgA6GqOoCQxmm/AiwlMhgia0q9IEWQucM35t3ZgG WejA== 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=hrW151Pn3PyP3za7zVLCbht2FcxzTewAzo6dwWGEqVU=; b=JViZynxMC0BTguzu8kV5IGAWamnM+x1n6tDMZzziKKX0oZh54twgo/QMf47j2G7maJ f8D8jWXtV0mndVWn6crjMPZDnd9K9Q8YE2WZPpmHqyNY/TzmmUbXUM8Pyo1GywQBvVtY tFf9NjEsfkwqlN/wObcOeDCwRUHK70ONAui/afSBpVN10kSDh/v+b3FftOwttPonNwIp azPnrDRHuLUm6XMgfIcpT+XfFQq/fe4MikizVVScvgK/jraF4f3tSGCz7ZxlIkdvAf/r VPMNkncdMkMkvWEwJKFnxGyM7gjHPUcfLdIxvH0EzppxgzTOcXLd7WfpzC7XaTY1hTtk jgrg== X-Gm-Message-State: AOAM531SqzYXEIdByPbVtxNE93/K5U9xgUJEWUAbNOdo2ieSBPGtyA1W pVgEOPhogo/01silz1c2+3RQoBpWRfg= X-Google-Smtp-Source: ABdhPJzt9ZlZEBCnM5k9rLLU/Zi6Qrtzj23d7bzRA4B8Hmo0JcAyQKiyusR2vxgD//ruRm6yTB+myQ== X-Received: by 2002:a2e:9410:: with SMTP id i16mr4390219ljh.134.1632986012562; Thu, 30 Sep 2021 00:13:32 -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, bertrand.marquis@arm.com, rahul.singh@arm.com, Oleksandr Andrushchenko Subject: [PATCH v3 05/11] xen/arm: Mark device as PCI while creating one Date: Thu, 30 Sep 2021 10:13:20 +0300 Message-Id: <20210930071326.857390-6-andr2000@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210930071326.857390-1-andr2000@gmail.com> References: <20210930071326.857390-1-andr2000@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1632986054613100002 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. Signed-off-by: Oleksandr Andrushchenko Acked-by: Jan Beulich --- 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 | 5 +++++ xen/include/asm-x86/pci.h | 2 ++ 4 files changed, 14 insertions(+) diff --git a/xen/arch/arm/pci/pci.c b/xen/arch/arm/pci/pci.c index 9fc522e566a9..a8d10e869603 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 38eb451448a3..9f804a50e780 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..566a9436a18e 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,7 @@ static inline int pci_get_host_bridge_segment(const str= uct dt_device_node *node, return -EINVAL; } =20 +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 61b940c91d4a..e7f10beb4eb8 100644 --- a/xen/include/asm-x86/pci.h +++ b/xen/include/asm-x86/pci.h @@ -38,4 +38,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 Fri Nov 29 16:36:00 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=1632986053; cv=none; d=zohomail.com; s=zohoarc; b=ghNmnZuGP+RcpnaFtM1Vu8peRkm4GbY/eLKsQ2FQgOobaQxs4OhtaXMwdhcWiNfaiAjX+5cw9ZBOljDIlujJKgJJvL2NTQ3cukF0uffpOppKmq3Ggn1CF8TRe5TMlKS3AcmfjLpFreOBoRV9HLvx2kf9jUzCDy/go4g2e5H/Lbs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1632986053; 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=ZagcYa4i7qSFN7/sZKUizl6CWwdpWxvzMqyJb7seEOLRbLodRW3+PBgDDSWjfwoVKbT7O2dAB6cgZYRhcUsKjtRa6zrHdfeY62TJueOsd9Qj1++4wxSM9TYpwhdpfV0OaNVwBLFddio9N3uEQQ1Y4qVuT98znksI0y6Tgy44RHc= 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 16329860537421019.236245537363; Thu, 30 Sep 2021 00:14:13 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.199405.353481 (Exim 4.92) (envelope-from ) id 1mVqGX-0006mR-9Z; Thu, 30 Sep 2021 07:14:01 +0000 Received: by outflank-mailman (output) from mailman id 199405.353481; Thu, 30 Sep 2021 07:14:01 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mVqGX-0006mD-61; Thu, 30 Sep 2021 07:14:01 +0000 Received: by outflank-mailman (input) for mailman id 199405; Thu, 30 Sep 2021 07:14:00 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mVqGW-0004B3-A0 for xen-devel@lists.xenproject.org; Thu, 30 Sep 2021 07:14:00 +0000 Received: from mail-lf1-x129.google.com (unknown [2a00:1450:4864:20::129]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id fd2f18fa-4e3d-477f-b7ea-6800107a4ee7; Thu, 30 Sep 2021 07:13:34 +0000 (UTC) Received: by mail-lf1-x129.google.com with SMTP id b20so21448376lfv.3 for ; Thu, 30 Sep 2021 00:13:34 -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 y3sm267835lfh.132.2021.09.30.00.13.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Sep 2021 00:13:33 -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: fd2f18fa-4e3d-477f-b7ea-6800107a4ee7 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=fE5/IjUDjo4l107VbJ4aqktSyFzd7iAjLsxvokbkRHyLo4sKvfQL4RQpibEt36GD28 4C6KrzW4Q8H4zCYcaEyMQYWNKFUaB/2kZi9MAWp2Q3qzzg+UCq/5rWPHvhvpcQ9/etwK CkKOm1FYGwihWockE7SHYnX3bdl7BG2uN+Or25KDZzJcvSLaqOBRjGdm09nXqFIN0Gkn LOCPa24WrPp0twSwtoraG/DDudssRsvSI3T1XzByPAoff5lcqX25ey1HogZNmgZ53fAO neyW7FovDTbbLvFWucFJ74aD+gu1bdgd5/qTW3PMuIvnqzAormQOEIvOu4pbeYDAWOUf UvtQ== 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=rWOf1NzpFS0eyKDFQ9QoaWlPFI2nwaOoU+iu7Lzo4YfX9GvnBnOx9KZ7YTvYKlaT2c M9Aafjm+kksGK2VGP+n++KP5Gdl4UvgBTYMyyEhLlati2GNcVCpThk4XUbKU9U6C5xkI 7ZgRJnayZfHFIHz3KrPKo9+Wc4ThVrTGcLPZoHOobv/SpurE7uuUy9AWPQdZiwfXObyb tcCylXn8iIoSwhAP5dSwfJzWm7cmCoT1aEhEEVinbbbDHXBSxVbUYvy7wLRkgukvTupq JbMcnbmvbnU8FiX3didYjPxySRKbomhFneSmHKf/m88I368ZyJQLAnZGVd/S7mRfJEOL 2RGg== X-Gm-Message-State: AOAM530rwyOl/nUbhnNNnu60tiMWOL8Cldeh6G06J13z4EWzhWotOzEH 1031yPR0AO4Es7EKjgpNAO4DCqsjBVo= X-Google-Smtp-Source: ABdhPJz3/MVKmhM5NSLFMJHtFSPfgOVqhklIHuHK5sSHXtiDLFtawOUTyUxTLRQNQ4StGxtpEF7bfg== X-Received: by 2002:ac2:50d1:: with SMTP id h17mr4320299lfm.212.1632986013540; Thu, 30 Sep 2021 00:13:33 -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, bertrand.marquis@arm.com, rahul.singh@arm.com, Oleksandr Andrushchenko Subject: [PATCH v3 06/11] xen/domain: Call pci_release_devices() when releasing domain resources Date: Thu, 30 Sep 2021 10:13:21 +0300 Message-Id: <20210930071326.857390-7-andr2000@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210930071326.857390-1-andr2000@gmail.com> References: <20210930071326.857390-1-andr2000@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1632986054608100001 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 --- 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 Fri Nov 29 16:36:00 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=1632986059; cv=none; d=zohomail.com; s=zohoarc; b=T23LGZCl4qBKZyFygSuk9VlNK2POxHCH68cyRkDV+3IFrGjrGdR/SIFHAtz4D678zaSZPcLusUUJmwwVSnS26O9x++IsLGx+rz4Nrk+1dkyXqv78NrBvBIpPWzfvW8vnSq3o8yJRMcIpvKEhYH43rSzA6ja6vstakG85DppPTq0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1632986059; 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=kD50gSwDk757eJ2CQu1b9/IhYMvfHenQQYtu99uRv54=; b=LIZQ5oZ/Xtfc6dmbvPbczDe7uL5ZeVUCFQrmzCdKhVggB4+eNdtz54unKOLHXfDgilJ0D9aaJsHpKokPPZcZw+9yzA/A2qJnYR9vbcAPSNFgA03DPAC2oJWS8PnNiFK8mgxlb311PIf4bUawvQzj4sGHCcStK/ubDqphnc+GPPM= 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 1632986059319195.06846607119337; Thu, 30 Sep 2021 00:14:19 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.199409.353493 (Exim 4.92) (envelope-from ) id 1mVqGc-0007FS-L9; Thu, 30 Sep 2021 07:14:06 +0000 Received: by outflank-mailman (output) from mailman id 199409.353493; Thu, 30 Sep 2021 07:14:06 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mVqGc-0007FC-HH; Thu, 30 Sep 2021 07:14:06 +0000 Received: by outflank-mailman (input) for mailman id 199409; Thu, 30 Sep 2021 07:14:05 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mVqGb-0004B3-AJ for xen-devel@lists.xenproject.org; Thu, 30 Sep 2021 07:14:05 +0000 Received: from mail-lf1-x135.google.com (unknown [2a00:1450:4864:20::135]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id d1ae476d-7a57-4cb3-97fd-038cc0246998; Thu, 30 Sep 2021 07:13:35 +0000 (UTC) Received: by mail-lf1-x135.google.com with SMTP id x27so21169465lfa.9 for ; Thu, 30 Sep 2021 00:13:35 -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 y3sm267835lfh.132.2021.09.30.00.13.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Sep 2021 00:13:34 -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: d1ae476d-7a57-4cb3-97fd-038cc0246998 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=kD50gSwDk757eJ2CQu1b9/IhYMvfHenQQYtu99uRv54=; b=FiQ0pvnKAQPmcXJwpGM/6RO4ozSTrcDZxYX1z5919gATo4P3P1EFGVZYDPBys8gdiE EWLY95k4AM5D6CpQHdaw0QMd+PUlp9+pj3TGfpPgcv3Fdo4y0lXHyg9DnV7qBTSW/x0f 3CiMwVJdQzHtxQHHeK8jtEVxEgrj5/RXegApxZfc84UlAgVWWL0hMhQyChFGUV5kmMtv pHM8xSFrotLYTq6YLyeQZlhn/CQ4ZZYL7mT3fHXBG8zi7HXBMSFPTeG5fzzXgGjc7hWL +xZmGUDnB9Le0mvIndlJEF7UOLeu0JCciIxHox1KZcmELzt5L1xesbt5SvTT7viC259m 1B8A== 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=kD50gSwDk757eJ2CQu1b9/IhYMvfHenQQYtu99uRv54=; b=26TCNL0p5uhGx75DlxgKlk243S35sGayyy+AiUx74dgHWA19puozOPcsOVv/zdOoLZ /kby0Gaqc3gCMVINhc68gmHQNmWh3veGJjEekiWWSTaANooo+6a4oRJHCZVLkLgGAsDZ EZpSWKMWdAuybBZTrVjQ6yRFN28q+itNNEt5gX+eHnCMsjrBv8PhqD/NgN+QaQRB2htv aXfn9E532CpeWFmOqVIXARQzjlQJ2OlFhI+/DSoxjpBS2nbuTpS6WMBZ1UVqgh8KWRDH bH90mGVS7p3hMyZuJMXEMqqTCDmLj0E8COqyta5kMG4LIi8ZXyZ8XzCX7p/tvUthuXQ4 9hjw== X-Gm-Message-State: AOAM5333rBkZFn+TsgfoqJ4cv61IWBoDDlbsunaoXIFMchPqN6S1rGuA Ah0jHcH20FPSMVgf9dXlGfLhTCeueoE= X-Google-Smtp-Source: ABdhPJxK2IG4yCGDAvt+yiuT3W0VTju+UvV6mAq2t5rLimiqArg9MYluOZtC5rhtEqDjKIwfSmFz+Q== X-Received: by 2002:a2e:7311:: with SMTP id o17mr4344687ljc.488.1632986014658; Thu, 30 Sep 2021 00:13:34 -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, bertrand.marquis@arm.com, rahul.singh@arm.com, Oleksandr Andrushchenko , Ian Jackson , Juergen Gross Subject: [PATCH v3 07/11] libxl: Allow removing PCI devices for all types of domains Date: Thu, 30 Sep 2021 10:13:22 +0300 Message-Id: <20210930071326.857390-8-andr2000@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210930071326.857390-1-andr2000@gmail.com> References: <20210930071326.857390-1-andr2000@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1632986062026100001 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. Signed-off-by: Oleksandr Andrushchenko Cc: Ian Jackson Cc: Juergen Gross Acked-by: Stefano Stabellini --- 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 Fri Nov 29 16:36:00 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=1632986068; cv=none; d=zohomail.com; s=zohoarc; b=HusG9l7Ll0DWRnJ76bVzvgw27Bsij0hfAHbHqf4wEsHTIq4pABxJaGIOiTByHV3bge6uwmNvd6bDgLTIR19KYMrHjEPWS+sOlQbRlqnctNwJj6oGGE6ZLDCXWGb5wJDDjTEG6zQMem7apiFoFTSnsPCnJutLfS3rpKMspjsBVKo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1632986068; 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=7YmzvU66v4oKyYcFR8Qcx6xXzeJU6lQheixQJ2KXwag=; b=OkBMuGFq2onvFBNHfQww0cWkHG7MJsnJQmSAmxaBkIcrrMl9Z3cVOBOxyDHmgQgsH7TC6jQ9uJhK227pnboh5pgeh5X3dZoOXSLhN2tJKy9Ov7rbzYuBEmUdTWGvKVcUPWtj5UsBduosgK5R3PngXKOik72lJSY6KsbtSS7/60M= 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 1632986068911715.87947624705; Thu, 30 Sep 2021 00:14:28 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.199415.353504 (Exim 4.92) (envelope-from ) id 1mVqGm-00086w-Vq; Thu, 30 Sep 2021 07:14:16 +0000 Received: by outflank-mailman (output) from mailman id 199415.353504; Thu, 30 Sep 2021 07:14:16 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mVqGm-00086d-RW; Thu, 30 Sep 2021 07:14:16 +0000 Received: by outflank-mailman (input) for mailman id 199415; Thu, 30 Sep 2021 07:14:15 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mVqGl-0004B3-Ag for xen-devel@lists.xenproject.org; Thu, 30 Sep 2021 07:14:15 +0000 Received: from mail-lf1-x131.google.com (unknown [2a00:1450:4864:20::131]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 0e1c1189-8353-42d6-9b1f-c782ada7b6bb; Thu, 30 Sep 2021 07:13:37 +0000 (UTC) Received: by mail-lf1-x131.google.com with SMTP id m3so21062150lfu.2 for ; Thu, 30 Sep 2021 00:13:37 -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 y3sm267835lfh.132.2021.09.30.00.13.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Sep 2021 00:13:35 -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: 0e1c1189-8353-42d6-9b1f-c782ada7b6bb 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=7YmzvU66v4oKyYcFR8Qcx6xXzeJU6lQheixQJ2KXwag=; b=DPS9owDYe0SrU04Tkqz8pVBaOYEPDHe/1M9uoRWQbJ4fzwucCP0lzxCsleZaVXMjy2 WAonXBRY6B8YdoUTs5VRCU693cgFzaezS8q6briLup4Tj48PQI+K5skX5J/Sn1IsBGAX B00kUojW7vkP/GM6oOAnEKDYRBBHAdyhyExNEZMOc7yGGv5fpG+hhQo3kDVKFZ34xHj1 zb1lghVJEQP4z6hcLdv2twbzp3p8kPrBaM21XVA0M9ssRK8Zx44U9CwQ3UnGokchlGoH 2JSCe/e7pa2XJiVkco+vYBV4jDN6BEzfKTaBhoqkw7Kycb+jNR4b/Mw0US0jMKqTbIP1 KZ5g== 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=7YmzvU66v4oKyYcFR8Qcx6xXzeJU6lQheixQJ2KXwag=; b=W+95KdK3XgJ+sOU8ZXvH/DfRHOpT82Tb80wyTTr3IQ2KY9AlKtRaVUCKj8RS7/3fK+ 2mqlXGFm1m2YPcBppJoORNAclg/MFcNjwiERMvYRf1TjZid1EF+DLEQKf3e4kT9OrnrY 9DxAr0mMR56PkGstjjiKyFrlvZ2E9tp3S04EXXzyyNU1kpqSyywg/XUP9HfJ/u2MW3rb ep/fMd5VOilQFJfFAbt5FzfSxe5Iaf/mroBgmBcpHWlfIRJgGV1hL7kDgQLqKMyUBKiO /H8Wu6xZmDcZbFkoSx71Es3Wbv010lXBjV5ZAnybF7iZeCVvo5qAMdLG35uA9bf3Sp8x i/mg== X-Gm-Message-State: AOAM531YneY5DMo3Dzpchm5MUC5wHjGi8oncqYEpirWTrhlS9Zp7LL27 Jhs5Nu3m3ap3kjiH76HHhpls8U4dR8Y= X-Google-Smtp-Source: ABdhPJzdNWHX6vLA3+VFvxgtFIgKFatKPLdNOnkIiZ8AUSDd7r1CIz1XOK8h44L41T5B42wSG7tgJQ== X-Received: by 2002:ac2:59c7:: with SMTP id x7mr4391563lfn.662.1632986015644; Thu, 30 Sep 2021 00:13:35 -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, bertrand.marquis@arm.com, rahul.singh@arm.com, Oleksandr Andrushchenko , Ian Jackson , Juergen Gross Subject: [PATCH v3 08/11] libxl: Only map legacy PCI IRQs if they are supported Date: Thu, 30 Sep 2021 10:13:23 +0300 Message-Id: <20210930071326.857390-9-andr2000@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210930071326.857390-1-andr2000@gmail.com> References: <20210930071326.857390-1-andr2000@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1632986070036100001 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. Signed-off-by: Oleksandr Andrushchenko Cc: Ian Jackson Cc: Juergen Gross Reviewed-by: Stefano Stabellini --- 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 Fri Nov 29 16:36:00 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=1632986246; cv=none; d=zohomail.com; s=zohoarc; b=l8TvNMmIrluMN/ZToLdkEKQpM+OdxQ79MXZ3gSP0HLkSWWEBsH6KbKX2PjKNDRckzDXtIw1lFLttT430StPvYBdEML8e7omNtxOx5HoziqB9dBlg2/kJNbfLNAFcPEx99HEMkweT6GRBKiofnZtFnW/Pa8aZCj3puiuZ67NmF8g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1632986246; 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=ed0cb37zU/24QxEPfk3Zh0UOvwcZKTudBJfaTlZ2/uM=; b=Hs0jwrQe7+AnEoYzZ5KAgFzi3I4fEXi76WR9hsLqDuLuTHd8G+sQHK5Muiy+FaY/NQLedxPOkMN8tMPrx7XrRfdtPxBqrCfNhYDtje9A4cP5vloIplwSLLMu8N7HOO+fJUk8I/SzLKp7sgAG6j0eMYw+IdfnZyjKeVvGD6xAwAo= 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 1632986246797197.63139180175244; Thu, 30 Sep 2021 00:17:26 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.199441.353537 (Exim 4.92) (envelope-from ) id 1mVqJd-0001sK-4q; Thu, 30 Sep 2021 07:17:13 +0000 Received: by outflank-mailman (output) from mailman id 199441.353537; Thu, 30 Sep 2021 07:17:13 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mVqJd-0001s7-1W; Thu, 30 Sep 2021 07:17:13 +0000 Received: by outflank-mailman (input) for mailman id 199441; Thu, 30 Sep 2021 07: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 1mVqGq-0004B3-Ak for xen-devel@lists.xenproject.org; Thu, 30 Sep 2021 07:14:20 +0000 Received: from mail-lf1-x131.google.com (unknown [2a00:1450:4864:20::131]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 68e97808-1059-4749-9c40-e1fa980222f6; Thu, 30 Sep 2021 07:13:37 +0000 (UTC) Received: by mail-lf1-x131.google.com with SMTP id z24so21167038lfu.13 for ; Thu, 30 Sep 2021 00:13:37 -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 y3sm267835lfh.132.2021.09.30.00.13.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Sep 2021 00:13:36 -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: 68e97808-1059-4749-9c40-e1fa980222f6 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=ed0cb37zU/24QxEPfk3Zh0UOvwcZKTudBJfaTlZ2/uM=; b=HSe7JfAQdriC3ZOfjhvs1qHTJcCnMu5luam2DqethH9rst2ywFP4j5/KS/rE6tPfsC /9hXHbefKF40vX1HA9T5roPW8CTYykp093i//AZbnwYh75tzLf6iRhxI5DQQvyyb9VNY STaMAxJZlD8dtJUKCNPiG1zLg+SiQ9/bDO/6OCuDotfYs5kre+7ZP+9jeHKPqPJWb2EV ERcUbFEsA54oaWI9RPTSjugVcXnE6qIsNQXA+zBvYNvtBJa8qgqMSLsaNnBaRohugRdc wiS7jW66GBKPL0IBNav1MPBja4vX0/1X0PI99qEPzvWHRRlhrV8Kswzcig8IMnmGocoj 9k6A== 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=ed0cb37zU/24QxEPfk3Zh0UOvwcZKTudBJfaTlZ2/uM=; b=MzpeClWebIA3NSHxtUcC4cTz6Noz70eB+9Ez0MAuF4qCx7lJGPJ5sa3mCsOd0sAeDs ME61teX5w91qTOkZY3Jb9wfDqlhjA/RB7WGackASzyPpBH5TgN4ytB8PYkUlgeVA778w b9J6UWz3KbHsC0un4olzOgmmCsEWpGJpdLUvcFh8hiRkHICUOrQ+ad7FxKCcPE9OicWO lO41HfU5xbcGkAYsxgTznazWwgHu71pEc/a+mHi3Exzly+F9kw5PfOrFGARF6Uv14H83 HUuOJm0Ed97RMN03gfENJnnB+CfCagkSY4rbcqXj0zfoCO5k8qLC/XCJv8k3AvVFCEE7 6IeQ== X-Gm-Message-State: AOAM5312mryDk5ovubnxVuApDO4auDMysfHujui3+m+JAPka6RLu5VfF OHs9CDGBMcR76EshwH8HGBi13gNj5oY= X-Google-Smtp-Source: ABdhPJwVw+tTaWEnG4vCJ2L8eQD0NQFZzHaVSmlxZ4kRzOcOMsOqFQ/APk7egIw+0tz53PGxMYTINw== X-Received: by 2002:a19:8c0f:: with SMTP id o15mr4428022lfd.464.1632986016583; Thu, 30 Sep 2021 00:13:36 -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, bertrand.marquis@arm.com, rahul.singh@arm.com, Oleksandr Andrushchenko Subject: [PATCH v3 09/11] xen/arm: Setup MMIO range trap handlers for hardware domain Date: Thu, 30 Sep 2021 10:13:24 +0300 Message-Id: <20210930071326.857390-10-andr2000@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210930071326.857390-1-andr2000@gmail.com> References: <20210930071326.857390-1-andr2000@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1632986248038100001 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 --- 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 | 33 ++++++++++++++++++++++++++++++ xen/arch/arm/vpci.h | 6 ++++++ xen/include/asm-arm/pci.h | 5 +++++ 5 files changed, 74 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..5d6c29c8dcd9 100644 --- a/xen/arch/arm/vpci.c +++ b/xen/arch/arm/vpci.c @@ -80,17 +80,50 @@ 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 566a9436a18e..0d0266b13cba 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 Fri Nov 29 16:36:00 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=1632986244; cv=none; d=zohomail.com; s=zohoarc; b=jP8o/I2bOjC5K+8ZeGoNGHH8NJUc4oHxAIak1qjah2nfcyyYq60X2pC849extwR0TAV2BAzQ5eDmlUsEzNNfwLHkHFyrXlZV/EmGDgHMtxIub/xz4/kjhWIHXxqvCKu4XPRz6f4grefby8dhAHVQAm8fYVzQo3hOL6ZmnEJm+d0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1632986244; 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=ouh1MyH5wsYBFAWUFQt0I31bU+DCu59CTYrgPlr2Ams=; b=GNm+rlrpDinL+LCp/qebEELVZ3aXS4h69zcacVlz0kq3ec7Ft4v14WEQzkFuN82qcfiGqMWdU9NLlz8CrFL7SwRyCkkCdoLzlc72wu39qYNoArTtHbF3nf2m0WNDDoMLFEWrpaLUwojvlHxpkaZwcL8NGcJIzxQeXecdtjHDlSo= 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 1632986244633415.8946921119043; Thu, 30 Sep 2021 00:17:24 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.199432.353515 (Exim 4.92) (envelope-from ) id 1mVqJX-0001F6-FV; Thu, 30 Sep 2021 07:17:07 +0000 Received: by outflank-mailman (output) from mailman id 199432.353515; Thu, 30 Sep 2021 07:17:07 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mVqJX-0001Ez-CA; Thu, 30 Sep 2021 07:17:07 +0000 Received: by outflank-mailman (input) for mailman id 199432; Thu, 30 Sep 2021 07:17:06 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mVqGv-0004B3-B3 for xen-devel@lists.xenproject.org; Thu, 30 Sep 2021 07:14:25 +0000 Received: from mail-lf1-x12b.google.com (unknown [2a00:1450:4864:20::12b]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id f6020577-704f-4491-a844-1f63bf867f4d; Thu, 30 Sep 2021 07:13:39 +0000 (UTC) Received: by mail-lf1-x12b.google.com with SMTP id z24so21167246lfu.13 for ; Thu, 30 Sep 2021 00:13:38 -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 y3sm267835lfh.132.2021.09.30.00.13.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Sep 2021 00:13:37 -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: f6020577-704f-4491-a844-1f63bf867f4d 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=ouh1MyH5wsYBFAWUFQt0I31bU+DCu59CTYrgPlr2Ams=; b=VcKcE+jcaXiXp/2dpGdv+Mnjvwe6akCaqH0aUi5/stb0aVWw1j0V32hdsc4Kx0nxGv 62DR1w79fvwDnHtk0JE47EYTeZq3g1h0q0HvJIZ0Ik9HK78uN2qZyUwY4ytD8heJ2YEx wP5xoJIJDhCFDJRmSx9Dcvy5yQEAlyyPP6q+23O/aUX1nAQ9qDf4eFoYLUcIT4Abub4H XZjoBb/uRUwKVX0jIau1PZYaspx3EuupvknEJmVMu+y8hunNrTMFPMgDCOqd/hhnzNPu bSn7/9QiwKhjV4IZCwv1hoBxOmiW1MXaVhT3cWW1+zLcn9nqqXje9qg5DGX2W00/YKG+ Eymg== 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=ouh1MyH5wsYBFAWUFQt0I31bU+DCu59CTYrgPlr2Ams=; b=fbABh9ZRGMV/ogsvHHt1Gky+sKx5cEEQXKVF9uakeMkPCcbEDdfy4TDhWhX1IiLMsp a4Rj5I2oSj0eRuBDyhlf75GlBLdRb5o8rUsLir6kxypftjvUfdjMdagAZAGxNFxUU1c8 f8VuqxfRkYip9pDd82br0rGY+JQpLs2CWYhJyQkbCb1GB3gdtNZwTcC5U4lFOvsEhtuG /FMi0s+xQOixC7PIlrNOM8cBC/3QbPAWWZEkLTlY17CfSDC1mbRM3sdAoOvS/H+ah4B1 KV1gjKRDehHMhfKALBmdVUHGWEElGYbXeD06s6p6I5GSWamOIzr3B5gojadrb1sKeYk4 xzSQ== X-Gm-Message-State: AOAM533zsSGCVqD0EOW5zzB2wZCbP4SmkYZI5iQBNQiYZw8XmPVN1xwy U+6s+EV+dCV0Mx0OzELaLZoS40bukrQ= X-Google-Smtp-Source: ABdhPJzWPbyxltCvg1odF5xweKWtH4/vqqNiEOkxAEqP9mTxT1BkhSBqK9jNGwdY2GKSV3cBacklyw== X-Received: by 2002:a05:6512:2036:: with SMTP id s22mr4417721lfs.317.1632986017656; Thu, 30 Sep 2021 00:13:37 -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, bertrand.marquis@arm.com, rahul.singh@arm.com, Oleksandr Andrushchenko Subject: [PATCH v3 10/11] xen/arm: Do not map PCI ECAM and MMIO space to Domain-0's p2m Date: Thu, 30 Sep 2021 10:13:25 +0300 Message-Id: <20210930071326.857390-11-andr2000@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210930071326.857390-1-andr2000@gmail.com> References: <20210930071326.857390-1-andr2000@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1632986245827100002 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 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 | 45 ++++++++++++++------------- 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, 111 insertions(+), 21 deletions(-) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index 026c9e5c6cc4..ed46bcf8e7eb 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 @@ -47,12 +46,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)) @@ -1388,13 +1381,13 @@ 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 !dt_device_for_passthrough(dev) && + !mr_data->skip_mapping; int res; =20 /* @@ -1446,23 +1439,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->d= ); 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; } @@ -1543,6 +1534,12 @@ 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 is_pci_passthrough_enabled() && + (device_get_class(dev) =3D=3D DEVICE_PCI) + }; =20 naddr =3D dt_number_of_address(dev); =20 @@ -1582,7 +1579,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 ) { @@ -1596,7 +1592,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 @@ -2754,7 +2750,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 6ccbfd15c968..a57bf0fbc1cc 100644 --- a/xen/arch/arm/pci/pci-host-zynqmp.c +++ b/xen/arch/arm/pci/pci-host-zynqmp.c @@ -33,6 +33,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 0d0266b13cba..1bfba3da8f51 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 Fri Nov 29 16:36:00 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=1632986244; cv=none; d=zohomail.com; s=zohoarc; b=dRVgOxvidRl/tyqr6bMoomlV6O9T0edtPbi+g1eSxB5Dy/GPKSs8gQAhtepn70yPi4zBF6/zIb2PoWZKVaADcEXv+I+2FuoAR/1n3wpjRcerJZj4mL4OTBf8szjmGfMPJb8JC3Kwp+o/uGr0hv9OuoEl92HkybFz9J0ny2sFxzM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1632986244; 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=kkjiAREPfgf5h7Wy+LaOiO2DkflhH8+fOSmHBO3xXoo=; b=hsDTFViBAmYW0CKVzw2zqzepYPUJW0mfbJY3F7VF6eIy/iUcRiokSIesKZUYievCmpigpf4tninaX2QpsAAYnL20GvnlQiCfu4xwrvU/nTbE1OTXSlikYCoyTsmL2GvG+maf0NQiDqwYsLYT0LxfjzUMnIYoyHABbbCAN13/o9Q= 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 1632986244625907.983767014716; Thu, 30 Sep 2021 00:17:24 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.199438.353526 (Exim 4.92) (envelope-from ) id 1mVqJb-0001bA-Sf; Thu, 30 Sep 2021 07:17:11 +0000 Received: by outflank-mailman (output) from mailman id 199438.353526; Thu, 30 Sep 2021 07:17:11 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mVqJb-0001b1-OW; Thu, 30 Sep 2021 07:17:11 +0000 Received: by outflank-mailman (input) for mailman id 199438; Thu, 30 Sep 2021 07:17:10 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mVqH0-0004B3-BD for xen-devel@lists.xenproject.org; Thu, 30 Sep 2021 07:14:30 +0000 Received: from mail-lf1-x131.google.com (unknown [2a00:1450:4864:20::131]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 93ee8183-6f97-4d4d-abc4-45984e718a69; Thu, 30 Sep 2021 07:13:39 +0000 (UTC) Received: by mail-lf1-x131.google.com with SMTP id x27so21403290lfu.5 for ; Thu, 30 Sep 2021 00:13:39 -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 y3sm267835lfh.132.2021.09.30.00.13.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Sep 2021 00:13:38 -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: 93ee8183-6f97-4d4d-abc4-45984e718a69 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=kkjiAREPfgf5h7Wy+LaOiO2DkflhH8+fOSmHBO3xXoo=; b=n1p4J0xc5EcdU1E6lwrvdv3FPUzNKkurjTyMdCLcMChhvN3HWpV6H/wS+bys/5fzrD m8dZmv640qhzH1JBFUK/WGgaMIckyYxAD+g3zIu2xKQyrQ6pCqT6W8ih3CoiSrboZz0b BuiGlhmHlYc6MC2nXi8UUQAgUduMgeCQ7FjpbcBWUpb/pwp/tUl2PUg69rXnunj/9w42 a6TNcmIiSyeRw/3L8y+Fh3+DLPAuybhQxQFk4HprAGlLnzluUf+IIZ834a80OyD2AljH w1zmf87nMP4V4oflrC0O5vhbSKyhkasge0M1y838mvE1dTQIL00//cZaMAdbPoRAiiDu tOEQ== 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=kkjiAREPfgf5h7Wy+LaOiO2DkflhH8+fOSmHBO3xXoo=; b=Nj7IImJ7D5XRQgjdxfW7tORkBzP9oDr+ruaPtC+orOn0T4LVLFRpU5BkD3drI8Sg9z +91rJC8DG4RcZIqc/F1v1F4P2CCamv6pKFpWJAccXJBgisJ043LthFrfIuiJaeq6qTDS YZF7mWxJi3IR7KiIr+mnqk2IgK0hvYTNSOr33RU9vj5Pbg35wW5qsUv69EQSnrQDune/ ctbuhuX5JXurXRDwXYkZJHllxfrVnvrWpQV026ZzZC742ClZSay3HY5PHHsSR9Gr6xqq JlbHVVgS8i9J8ncWkLHn2UZJ3txfTweAjTHnbfeTSZldMMuwvBFJxhkTTdpK/k4sHNX6 GyEg== X-Gm-Message-State: AOAM532cerGvYL4CiOxxMSdXWz2TTt+2zd9eklDsPrWOjnJSNY5ZULnA 5KEorH1gCMClr5B7je85vhoWjNTtkqo= X-Google-Smtp-Source: ABdhPJyLQMp8dJHYSa+Pdww4/1nbcTrHpwgOpkBAqfeXXjEnwv9CdhpTtc4T4AAV0iwYluKZM/Jtlg== X-Received: by 2002:a2e:8e90:: with SMTP id z16mr4165430ljk.513.1632986018612; Thu, 30 Sep 2021 00:13:38 -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, bertrand.marquis@arm.com, rahul.singh@arm.com, Oleksandr Andrushchenko Subject: [PATCH v3 11/11] xen/arm: Process pending vPCI map/unmap operations Date: Thu, 30 Sep 2021 10:13:26 +0300 Message-Id: <20210930071326.857390-12-andr2000@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210930071326.857390-1-andr2000@gmail.com> References: <20210930071326.857390-1-andr2000@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1632986245792100001 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. Signed-off-by: Oleksandr Andrushchenko Acked-by: Jan Beulich Reviewed-by: Stefano Stabellini --- 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 7b48a1b925bb..38bf697c5b04 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