From patchwork Thu May 11 17:53:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Przywara X-Patchwork-Id: 9722643 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 84A2B60387 for ; Thu, 11 May 2017 17:53:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8285F286E5 for ; Thu, 11 May 2017 17:53:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 767F5286E7; Thu, 11 May 2017 17:53:44 +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 0D217286E6 for ; Thu, 11 May 2017 17:53:44 +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 1d8sG0-0001EO-1M; Thu, 11 May 2017 17:52:08 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d8sFy-0000ym-4P for xen-devel@lists.xenproject.org; Thu, 11 May 2017 17:52:06 +0000 Received: from [85.158.137.68] by server-8.bemta-3.messagelabs.com id 71/2B-02183-5C4A4195; Thu, 11 May 2017 17:52:05 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrMLMWRWlGSWpSXmKPExsVysyfVTffoEpF Ig0cLuSy+b5nM5MDocfjDFZYAxijWzLyk/IoE1ozze7vYC16pVDR9W8TWwNgk3cXIxSEksJlR 4texp6wQznIg59Fcpi5GTg42AV2JHTdfM4PYIgKhEk8XfGcGKWIWWMMocW7RTzaQhLCAi8ThG wtYQGwWAVWJqw/usoLYvALWEr8+r2QHsSUE5CQazt8HG8QJFF8yfRZYvZCAlcSu3adZJzByL2 BkWMWoXpxaVJZapGuql1SUmZ5RkpuYmaNraGCsl5taXJyYnpqTmFSsl5yfu4kR6OF6BgbGHYy XvzodYpTkYFIS5WWcKBIpxJeUn1KZkVicEV9UmpNafIhRg4NDYPPa1RcYpVjy8vNSlSR4IxcD 1QkWpaanVqRl5gBDEKZUgoNHSYR38yKgNG9xQWJucWY6ROoUo6KUOC8PSJ8ASCKjNA+uDRb2l xhlpYR5GRkYGIR4ClKLcjNLUOVfMYpzMCoJ8+4EmcKTmVcCN/0V0GImoMX9f4RBFpckIqSkGh i3LOSd8fa4PUtTyWcd/stfAl4HcW4oMvgRlRRjL8dg1L7m2lensuTelYGXdTxtH340mfpNUPC u3/oEfpsSyar/j/USPuzpubJ0+7tI067CZczniiZVhex/JxPPs/zdg08nKmd2njrKZei6/F8C Y5LqKf+2DsW6j9mGRhMLN3V7rErWvB+/zUCJpTgj0VCLuag4EQD+igrOdgIAAA== X-Env-Sender: andre.przywara@arm.com X-Msg-Ref: server-5.tower-31.messagelabs.com!1494525124!96792875!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.12; banners=-,-,- X-VirusChecked: Checked Received: (qmail 9398 invoked from network); 11 May 2017 17:52:04 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-5.tower-31.messagelabs.com with SMTP; 11 May 2017 17:52:04 -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 3E1621C01; Thu, 11 May 2017 10:52:04 -0700 (PDT) Received: from e104803-lin.lan (unknown [10.1.207.46]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 183063F4FF; Thu, 11 May 2017 10:52:02 -0700 (PDT) From: Andre Przywara To: Julien Grall , Stefano Stabellini Date: Thu, 11 May 2017 18:53:40 +0100 Message-Id: <20170511175340.8448-29-andre.przywara@arm.com> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20170511175340.8448-1-andre.przywara@arm.com> References: <20170511175340.8448-1-andre.przywara@arm.com> Cc: xen-devel@lists.xenproject.org, Vijaya Kumar K , Vijay Kilari , Shanker Donthineni Subject: [Xen-devel] [PATCH v9 28/28] 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 | 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 f00597e..339ecce 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 @@ -945,6 +946,78 @@ int gicv3_lpi_change_vcpu(struct domain *d, paddr_t vdoorbell, return 0; } +/* + * 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 e41f8fd..94c577a 100644 --- a/xen/include/asm-arm/gic_v3_its.h +++ b/xen/include/asm-arm/gic_v3_its.h @@ -162,6 +162,11 @@ void vgic_v3_its_free_domain(struct domain *d); int vgic_v3_its_init_virtual(struct domain *d, paddr_t guest_addr, unsigned int devid_bits, unsigned int evid_bits); +/* 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. @@ -248,6 +253,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