From patchwork Thu Mar 16 11:20:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Przywara X-Patchwork-Id: 9627949 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 326656048C for ; Thu, 16 Mar 2017 11:20:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 267D3285B5 for ; Thu, 16 Mar 2017 11:20:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1B30F28628; Thu, 16 Mar 2017 11:20:52 +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 AA913285B5 for ; Thu, 16 Mar 2017 11:20:51 +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 1coTRH-00005a-0e; Thu, 16 Mar 2017 11:19:27 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1coTRF-0008TJ-UA for xen-devel@lists.xenproject.org; Thu, 16 Mar 2017 11:19:26 +0000 Received: from [85.158.137.68] by server-12.bemta-3.messagelabs.com id C8/08-12861-CB47AC85; Thu, 16 Mar 2017 11:19:24 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrMLMWRWlGSWpSXmKPExsVysyfVTXd3yak Ig5d/VC2+b5nM5MDocfjDFZYAxijWzLyk/IoE1oyWhjfsBRfUKp7dmcncwNgu08XIxSEksJlR 4tfGw8wQznJGid7lSxi7GDk52AR0JXbcfM0MYosIhErM+fkIzGYWqJS4+GE/G4gtLOAi0fvuJ FicRUBVYt2cP6wgNq+AjcSEjilgcQkBOYmG8/fBbE6geMfJPWC9QgLWEp+PfmafwMi9gJFhFa NGcWpRWWqRrqGRXlJRZnpGSW5iZo6uoYGxXm5qcXFiempOYlKxXnJ+7iZGoIcZgGAH46tu50O MkhxMSqK85T9ORAjxJeWnVGYkFmfEF5XmpBYfYtTg4BDYvHb1BUYplrz8vFQlCV5lkDrBotT0 1Iq0zBxgCMKUSnDwKInwXgZJ8xYXJOYWZ6ZDpE4xKkqJ88qAJARAEhmleXBtsLC/xCgrJczLC HSUEE9BalFuZgmq/CtGcQ5GJWHeVJApPJl5JXDTXwEtZgJa/PYD2OKSRISUVAOj626zt4tk5E 7MtZKdW2gu9939RcIvt3uZQgsndfScqvu5MFj33bkoi3/6GtzGv9O6zrRKHtqUl/n7nF34u35 xuVUayuadZXs1dZJ/8y67c9vpaUH+q+oVrxUDtNRd9hsrbDao+ciyQ3rzia1Nay1OBzw7cb9k 14csF7vy2est/KY0LWef91xBiaU4I9FQi7moOBEANxmopXYCAAA= X-Env-Sender: andre.przywara@arm.com X-Msg-Ref: server-13.tower-31.messagelabs.com!1489663162!89921580!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.2.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 46375 invoked from network); 16 Mar 2017 11:19:23 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-13.tower-31.messagelabs.com with SMTP; 16 Mar 2017 11:19:23 -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 B012F13D5; Thu, 16 Mar 2017 04:19:22 -0700 (PDT) Received: from e104803-lin.lan (unknown [10.1.207.46]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id A93BE3F5C9; Thu, 16 Mar 2017 04:19:21 -0700 (PDT) From: Andre Przywara To: Stefano Stabellini , Julien Grall Date: Thu, 16 Mar 2017 11:20:29 +0000 Message-Id: <20170316112030.20419-27-andre.przywara@arm.com> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20170316112030.20419-1-andre.przywara@arm.com> References: <20170316112030.20419-1-andre.przywara@arm.com> Cc: xen-devel@lists.xenproject.org, Shanker Donthineni , Vijay Kilari Subject: [Xen-devel] [PATCH v2 26/27] 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 --- xen/arch/arm/gic-v3-its.c | 78 ++++++++++++++++++++++++++++++++++++++++ xen/arch/arm/gic-v3.c | 4 ++- xen/include/asm-arm/gic_v3_its.h | 13 +++++++ 3 files changed, 94 insertions(+), 1 deletion(-) diff --git a/xen/arch/arm/gic-v3-its.c b/xen/arch/arm/gic-v3-its.c index aa9b1b2..b8fe5a3 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 @@ -802,6 +803,83 @@ int gicv3_lpi_change_vcpu(struct domain *d, paddr_t doorbell, return 0; } +/* + * Create the respective guest DT nodes for a list of host ITSes. + * This copies the reg property, so the guest sees the ITS at the same address + * as the host. + * Giving NULL for the its_list will make it use the list of host ITSes. + */ +int gicv3_its_make_dt_nodes(struct list_head *its_list, + 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 ( !its_list ) + its_list = &host_its_list; + + if ( list_empty(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, 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 83a839a..f9193a6 100644 --- a/xen/arch/arm/gic-v3.c +++ b/xen/arch/arm/gic-v3.c @@ -1167,8 +1167,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_dt_nodes(NULL, 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 55ef143..67cd48d 100644 --- a/xen/include/asm-arm/gic_v3_its.h +++ b/xen/include/asm-arm/gic_v3_its.h @@ -154,6 +154,12 @@ int gicv3_its_setup_collection(unsigned int cpu); */ int vgic_v3_its_init_virtual(struct domain *d, paddr_t guest_addr); +/* Given a list of ITSes, create the appropriate DT nodes for a domain. */ +int gicv3_its_make_dt_nodes(struct list_head *its_list, + 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. @@ -222,6 +228,13 @@ static inline int vgic_v3_its_init_virtual(struct domain *d, paddr_t guest_addr) { return 0; } +static inline int gicv3_its_make_dt_nodes(struct list_head *its_list, + const struct domain *d, + const struct dt_device_node *gic, + void *fdt) +{ + return 0; +} #endif /* CONFIG_HAS_ITS */