From patchwork Fri Sep 3 08:33:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksandr Andrushchenko X-Patchwork-Id: 12473835 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D048DC433EF for ; Fri, 3 Sep 2021 08:34:10 +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 902AC60F92 for ; Fri, 3 Sep 2021 08:34:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 902AC60F92 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.177836.323555 (Exim 4.92) (envelope-from ) id 1mM4e5-00071E-GG; Fri, 03 Sep 2021 08:33:57 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 177836.323555; Fri, 03 Sep 2021 08:33:57 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mM4e5-000711-Ca; Fri, 03 Sep 2021 08:33:57 +0000 Received: by outflank-mailman (input) for mailman id 177836; Fri, 03 Sep 2021 08:33:56 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mM4e4-0006kQ-CN for xen-devel@lists.xenproject.org; Fri, 03 Sep 2021 08:33:56 +0000 Received: from mail-ed1-x52d.google.com (unknown [2a00:1450:4864:20::52d]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 53a80e4d-17ef-4a2f-8cff-1eaa68946a8d; Fri, 03 Sep 2021 08:33:51 +0000 (UTC) Received: by mail-ed1-x52d.google.com with SMTP id z19so6890788edi.9 for ; Fri, 03 Sep 2021 01:33:51 -0700 (PDT) Received: from a2klaptop.epam.com (host-176-36-245-220.b024.la.net.ua. [176.36.245.220]) by smtp.gmail.com with ESMTPSA id i7sm2311932ejx.73.2021.09.03.01.33.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Sep 2021 01:33:49 -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: 53a80e4d-17ef-4a2f-8cff-1eaa68946a8d 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=zjlQkuHh6kZKwoZ8mUieXYtJ9esYGLvw5t0GDKDUbQk=; b=Xgp3IkxX/SfY/PfG+BOgIO+ADKUy/5Rb8UIuqEw2MjrDLDSn+HntfDhndHbMQEaScL FjmrDAnyZcW6+xVcPZwu1EP7ndImdZ0KeimUQLoaibXp19/yI5ifx9Mgd4XDHmgSsifl DEvRHIV40w0i9zsWwxea2m9bOGHPSDHt24SoDK7stOg+g1Tdc/9POfAGzlMJ9dfQ3CHs Di8p521g87IwoOeOcp2ltO9kq52QKbjG70LiiCsYOZqXZK9/EjouzbmL5WtPRAbiWcCF lxvSO0V1GfTAsxF6og3u/5lCxROSkhvfw5FJOZueqx+bwmhq+i8/2CAFs7DUgsQ90wSm 4KEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=zjlQkuHh6kZKwoZ8mUieXYtJ9esYGLvw5t0GDKDUbQk=; b=UdVccc3g9rFVrXh81QNyHCPyMbdBIJTX7yfPGXxwB1o5FwwNVs2xqTL7hK2836W9M2 35TtrgD+FzboohBUYt9XoxABD8ZjoRPHnejIO1eFgiyprFBi/mKMOvhy/EYoZWvnPEzj TmdmGEMGmoHoRTynt3ZY7X7jYsON2SrK/6UPq5u9CY39jk6e1KOvOqBu8kKOCiyXP1wX rp/IplvkD4uYtLTDmuwv8m2z9Sqy2mXSqrEplRVV3ZQ29r80+TGdVgMaRuL62IV7YQGC 70QtshEMrGWbHKpTv6hN0Ep04QyFB+AAkgY/tkAbgAiHxNB+dvjIBciiltTAWZwtDKGe k+sg== X-Gm-Message-State: AOAM530+wApQVPgt820BrvHk0yNdDbrcYVAx4xOuJjqbepovzBkHapVl nMDXIPzA7Spq0OXfBKNT+lCyNJPyikI= X-Google-Smtp-Source: ABdhPJwdIkQ8KNRmfmDrpt7oR/v1jpWaKOTo/d+eapgA54xtdvm5mj3qW6yJP5PMshdGxMxg314tWA== X-Received: by 2002:a05:6402:1cb4:: with SMTP id cz20mr2815841edb.0.1630658030445; Fri, 03 Sep 2021 01:33:50 -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 01/11] xen/arm: Add new device type for PCI Date: Fri, 3 Sep 2021 11:33:37 +0300 Message-Id: <20210903083347.131786-2-andr2000@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210903083347.131786-1-andr2000@gmail.com> References: <20210903083347.131786-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. While at it fix dev_is_dt macro. Signed-off-by: Oleksandr Andrushchenko --- xen/include/asm-arm/device.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/xen/include/asm-arm/device.h b/xen/include/asm-arm/device.h index 5ecd5e7bd15e..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,9 +26,8 @@ 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_dt(dev) ((dev->type == DEV_DT) +#define dev_is_pci(dev) ((dev)->type == DEV_PCI) +#define dev_is_dt(dev) ((dev)->type == DEV_DT) enum device_class { From patchwork Fri Sep 3 08:33:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksandr Andrushchenko X-Patchwork-Id: 12473839 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3D8D0C433FE for ; Fri, 3 Sep 2021 08:34:11 +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 00BDA60FDA for ; Fri, 3 Sep 2021 08:34:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 00BDA60FDA 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.177837.323566 (Exim 4.92) (envelope-from ) id 1mM4eA-0007LT-Nx; Fri, 03 Sep 2021 08:34:02 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 177837.323566; Fri, 03 Sep 2021 08:34:02 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mM4eA-0007LH-KJ; Fri, 03 Sep 2021 08:34:02 +0000 Received: by outflank-mailman (input) for mailman id 177837; Fri, 03 Sep 2021 08:34:01 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mM4e9-0006kQ-Ce for xen-devel@lists.xenproject.org; Fri, 03 Sep 2021 08:34:01 +0000 Received: from mail-ej1-x629.google.com (unknown [2a00:1450:4864:20::629]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 24e6dbd2-53dd-4a2f-b109-cd7d7a4e1bc1; Fri, 03 Sep 2021 08:33:52 +0000 (UTC) Received: by mail-ej1-x629.google.com with SMTP id mf2so10484692ejb.9 for ; Fri, 03 Sep 2021 01:33:52 -0700 (PDT) Received: from a2klaptop.epam.com (host-176-36-245-220.b024.la.net.ua. [176.36.245.220]) by smtp.gmail.com with ESMTPSA id i7sm2311932ejx.73.2021.09.03.01.33.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Sep 2021 01:33:51 -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: 24e6dbd2-53dd-4a2f-b109-cd7d7a4e1bc1 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=e6QStZ2WIeXjyjg6BwJ+X2ETh+SFauYaLcc7bbXleUI=; b=nWqFogticuAbAM8eSH4t1N6ThkVzCw+SXxxF9K1ll2yiZMh1ba0KqHkEcuIICyZxA+ SzrMGymV0AEdKm8ZZ/3WuQ6zOTDzu3Qxl2rYf1kjguYpIH6KYlhCyq4IRG8TfcKBRTEa iMEDEVpEa1K4k9kdeisup0kiYmqigISQlt8BUksAZ9OhIz75hqYC7L9u4YBATeJvnifO b13khRAluSa+dJjLlvArcmT+T3oNHIcHa6lln6cGdZNaR3DGxhgy9yz1WLBpn0CaTKgf JKlqdN0FSVOjxPDLSx+rh4zcWbdqnO+Fq6F81ZteVy6jV9HuhiWHdOcfUqqsdjHTdnlT suoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=e6QStZ2WIeXjyjg6BwJ+X2ETh+SFauYaLcc7bbXleUI=; b=DqfUBp3HYqyVJuvEWaAbOqwC+iP0kKM/BtDXEVHjL6xQ2EfXLT3VuN0ZFMiZ+SAzPs Moa683XQnMe0Xi8Erj6k69B5Pu6kd3hQVL0vD9jcAB4EQ6oK4YdrGWTsJ+3UUyVIazwE Xqgl56ITOKzRi0jItqS/W/TYqs7KWadXopTG5Dx0nrJVFWiEAxQMH3xKU8fsg805fRNV O9mUCJ2o4vAYxzTxCWuaRdUDiD93AVNdlAnPKG/SEzv5GO18QwEGM17T2hR8/G9SVUpp H1/an6zN52wDlP+iAFUudlGDxdULP1maooWYPv/L0au+vpqZJO/8+VJVl/XPVVvzOMZT C1dQ== X-Gm-Message-State: AOAM532EVpJhMEJNMXKgNeiEuN+lD15r3Kf80L4/AiQdmRGklpph2xqw J6gNBPYL4kU14A7sBvyYlg0FOW8cayg= X-Google-Smtp-Source: ABdhPJyTGMDmf4scjKeBebTeFdkThiwTB1tUX8NLSvZRs7ZtFuZfBJOLUJ5uJ8kRB25bkqYfTjUf0g== X-Received: by 2002:a17:907:2721:: with SMTP id d1mr2923277ejl.24.1630658031656; Fri, 03 Sep 2021 01:33:51 -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 02/11] xen/arm: Add dev_to_pci helper Date: Fri, 3 Sep 2021 11:33:38 +0300 Message-Id: <20210903083347.131786-3-andr2000@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210903083347.131786-1-andr2000@gmail.com> References: <20210903083347.131786-1-andr2000@gmail.com> MIME-Version: 1.0 From: Oleksandr Andrushchenko 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. Macro can be implemented, but looks scary: #define dev_to_pci_dev(dev) container_of((container_of((dev), \ struct arch_pci_dev, dev), struct pci_dev, arch) Signed-off-by: Oleksandr Andrushchenko --- xen/arch/arm/pci/pci.c | 10 ++++++++++ xen/include/asm-arm/pci.h | 7 +++++++ 2 files changed, 17 insertions(+) diff --git a/xen/arch/arm/pci/pci.c b/xen/arch/arm/pci/pci.c index dc63bbc2a2c1..6573f179af55 100644 --- a/xen/arch/arm/pci/pci.c +++ b/xen/arch/arm/pci/pci.c @@ -26,6 +26,16 @@ int arch_pci_clean_pirqs(struct domain *d) return 0; } +struct pci_dev *dev_to_pci(struct device *dev) +{ + struct arch_pci_dev *arch_dev; + + ASSERT(dev->type == DEV_PCI); + + arch_dev = container_of((dev), struct arch_pci_dev, dev); + return container_of(arch_dev, struct pci_dev, arch); +} + static int __init dt_pci_init(void) { struct dt_device_node *np; diff --git a/xen/include/asm-arm/pci.h b/xen/include/asm-arm/pci.h index 2d4610a23a25..e1aa05190bda 100644 --- a/xen/include/asm-arm/pci.h +++ b/xen/include/asm-arm/pci.h @@ -27,6 +27,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 Fri Sep 3 08:33:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksandr Andrushchenko X-Patchwork-Id: 12473841 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0FBA9C433F5 for ; Fri, 3 Sep 2021 08:34:15 +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 CB09360FD7 for ; Fri, 3 Sep 2021 08:34:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org CB09360FD7 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.177838.323577 (Exim 4.92) (envelope-from ) id 1mM4eG-0007k4-23; Fri, 03 Sep 2021 08:34:08 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 177838.323577; Fri, 03 Sep 2021 08:34:08 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mM4eF-0007jr-UN; Fri, 03 Sep 2021 08:34:07 +0000 Received: by outflank-mailman (input) for mailman id 177838; Fri, 03 Sep 2021 08:34: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 1mM4eE-0006kQ-Cm for xen-devel@lists.xenproject.org; Fri, 03 Sep 2021 08:34:06 +0000 Received: from mail-ed1-x529.google.com (unknown [2a00:1450:4864:20::529]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id d791cd72-1871-4ccf-817a-e51d3db5b6c3; Fri, 03 Sep 2021 08:33:53 +0000 (UTC) Received: by mail-ed1-x529.google.com with SMTP id r7so6926076edd.6 for ; Fri, 03 Sep 2021 01:33:53 -0700 (PDT) Received: from a2klaptop.epam.com (host-176-36-245-220.b024.la.net.ua. [176.36.245.220]) by smtp.gmail.com with ESMTPSA id i7sm2311932ejx.73.2021.09.03.01.33.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Sep 2021 01:33:52 -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: d791cd72-1871-4ccf-817a-e51d3db5b6c3 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=LGWgNsGMc39sVj5QGdwU3RC9MH61fd0rOAc+HjnetL4=; b=jzF3nEIJXkuxIUCpc0qM5Oiu8hLlldWQ+Lz0hhNI2Ub1RMF3Qbrij1SFl/emQEQscX OctS5kVKgfSmIlkAEokYDlh7KTdaWXM0wDAYf9/2NdD6neoTsa3t2DKhbRd5ZdUKiPOx S2PsK64LPXN+uZeNXjPPxgQjMJjKSFc6YGWqsQVbMF6xtxnZDnoHezWhH2nT/vwym0Yv 0CNidcd1Mx+4PJKuDXmrq2uXK50XYtdBR/DUdsISNvXiS0MjoUtZx7LKVdsMWZlTQkxu ruWxAhOgTOoVzm1FC+ANk+ZBh3e633gonZWlfdEMs3pAoxm7xgjBcF1AwkgxVuzftbjM lmoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=LGWgNsGMc39sVj5QGdwU3RC9MH61fd0rOAc+HjnetL4=; b=gFEF3vI+84Y3nriEaeUXr/5nOWigp71+vuqb1g44w9QEEMom02M9m8dU9IVlOyNYhN AWRc1uk4LSOfu3GqcZwGnvreAVYrqjp7b1N6Kacs5p3hkVCgNPPtb6JF6d2hk1k9d5iw lYZfj4mx7X4+yEMowDQzY2EeXQYF5XQpuZ66Yw5Gv/9GRf864HTgAOEUbtk+t1AyY//c bvvWAiye7e1aNAQigt4y0UVP/CL/QACcniAUFHLhHZhHtgxDXBdvSATthqFlqO8V8lfy Cn0XzcsvgWI1LYYyBGMmCZqTeSU4/+ZaMw94Az14P/p+jCCc8in/H00i4t0K+jI/TxjW 0JDA== X-Gm-Message-State: AOAM533T29VmwjjdpxeGBjsIw1GF/1YGfe5TF4KSgBNOw6Q+nUGLh3O7 OLuWyYoVesOzLVpY14INbxAW2qVrYXQ= X-Google-Smtp-Source: ABdhPJzoCD96lMsn4O6MjQ9c1RPiG7IXqQPjSOWYZAYm2R5Ns/eebk9CaPXrFjkNmkqhirqr1Rp1sg== X-Received: by 2002:a05:6402:4d:: with SMTP id f13mr2792315edu.275.1630658032768; Fri, 03 Sep 2021 01:33:52 -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 03/11] xen/arm: Introduce pci_find_host_bridge_node helper Date: Fri, 3 Sep 2021 11:33:39 +0300 Message-Id: <20210903083347.131786-4-andr2000@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210903083347.131786-1-andr2000@gmail.com> References: <20210903083347.131786-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 --- xen/arch/arm/pci/pci-host-common.c | 17 +++++++++++++++++ xen/include/asm-arm/pci.h | 1 + 2 files changed, 18 insertions(+) diff --git a/xen/arch/arm/pci/pci-host-common.c b/xen/arch/arm/pci/pci-host-common.c index 5e34252deb9d..d2fef5476b8e 100644 --- a/xen/arch/arm/pci/pci-host-common.c +++ b/xen/arch/arm/pci/pci-host-common.c @@ -301,6 +301,23 @@ 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 "PRI_pci"\n", + pdev->seg, pdev->bus, pdev->sbdf.dev, pdev->sbdf.fn); + 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 e1aa05190bda..7dc4c8dc9026 100644 --- a/xen/include/asm-arm/pci.h +++ b/xen/include/asm-arm/pci.h @@ -105,6 +105,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); #else /*!CONFIG_HAS_PCI*/ From patchwork Fri Sep 3 08:33:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksandr Andrushchenko X-Patchwork-Id: 12473843 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0293FC433EF for ; Fri, 3 Sep 2021 08:34:21 +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 B703960F92 for ; Fri, 3 Sep 2021 08:34:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org B703960F92 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.177840.323588 (Exim 4.92) (envelope-from ) id 1mM4eL-0008Ff-CR; Fri, 03 Sep 2021 08:34:13 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 177840.323588; Fri, 03 Sep 2021 08:34: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 1mM4eL-0008FR-82; Fri, 03 Sep 2021 08:34:13 +0000 Received: by outflank-mailman (input) for mailman id 177840; Fri, 03 Sep 2021 08:34: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 1mM4eJ-0006kQ-Cz for xen-devel@lists.xenproject.org; Fri, 03 Sep 2021 08:34:11 +0000 Received: from mail-ed1-x531.google.com (unknown [2a00:1450:4864:20::531]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id abac851f-78b0-46af-ba55-f6067286fe72; Fri, 03 Sep 2021 08:33:55 +0000 (UTC) Received: by mail-ed1-x531.google.com with SMTP id g22so6893686edy.12 for ; Fri, 03 Sep 2021 01:33:55 -0700 (PDT) Received: from a2klaptop.epam.com (host-176-36-245-220.b024.la.net.ua. [176.36.245.220]) by smtp.gmail.com with ESMTPSA id i7sm2311932ejx.73.2021.09.03.01.33.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Sep 2021 01:33:53 -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: abac851f-78b0-46af-ba55-f6067286fe72 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=gT/ZFZNUCDilPZAOY4tWpXuhNvzOpcakatBoOBy/O1k=; b=AeeHVvoDQgATpWSZNB/AO4OIyw4Mg9oLVflwbPYmCY/dNrU1qFSQB6Db3RqYWroQIm 7dL4DAlFEW2GS7PnIsgS7gE9t4WMgwHb0M5oO5gEtI/deFPJO4ufJeIIE6jGpdTIuNXv HO3CaROk5N0KkNEEdY7x1NBl3FxGPdgHarce5VLXc0j0PuLaobvKmi3gSljvQcSX+aPc //aaqhRjf3R96XiFwTYuAJ4GXlwIF3VVYkQFUG2Fu1uqXBJPRpNuEPYYXKO2Xf6aeIxP zG8rAY1KwYJ2z5GY75QLpNcSi/kpSMO3mJAHsjUmpyFmB7ff8JMJd20fYfkj258kxD4V PMSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=gT/ZFZNUCDilPZAOY4tWpXuhNvzOpcakatBoOBy/O1k=; b=AKT9Qirdlz2Tnu9mJr/AmWdARIaR25QIApx9cutv45Bb8poD82/RxZ+GlwzIWWK/jN vwH8m6sZI1dOy9tWslgbkcPUfjFkdXf/028gzwqLHU3N8EvrlBeGusD9iRJC4YyaDzYr ibmj6MAF23RwNDdatmZ5QKlYkPnTikZS5jTe3lxS1NFhPLwiT0spVHuhLSbMydSznAA3 y2Nupp/ycyftCrSsBpYimh3hRpN4QPUrfwGmETZo7ldY324LnAeYB6VQbPxDzaORkEfK O+PecLffVpdYBV8Uj+cgaYzP7EtrQZ7KnHLZtm6Y/y1cev/RIbr5pYbGhoDiAy5nKaHK cEsQ== X-Gm-Message-State: AOAM531b95LbkD8D/U3k/TYzb2/vrmJ7a8/LrjtzlF8XrJDv464yiVDU fWc4zqUnUhEkVvt/LHw8+E62ttNAkn4= X-Google-Smtp-Source: ABdhPJwY8ZltlgwVhwjnryt/5IUzAOzh/IBbZ1FvlM/J72PFOBmQxVLdVpjv5yPJL3sHkLXKtBoe/g== X-Received: by 2002:a05:6402:b9c:: with SMTP id cf28mr2924531edb.356.1630658034045; Fri, 03 Sep 2021 01:33:54 -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 04/11] xen/device-tree: Make dt_find_node_by_phandle global Date: Fri, 3 Sep 2021 11:33:40 +0300 Message-Id: <20210903083347.131786-5-andr2000@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210903083347.131786-1-andr2000@gmail.com> References: <20210903083347.131786-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 --- 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 03d25a81cea8..c2e33b99832f 100644 --- a/xen/common/device_tree.c +++ b/xen/common/device_tree.c @@ -986,7 +986,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 b02696be9416..07393da1df90 100644 --- a/xen/include/xen/device_tree.h +++ b/xen/include/xen/device_tree.h @@ -776,6 +776,8 @@ int dt_count_phandle_with_args(const struct dt_device_node *np, const char *list_name, const char *cells_name); +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 Fri Sep 3 08:33:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksandr Andrushchenko X-Patchwork-Id: 12473845 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 88096C433F5 for ; Fri, 3 Sep 2021 08:34:25 +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 5200860FDA for ; Fri, 3 Sep 2021 08:34:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 5200860FDA 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.177845.323599 (Exim 4.92) (envelope-from ) id 1mM4eP-0000Nh-Rt; Fri, 03 Sep 2021 08:34:17 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 177845.323599; Fri, 03 Sep 2021 08:34:17 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mM4eP-0000MS-Lw; Fri, 03 Sep 2021 08:34:17 +0000 Received: by outflank-mailman (input) for mailman id 177845; Fri, 03 Sep 2021 08:34:16 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mM4eO-0006kQ-DJ for xen-devel@lists.xenproject.org; Fri, 03 Sep 2021 08:34:16 +0000 Received: from mail-ej1-x62f.google.com (unknown [2a00:1450:4864:20::62f]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 27e92245-e9a7-4d08-b7db-06c719470729; Fri, 03 Sep 2021 08:33:56 +0000 (UTC) Received: by mail-ej1-x62f.google.com with SMTP id x11so10579940ejv.0 for ; Fri, 03 Sep 2021 01:33:56 -0700 (PDT) Received: from a2klaptop.epam.com (host-176-36-245-220.b024.la.net.ua. [176.36.245.220]) by smtp.gmail.com with ESMTPSA id i7sm2311932ejx.73.2021.09.03.01.33.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Sep 2021 01:33:54 -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: 27e92245-e9a7-4d08-b7db-06c719470729 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=zEaEEkjSVbLwgqZ2cO/SvSyYHTCsAuDtk1o9tcPz34M=; b=HOEWMOzgAHfhqGy9RD08ptIgiNJDtfBpZENO+7wmukitpCXKU/tg2fBV+y4B5GPbeZ nc617mYgWSgBkpaW4vuo16HZ9MEpN6RQrgWJ6q05CQtakHUM9tZgI3oY9+bCavK6RfvD /Z5kGtwMD+pBzSNmg8rVMzrHjsh3Ac/qSBRoejs561XlEe8rtWJROHH3P8toAYjpOg0u GC5NtpzMwvW+z9I37LMc3EWyZY+bAC5A7dznB6kxyhp8224v3H81NjGIfPkG4Ng//ZK9 jmNQ+aYz/U+d5xKG/+qYldB4flk+vPZS3BIDdQ7TKOzfrfzmsoFflWkGBScLO5yZ2+dc LL0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=zEaEEkjSVbLwgqZ2cO/SvSyYHTCsAuDtk1o9tcPz34M=; b=DdGy+TRLNw447nRDWa8eJGApCfFbQfReNvgW8pH60UiCN/SorZTs60lprwxoqtb4hs rmgP1lGzTtV2swotSG1xTKz9qnrfWW/fDrQ9sj8KSea4C84Jqfm5NdtYq2JGrGbCm8fL fG805Mgc3AUF1E2QTo88vuwvadMZXvX2IQKpZkNYtYobbkYGN90hEL34gJrjxGHgrgAz I8WIIqLWAI2Ii3/BaOZnzSouaSc0YRFQQ3zD9UJF2xMRcDMuooDYCvQG+UFgNI6JwzTW mmApM5Ap2CcM5SZ6RbiO1a/5WKpxT5VRU1rk5mULWN0vjkr3MUQJJt48ANSvqLRzrocA u8eQ== X-Gm-Message-State: AOAM530l5Uu+nBzJSIgtyQkQA41cdnN7ZvTYnI2/5urjS4An/BSc8jhD QrgONB206CkZ7AO4HjjL4+SqUNh3dO8= X-Google-Smtp-Source: ABdhPJwRW77fMud+VU+y2+UHwAx3A+siV93Yru3KtspqID6C5FmqhT1A5wFmO04G72SDTjkT5t52Uw== X-Received: by 2002:a17:906:ff41:: with SMTP id zo1mr2759320ejb.525.1630658035099; Fri, 03 Sep 2021 01:33:55 -0700 (PDT) From: Oleksandr Andrushchenko To: xen-devel@lists.xenproject.org Cc: julien@xen.org, sstabellini@kernel.org, oleksandr_tyshchenko@epam.com, volodymyr_babchuk@epam.com, Artem_Mygaiev@epam.com, roger.pau@citrix.com, bertrand.marquis@arm.com, rahul.singh@arm.com, Oleksandr Andrushchenko Subject: [PATCH 05/11] xen/arm: Mark device as PCI while creating one Date: Fri, 3 Sep 2021 11:33:41 +0300 Message-Id: <20210903083347.131786-6-andr2000@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210903083347.131786-1-andr2000@gmail.com> References: <20210903083347.131786-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 form DT devices. Signed-off-by: Oleksandr Andrushchenko --- xen/drivers/passthrough/pci.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/xen/drivers/passthrough/pci.c b/xen/drivers/passthrough/pci.c index 56e261e9bd08..25304dbe9956 100644 --- a/xen/drivers/passthrough/pci.c +++ b/xen/drivers/passthrough/pci.c @@ -1301,6 +1301,9 @@ static int iommu_add_device(struct pci_dev *pdev) if ( !is_iommu_enabled(pdev->domain) ) return 0; +#ifdef CONFIG_ARM + pci_to_dev(pdev)->type = DEV_PCI; +#endif rc = hd->platform_ops->add_device(pdev->devfn, pci_to_dev(pdev)); if ( rc || !pdev->phantom_stride ) return rc; From patchwork Fri Sep 3 08:33:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksandr Andrushchenko X-Patchwork-Id: 12473847 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 877E2C433EF for ; Fri, 3 Sep 2021 08:34:30 +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 5489F60FD7 for ; Fri, 3 Sep 2021 08:34:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 5489F60FD7 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.177848.323610 (Exim 4.92) (envelope-from ) id 1mM4eV-0000uw-AO; Fri, 03 Sep 2021 08:34:23 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 177848.323610; Fri, 03 Sep 2021 08:34:23 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mM4eV-0000ue-67; Fri, 03 Sep 2021 08:34:23 +0000 Received: by outflank-mailman (input) for mailman id 177848; Fri, 03 Sep 2021 08:34:21 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mM4eT-0006kQ-DN for xen-devel@lists.xenproject.org; Fri, 03 Sep 2021 08:34:21 +0000 Received: from mail-ed1-x52e.google.com (unknown [2a00:1450:4864:20::52e]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id fdf50016-d48a-46db-8d04-c3242be972e1; Fri, 03 Sep 2021 08:33:57 +0000 (UTC) Received: by mail-ed1-x52e.google.com with SMTP id n11so6903634edv.11 for ; Fri, 03 Sep 2021 01:33:57 -0700 (PDT) Received: from a2klaptop.epam.com (host-176-36-245-220.b024.la.net.ua. [176.36.245.220]) by smtp.gmail.com with ESMTPSA id i7sm2311932ejx.73.2021.09.03.01.33.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Sep 2021 01:33:55 -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: fdf50016-d48a-46db-8d04-c3242be972e1 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=/iiGZOLolgjA2ZPldrvDxiQ5Z5+rXkMHlrxZBGQ1V6g=; b=Thp1SViWRIliiAx3L7i8dGQs8jHSK15JDP1ZAcNVhPgnWdIyDDHzN7LnytjXMbIJGT 2aj1NBBC9Fu1xWxM0uHHq4g2BnsU8a/mnvbjF5ljWBOSqkyfveqsDXi0U8D5UwEzaL+c CEj7XN/MJOAGR2zNbfqHuzkpEq2avwghGsdsSVSbRe7N2V4EIwDJsbOWGfI6CSgqlxeb mcHWEL6UK8lF5q/wFWsS0s5Kq9z5yV8KKrpO5t0pufBbczyE4q+Gw2WE96KobfzMF2BS lSpWrUci/mFJPcibc3S1lKaxt7Y7SV2Q08CoJNTxpxXB2eDudckd2zo5dQ76y5qmNNa2 YJEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/iiGZOLolgjA2ZPldrvDxiQ5Z5+rXkMHlrxZBGQ1V6g=; b=aTKcGwa9+82WQZhK8PxotLTJGD5bJdp/YKJmn6ttLaDFvAPQ/W5PuhrCI5PrXDMD9c 4MLYRzzcs6/2CtCYVWVtTeMNUq2pnVeTRVi01/tbXVAc6n+PITQR3H9fwvCDdq/pwqnU zRJ8q8FTFzxCVmOtKWN3k1GjYVOrOLW6g208FTYnkvjkv1yqaUyFASmtc92slpNrU3S6 GU7DqzvchSdfAyNy3MyRIxHEj9gUPJ0DCpICkXlpNF75piWYIFbTR2G46ec+mZSIURMt zAyOd75zuNEiBDd+ph5429G34WkCIVVl9+/GnDIHUEKD6JAXkvIXbgIqY/W4hhpBGwTF kijA== X-Gm-Message-State: AOAM533j4pWEUlFIHjIEKFwB35po1xJXQZA9VKe1K4XrNP96LOZI5fuN CGi8JjQjg0mRC9nYjKJr3bgCpCoxHag= X-Google-Smtp-Source: ABdhPJy4fYHKLqSsXdIUKB/e5T2+22yYDBhCrp7iQB/x8B/pbhcNDDdtAnMUCrCtYVr2mtO64vRMIA== X-Received: by 2002:aa7:c94c:: with SMTP id h12mr2776075edt.378.1630658036325; Fri, 03 Sep 2021 01:33:56 -0700 (PDT) From: Oleksandr Andrushchenko To: xen-devel@lists.xenproject.org Cc: julien@xen.org, sstabellini@kernel.org, oleksandr_tyshchenko@epam.com, volodymyr_babchuk@epam.com, Artem_Mygaiev@epam.com, roger.pau@citrix.com, bertrand.marquis@arm.com, rahul.singh@arm.com Subject: [PATCH 06/11] xen/domain: Call pci_release_devices() when releasing domain resources Date: Fri, 3 Sep 2021 11:33:42 +0300 Message-Id: <20210903083347.131786-7-andr2000@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210903083347.131786-1-andr2000@gmail.com> References: <20210903083347.131786-1-andr2000@gmail.com> MIME-Version: 1.0 From: Oleksandr Tyshchenko This is the very same what we do for DT devices. What is more that x86 already calls pci_release_devices(). Signed-off-by: Oleksandr Tyshchenko --- 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 d99c653626e4..4e40c4098280 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 Fri Sep 3 08:33:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksandr Andrushchenko X-Patchwork-Id: 12473849 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CB386C433EF for ; Fri, 3 Sep 2021 08:34:34 +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 9631560F92 for ; Fri, 3 Sep 2021 08:34:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 9631560F92 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.177852.323621 (Exim 4.92) (envelope-from ) id 1mM4eZ-0001TH-Kf; Fri, 03 Sep 2021 08:34:27 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 177852.323621; Fri, 03 Sep 2021 08:34:27 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mM4eZ-0001T7-Gj; Fri, 03 Sep 2021 08:34:27 +0000 Received: by outflank-mailman (input) for mailman id 177852; Fri, 03 Sep 2021 08:34:26 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mM4eY-0006kQ-Df for xen-devel@lists.xenproject.org; Fri, 03 Sep 2021 08:34:26 +0000 Received: from mail-ej1-x62e.google.com (unknown [2a00:1450:4864:20::62e]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 0898630a-f5e4-4ab6-8354-bf16210b9e36; Fri, 03 Sep 2021 08:33:58 +0000 (UTC) Received: by mail-ej1-x62e.google.com with SMTP id me10so10462374ejb.11 for ; Fri, 03 Sep 2021 01:33:58 -0700 (PDT) Received: from a2klaptop.epam.com (host-176-36-245-220.b024.la.net.ua. [176.36.245.220]) by smtp.gmail.com with ESMTPSA id i7sm2311932ejx.73.2021.09.03.01.33.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Sep 2021 01:33:57 -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: 0898630a-f5e4-4ab6-8354-bf16210b9e36 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=G9YXRhru3uNLxB1PDUiun9J9pMrCuA67iL9Y2S0hbpXL6f5CH2X0QxIT5S1a9tUVI0 ngdOqG5buY4ynepqOc4Mqw/59P8H5sjq34iVC/u0iXKce95prSaaImHKqsL0PaYH7vcE D1V6AOs2vm4fw/w3cgP9IhSPze4c2q6V0JyGGMv/a3ElMGbTNF0S7auFCdB0/MVNyqHt MSsg6wqzDA1lelto4azizexS43392uIQej/nGbEwF7OGVlS74cihi3/3uWxljNDqJhHU wFIzTiQMGRpJzgDNE4+dQa/3yv3zMkXoX1BmCUXGm3S/B7/wgbcEBjWuZCJOL6udh3zY kX1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; 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=AP9HIzrCzQkFkZvqieTGE4tmU+0QANe3qh/xgxiywNDWgviFk0YWP8YwbWKO5e0JoX 7VfKO2dAT/dMkoNTCtzWwwdLHfKWWK9qIBrtnVuc1WTKjhyrob7hDBMRVYIXhABpeDui C9bvM3qArCy6hfhVIwyLJUw9EAfE+v1q7JQuFVXI9MX1vQyqzM/lrU8wt+dbj6+sVh7g 6aqrsJZro0owjPWvFQUmw8zcltCArkgxX/pJmMnAXF91fxajQYfnItw2bHbm3S0fzuKi B8cGRUudIGaoFiJC5fUQqCop5n7MuaTYiGmiGPbjEN0EtEHQWASH645RT5eWuhp1ZAVq eKhA== X-Gm-Message-State: AOAM533KzecWeoojC2rWm7Gni1Du+O0rT40VNhGHm+p+LhXB8GYxfmoQ XtAkmYVHree4A9HaC2c44t8VqYf/cMs= X-Google-Smtp-Source: ABdhPJzGKTmhAkRttkjaVwij4GDfdpVmfRmx6aBuBdUijcAaoOwlRu3VoW1BGbNMMqkWyy5d8+/pYQ== X-Received: by 2002:a17:906:9b1:: with SMTP id q17mr2879682eje.546.1630658037434; Fri, 03 Sep 2021 01:33:57 -0700 (PDT) From: Oleksandr Andrushchenko To: xen-devel@lists.xenproject.org Cc: julien@xen.org, sstabellini@kernel.org, oleksandr_tyshchenko@epam.com, volodymyr_babchuk@epam.com, Artem_Mygaiev@epam.com, roger.pau@citrix.com, bertrand.marquis@arm.com, rahul.singh@arm.com, Oleksandr Andrushchenko , Ian Jackson , Juergen Gross Subject: [PATCH 07/11] libxl: Allow removing PCI devices for all types of domains Date: Fri, 3 Sep 2021 11:33:43 +0300 Message-Id: <20210903083347.131786-8-andr2000@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210903083347.131786-1-andr2000@gmail.com> References: <20210903083347.131786-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 --- 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 Fri Sep 3 08:33:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksandr Andrushchenko X-Patchwork-Id: 12473851 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1D665C433F5 for ; Fri, 3 Sep 2021 08:34:41 +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 E52F660F92 for ; Fri, 3 Sep 2021 08:34:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org E52F660F92 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.177859.323632 (Exim 4.92) (envelope-from ) id 1mM4ee-00025Z-WA; Fri, 03 Sep 2021 08:34:32 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 177859.323632; Fri, 03 Sep 2021 08:34:32 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mM4ee-00025O-S0; Fri, 03 Sep 2021 08:34:32 +0000 Received: by outflank-mailman (input) for mailman id 177859; Fri, 03 Sep 2021 08:34:31 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mM4ed-0006kQ-Dn for xen-devel@lists.xenproject.org; Fri, 03 Sep 2021 08:34:31 +0000 Received: from mail-ej1-x633.google.com (unknown [2a00:1450:4864:20::633]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id fcfff0c5-87bc-448e-bd89-368f58f11371; Fri, 03 Sep 2021 08:33:59 +0000 (UTC) Received: by mail-ej1-x633.google.com with SMTP id jg16so7370339ejc.1 for ; Fri, 03 Sep 2021 01:33:59 -0700 (PDT) Received: from a2klaptop.epam.com (host-176-36-245-220.b024.la.net.ua. [176.36.245.220]) by smtp.gmail.com with ESMTPSA id i7sm2311932ejx.73.2021.09.03.01.33.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Sep 2021 01:33:58 -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: fcfff0c5-87bc-448e-bd89-368f58f11371 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=Hx54vdgUoheVTz/8kdwndGE5xFCEvdbxwnx2M5LV2vg=; b=RdDtLXI6Rg8R+9WLRJYoNMq8UIn9C9UYiKM3atwuaiVC9bWq2G1D1gEb8701s40UoB q3Vkp/Q+AaXXiFaOTz5uyjQxEyJLgSw8QJB7PO+sZnWNbsk2QivJXAbq5fg+Jqbdfysp +QSpl4wnAMWZmYNE5OUiwggYvVyrZQF2WSlhbdngi69rmyZVt6LY3os3UdU+56o7z0Qz aXLK85ahPpB0tLKxrNsEPTzR/jIdjbVD9jnl5/AcTadm4B0eFB/U0iKObJlOH+vNr5El RDPi9bmWAmk9pV5ibKbmzIYJq18buRGok9BqADlAyv9Sraqe2G5UHaYHUFkzWsJQvwxk vQEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Hx54vdgUoheVTz/8kdwndGE5xFCEvdbxwnx2M5LV2vg=; b=ZU935E9As03e8TxEeil25qhW+riYm6XE9eWITrr/ZJ9UU6It0Y8jMfSb27gbCyZYQH 7rVTysvwC+z+PqfePhYlj9jhf8iLKqItd5YCy/pp6AwTvmRxvSNdGRr8bw+AQ09xauuC aOg4wIrhnSUkmfE//8coPTDi1QWx1XoPJCDGAzhgqSsscpeuoyHZM93lvn+7p+tgkGCi tpLceNS3iPxbtrDhEmKVVVO/HGnb84qfctwWpCLdxhnV3eSyXNmGgI264Bg354M5o7g3 KKqrCyHRhrobvkbroh5XCSw5ojMMTlDPWV22YeF7t3kwE3lpR6pbSAwVAN2wMIvsW1KJ aenw== X-Gm-Message-State: AOAM5307TcEyC4GgLUAmz5c86aiXM/0OKVw8x0dRJJCxgTU1kneIREPD tkiVI4TVLaedressSxtb1tk39/tniUM= X-Google-Smtp-Source: ABdhPJxbTzY7zXsW8PjrsejxN3DPMeW22l0e+skzCHi5HgMf4ECl+/PSNQ7TpHFwniDROzLZHbVUSw== X-Received: by 2002:a17:906:a01:: with SMTP id w1mr2947033ejf.117.1630658038658; Fri, 03 Sep 2021 01:33:58 -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 08/11] libxl: Only map legacy PCI IRQs if they are supported Date: Fri, 3 Sep 2021 11:33:44 +0300 Message-Id: <20210903083347.131786-9-andr2000@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210903083347.131786-1-andr2000@gmail.com> References: <20210903083347.131786-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 --- 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..cd4fea46c3f7 100644 --- a/tools/libs/light/libxl_pci.c +++ b/tools/libs/light/libxl_pci.c @@ -1434,6 +1434,7 @@ static void pci_add_dm_done(libxl__egc *egc, } } fclose(f); +#ifndef CONFIG_PCI_SUPP_LEGACY_IRQ sysfs_path = GCSPRINTF(SYSFS_PCI_DEV"/"PCI_BDF"/irq", pci->domain, pci->bus, pci->dev, pci->func); f = fopen(sysfs_path, "r"); @@ -1460,6 +1461,7 @@ static void pci_add_dm_done(libxl__egc *egc, } } fclose(f); +#endif /* Don't restrict writes to the PCI config space from this VM */ if (pci->permissive) { @@ -1471,7 +1473,9 @@ static void pci_add_dm_done(libxl__egc *egc, } } +#ifndef CONFIG_PCI_SUPP_LEGACY_IRQ out_no_irq: +#endif if (!isstubdom) { if (pci->rdm_policy == LIBXL_RDM_RESERVE_POLICY_STRICT) { flag &= ~XEN_DOMCTL_DEV_RDM_RELAXED; @@ -1951,7 +1955,9 @@ static void do_pci_remove(libxl__egc *egc, pci_remove_state *prs) pci->bus, pci->dev, pci->func); FILE *f = fopen(sysfs_path, "r"); unsigned int start = 0, end = 0, flags = 0, size = 0; +#ifndef CONFIG_PCI_SUPP_LEGACY_IRQ int irq = 0; +#endif int i; if (f == NULL) { @@ -1983,6 +1989,7 @@ static void do_pci_remove(libxl__egc *egc, pci_remove_state *prs) } fclose(f); skip1: +#ifndef CONFIG_PCI_SUPP_LEGACY_IRQ sysfs_path = GCSPRINTF(SYSFS_PCI_DEV"/"PCI_BDF"/irq", pci->domain, pci->bus, pci->dev, pci->func); f = fopen(sysfs_path, "r"); @@ -2001,8 +2008,14 @@ skip1: } } fclose(f); +#else + /* Silence error: label at end of compound statement */ + ; +#endif } +#ifndef CONFIG_PCI_SUPP_LEGACY_IRQ skip_irq: +#endif rc = 0; out_fail: pci_remove_detached(egc, prs, rc); /* must be last */ From patchwork Fri Sep 3 08:33:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksandr Andrushchenko X-Patchwork-Id: 12473853 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BB25EC433EF for ; Fri, 3 Sep 2021 08:34:45 +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 7091960FDA for ; Fri, 3 Sep 2021 08:34:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 7091960FDA 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.177865.323642 (Exim 4.92) (envelope-from ) id 1mM4ek-0002hQ-B6; Fri, 03 Sep 2021 08:34:38 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 177865.323642; Fri, 03 Sep 2021 08:34:38 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mM4ek-0002hH-7X; Fri, 03 Sep 2021 08:34:38 +0000 Received: by outflank-mailman (input) for mailman id 177865; Fri, 03 Sep 2021 08:34:36 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mM4ei-0006kQ-E5 for xen-devel@lists.xenproject.org; Fri, 03 Sep 2021 08:34:36 +0000 Received: from mail-ej1-x630.google.com (unknown [2a00:1450:4864:20::630]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 3bb67d0b-f39f-4b34-9864-f3691fc81bea; Fri, 03 Sep 2021 08:34:00 +0000 (UTC) Received: by mail-ej1-x630.google.com with SMTP id mf2so10485515ejb.9 for ; Fri, 03 Sep 2021 01:34:00 -0700 (PDT) Received: from a2klaptop.epam.com (host-176-36-245-220.b024.la.net.ua. [176.36.245.220]) by smtp.gmail.com with ESMTPSA id i7sm2311932ejx.73.2021.09.03.01.33.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Sep 2021 01:33:59 -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: 3bb67d0b-f39f-4b34-9864-f3691fc81bea 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=/GHtMwVtwcasyb8hly1Zcy56jKyqF6v6oGi9z4wXBlU=; b=mQ3lDyAu7ulppaS1JJy+SWOFwu+RvtpP1zI3cgCUuBtIuinOwyvLCIG9MxewYdI7wb dV/QNQp9gaBilxa1L3saoMIiNAKa4GjxcPpTanA20hGKCzz5QpJAiNHS/6eiO+aEby+f l7w6stPig8p506HVXOzw2BgAPYcOwkZ+OD0tZuyYui/AU5k+tg6rbLKS49n75aRhxpxL FFVTa9P9ikuYd6dbk2C9zfDC/kBVTCpJCMhTRepxDPdAUW12LYD4QcV3R1ooZ2wQyzED /H+subTI7EzgC9RApqZqRkYcedmNM4JZlibRP0m4S+GaRm+tZmLehtpvYwPU05nhGVEk 4LLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/GHtMwVtwcasyb8hly1Zcy56jKyqF6v6oGi9z4wXBlU=; b=O4lfH5P6mjh536gva7arPTU9Frb1mcd1r2huTLL9NwRMe4CMVErcHhWA1YyUz1Gn8F tWfkw4jaYubWiEFKwx6qq7PfIWMfh3MD4b+gmG5TbpkKLeHzxcAHMD8Elrjo7PNIUkrf H5cMpYSQSQfTGWG2V2unKdAlXz2FgOFAj6TtXZQol9SqCt3ULYAbvE/PYzawRwWMsMvj nrO9aLXEqip9GkQlLsUeqsJ7kojKilNOv3gnZ+7ULWhIniUF9ewwtlG0kNAqCJUjT7Yf c7rucReZ9HOS56umrG5LTZqKfPlceVAGC5FhP7KHWZidf1iVy9oGKU4S3aYtvP7iNLvJ 02+w== X-Gm-Message-State: AOAM532JkJfQzvOgGj6QtsslnH1vxGZEAnffzrJ39RlJGKs5sgjk4mFU wGuCSbTMJ19X/nPsKqJSSQtMf6X5OsU= X-Google-Smtp-Source: ABdhPJzkdXq4/oqy7sAR6jAHLZTgcQFNU12ssgRybTwH6NU5CgLqCQqqVvZtmbSCS+UTenNgcBH03A== X-Received: by 2002:a17:906:2a8e:: with SMTP id l14mr2909109eje.321.1630658039681; Fri, 03 Sep 2021 01:33:59 -0700 (PDT) From: Oleksandr Andrushchenko To: xen-devel@lists.xenproject.org Cc: julien@xen.org, sstabellini@kernel.org, oleksandr_tyshchenko@epam.com, volodymyr_babchuk@epam.com, Artem_Mygaiev@epam.com, roger.pau@citrix.com, bertrand.marquis@arm.com, rahul.singh@arm.com, Oleksandr Andrushchenko Subject: [PATCH 09/11] xen/arm: Setup MMIO range trap handlers for hardware domain Date: Fri, 3 Sep 2021 11:33:45 +0300 Message-Id: <20210903083347.131786-10-andr2000@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210903083347.131786-1-andr2000@gmail.com> References: <20210903083347.131786-1-andr2000@gmail.com> MIME-Version: 1.0 From: Oleksandr Andrushchenko In order vPCI to work it needs all access to PCI configuration space (ECAM) to be synchronized among all entities, e.g. hardware domain and guests. For that implement PCI host bridge specific callbacks to properly setup those ranges depending on particular host bridge implementation. Signed-off-by: Oleksandr Andrushchenko --- xen/arch/arm/pci/ecam.c | 11 +++++++++++ xen/arch/arm/pci/pci-host-common.c | 16 ++++++++++++++++ xen/arch/arm/vpci.c | 13 +++++++++++++ xen/include/asm-arm/pci.h | 8 ++++++++ 4 files changed, 48 insertions(+) diff --git a/xen/arch/arm/pci/ecam.c b/xen/arch/arm/pci/ecam.c index 91c691b41fdf..92ecb2e0762b 100644 --- a/xen/arch/arm/pci/ecam.c +++ b/xen/arch/arm/pci/ecam.c @@ -42,6 +42,16 @@ void __iomem *pci_ecam_map_bus(struct pci_host_bridge *bridge, return base + (PCI_DEVFN(sbdf_t.dev, sbdf_t.fn) << devfn_shift) + where; } +static int pci_ecam_register_mmio_handler(struct domain *d, + struct pci_host_bridge *bridge, + const struct mmio_handler_ops *ops) +{ + struct pci_config_window *cfg = bridge->sysdata; + + register_mmio_handler(d, ops, cfg->phys_addr, cfg->size, NULL); + return 0; +} + /* ECAM ops */ const struct pci_ecam_ops pci_generic_ecam_ops = { .bus_shift = 20, @@ -49,6 +59,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, + .register_mmio_handler = pci_ecam_register_mmio_handler, } }; diff --git a/xen/arch/arm/pci/pci-host-common.c b/xen/arch/arm/pci/pci-host-common.c index d2fef5476b8e..a89112bfbb7c 100644 --- a/xen/arch/arm/pci/pci-host-common.c +++ b/xen/arch/arm/pci/pci-host-common.c @@ -318,6 +318,22 @@ 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 (*clb)(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 = clb(d, bridge); + if ( err ) + return err; + } + return 0; +} /* * Local variables: * mode: C diff --git a/xen/arch/arm/vpci.c b/xen/arch/arm/vpci.c index da8b1ca13c07..258134292458 100644 --- a/xen/arch/arm/vpci.c +++ b/xen/arch/arm/vpci.c @@ -74,11 +74,24 @@ 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) +{ + if ( bridge->ops->register_mmio_handler ) + return bridge->ops->register_mmio_handler(d, bridge, + &vpci_mmio_handler); + 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); diff --git a/xen/include/asm-arm/pci.h b/xen/include/asm-arm/pci.h index 7dc4c8dc9026..2c7c7649e00f 100644 --- a/xen/include/asm-arm/pci.h +++ b/xen/include/asm-arm/pci.h @@ -17,6 +17,8 @@ #ifndef __ARM_PCI_H__ #define __ARM_PCI_H__ +#include + #ifdef CONFIG_HAS_PCI #define pci_to_dev(pcidev) (&(pcidev)->arch.dev) @@ -77,6 +79,9 @@ struct pci_ops { uint32_t reg, uint32_t len, uint32_t *value); int (*write)(struct pci_host_bridge *bridge, uint32_t sbdf, uint32_t reg, uint32_t len, uint32_t value); + int (*register_mmio_handler)(struct domain *d, + struct pci_host_bridge *bridge, + const struct mmio_handler_ops *ops); }; /* @@ -107,6 +112,9 @@ 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); +int pci_host_iterate_bridges(struct domain *d, + int (*clb)(struct domain *d, + struct pci_host_bridge *bridge)); #else /*!CONFIG_HAS_PCI*/ struct arch_pci_dev { }; From patchwork Fri Sep 3 08:33:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksandr Andrushchenko X-Patchwork-Id: 12473859 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A24E3C433F5 for ; Fri, 3 Sep 2021 08:41:50 +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 4CFAA60FD7 for ; Fri, 3 Sep 2021 08:41:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 4CFAA60FD7 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.177903.323664 (Exim 4.92) (envelope-from ) id 1mM4la-0005z8-Il; Fri, 03 Sep 2021 08:41:42 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 177903.323664; Fri, 03 Sep 2021 08:41:42 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mM4la-0005z1-Fe; Fri, 03 Sep 2021 08:41:42 +0000 Received: by outflank-mailman (input) for mailman id 177903; Fri, 03 Sep 2021 08:41:41 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mM4en-0006kQ-E9 for xen-devel@lists.xenproject.org; Fri, 03 Sep 2021 08:34:41 +0000 Received: from mail-ed1-x531.google.com (unknown [2a00:1450:4864:20::531]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 3cbf0903-612d-4e40-aaea-917bad9342ef; Fri, 03 Sep 2021 08:34:01 +0000 (UTC) Received: by mail-ed1-x531.google.com with SMTP id v5so1613984edc.2 for ; Fri, 03 Sep 2021 01:34:01 -0700 (PDT) Received: from a2klaptop.epam.com (host-176-36-245-220.b024.la.net.ua. [176.36.245.220]) by smtp.gmail.com with ESMTPSA id i7sm2311932ejx.73.2021.09.03.01.33.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Sep 2021 01:34:00 -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: 3cbf0903-612d-4e40-aaea-917bad9342ef 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=RKj8rEW+uLzxBa1xS9FCgER2pVUMxy97v84H9BueJo8=; b=Cc7VjnWxryLAC/tqYxNfb0Vqq0sB/g3r4rmDDY0lS2y4ND5fCxj+3AtTH0jMf3UD7I lArRxEur0IpiP8IRmM5bMXAd2tDTqstoOHd1vrOJQB+pAYbF+caMEs1aDP0y6JUJoUAC xEaHLm1ca7cVFaDLT1hlicqg/QeFfEAaQY7S1SpqIHJhYw6d6GtxExLoUnpq0E0zuH+m 4NCp+Ya/PMN9z0TzuqE1T/2/rlEnc8XJFLpeu56yU2FZu5xlOk5bPOVjQrgrStQv7HvU TwhRciy77N17AemdAXrbaCnjfawSj07zHK5ot06VaJwpM/HtZHOSN1AfqKhUFuuc/1HO ob5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=RKj8rEW+uLzxBa1xS9FCgER2pVUMxy97v84H9BueJo8=; b=oBLpbapiCNQnIjv9Mo/sSyhL3oVakBxi1XwL1Wi7m4raUtBsNmjtGeWCoq7dTXXeTC KhocmQ1iynUJWKyuksEXh1BgFK/jRTRPbFN9qbQGg3QpeHcER3uNfb0r1fulY1GJFamB 62zgQyF5dXtDweUZgg+/rJfYhR1agFpdUJtTWRgPVyZ8E3dkOV4MxOj72N2h1gVKp5b9 vw15weokEfFftha6EM7IAETNzYpDgpzrZhG6Te4CYpQzeWncKy3llziRgqTWuOUkSF5w +q8Ng9ouUhGTopIjWQh/VhFVLNkp8wFO1HvkvKKBqNBPjPXhP9sPPQc9MbI4DGh/0pTk Kzfg== X-Gm-Message-State: AOAM533uKOsAif0Gr5pPehfRtIiQNwbwfBJWC0recNqto4ZX7hQfZS3k Xjt3APquPw91Bq5Rgk6LA7LYf07qXZs= X-Google-Smtp-Source: ABdhPJwyyY+X4Ff7jtwDvNQrMZN78ZPm6ovgltm1mRQGeZ/mmH2TfThaCYtmDMf1K+WgzeKR4mkDAg== X-Received: by 2002:aa7:c9d6:: with SMTP id i22mr605692edt.307.1630658040780; Fri, 03 Sep 2021 01:34:00 -0700 (PDT) From: Oleksandr Andrushchenko To: xen-devel@lists.xenproject.org Cc: julien@xen.org, sstabellini@kernel.org, oleksandr_tyshchenko@epam.com, volodymyr_babchuk@epam.com, Artem_Mygaiev@epam.com, roger.pau@citrix.com, bertrand.marquis@arm.com, rahul.singh@arm.com, Oleksandr Andrushchenko Subject: [PATCH 10/11] xen/arm: Do not map PCI ECAM space to Domain-0's p2m Date: Fri, 3 Sep 2021 11:33:46 +0300 Message-Id: <20210903083347.131786-11-andr2000@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210903083347.131786-1-andr2000@gmail.com> References: <20210903083347.131786-1-andr2000@gmail.com> MIME-Version: 1.0 From: Oleksandr Andrushchenko Host bridge controller's ECAM space is mapped into Domain-0's p2m, thus it is not possible to trap the same for vPCI via MMIO handlers. For this to work we need to not map those while constructing the domain. Note, that during Domain-0 creation there is no pci_dev yet allocated for host bridges, thus we cannot match PCI host and its associated bridge by SBDF. Use dt_device_node field for checks instead. Signed-off-by: Oleksandr Andrushchenko Signed-off-by: Oleksandr Andrushchenko --- xen/arch/arm/domain_build.c | 3 +++ xen/arch/arm/pci/ecam.c | 17 +++++++++++++++++ xen/arch/arm/pci/pci-host-common.c | 22 ++++++++++++++++++++++ xen/include/asm-arm/pci.h | 12 ++++++++++++ 4 files changed, 54 insertions(+) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index da427f399711..76f5b513280c 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -1257,6 +1257,9 @@ static int __init map_range_to_domain(const struct dt_device_node *dev, } } + if ( need_mapping && (device_get_class(dev) == DEVICE_PCI) ) + need_mapping = pci_host_bridge_need_p2m_mapping(d, dev, addr, len); + if ( need_mapping ) { res = map_regions_p2mt(d, diff --git a/xen/arch/arm/pci/ecam.c b/xen/arch/arm/pci/ecam.c index 92ecb2e0762b..d32efb7fcbd0 100644 --- a/xen/arch/arm/pci/ecam.c +++ b/xen/arch/arm/pci/ecam.c @@ -52,6 +52,22 @@ static int pci_ecam_register_mmio_handler(struct domain *d, return 0; } +static int pci_ecam_need_p2m_mapping(struct domain *d, + struct pci_host_bridge *bridge, + uint64_t addr, uint64_t len) +{ + struct pci_config_window *cfg = bridge->sysdata; + + if ( !is_hardware_domain(d) ) + return true; + + /* + * We do not want ECAM address space to be mapped in domain'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, @@ -60,6 +76,7 @@ const struct pci_ecam_ops pci_generic_ecam_ops = { .read = pci_generic_config_read, .write = pci_generic_config_write, .register_mmio_handler = pci_ecam_register_mmio_handler, + .need_p2m_mapping = pci_ecam_need_p2m_mapping, } }; diff --git a/xen/arch/arm/pci/pci-host-common.c b/xen/arch/arm/pci/pci-host-common.c index a89112bfbb7c..c04be636452d 100644 --- a/xen/arch/arm/pci/pci-host-common.c +++ b/xen/arch/arm/pci/pci-host-common.c @@ -334,6 +334,28 @@ int pci_host_iterate_bridges(struct domain *d, } return 0; } + +bool pci_host_bridge_need_p2m_mapping(struct domain *d, + const struct dt_device_node *node, + uint64_t addr, uint64_t len) +{ + struct pci_host_bridge *bridge; + + list_for_each_entry( bridge, &pci_host_bridges, node ) + { + if ( bridge->dt_node != node ) + continue; + + if ( !bridge->ops->need_p2m_mapping ) + return true; + + return bridge->ops->need_p2m_mapping(d, bridge, addr, len); + } + printk(XENLOG_ERR "Unable to find PCI bridge for %s segment %d, addr %lx\n", + node->full_name, bridge->segment, addr); + return true; +} + /* * Local variables: * mode: C diff --git a/xen/include/asm-arm/pci.h b/xen/include/asm-arm/pci.h index 2c7c7649e00f..9c28a4bdc4b7 100644 --- a/xen/include/asm-arm/pci.h +++ b/xen/include/asm-arm/pci.h @@ -82,6 +82,8 @@ struct pci_ops { int (*register_mmio_handler)(struct domain *d, struct pci_host_bridge *bridge, const struct mmio_handler_ops *ops); + int (*need_p2m_mapping)(struct domain *d, struct pci_host_bridge *bridge, + uint64_t addr, uint64_t len); }; /* @@ -115,9 +117,19 @@ struct dt_device_node *pci_find_host_bridge_node(struct device *dev); int pci_host_iterate_bridges(struct domain *d, int (*clb)(struct domain *d, struct pci_host_bridge *bridge)); +bool pci_host_bridge_need_p2m_mapping(struct domain *d, + const struct dt_device_node *node, + uint64_t addr, uint64_t len); #else /*!CONFIG_HAS_PCI*/ struct arch_pci_dev { }; +static inline bool +pci_host_bridge_need_p2m_mapping(struct domain *d, + const struct dt_device_node *node, + uint64_t addr, uint64_t len) +{ + return true; +} #endif /*!CONFIG_HAS_PCI*/ #endif /* __ARM_PCI_H__ */ From patchwork Fri Sep 3 08:33:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksandr Andrushchenko X-Patchwork-Id: 12473857 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E9D43C433EF for ; Fri, 3 Sep 2021 08:41:25 +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 B21E661056 for ; Fri, 3 Sep 2021 08:41:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org B21E661056 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.177892.323653 (Exim 4.92) (envelope-from ) id 1mM4lA-0005HT-4D; Fri, 03 Sep 2021 08:41:16 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 177892.323653; Fri, 03 Sep 2021 08:41: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 1mM4lA-0005HM-1J; Fri, 03 Sep 2021 08:41:16 +0000 Received: by outflank-mailman (input) for mailman id 177892; Fri, 03 Sep 2021 08:41:14 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mM4es-0006kQ-EK for xen-devel@lists.xenproject.org; Fri, 03 Sep 2021 08:34:46 +0000 Received: from mail-ej1-x631.google.com (unknown [2a00:1450:4864:20::631]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 1d926dc1-80ff-4ebb-a723-1fd24234f40a; Fri, 03 Sep 2021 08:34:02 +0000 (UTC) Received: by mail-ej1-x631.google.com with SMTP id lc21so10503499ejc.7 for ; Fri, 03 Sep 2021 01:34:02 -0700 (PDT) Received: from a2klaptop.epam.com (host-176-36-245-220.b024.la.net.ua. [176.36.245.220]) by smtp.gmail.com with ESMTPSA id i7sm2311932ejx.73.2021.09.03.01.34.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Sep 2021 01:34:01 -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: 1d926dc1-80ff-4ebb-a723-1fd24234f40a 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=Xy7BJSB6xaM30OyXxkPFQIY2JXEW71Y3R+/OfIHEOBE=; b=pnUw4Mlz8wE01ctr0MxVIgMnhwLnYDb2XDSr3Mz0utU10pdqiieFvIuxCCByexKtyf B06Oyzl54Te+zID2si0YkZIjwWSmkUavw3mR3hfVyzP1prT4JWTQ2NTIK4x6xtbcRpqc KxtBQtIPNwv9OGv7Awvjre3ntebXcDrWFI2SG529YegtLTDoGtS7s1bc/D2jQxUVo3N7 BdhYDhJHI86NLX1Mc5Y1L3MlkT/LPFTYKEkS5Mb0pAz3/VB/Hn65DqjDFmLtvlvBfV5r z6WPuzwT0gYxxiczN3UQkXeeK6u22iH64pxd2K8aSWXJ8LKEUvYiJdgFvuoa8TTDahw0 xKfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Xy7BJSB6xaM30OyXxkPFQIY2JXEW71Y3R+/OfIHEOBE=; b=Tb8crlNetyA6rFLsr9BPepDhb+mT9n9jfsUBW8A0hc7C/6FqN8EkpaSUFDLxZx5Bm0 EFyPIyQ/FBKiqjBTGdcEYbw27nAms0HXXuw4ith3GQIZT8uX8g1CEoOKpjrOVvimfx5H VFMdHmp7LNZHQUWt6F++n7mtvjQ/iZ8tJxutQaf0Kz6YLSq1dX3aT0TA8EMRT1vHN9rG 0SszP9zXs6zXvrFAGNX6T38VwiduYKf+EWML+ycm9J+wssNO5DKunxRWtf/kP9F0INQM XVNDV/9u0aMfmHpyMCkGGxpYEBsyY5xUaq+gFNREXGgYvoPUo+WA5dUXo5WPfPCrtixp oKOw== X-Gm-Message-State: AOAM5308j4Iig0X44JLaWCBB9ZOGEhuPoZvkJFtBcA9wOI/JQwhpGQ33 8s99qzGcnqNjJqAC3WcSHIWGHWQ1amo= X-Google-Smtp-Source: ABdhPJyJcdfQj9c9044SVO6J1UJQYGNr5fMQWFYrfhn9ETnMa9xx30aD81J57K8Jf8DgGximyczXvQ== X-Received: by 2002:a17:907:2174:: with SMTP id rl20mr2987996ejb.199.1630658041886; Fri, 03 Sep 2021 01:34:01 -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 11/11] xen/arm: Process pending vPCI map/unmap operations Date: Fri, 3 Sep 2021 11:33:47 +0300 Message-Id: <20210903083347.131786-12-andr2000@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210903083347.131786-1-andr2000@gmail.com> References: <20210903083347.131786-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. Run the corresponding vPCI code while switching a vCPU. Signed-off-by: Oleksandr Andrushchenko --- xen/arch/arm/traps.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c index 219ab3c3fbde..1571fb8afd03 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,11 @@ static bool check_for_vcpu_work(void) } #endif + local_irq_enable(); + if ( has_vpci(v->domain) && vpci_process_pending(v) ) + raise_softirq(SCHEDULE_SOFTIRQ); + local_irq_disable(); + if ( likely(!v->arch.need_flush_to_ram) ) return false;