From patchwork Wed Apr 5 23:19:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Przywara X-Patchwork-Id: 9665875 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 A174760352 for ; Wed, 5 Apr 2017 23:22:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 936802816B for ; Wed, 5 Apr 2017 23:22:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8885D28584; Wed, 5 Apr 2017 23:22: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 215512816B for ; Wed, 5 Apr 2017 23:22:52 +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 1cvuEv-0005Sm-A8; Wed, 05 Apr 2017 23:21:25 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cvuEt-0005OW-S1 for xen-devel@lists.xenproject.org; Wed, 05 Apr 2017 23:21:23 +0000 Received: from [85.158.137.68] by server-12.bemta-3.messagelabs.com id 5B/44-12861-3FB75E85; Wed, 05 Apr 2017 23:21:23 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrILMWRWlGSWpSXmKPExsVysyfVTfdT9dM IgzurdSy+b5nM5MDocfjDFZYAxijWzLyk/IoE1oye3RfYCj6qVbROucXcwDhPpouRi0NIYBOj xISXF1ggnL2MEm9ePWHrYuTkYBPQldhx8zUziC0iECox5+cjIJuDg1mgUqJ7ET9IWFjAReLJr UcsIDaLgKrE789zWUFsXgF3iUXTT7GBlEsIyElc+ZcAEuYECr9sPQZWLiTgJnFt4lSWCYzcCx gZVjFqFKcWlaUW6RqZ6yUVZaZnlOQmZuboGhoY6+WmFhcnpqfmJCYV6yXn525iBHq3noGBcQd jy16/Q4ySHExKorwKPk8ihPiS8lMqMxKLM+KLSnNSiw8xanBwCGxeu/oCoxRLXn5eqpIELx8w iIQEi1LTUyvSMnOA4QdTKsHBoyTCqw2S5i0uSMwtzkyHSJ1iVJQS5+UFSQiAJDJK8+DaYCF/i VFWSpiXkYGBQYinILUoN7MEVf4VozgHo5IwryfIFJ7MvBK46a+AFjMBLX5y5yHI4pJEhJRUA6 Ps98BpJVfdt/8pDXZJ8K0TKHps0zfhW9Sxlu+H+qu27FjF+D5n/ov3gY6TL+kGH58QXcPVxfr jebeZd+2MjMoZItGhoYwt7D17bnfNKuKNTzLgFp4nmD+v7/WEZV3W86236QdpxlyorjbduzpS 5uvuSE3fpYePn9ut9fAalwbTzEfvHV/t+qzEUpyRaKjFXFScCABWudB4dAIAAA== X-Env-Sender: andre.przywara@arm.com X-Msg-Ref: server-12.tower-31.messagelabs.com!1491434482!77642431!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 18065 invoked from network); 5 Apr 2017 23:21:22 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-12.tower-31.messagelabs.com with SMTP; 5 Apr 2017 23:21:22 -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 CBADFB16; Wed, 5 Apr 2017 16:21:21 -0700 (PDT) Received: from slackpad.lan (usa-sjc-mx-foss1.foss.arm.com [217.140.101.70]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 886B73F4FF; Wed, 5 Apr 2017 16:21:20 -0700 (PDT) From: Andre Przywara To: Stefano Stabellini , Julien Grall Date: Thu, 6 Apr 2017 00:19:21 +0100 Message-Id: <1491434362-30310-30-git-send-email-andre.przywara@arm.com> X-Mailer: git-send-email 2.8.2 In-Reply-To: <1491434362-30310-1-git-send-email-andre.przywara@arm.com> References: <1491434362-30310-1-git-send-email-andre.przywara@arm.com> Cc: xen-devel@lists.xenproject.org, Shanker Donthineni , Vijay Kilari Subject: [Xen-devel] [PATCH v5 29/30] 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 a57e63a..a167471 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 @@ -875,6 +876,83 @@ int gicv3_lpi_change_vcpu(struct domain *d, paddr_t vdoorbell, 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 54fbb19..2fbcf52 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_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 1b8e47c..6538916 100644 --- a/xen/include/asm-arm/gic_v3_its.h +++ b/xen/include/asm-arm/gic_v3_its.h @@ -165,6 +165,12 @@ 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 intid_bits); +/* 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. @@ -248,6 +254,13 @@ static inline int vgic_v3_its_init_virtual(struct domain *d, { 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 */