From patchwork Mon Feb 1 09:26:37 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: vijayak@caviumnetworks.com X-Patchwork-Id: 8177361 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 89481BEEE5 for ; Mon, 1 Feb 2016 09:33:26 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8C45B2041D for ; Mon, 1 Feb 2016 09:33:24 +0000 (UTC) Received: from lists.xen.org (lists.xenproject.org [50.57.142.19]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 086E62041E for ; Mon, 1 Feb 2016 09:33:23 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aQAoc-0006xu-Su; Mon, 01 Feb 2016 09:30:34 +0000 Received: from mail6.bemta4.messagelabs.com ([85.158.143.247]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aQAo6-0006n6-FW for xen-devel@lists.xen.org; Mon, 01 Feb 2016 09:30:02 +0000 Received: from [85.158.143.35] by server-2.bemta-4.messagelabs.com id B8/40-08977-9952FA65; Mon, 01 Feb 2016 09:30:01 +0000 X-Env-Sender: Vijaya.Kumar@caviumnetworks.com X-Msg-Ref: server-14.tower-21.messagelabs.com!1454318996!13209561!1 X-Originating-IP: [207.46.100.58] X-SpamReason: No, hits=0.5 required=7.0 tests=BODY_RANDOM_LONG X-StarScan-Received: X-StarScan-Version: 7.35.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 16898 invoked from network); 1 Feb 2016 09:30:00 -0000 Received: from mail-by2on0058.outbound.protection.outlook.com (HELO na01-by2-obe.outbound.protection.outlook.com) (207.46.100.58) by server-14.tower-21.messagelabs.com with AES256-SHA256 encrypted SMTP; 1 Feb 2016 09:30:00 -0000 Received: from cavium-Vostro-2520.caveonetworks.com (111.93.218.67) by BN3PR0701MB1688.namprd07.prod.outlook.com (10.163.39.154) with Microsoft SMTP Server (TLS) id 15.1.396.15; Mon, 1 Feb 2016 09:29:51 +0000 From: To: , , , , , Date: Mon, 1 Feb 2016 14:56:37 +0530 Message-ID: <1454318798-31913-28-git-send-email-vijayak@caviumnetworks.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1454318798-31913-1-git-send-email-vijayak@caviumnetworks.com> References: <1454318798-31913-1-git-send-email-vijayak@caviumnetworks.com> MIME-Version: 1.0 X-Originating-IP: [111.93.218.67] X-ClientProxiedBy: BM1PR01CA0026.INDPRD01.PROD.OUTLOOK.COM (25.163.198.161) To BN3PR0701MB1688.namprd07.prod.outlook.com (25.163.39.154) X-Microsoft-Exchange-Diagnostics: 1; BN3PR0701MB1688; 2:Rmqxr1BS+cu+4Z1hy2hlT9fKHpvbmZbFMB3kaeCtKllXqG1zyR5nxPjyvve2Y4l6/87tl0gdp85RZt0EL039A7VwJn5pIHlZxZHNf3M5yQNVjGIlDIcGCKwqa0baX3zrOklTxp/sMx1CbuSZgkSL9w==; 3:MsGhX34Zj3MqpnlkA5fhA9PmVGTgkNh96WnshsSS6l2EOOgh1TEjajpTxjlo9nwZH0gI3vjrvGg4K5PohFjic2HbDJkTFfGpJePnyDXalfPj83KbsXi9W462I7w6NQgt; 25:Ps/Bf3vEjnBNp/MXNLov53U9IEKDg3hhv1fGNY+E7Mr5VuiN0ztGto/A0mvVoNizeBL1WBQ6rz7GY3EN6piAZ5IlBPvmQUiWOy9yMWg52lBkztVEHbkCnJzM7BlN4UeY+HNoZGyH8kBD+yA2fOyw+AZJLs7XcZdRj2l4BbvyWoXwRYUKpemHWpVHeH7R7FmaUMUiUouXHcy0/O3Wub8JAe9iG5N9+dG50RpW5AEERJK+2UtKHAoKou8zyUfX/zPo X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BN3PR0701MB1688; X-MS-Office365-Filtering-Correlation-Id: f260bd90-973a-453d-4aad-08d32aea3e8e X-Microsoft-Exchange-Diagnostics: 1; BN3PR0701MB1688; 20:ylfUhVbLor0MmHpjV3QHLNDJpUisMY0JfYpYixYc5H6vxf4MCW6viO/Uj+4JK5eW5eTyUz8SnD3kbbAnfPz1DxRYA5xQFXVhq7AabIH6mwKGnOem9te9qjLsKkNU12cfdw96qmRkpkIAFqmdKupkyZ78FxW/Id5qUXOM/dsIfmn1TB7gRGfsPXFFhPjrenzto7ESyTzAuM0eeR2gcjts1S16oov8wl34JJ6thh57cZ+U/x6OOTkSYEcuxd1TosXxlEHmcPAwSeQWPrP133tNfphUUzXvSF5T7fL5PWU8dXTK1CsBUaZqXuK/hGWqMxXjmH8U2+2+iNOnWnHFq8B+1lFc4rOO1sCxhHwVbrXs9QYHyV4vsWXjub2Ma6LBuSO6QxF46DwYuZwFbfW2RMzlK0ClXPutOiWqSchTBKwZNbPA+hUiY15w7l7ODJEQLwpCstdCnKdH00vNtL2/JxNjiqR0Dvx0EJGiXBFByopd8Zgzm5JhUhac+NQLqx0k5sEDcPn1recQlzNOtZTEtY6EJKaD+uIkWPP5lynyo4k27Z4CdG1aqyEueRPdv8dGZ/K1mzBwK2dntPRkuBgMs2zUjQiq3ZSmpux3XyT6phKUeWY= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(5005006)(8121501046)(3002001)(10201501046); SRVR:BN3PR0701MB1688; BCL:0; PCL:0; RULEID:; SRVR:BN3PR0701MB1688; X-Microsoft-Exchange-Diagnostics: 1; BN3PR0701MB1688; 4:fgtMBfyGXq4e13CMCufogG5teY4KJM0bfjiKY68UYICjthJiCP8srlxwpn67aT4QXeu2c+MXsv3TS0XnAJNNvCqNhEK5Ix0YOVkSff1X4bhzncVgqkUvNjNhlaHdbAuRrTbWeb6VrzF97rLyJLSGV1DWkMlBp+qenoB3Ov9Mqwlo7kC8FnG0ZRm90MevkImwppIhCHke/1gKzS3UlTvY16OOu5+aE7CbMhUjl+VXS0c4lp1eMjEWtWvgCrivGLzk6z1pR7LGDPiLAYMaZG7yoCDSzHAJUoj5UyyT7fMX6hw/RvVqG0WrYrHSdt1n7N5pZQP0ukG1UddYdvEpInN+XRl4IR+Ge7dMaekByaYwUbAtPKNQCNCtah2Bk03k3vp1 X-Forefront-PRVS: 0839D067E7 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6009001)(3846002)(5009440100003)(4001430100002)(586003)(1096002)(76176999)(50986999)(36756003)(189998001)(92566002)(5004730100002)(2950100001)(229853001)(50226001)(87976001)(86152002)(107886002)(2201001)(5001960100002)(77096005)(53416004)(48376002)(19580395003)(19580405001)(5003940100001)(5001770100001)(42186005)(33646002)(66066001)(47776003)(2906002)(2876002)(4326007)(122386002)(3470700001)(5008740100001)(50466002)(575784001)(40100003)(7099028)(7059030)(2101003); DIR:OUT; SFP:1101; SCL:1; SRVR:BN3PR0701MB1688; H:cavium-Vostro-2520.caveonetworks.com; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BN3PR0701MB1688; 23:kOwkOIoGzJssNVT95dR6lS5W29I4YQE3ImfzCpY?= =?us-ascii?Q?w7rhMm8DmuJlZRjLsFi1cwIqErE8R6tlv43/8I3AeoJjYe6oGKcJuikr/C1h?= =?us-ascii?Q?xNJ+eoveRKamFw31x2kHLRnquym9Tt21xdv+ZSlo36DnN+hVPdXPh0JnC8Ex?= =?us-ascii?Q?E0hcFJ1x+2KaV7+bVqkZ4ImugDmXW2t+Fx3+9DdSFMqizIhS3YhVf5lgb6V2?= =?us-ascii?Q?nMP1eopO5OmfVcz37QIVc5uOzBd6sALx0MPleUu6bZ5v7Ncx8Sl2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CzA5173dAoT9d23dA=3D?= =?us-ascii?Q?=3D?= X-Microsoft-Exchange-Diagnostics: 1; BN3PR0701MB1688; 5:SbyNMcSvX54BOEygDnyyWKMV2RV80NSnm/Vao7NduwriGS7DO9zTXXL+Sy6LTmzcNrZZJWT4EwmJr7drSX5g/j7SAgjQgsSPmt3OcLP+Akikum0/d1In/WBL9muu/HD5uW260rdJukHXRMwW+ZiUGg==; 24:RMB2f7js/X2PH+9wSqLPJ0r6bMulzQhoWcLvKeC9Db14MFobXXibJCEiCxLctYQrZDgP4/UIXpvDjE8CBjZ8HGl1FKWUAEBg4M+gvuikvuw= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Feb 2016 09:29:51.2685 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN3PR0701MB1688 X-Mailman-Approved-At: Mon, 01 Feb 2016 09:30:20 +0000 Cc: Prasun.Kapoor@caviumnetworks.com, manish.jaggi@caviumnetworks.com, Vijaya Kumar K , vijay.kilari@gmail.com Subject: [Xen-devel] [PATCH v8 27/28] xen/arm: ITS: Generate ITS node for Dom0 X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAD_ENC_HEADER,BAYES_00, RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Vijaya Kumar K Parse host dt and generate ITS node for Dom0. ITS node resides inside GIC node so when GIC node is encountered look for ITS node. Signed-off-by: Vijaya Kumar K --- v7: - Check on return value v6: - Introduced get_its_phandle in gic_hw_ops - Removed make_hwdom_its_dt_node callback in gic_hw_ops - Renamed gic_get_msi_handle() as gic_update_msi_phandle() - Renamed its_get_phandle to its_update_phandle() - ITS node generation is wrapped inside GICv3 - Update msi-parent phandle only if msi-parent is ITS and find its phandle on demand v5: - Moved ITS dt node generation to ITS driver v4: - Generate only one ITS node for Dom0 - Replace msi-parent references to single its phandle --- xen/arch/arm/domain_build.c | 14 +++++ xen/arch/arm/gic-v3-its.c | 120 +++++++++++++++++++++++++++++++++++++++++ xen/arch/arm/gic-v3.c | 17 +++++- xen/arch/arm/gic.c | 8 +++ xen/include/asm-arm/gic-its.h | 2 + xen/include/asm-arm/gic.h | 5 +- 6 files changed, 164 insertions(+), 2 deletions(-) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index 0f0f53e..0c39846 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -468,6 +468,20 @@ static int write_properties(struct domain *d, struct kernel_info *kinfo, continue; } + /* + * Replace all msi-parent phandle references to single ITS node + * generated for Dom0 + */ + if ( dt_property_name_is_equal(prop, "msi-parent") ) + { + DPRINT(" Set msi-parent with ITS phandle (if ITS available)\n"); + res = gic_update_msi_phandle(kinfo->fdt, prop); + if ( res ) + return res; + + continue; + } + res = fdt_property(kinfo->fdt, prop->name, prop_data, prop_len); if ( res ) diff --git a/xen/arch/arm/gic-v3-its.c b/xen/arch/arm/gic-v3-its.c index cbf517a..2a73b00 100644 --- a/xen/arch/arm/gic-v3-its.c +++ b/xen/arch/arm/gic-v3-its.c @@ -27,6 +27,8 @@ #include #include #include +#include +#include #include #include #include @@ -1303,6 +1305,124 @@ static void its_cpu_init_collection(void) spin_unlock(&its_lock); } +int its_make_dt_node(const struct domain *d, void *fdt) +{ + struct its_node *its; + const struct dt_device_node *node; + const void *compatible = NULL; + u32 len; + __be32 *new_cells, *tmp; + int res = 0; + + /* Will pass only first ITS node info */ + its = list_first_entry(&its_nodes, struct its_node, entry); + if ( !its ) + { + dprintk(XENLOG_ERR, "ITS node not found\n"); + return -FDT_ERR_XEN(ENOENT); + } + + node = its->dt_node; + + compatible = dt_get_property(node, "compatible", &len); + if ( !compatible ) + { + dprintk(XENLOG_ERR, "Can't find compatible property for the its node\n"); + return -FDT_ERR_XEN(ENOENT); + } + + res = fdt_begin_node(fdt, "gic-its"); + if ( res ) + return res; + + res = fdt_property(fdt, "compatible", compatible, len); + if ( res ) + return res; + + res = fdt_property(fdt, "msi-controller", NULL, 0); + if ( res ) + return res; + + len = dt_cells_to_size(dt_n_addr_cells(node) + dt_n_size_cells(node)); + + new_cells = xzalloc_bytes(len); + if ( new_cells == NULL ) + return -FDT_ERR_XEN(ENOMEM); + tmp = new_cells; + + dt_set_range(&tmp, node, its->phys_base, its->phys_size); + + res = fdt_property(fdt, "reg", new_cells, len); + xfree(new_cells); + if ( res ) + return res; + + if ( node->phandle ) + { + res = fdt_property_cell(fdt, "phandle", node->phandle); + if ( res ) + return res; + } + + res = fdt_end_node(fdt); + + return res; +} + +static int its_find_compatible_phandle(fdt32_t msi_parent_phandle) +{ + struct its_node *its; + const struct dt_device_node *node; + fdt32_t phandle; + + list_for_each_entry(its, &its_nodes, entry) + { + node = its->dt_node; + + if ( node->phandle ) + { + phandle = cpu_to_fdt32(node->phandle); + if ( phandle == msi_parent_phandle ) + return 0; + } + } + + return -FDT_ERR_XEN(ENOENT); +} + +int its_update_phandle(void *fdt, const struct dt_property *prop) +{ + struct its_node *its; + const struct dt_device_node *node; + fdt32_t phandle, msi_parent_phandle; + + memcpy(&msi_parent_phandle, prop->value, sizeof(msi_parent_phandle)); + + /* chech if msi-parent phandle is ITS */ + if ( its_find_compatible_phandle(msi_parent_phandle) ) + return -FDT_ERR_XEN(ENOENT); + + /* Only first ITS node phandle is considered */ + its = list_first_entry(&its_nodes, struct its_node, entry); + if ( !its ) + { + dprintk(XENLOG_ERR, "ITS node not found\n"); + return -FDT_ERR_XEN(ENOENT); + } + + node = its->dt_node; + + if ( node->phandle ) + { + phandle = cpu_to_fdt32(node->phandle); + fdt_property(fdt, prop->name, (void *)&phandle, sizeof(phandle)); + + return 0; + } + + return -FDT_ERR_XEN(ENOENT); +} + static int its_force_quiescent(void __iomem *base) { u32 count = 1000000; /* 1s */ diff --git a/xen/arch/arm/gic-v3.c b/xen/arch/arm/gic-v3.c index 47e6b8a..df8f594 100644 --- a/xen/arch/arm/gic-v3.c +++ b/xen/arch/arm/gic-v3.c @@ -1124,6 +1124,14 @@ static void gicv3_irq_set_affinity(struct irq_desc *desc, const cpumask_t *mask) spin_unlock(&gicv3.lock); } +static int gicv3_update_its_phandle(void *fdt, const struct dt_property *prop) +{ + if ( its_enabled ) + return its_update_phandle(fdt, prop); + + return 0; +} + static int gicv3_make_hwdom_dt_node(const struct domain *d, const struct dt_device_node *gic, void *fdt) @@ -1144,6 +1152,10 @@ static int gicv3_make_hwdom_dt_node(const struct domain *d, if ( res ) return res; + res = fdt_property(fdt, "ranges", NULL, 0); + if ( res ) + return res; + res = fdt_property_cell(fdt, "redistributor-stride", d->arch.vgic.rdist_stride); if ( res ) @@ -1175,8 +1187,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 its_make_dt_node(d, fdt); } static const hw_irq_controller gicv3_host_irq_type = { @@ -1424,6 +1438,7 @@ static const struct gic_hw_operations gicv3_ops = { .read_vmcr_priority = gicv3_read_vmcr_priority, .read_apr = gicv3_read_apr, .secondary_init = gicv3_secondary_cpu_init, + .update_its_phandle = gicv3_update_its_phandle, .make_hwdom_dt_node = gicv3_make_hwdom_dt_node, }; diff --git a/xen/arch/arm/gic.c b/xen/arch/arm/gic.c index ca115c3..a8a87c9 100644 --- a/xen/arch/arm/gic.c +++ b/xen/arch/arm/gic.c @@ -739,6 +739,14 @@ void init_maintenance_interrupt(void) "irq-maintenance", NULL); } +int gic_update_msi_phandle(void *fdt, const struct dt_property *prop) +{ + if ( gic_hw_ops->update_its_phandle != NULL ) + return gic_hw_ops->update_its_phandle(fdt, prop); + + return 0; +} + int gic_make_hwdom_dt_node(const struct domain *d, const struct dt_device_node *gic, void *fdt) diff --git a/xen/include/asm-arm/gic-its.h b/xen/include/asm-arm/gic-its.h index 44919ee..587844d 100644 --- a/xen/include/asm-arm/gic-its.h +++ b/xen/include/asm-arm/gic-its.h @@ -306,6 +306,8 @@ int its_assign_device(struct domain *d, u32 vdevid, u32 pdevid); void its_set_lpi_properties(struct irq_desc *desc, const cpumask_t *cpu_mask, unsigned int priority); +int its_update_phandle(void *fdt, const struct dt_property *prop); +int its_make_dt_node(const struct domain *d, void *fdt); #endif /* __ASM_ARM_GIC_ITS_H__ */ /* diff --git a/xen/include/asm-arm/gic.h b/xen/include/asm-arm/gic.h index 2007e51..1d8075c 100644 --- a/xen/include/asm-arm/gic.h +++ b/xen/include/asm-arm/gic.h @@ -156,6 +156,7 @@ #ifndef __ASSEMBLY__ #include +#include #include #include @@ -365,7 +366,8 @@ struct gic_hw_operations { int (*secondary_init)(void); /* Create GIC node for the hardware domain */ int (*make_hwdom_dt_node)(const struct domain *d, - const struct dt_device_node *gic, void *fdt); + const struct dt_device_node *node, void *fdt); + int (*update_its_phandle)(void *fdt, const struct dt_property *prop); }; void register_gic_ops(const struct gic_hw_operations *ops); @@ -374,6 +376,7 @@ int gic_make_hwdom_dt_node(const struct domain *d, void *fdt); unsigned int gic_nr_irq_ids(void); bool_t gic_is_lpi(unsigned int irq); +int gic_update_msi_phandle(void *fdt, const struct dt_property *prop); #endif /* __ASSEMBLY__ */ #endif