From mboxrd@z Thu Jan 1 00:00:00 1970 From: Julien Grall Subject: Re: [PATCH 07/16] xen: arm: Handle cpus nodes with #address-calls > 1 Date: Wed, 20 Nov 2013 16:46:57 +0000 Message-ID: <528CE781.8040104@linaro.org> References: <1384958746.6071.64.camel@kazak.uk.xensource.com> <1384958897-13074-7-git-send-email-ian.campbell@citrix.com> <528CE3DB.8040801@linaro.org> <1384965471.6071.89.camel@kazak.uk.xensource.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1384965471.6071.89.camel@kazak.uk.xensource.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Ian Campbell Cc: pranavkumar@linaro.org, stefano.stabellini@eu.citrix.com, tim@xen.org, Anup Patel , xen-devel@lists.xen.org List-Id: xen-devel@lists.xenproject.org On 11/20/2013 04:37 PM, Ian Campbell wrote: > On Wed, 2013-11-20 at 16:31 +0000, Julien Grall wrote: >> On 11/20/2013 02:48 PM, Ian Campbell wrote: >>> The APM X-Gene Mustang board DTS has #address-cells = 2. >>> >>> Signed-off-by: Ian Campbell >>> --- >>> xen/arch/arm/smpboot.c | 25 +++++++++++++++++++++---- >>> 1 file changed, 21 insertions(+), 4 deletions(-) >>> >>> diff --git a/xen/arch/arm/smpboot.c b/xen/arch/arm/smpboot.c >>> index 6c90fa6..ce832ae 100644 >>> --- a/xen/arch/arm/smpboot.c >>> +++ b/xen/arch/arm/smpboot.c >>> @@ -125,18 +125,35 @@ void __init smp_init_cpus(void) >>> >>> dt_for_each_child_node( cpus, cpu ) >>> { >>> + const __be32 *prop; >>> + u64 addr, size; >>> u32 hwid; >>> >>> if ( !dt_device_type_is_equal(cpu, "cpu") ) >>> continue; >>> >>> - if ( !dt_property_read_u32(cpu, "reg", &hwid) ) >>> + if ( dt_n_size_cells(cpu) != 0 ) >>> + printk(XENLOG_WARNING "cpu node `%s`: #size-cells %d\n", >>> + dt_node_full_name(cpu), dt_n_size_cells(cpu)); >>> + >>> + prop = dt_get_property(cpu, "reg", NULL); >>> + if ( !prop ) >>> { >>> - printk(XENLOG_WARNING "cpu node `%s`: missing reg property\n", >>> + printk(XENLOG_WARNING "cpu node `%s`: has no reg property\n", >>> dt_node_full_name(cpu)); >>> continue; >>> } >>> >>> + dt_get_range(&prop, cpu, &addr, &size); >> >> You can use dt_read_number here. > > As in > dt_read_number(&prop, dt_n_addr_cells(cpu) > ? Is there a helper which will take (&prop, cpu, &addr) and figure out > the size etc internally, that's really what I was looking for. Except dt_get_range, no. I would prefer the solution with dt_read_number because it more clear that we want only a number. A cpu is not defined by a range. In the both case, you will also need to check the size of the property. A bad crafted device tree can have reg smaller than #address-cells + #size-cells. -- Julien Grall