From patchwork Fri Jun 9 17:41:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Przywara X-Patchwork-Id: 9779027 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 429E760318 for ; Fri, 9 Jun 2017 17:44:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2F609286E0 for ; Fri, 9 Jun 2017 17:44:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 24481286E7; Fri, 9 Jun 2017 17:44:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A4F61286E2 for ; Fri, 9 Jun 2017 17:44:11 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dJNvg-0004pw-40; Fri, 09 Jun 2017 17:42:36 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dJNvd-0004jh-Vz for xen-devel@lists.xenproject.org; Fri, 09 Jun 2017 17:42:34 +0000 Received: from [193.109.254.147] by server-2.bemta-6.messagelabs.com id FC/58-03058-90EDA395; Fri, 09 Jun 2017 17:42:33 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrMLMWRWlGSWpSXmKPExsVysyfVTZfjnlW kQX+rqcX3LZOZHBg9Dn+4whLAGMWamZeUX5HAmjH/5hbWgv8qFRu6rRoYF0h3MXJxCAlsZpTY tv0kG4SznFHi+7apTF2MnBxsAroSO26+ZgaxRQRCJZ4u+M4MUsQscJ1R4vSO+WwgCWEBV4m/7 5aDNbAIqEo8ObCKBcTmFbCWWDf5BjuILSEgJ9Fw/j7YIE6g+LY9a8F6hQSsJFoOXWafwMi9gJ FhFaNGcWpRWWqRrpGlXlJRZnpGSW5iZo6uoYGZXm5qcXFiempOYlKxXnJ+7iZGoIcZgGAH44F FgYcYJTmYlER5pxVYRQrxJeWnVGYkFmfEF5XmpBYfYtTg4BDYvHb1BUYplrz8vFQlCd5Xd4Dq BItS01Mr0jJzgCEIUyrBwaMkwvviJFCat7ggMbc4Mx0idYpRUUqcdyNInwBIIqM0D64NFvaXG GWlhHkZgY4S4ilILcrNLEGVf8UozsGoJMxreBdoCk9mXgnc9FdAi5mAFi95ZwGyuCQRISXVwF jeEy/20vesCKd56su/rkHHdy9138e3hetIKtekrykN5vsdWzrconm2Van1GLZ6z/uXyrdT6/g PlfVC4ot+KK9sbFSp9/VU0Dx3bkqz5IHVbwrmHdunsenfwS9CMi4u395r71PM2VM2b7JFwd6r /Ctm7hFRfGr4N05qZ60SR3G0Z/0KCcntCUosxRmJhlrMRcWJAGqTMW52AgAA X-Env-Sender: andre.przywara@arm.com X-Msg-Ref: server-16.tower-27.messagelabs.com!1497030152!106615710!1 X-Originating-IP: [217.140.101.70] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.19; banners=-,-,- X-VirusChecked: Checked Received: (qmail 18651 invoked from network); 9 Jun 2017 17:42:32 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-16.tower-27.messagelabs.com with SMTP; 9 Jun 2017 17:42:32 -0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 0D0D315BF; Fri, 9 Jun 2017 10:42:32 -0700 (PDT) Received: from e104803-lin.lan (unknown [10.1.207.46]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id B73EC3F578; Fri, 9 Jun 2017 10:42:30 -0700 (PDT) From: Andre Przywara To: Julien Grall , Stefano Stabellini Date: Fri, 9 Jun 2017 18:41:41 +0100 Message-Id: <20170609174141.5068-35-andre.przywara@arm.com> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20170609174141.5068-1-andre.przywara@arm.com> References: <20170609174141.5068-1-andre.przywara@arm.com> Cc: xen-devel@lists.xenproject.org, Vijaya Kumar K , Vijay Kilari , Shanker Donthineni , Manish Jaggi Subject: [Xen-devel] [PATCH v11 34/34] ARM: vITS: create ITS subnodes for Dom0 DT X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP Dom0 expects all ITSes in the system to be propagated to be able to use MSIs. Create Dom0 DT nodes for each hardware ITS, keeping the register frame address the same, as the doorbell address that the Dom0 drivers program into the BARs has to match the hardware. Signed-off-by: Andre Przywara Acked-by: Julien Grall --- xen/arch/arm/gic-v3-its.c | 73 ++++++++++++++++++++++++++++++++++++++++ xen/arch/arm/gic-v3.c | 4 ++- xen/include/asm-arm/gic_v3_its.h | 12 +++++++ 3 files changed, 88 insertions(+), 1 deletion(-) diff --git a/xen/arch/arm/gic-v3-its.c b/xen/arch/arm/gic-v3-its.c index 3d863cd..2d36030 100644 --- a/xen/arch/arm/gic-v3-its.c +++ b/xen/arch/arm/gic-v3-its.c @@ -20,6 +20,7 @@ #include #include +#include #include #include #include @@ -903,6 +904,78 @@ struct pending_irq *gicv3_assign_guest_event(struct domain *d, return pirq; } +/* + * Create the respective guest DT nodes from a list of host ITSes. + * This copies the reg property, so the guest sees the ITS at the same address + * as the host. + */ +int gicv3_its_make_hwdom_dt_nodes(const struct domain *d, + const struct dt_device_node *gic, + void *fdt) +{ + uint32_t len; + int res; + const void *prop = NULL; + const struct dt_device_node *its = NULL; + const struct host_its *its_data; + + if ( list_empty(&host_its_list) ) + return 0; + + /* The sub-nodes require the ranges property */ + prop = dt_get_property(gic, "ranges", &len); + if ( !prop ) + { + printk(XENLOG_ERR "Can't find ranges property for the gic node\n"); + return -FDT_ERR_XEN(ENOENT); + } + + res = fdt_property(fdt, "ranges", prop, len); + if ( res ) + return res; + + list_for_each_entry(its_data, &host_its_list, entry) + { + its = its_data->dt_node; + + res = fdt_begin_node(fdt, its->name); + if ( res ) + return res; + + res = fdt_property_string(fdt, "compatible", "arm,gic-v3-its"); + if ( res ) + return res; + + res = fdt_property(fdt, "msi-controller", NULL, 0); + if ( res ) + return res; + + if ( its->phandle ) + { + res = fdt_property_cell(fdt, "phandle", its->phandle); + if ( res ) + return res; + } + + /* Use the same reg regions as the ITS node in host DTB. */ + prop = dt_get_property(its, "reg", &len); + if ( !prop ) + { + printk(XENLOG_ERR "GICv3: Can't find ITS reg property.\n"); + res = -FDT_ERR_XEN(ENOENT); + return res; + } + + res = fdt_property(fdt, "reg", prop, len); + if ( res ) + return res; + + fdt_end_node(fdt); + } + + return res; +} + /* Scan the DT for any ITS nodes and create a list of host ITSes out of it. */ void gicv3_its_dt_init(const struct dt_device_node *node) { diff --git a/xen/arch/arm/gic-v3.c b/xen/arch/arm/gic-v3.c index d539d6c..c927306 100644 --- a/xen/arch/arm/gic-v3.c +++ b/xen/arch/arm/gic-v3.c @@ -1172,8 +1172,10 @@ static int gicv3_make_hwdom_dt_node(const struct domain *d, res = fdt_property(fdt, "reg", new_cells, len); xfree(new_cells); + if ( res ) + return res; - return res; + return gicv3_its_make_hwdom_dt_nodes(d, gic, fdt); } static const hw_irq_controller gicv3_host_irq_type = { diff --git a/xen/include/asm-arm/gic_v3_its.h b/xen/include/asm-arm/gic_v3_its.h index 459b6fe..1fac1c7 100644 --- a/xen/include/asm-arm/gic_v3_its.h +++ b/xen/include/asm-arm/gic_v3_its.h @@ -158,6 +158,11 @@ int gicv3_its_setup_collection(unsigned int cpu); int vgic_v3_its_init_domain(struct domain *d); void vgic_v3_its_free_domain(struct domain *d); +/* Create the appropriate DT nodes for a hardware domain. */ +int gicv3_its_make_hwdom_dt_nodes(const struct domain *d, + const struct dt_device_node *gic, + void *fdt); + /* * Map a device on the host by allocating an ITT on the host (ITS). * "nr_event" specifies how many events (interrupts) this device will need. @@ -242,6 +247,13 @@ static inline void vgic_v3_its_free_domain(struct domain *d) { } +static inline int gicv3_its_make_hwdom_dt_nodes(const struct domain *d, + const struct dt_device_node *gic, + void *fdt) +{ + return 0; +} + #endif /* CONFIG_HAS_ITS */ #endif