From patchwork Tue May 24 10:20:41 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 9133365 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 3CA07607D5 for ; Tue, 24 May 2016 10:22:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 346BF2824F for ; Tue, 24 May 2016 10:22:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2957E2829A; Tue, 24 May 2016 10:22:57 +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 6FD302824F for ; Tue, 24 May 2016 10:22:56 +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 1b59SH-0007tk-M9; Tue, 24 May 2016 10:20:53 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b59SG-0007tc-R6 for xen-devel@lists.xen.org; Tue, 24 May 2016 10:20:52 +0000 Received: from [193.109.254.147] by server-4.bemta-14.messagelabs.com id 94/9C-24264-40B24475; Tue, 24 May 2016 10:20:52 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrILMWRWlGSWpSXmKPExsVysyfVTZdZ2yX cYEuTnMWSj4tZHBg9ju7+zRTAGMWamZeUX5HAmvG4/yxzwdfQinX/jzE1MP5x7GLk4hAS2Mgo sfr5UhYI5zSjxI5b31i7GDk52AQ0Je58/sQEYosISEtc+3yZEcRmFnCQePPxHguILSwQJtFz8 DZbFyMHB4uAqsShFXogYV4BF4ktt6+ClUsIyEmcPDYZbCSngKvE8rkT2UFsIaCa1zNnsk5g5F 7AyLCKUb04tagstUjXWC+pKDM9oyQ3MTNH19DQRC83tbg4MT01JzGpWC85P3cTI9C7DECwg/F un/MhRkkOJiVR3tXvnMOF+JLyUyozEosz4otKc1KLDzHKcHAoSfD2aLqECwkWpaanVqRl5gDD DCYtwcGjJMIrDZLmLS5IzC3OTIdInWLU5Zj2/dpaJiGWvPy8VClx3gSQIgGQoozSPLgRsJC/x CgrJczLCHSUEE9BalFuZgmq/CtGcQ5GJWHesyBTeDLzSuA2vQI6ggnoCP8vziBHlCQipKQaGC WkNvNpC3zZ9e3ol7zYIz+Y1izou5O082G+h0rT4wmn/5U3PV/69Qbb3mmvXKJVy/Q/fN3Bqjj 5uX1Iwj2ufx/+787YJnCWUcliqm+W8uPp8TfO7245Hm757MSM3F07ysTMDhocNW9eNGOW1+Wc 3QJOtwIP5K8K5P669cqlDz83mWxt2VUp5XJXiaU4I9FQi7moOBEAr5DPsHQCAAA= X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-5.tower-27.messagelabs.com!1464085250!43472750!1 X-Originating-IP: [217.140.101.70] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.34; banners=-,-,- X-VirusChecked: Checked Received: (qmail 11445 invoked from network); 24 May 2016 10:20:50 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-5.tower-27.messagelabs.com with SMTP; 24 May 2016 10:20:50 -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 20BC53C; Tue, 24 May 2016 03:21:13 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.215.28]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id BB8493F5C4; Tue, 24 May 2016 03:20:49 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Tue, 24 May 2016 11:20:41 +0100 Message-Id: <1464085241-12929-3-git-send-email-julien.grall@arm.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1464085241-12929-1-git-send-email-julien.grall@arm.com> References: <1464085241-12929-1-git-send-email-julien.grall@arm.com> Cc: Julien Grall , sstabellini@kernel.org Subject: [Xen-devel] [for-4.8 2/2] xen/arm: Provide device tree debugging helper in a single place 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 Provide helper to debug the device tree in device_tree.h. This will avoid to have to redeclare helper for each file requiring debug. Also replace DPRINT by the new helper dt_dprintk in domain_build.c Signed-off-by: Julien Grall Reviewed-by: Konrad Rzeszutek Wilk Reviewed-by: Edgar E. Iglesias --- xen/arch/arm/domain_build.c | 71 +++++++++++++++++++++---------------------- xen/common/device_tree.c | 2 -- xen/include/xen/device_tree.h | 9 ++++++ 3 files changed, 43 insertions(+), 39 deletions(-) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index fb035ff..71ead8b 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -42,12 +42,6 @@ static void __init parse_dom0_mem(const char *s) } custom_param("dom0_mem", parse_dom0_mem); -#ifdef CONFIG_DEVICE_TREE_DEBUG -# define DPRINT(fmt, args...) printk(XENLOG_DEBUG fmt, ##args) -#else -# define DPRINT(fmt, args...) do {} while ( 0 ) -#endif - //#define DEBUG_11_ALLOCATION #ifdef DEBUG_11_ALLOCATION # define D11PRINT(fmt, args...) printk(XENLOG_DEBUG fmt, ##args) @@ -364,7 +358,7 @@ static void allocate_memory(struct domain *d, struct kernel_info *kinfo) { int l; - DPRINT("memory node\n"); + dt_dprintk("memory node\n"); reg_size = dt_cells_to_size(dt_n_addr_cells(memory) + dt_n_size_cells(memory)); @@ -571,7 +565,8 @@ static int make_memory_node(const struct domain *d, __be32 reg[nr_cells]; __be32 *cells; - DPRINT("Create memory node (reg size %d, nr cells %d)\n", reg_size, nr_cells); + dt_dprintk("Create memory node (reg size %d, nr cells %d)\n", + reg_size, nr_cells); /* ePAPR 3.4 */ res = fdt_begin_node(fdt, "memory"); @@ -588,8 +583,8 @@ static int make_memory_node(const struct domain *d, u64 start = kinfo->mem.bank[i].start; u64 size = kinfo->mem.bank[i].size; - DPRINT(" Bank %d: %#"PRIx64"->%#"PRIx64"\n", - i, start, start + size); + dt_dprintk(" Bank %d: %#"PRIx64"->%#"PRIx64"\n", + i, start, start + size); dt_child_set_range(&cells, parent, start, size); } @@ -618,7 +613,7 @@ static int make_hypervisor_node(const struct kernel_info *kinfo, int sizecells = dt_child_n_size_cells(parent); void *fdt = kinfo->fdt; - DPRINT("Create hypervisor node\n"); + dt_dprintk("Create hypervisor node\n"); /* * Sanity-check address sizes, since addresses and sizes which do @@ -667,7 +662,7 @@ static int make_psci_node(void *fdt, const struct dt_device_node *parent) "arm,psci-0.2""\0" "arm,psci"; - DPRINT("Create PSCI node\n"); + dt_dprintk("Create PSCI node\n"); /* See linux Documentation/devicetree/bindings/arm/psci.txt */ res = fdt_begin_node(fdt, "psci"); @@ -710,7 +705,7 @@ static int make_cpus_node(const struct domain *d, void *fdt, bool_t clock_valid; uint64_t mpidr_aff; - DPRINT("Create cpus node\n"); + dt_dprintk("Create cpus node\n"); if ( !cpus ) { @@ -765,7 +760,8 @@ static int make_cpus_node(const struct domain *d, void *fdt, * is enough for the current max vcpu number. */ mpidr_aff = vcpuid_to_vaffinity(cpu); - DPRINT("Create cpu@%"PRIx64" (logical CPUID: %d) node\n", mpidr_aff, cpu); + dt_dprintk("Create cpu@%"PRIx64" (logical CPUID: %d) node\n", + mpidr_aff, cpu); snprintf(buf, sizeof(buf), "cpu@%"PRIx64, mpidr_aff); res = fdt_begin_node(fdt, buf); @@ -821,11 +817,11 @@ static int make_gic_node(const struct domain *d, void *fdt, */ if ( node != dt_interrupt_controller ) { - DPRINT(" Skipping (secondary GIC)\n"); + dt_dprintk(" Skipping (secondary GIC)\n"); return 0; } - DPRINT("Create gic node\n"); + dt_dprintk("Create gic node\n"); res = fdt_begin_node(fdt, "interrupt-controller"); if ( res ) @@ -837,7 +833,7 @@ static int make_gic_node(const struct domain *d, void *fdt, */ if ( gic->phandle ) { - DPRINT(" Set phandle = 0x%x\n", gic->phandle); + dt_dprintk(" Set phandle = 0x%x\n", gic->phandle); res = fdt_property_cell(fdt, "phandle", gic->phandle); if ( res ) return res; @@ -894,7 +890,7 @@ static int make_timer_node(const struct domain *d, void *fdt, u32 clock_frequency; bool_t clock_valid; - DPRINT("Create timer node\n"); + dt_dprintk("Create timer node\n"); dev = dt_find_matching_node(NULL, timer_ids); if ( !dev ) @@ -922,15 +918,15 @@ static int make_timer_node(const struct domain *d, void *fdt, * level-sensitive interrupt */ irq = timer_get_irq(TIMER_PHYS_SECURE_PPI); - DPRINT(" Secure interrupt %u\n", irq); + dt_dprintk(" Secure interrupt %u\n", irq); set_interrupt_ppi(intrs[0], irq, 0xf, IRQ_TYPE_LEVEL_LOW); irq = timer_get_irq(TIMER_PHYS_NONSECURE_PPI); - DPRINT(" Non secure interrupt %u\n", irq); + dt_dprintk(" Non secure interrupt %u\n", irq); set_interrupt_ppi(intrs[1], irq, 0xf, IRQ_TYPE_LEVEL_LOW); irq = timer_get_irq(TIMER_VIRT_PPI); - DPRINT(" Virt interrupt %u\n", irq); + dt_dprintk(" Virt interrupt %u\n", irq); set_interrupt_ppi(intrs[2], irq, 0xf, IRQ_TYPE_LEVEL_LOW); res = fdt_property_interrupts(fdt, intrs, 3); @@ -984,7 +980,7 @@ static int map_irq_to_domain(const struct dt_device_node *dev, } } - DPRINT(" - IRQ: %u\n", irq); + dt_dprintk(" - IRQ: %u\n", irq); return 0; } @@ -1053,7 +1049,7 @@ static int map_range_to_domain(const struct dt_device_node *dev, } } - DPRINT(" - MMIO: %010"PRIx64" - %010"PRIx64"\n", addr, addr + len); + dt_dprintk(" - MMIO: %010"PRIx64" - %010"PRIx64"\n", addr, addr + len); return 0; } @@ -1070,7 +1066,8 @@ static int map_device_children(struct domain *d, if ( dt_device_type_is_equal(dev, "pci") ) { - DPRINT("Mapping children of %s to guest\n", dt_node_full_name(dev)); + dt_dprintk("Mapping children of %s to guest\n", + dt_node_full_name(dev)); ret = dt_for_each_irq_map(dev, &map_dt_irq_to_domain, d); if ( ret < 0 ) @@ -1105,12 +1102,12 @@ static int handle_device(struct domain *d, struct dt_device_node *dev) nirq = dt_number_of_irq(dev); naddr = dt_number_of_address(dev); - DPRINT("%s passthrough = %d nirq = %d naddr = %u\n", dt_node_full_name(dev), - need_mapping, nirq, naddr); + dt_dprintk("%s passthrough = %d nirq = %d naddr = %u\n", + dt_node_full_name(dev), need_mapping, nirq, naddr); if ( dt_device_is_protected(dev) && need_mapping ) { - DPRINT("%s setup iommu\n", dt_node_full_name(dev)); + dt_dprintk("%s setup iommu\n", dt_node_full_name(dev)); res = iommu_assign_dt_device(d, dev); if ( res ) { @@ -1137,8 +1134,8 @@ static int handle_device(struct domain *d, struct dt_device_node *dev) */ if ( rirq.controller != dt_interrupt_controller ) { - DPRINT("irq %u not connected to primary controller." - "Connected to %s\n", i, dt_node_full_name(rirq.controller)); + dt_dprintk("irq %u not connected to primary controller. Connected to %s\n", + i, dt_node_full_name(rirq.controller)); continue; } @@ -1217,17 +1214,17 @@ static int handle_node(struct domain *d, struct kernel_info *kinfo, path = dt_node_full_name(node); - DPRINT("handle %s\n", path); + dt_dprintk("handle %s\n", path); /* Skip theses nodes and the sub-nodes */ if ( dt_match_node(skip_matches, node) ) { - DPRINT(" Skip it (matched)\n"); + dt_dprintk(" Skip it (matched)\n"); return 0; } if ( platform_device_is_blacklisted(node) ) { - DPRINT(" Skip it (blacklisted)\n"); + dt_dprintk(" Skip it (blacklisted)\n"); return 0; } @@ -1243,7 +1240,7 @@ static int handle_node(struct domain *d, struct kernel_info *kinfo, /* Skip nodes used by Xen */ if ( dt_device_used_by(node) == DOMID_XEN ) { - DPRINT(" Skip it (used by Xen)\n"); + dt_dprintk(" Skip it (used by Xen)\n"); return 0; } @@ -1253,7 +1250,7 @@ static int handle_node(struct domain *d, struct kernel_info *kinfo, */ if ( device_get_class(node) == DEVICE_IOMMU ) { - DPRINT(" IOMMU, skip it\n"); + dt_dprintk(" IOMMU, skip it\n"); return 0; } @@ -1428,7 +1425,7 @@ static int acpi_make_chosen_node(const struct kernel_info *kinfo) const struct bootmodule *mod = kinfo->kernel_bootmodule; void *fdt = kinfo->fdt; - DPRINT("Create chosen node\n"); + dt_dprintk("Create chosen node\n"); res = fdt_begin_node(fdt, "chosen"); if ( res ) return res; @@ -1472,7 +1469,7 @@ static int acpi_make_hypervisor_node(const struct kernel_info *kinfo, /* Convenience alias */ void *fdt = kinfo->fdt; - DPRINT("Create hypervisor node\n"); + dt_dprintk("Create hypervisor node\n"); /* See linux Documentation/devicetree/bindings/arm/xen.txt */ res = fdt_begin_node(fdt, "hypervisor"); @@ -1502,7 +1499,7 @@ static int create_acpi_dtb(struct kernel_info *kinfo, struct membank tbl_add[]) int new_size; int ret; - DPRINT("Prepare a min DTB for DOM0\n"); + dt_dprintk("Prepare a min DTB for DOM0\n"); /* Allocate min size for DT */ new_size = ACPI_DOM0_FDT_MIN_SIZE; diff --git a/xen/common/device_tree.c b/xen/common/device_tree.c index 0df2e4b..b39c8ca 100644 --- a/xen/common/device_tree.c +++ b/xen/common/device_tree.c @@ -55,7 +55,6 @@ struct dt_alias_prop { static LIST_HEAD(aliases_lookup); #ifdef CONFIG_DEVICE_TREE_DEBUG -# define dt_dprintk(fmt, args...) printk(XENLOG_DEBUG fmt, ##args) static void dt_dump_addr(const char *s, const __be32 *addr, int na) { dt_dprintk("%s", s); @@ -64,7 +63,6 @@ static void dt_dump_addr(const char *s, const __be32 *addr, int na) dt_dprintk("\n"); } #else -# define dt_dprintk(fmt, args...) do {} while ( 0 ) static void dt_dump_addr(const char *s, const __be32 *addr, int na) { } #endif diff --git a/xen/include/xen/device_tree.h b/xen/include/xen/device_tree.h index e3fe77c..d7d1b40 100644 --- a/xen/include/xen/device_tree.h +++ b/xen/include/xen/device_tree.h @@ -753,6 +753,15 @@ int dt_parse_phandle_with_args(const struct dt_device_node *np, const char *cells_name, int index, struct dt_phandle_args *out_args); +#ifdef CONFIG_DEVICE_TREE_DEBUG +#define dt_dprintk(fmt, args...) \ + printk(XENLOG_DEBUG fmt, ## args) +#else +static inline void +__attribute__ ((__format__ (__printf__, 1, 2))) +dt_dprintk(const char *fmt, ...) {} +#endif + #endif /* __XEN_DEVICE_TREE_H */ /*