From patchwork Fri May 27 16:37:52 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 68777 Delivered-To: patch@linaro.org Received: by 10.140.92.199 with SMTP id b65csp188635qge; Fri, 27 May 2016 09:39:33 -0700 (PDT) X-Received: by 10.237.35.199 with SMTP id k7mr14770357qtc.37.1464367173854; Fri, 27 May 2016 09:39:33 -0700 (PDT) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id o1si17370212qta.2.2016.05.27.09.39.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 27 May 2016 09:39:33 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b6Kly-0003Ny-Rj; Fri, 27 May 2016 16:38:06 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b6Klx-0003NP-HE for xen-devel@lists.xen.org; Fri, 27 May 2016 16:38:05 +0000 Received: from [85.158.139.211] by server-9.bemta-5.messagelabs.com id 6F/3C-04011-CE778475; Fri, 27 May 2016 16:38:04 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrILMWRWlGSWpSXmKPExsVysyfVTfdNuUe 4wYNjzBZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8aaxnlsBZvCK5b9+M7awDjDuYuRi0NIYCOj RNP8S4wQzmlGicnPr7N2MXJysAloStz5/IkJxBYRkJa49vkyWBGzwGJGie59Z8CKhAUiJeYs6 mUHsVkEVCVmzp8L1MDBwSvgInFigihIWEJATuLkscmsIGFOAVeJl5ODQcJCQBVPnu5incDIvY CRYRWjenFqUVlqka6pXlJRZnpGSW5iZo6uoYGpXm5qcXFiempOYlKxXnJ+7iZGoHcZgGAH45d +50OMkhxMSqK871M9woX4kvJTKjMSizPii0pzUosPMcpwcChJ8DKXAeUEi1LTUyvSMnOAYQaT luDgURLhFQRJ8xYXJOYWZ6ZDpE4x6nJM+35tLZMQS15+XqqUOO+pUqAiAZCijNI8uBGwkL/EK CslzMsIdJQQT0FqUW5mCar8K0ZxDkYlYV51kFU8mXklcJteAR3BBHTEAhawI0oSEVJSDYybSn 0D0pJ+zFaadqHl2my2dTEZ5d0it6cbrhFauGjhxrr4PI79Fmuzv99rO1C7X/NXkfO34FM6pgK ps4qEfqdIz9UK79J8u7r14n3jO2KLJ5ismPjO1ftcw6zsWxdmSDjdXNWSmGcR0vDBiKGsa/qW /p2pSV/mxjbe7rALOT7n8J3LgZ+Kf5grsRRnJBpqMRcVJwIAkc6vdHQCAAA= X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-3.tower-206.messagelabs.com!1464367083!38341647!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 51534 invoked from network); 27 May 2016 16:38:03 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-3.tower-206.messagelabs.com with SMTP; 27 May 2016 16:38:03 -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 5EF1634; Fri, 27 May 2016 09:38:28 -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 088C23F246; Fri, 27 May 2016 09:38:01 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Fri, 27 May 2016 17:37:52 +0100 Message-Id: <1464367072-29262-3-git-send-email-julien.grall@arm.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1464367072-29262-1-git-send-email-julien.grall@arm.com> References: <1464367072-29262-1-git-send-email-julien.grall@arm.com> Cc: "Edgar E. Iglesias" , Julien Grall , sstabellini@kernel.org Subject: [Xen-devel] [for-4.8 v2 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" 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 --- Changes in v2: - Add Konrad's and Edgar's reviewed-by --- 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 */ /*