From patchwork Thu Sep 30 07:13:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksandr Andrushchenko X-Patchwork-Id: 12527495 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EA862C433EF for ; Thu, 30 Sep 2021 07:13:43 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B48716187A for ; Thu, 30 Sep 2021 07:13:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org B48716187A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.xenproject.org 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 X-Outflank-Mailman: Message body and most headers restored to incoming version 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-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 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; /* 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 == DEV_DT) +#define dev_is_dt(dev) ((dev)->type == DEV_DT) enum device_class { From patchwork Thu Sep 30 07:13:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksandr Andrushchenko X-Patchwork-Id: 12527497 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B24B0C433EF for ; Thu, 30 Sep 2021 07:13:49 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7958E61880 for ; Thu, 30 Sep 2021 07:13:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 7958E61880 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.xenproject.org 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 X-Outflank-Mailman: Message body and most headers restored to incoming version 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-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 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; } +struct pci_dev *dev_to_pci(struct device *dev) +{ + ASSERT(dev->type == 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, }; struct dev_archdata { @@ -25,8 +26,7 @@ typedef struct device device_t; #include -/* 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 == DEV_PCI) #define dev_is_dt(dev) ((dev)->type == DEV_DT) 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; }; +/* + * 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 { }; From patchwork Thu Sep 30 07:13:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksandr Andrushchenko X-Patchwork-Id: 12527499 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 07713C433F5 for ; Thu, 30 Sep 2021 07:13:54 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id BEFB06120D for ; Thu, 30 Sep 2021 07:13:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org BEFB06120D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.xenproject.org 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 X-Outflank-Mailman: Message body and most headers restored to incoming version 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-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 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; } +/* + * 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 = dev_to_pci(dev); + + bridge = pci_find_host_bridge(pdev->seg, pdev->bus); + if ( unlikely(!bridge) ) + { + printk(XENLOG_ERR "Unable to find PCI bridge for %pp\n", &pdev->sbdf); + 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 *bridge, 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); static always_inline bool is_pci_passthrough_enabled(void) { From patchwork Thu Sep 30 07:13:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksandr Andrushchenko X-Patchwork-Id: 12527501 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 19099C433F5 for ; Thu, 30 Sep 2021 07:14:00 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D64286120D for ; Thu, 30 Sep 2021 07:13:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org D64286120D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.xenproject.org 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 X-Outflank-Mailman: Message body and most headers restored to incoming version 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-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 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 *dev, * * 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; 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_node *np, */ int dt_get_pci_domain_nr(struct dt_device_node *node); +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) From patchwork Thu Sep 30 07:13:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksandr Andrushchenko X-Patchwork-Id: 12527503 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3DBB9C43219 for ; Thu, 30 Sep 2021 07:14:07 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0A61061880 for ; Thu, 30 Sep 2021 07:14:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 0A61061880 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.xenproject.org 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 X-Outflank-Mailman: Message body and most headers restored to incoming version 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-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 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); } +void arch_pci_init_pdev(struct pci_dev *pdev) +{ + pci_to_dev(pdev)->type = 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) = devfn; pdev->domain = NULL; + arch_pci_init_pdev(pdev); + rc = 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(void) { return pci_passthrough_enabled; } + +void arch_pci_init_pdev(struct pci_dev *pdev); + #else /*!CONFIG_HAS_PCI*/ struct arch_pci_dev { }; @@ -121,5 +124,7 @@ static inline int pci_get_host_bridge_segment(const struct dt_device_node *node, return -EINVAL; } +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; } +static inline void arch_pci_init_pdev(struct pci_dev *pdev) {} + #endif /* __X86_PCI_H__ */ From patchwork Thu Sep 30 07:13:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksandr Andrushchenko X-Patchwork-Id: 12527505 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 77173C433FE for ; Thu, 30 Sep 2021 07:14:08 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 42E6B61880 for ; Thu, 30 Sep 2021 07:14:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 42E6B61880 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.xenproject.org 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 X-Outflank-Mailman: Message body and most headers restored to incoming version 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-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 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 page_list_head *list) * function which may return -ERESTART. */ enum { - PROG_tee = 1, + PROG_pci = 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 = pci_release_devices(d); + if ( ret ) + return ret; +#endif PROGRESS(tee): ret = tee_relinquish_resources(d); From patchwork Thu Sep 30 07:13:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksandr Andrushchenko X-Patchwork-Id: 12527507 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3F3C4C433EF for ; Thu, 30 Sep 2021 07:14:13 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0695D6120D for ; Thu, 30 Sep 2021 07:14:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 0695D6120D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.xenproject.org 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 X-Outflank-Mailman: Message body and most headers restored to incoming version 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-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 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 == LIBXL_DOMAIN_TYPE_PV); - char *sysfs_path = GCSPRINTF(SYSFS_PCI_DEV"/"PCI_BDF"/resource", pci->domain, pci->bus, pci->dev, pci->func); FILE *f = fopen(sysfs_path, "r"); From patchwork Thu Sep 30 07:13:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksandr Andrushchenko X-Patchwork-Id: 12527511 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3C275C433EF for ; Thu, 30 Sep 2021 07:14:24 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0D6F86120D for ; Thu, 30 Sep 2021 07:14:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 0D6F86120D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.xenproject.org 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 X-Outflank-Mailman: Message body and most headers restored to incoming version 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-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 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 += -Wno-format-zero-length -Wmissing-declarations \ -Wno-declaration-after-statement -Wformat-nonliteral CFLAGS += -I. +ifeq ($(CONFIG_X86),y) +CFLAGS += -DCONFIG_PCI_SUPP_LEGACY_IRQ +endif + SRCS-$(CONFIG_X86) += libxl_cpuid.c SRCS-$(CONFIG_X86) += libxl_x86.c SRCS-$(CONFIG_X86) += 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); } +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 = GCSPRINTF(SYSFS_PCI_DEV"/"PCI_BDF"/irq", pci->domain, pci->bus, pci->dev, pci->func); f = 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 = GCSPRINTF(SYSFS_PCI_DEV"/"PCI_BDF"/irq", pci->domain, pci->bus, pci->dev, pci->func); f = fopen(sysfs_path, "r"); From patchwork Thu Sep 30 07:13:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksandr Andrushchenko X-Patchwork-Id: 12527517 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1F50EC43219 for ; Thu, 30 Sep 2021 07:17:20 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CF277615E5 for ; Thu, 30 Sep 2021 07:17:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org CF277615E5 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.xenproject.org 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 X-Outflank-Mailman: Message body and most headers restored to incoming version 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-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 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 = 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 = domain_vgic_register(d, &count)) != 0 ) goto fail; + count += domain_vpci_get_num_mmio_handlers(d); + if ( (rc = domain_io_init(d, count + MAX_IO_HANDLER)) != 0 ) goto fail; 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(struct 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 = cb(d, bridge); + if ( err ) + return err; + } + return 0; +} + +int pci_host_get_num_bridges(void) +{ + struct pci_host_bridge *bridge; + int count = 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 = { .write = vpci_mmio_write, }; +static int vpci_setup_mmio_handler(struct domain *d, + struct pci_host_bridge *bridge) +{ + struct pci_config_window *cfg = 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; + 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); return 0; } +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 = 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 = 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 @@ #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 #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(void) void arch_pci_init_pdev(struct pci_dev *pdev); +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*/ struct arch_pci_dev { }; From patchwork Thu Sep 30 07:13:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksandr Andrushchenko X-Patchwork-Id: 12527513 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1F576C433EF for ; Thu, 30 Sep 2021 07:17:16 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C1F226187A for ; Thu, 30 Sep 2021 07:17:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org C1F226187A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.xenproject.org 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 X-Outflank-Mailman: Message body and most headers restored to incoming version 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-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 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.html [2] https://www.kernel.org/doc/Documentation/devicetree/bindings/pci/host-generic-pci.txt [3] https://www.kernel.org/doc/Documentation/devicetree/bindings/pci/hisilicon-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); -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; } -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 = data; struct domain *d = mr_data->d; - bool need_mapping = !dt_device_for_passthrough(dev); + bool need_mapping = !dt_device_for_passthrough(dev) && + !mr_data->skip_mapping; int res; /* @@ -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 = { .d = d, .p2mt = 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)); - ret = dt_for_each_irq_map(dev, &map_dt_irq_to_domain, d); + ret = dt_for_each_irq_map(dev, &map_dt_irq_to_domain, mr_data->d); if ( ret < 0 ) return ret; - ret = dt_for_each_range(dev, &map_range_to_domain, &mr_data); + ret = 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, struct dt_device_node *dev, int res; u64 addr, size; bool need_mapping = !dt_device_for_passthrough(dev); + struct map_range_data mr_data = { + .d = d, + .p2mt = p2mt, + .skip_mapping = is_pci_passthrough_enabled() && + (device_get_class(dev) == DEVICE_PCI) + }; naddr = dt_number_of_address(dev); @@ -1582,7 +1579,6 @@ static int __init handle_device(struct domain *d, struct dt_device_node *dev, /* Give permission and map MMIOs */ for ( i = 0; i < naddr; i++ ) { - struct map_range_data mr_data = { .d = d, .p2mt = p2mt }; res = dt_device_get_address(dev, i, &addr, &size); if ( res ) { @@ -1596,7 +1592,7 @@ static int __init handle_device(struct domain *d, struct dt_device_node *dev, return res; } - res = map_device_children(d, dev, p2mt); + res = map_device_children(dev, &mr_data); if ( res ) return res; @@ -2754,7 +2750,14 @@ static int __init construct_dom0(struct domain *d) return rc; if ( acpi_disabled ) + { rc = prepare_dtb_hwdom(d, &kinfo); + if ( rc < 0 ) + return rc; +#ifdef CONFIG_HAS_PCI + rc = pci_host_bridge_mappings(d, p2m_mmio_direct_c); +#endif + } else rc = prepare_acpi(d, &kinfo); 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 *bridge, return base + (PCI_DEVFN2(sbdf.bdf) << devfn_shift) + where; } +bool pci_ecam_need_p2m_hwdom_mapping(struct domain *d, + struct pci_host_bridge *bridge, + uint64_t addr) +{ + struct pci_config_window *cfg = 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 != addr; +} + /* ECAM ops */ const struct pci_ecam_ops pci_generic_ecam_ops = { .bus_shift = 20, @@ -47,6 +60,7 @@ const struct pci_ecam_ops pci_generic_ecam_ops = { .map_bus = pci_ecam_map_bus, .read = pci_generic_config_read, .write = pci_generic_config_write, + .need_p2m_hwdom_mapping = pci_ecam_need_p2m_hwdom_mapping, } }; 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 @@ #include #include +#include #include #include #include @@ -320,6 +321,54 @@ int pci_host_get_num_bridges(void) return count; } +int __init pci_host_bridge_mappings(struct domain *d, p2m_type_t p2mt) +{ + struct pci_host_bridge *bridge; + struct map_range_data mr_data = { + .d = d, + .p2mt = p2mt, + .skip_mapping = 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 = bridge->dt_node; + unsigned int i; + + for ( i = 0; i < dt_number_of_address(dev); i++ ) + { + uint64_t addr, size; + int err; + + err = dt_device_get_address(dev, i, &addr, &size); + if ( err ) + { + printk(XENLOG_ERR + "Unable to retrieve address range index=%u for %s\n", + i, dt_node_full_name(dev)); + return err; + } + + if ( bridge->ops->need_p2m_hwdom_mapping(d, bridge, addr) ) + { + err = 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 = { .map_bus = pci_ecam_map_bus, .read = pci_generic_config_read, .write = pci_generic_config_write, + .need_p2m_hwdom_mapping = pci_ecam_need_p2m_hwdom_mapping, } }; 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 @@ #ifdef CONFIG_HAS_PCI +#include + #define pci_to_dev(pcidev) (&(pcidev)->arch.dev) 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); }; /* @@ -96,6 +101,9 @@ int pci_generic_config_write(struct pci_host_bridge *bridge, 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); +int pci_host_bridge_mappings(struct domain *d, p2m_type_t p2mt); + #else /*!CONFIG_HAS_PCI*/ 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_ #include +#include +#include #define MIN_FDT_ALIGN 8 #define MAX_FDT_SIZE SZ_2M @@ -77,6 +79,14 @@ struct bootinfo { #endif }; +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; extern domid_t max_init_domid; @@ -124,6 +134,9 @@ void device_tree_get_reg(const __be32 **cell, u32 address_cells, u32 device_tree_get_u32(const void *fdt, int node, const char *prop_name, u32 dflt); +int map_range_to_domain(const struct dt_device_node *dev, + u64 addr, u64 len, void *data); + #endif /* * Local variables: From patchwork Thu Sep 30 07:13:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksandr Andrushchenko X-Patchwork-Id: 12527515 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 37A77C433F5 for ; Thu, 30 Sep 2021 07:17:19 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DB2A8615E5 for ; Thu, 30 Sep 2021 07:17:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org DB2A8615E5 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.xenproject.org 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 X-Outflank-Mailman: Message body and most headers restored to incoming version 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-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 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 #include #include @@ -2304,6 +2305,18 @@ static bool check_for_vcpu_work(void) } #endif + if ( has_vpci(v->domain) ) + { + bool pending; + + local_irq_enable(); + pending = vpci_process_pending(v); + local_irq_disable(); + + if ( pending ) + return true; + } + if ( likely(!v->arch.need_flush_to_ram) ) return false; 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) pt_restore_timer(v); + if ( has_vpci(v->domain) && vpci_process_pending(v) ) + { + raise_softirq(SCHEDULE_SOFTIRQ); + return; + } + if ( !vcpu_ioreq_handle_completion(v) ) return; 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 #include #include @@ -212,19 +210,12 @@ static bool wait_for_io(struct ioreq_vcpu *sv, ioreq_t *p) bool vcpu_ioreq_handle_completion(struct vcpu *v) { - struct domain *d = v->domain; struct vcpu_io *vio = &v->io; struct ioreq_server *s; struct ioreq_vcpu *sv; enum vio_completion completion; bool res = true; - if ( has_vpci(d) && vpci_process_pending(v) ) - { - raise_softirq(SCHEDULE_SOFTIRQ); - return false; - } - while ( (sv = get_pending_vcpu(v, &s)) != NULL ) if ( !wait_for_io(sv, get_ioreq(s, v)) ) return false;