From patchwork Mon Apr 3 20:28:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Przywara X-Patchwork-Id: 9660553 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 2AE7F6032D for ; Mon, 3 Apr 2017 20:29:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1CC3D28403 for ; Mon, 3 Apr 2017 20:29:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 119632841C; Mon, 3 Apr 2017 20:29:01 +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 88D7C28403 for ; Mon, 3 Apr 2017 20:29:00 +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 1cv8Z4-0005Zt-Tt; Mon, 03 Apr 2017 20:27:02 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cv8Z3-0005VY-Mc for xen-devel@lists.xenproject.org; Mon, 03 Apr 2017 20:27:01 +0000 Received: from [85.158.143.35] by server-4.bemta-6.messagelabs.com id BA/63-03012-510B2E85; Mon, 03 Apr 2017 20:27:01 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrELMWRWlGSWpSXmKPExsVysyfVTVdkw6M Ig2szZC2+b5nM5MDocfjDFZYAxijWzLyk/IoE1owFpxewFnxSq9j/0ruBcb5MFyMXh5DAJkaJ v+sPMUI4yxklTvW+ZOpi5ORgE9CV2HHzNTOILSIQKvF0wXcwm1lASWL/2WuMILawgIvE3ylH2 UBsFgFViV87F4P18gpYSyxa9ggsLiEgJ9Fw/j5YLydQvPXjUbBeIQEriQkPm5gmMHIvYGRYxa hRnFpUllqka2Sul1SUmZ5RkpuYmaNraGCml5taXJyYnpqTmFSsl5yfu4kR6F8GINjBuHht4CF GSQ4mJVFe9UmPIoT4kvJTKjMSizPii0pzUosPMWpwcAhsXrv6AqMUS15+XqqSBO+xdUB1gkWp 6akVaZk5wACEKZXg4FES4d0MkuYtLkjMLc5Mh0idYlSUEuflXw+UEABJZJTmwbXBgv4So6yUM C8j0FFCPAWpRbmZJajyrxjFORiVhHlvgIznycwrgZv+CmgxE9DiJ3cegiwuSURISTUwJjB+FL BXL7nHmWT+9ULG5BM5JT8tfjJOb7lw+svm8Bs6Nysu3Vb1O9jh7ebnE7hUPGWmRE3fA/7ye56 vmr1098d0C27oZHwUsYpr63PJv0Hc3ad4H+wzdPlWUm6Yq1Aa8E9Q5dHGnQUN9fIp9qzX36+u zjU+efFxUMHmZR3mym+j7v6df1JHiaU4I9FQi7moOBEAQlkJuHUCAAA= X-Env-Sender: andre.przywara@arm.com X-Msg-Ref: server-13.tower-21.messagelabs.com!1491251219!56020266!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 24538 invoked from network); 3 Apr 2017 20:27:00 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-13.tower-21.messagelabs.com with SMTP; 3 Apr 2017 20:27:00 -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 9B9AD80D; Mon, 3 Apr 2017 13:26:59 -0700 (PDT) Received: from e104803-lin.lan (unknown [10.1.207.46]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 788F63F4FF; Mon, 3 Apr 2017 13:26:58 -0700 (PDT) From: Andre Przywara To: Julien Grall , Stefano Stabellini Date: Mon, 3 Apr 2017 21:28:28 +0100 Message-Id: <20170403202829.7278-27-andre.przywara@arm.com> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20170403202829.7278-1-andre.przywara@arm.com> References: <20170403202829.7278-1-andre.przywara@arm.com> Cc: xen-devel@lists.xenproject.org Subject: [Xen-devel] [PATCH v4 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 f611e2f..13b21bf 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 @@ -859,6 +860,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 eda3410..ddfdd97 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 fb05311..abf9e8c 100644 --- a/xen/include/asm-arm/gic_v3_its.h +++ b/xen/include/asm-arm/gic_v3_its.h @@ -161,6 +161,12 @@ int gicv3_its_setup_collection(unsigned int cpu); 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. @@ -234,6 +240,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 */