All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ian Campbell <Ian.Campbell@citrix.com>
To: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Cc: Anthony Perard <anthony.perard@citrix.com>,
	"Tim (Xen.org)" <tim@xen.org>,
	"xen-devel@lists.xen.org" <xen-devel@lists.xen.org>
Subject: Re: [PATCH 1/4] dtb: correct handling of #address-cells and #size-cells.
Date: Fri, 15 Feb 2013 13:18:48 +0000	[thread overview]
Message-ID: <1360934328.31407.41.camel@zakaz.uk.xensource.com> (raw)
In-Reply-To: <alpine.DEB.2.02.1302151229060.8231@kaball.uk.xensource.com>

On Fri, 2013-02-15 at 12:43 +0000, Stefano Stabellini wrote:
> On Wed, 30 Jan 2013, Ian Campbell wrote:
> > If a node does not have #*-cells then the parent's value should be
> > used. Currently we were asssuming zero which is useless.
> > 
> > Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
> > ---
> >  xen/arch/arm/domain_build.c   |    6 ++++--
> >  xen/common/device_tree.c      |   12 ++++++++----
> >  xen/include/xen/device_tree.h |    3 ++-
> >  3 files changed, 14 insertions(+), 7 deletions(-)
> > 
> > diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
> > index 7403f1a..bfbe7c7 100644
> > --- a/xen/arch/arm/domain_build.c
> > +++ b/xen/arch/arm/domain_build.c
> > @@ -198,8 +198,10 @@ static int write_nodes(struct domain *d, struct kernel_info *kinfo,
> >          while ( last_depth-- >= depth )
> >              fdt_end_node(kinfo->fdt);
> >  
> > -        address_cells[depth] = device_tree_get_u32(fdt, node, "#address-cells");
> > -        size_cells[depth] = device_tree_get_u32(fdt, node, "#size-cells");
> > +        address_cells[depth] = device_tree_get_u32(fdt, node, "#address-cells",
> > +                                    depth > 0 ? address_cells[depth-1] : 0);
> > +        size_cells[depth] = device_tree_get_u32(fdt, node, "#size-cells",
> > +                                    depth > 0 ? size_cells[depth-1] : 0);
> >  
> >          fdt_begin_node(kinfo->fdt, name);
> 
> The depth is always increasing by steps of 1 in this loop, right?
> Because retrieving address-cells and size-cells should be recursive: if
> n-1 doesn't have them, let's look at n-2, etc. Of course if we start from
> depth = 0 and go from there without missing any levels the results will
> be the same.

That was what I thought too. Perhaps it is too subtle?

I bet my "xen: strip xen,multiboot-module nodes from dom0 device tree"
patch changes this invariant. Better to make it explicitly walk
backwards now I think. (or maybe set things for level in
last_depth..depth). I'll change things along these lines.

> I think I convinced myself that this is correct.
> 
> 
> > diff --git a/xen/common/device_tree.c b/xen/common/device_tree.c
> > index 260c2d4..f10ba1b 100644
> > --- a/xen/common/device_tree.c
> > +++ b/xen/common/device_tree.c
> > @@ -120,13 +120,14 @@ void device_tree_set_reg(u32 **cell, u32 address_cells, u32 size_cells,
> >      set_val(cell, size_cells, size);
> >  }
> >  
> > -u32 device_tree_get_u32(const void *fdt, int node, const char *prop_name)
> > +u32 device_tree_get_u32(const void *fdt, int node, const char *prop_name,
> > +                        u32 dflt)
> >  {
> >      const struct fdt_property *prop;
> >  
> >      prop = fdt_get_property(fdt, node, prop_name, NULL);
> >      if ( !prop || prop->len < sizeof(u32) )
> > -        return 0; /* default to 0 */
> > +        return dflt;
> >  
> >      return fdt32_to_cpu(*(uint32_t*)prop->data);
> >  }
> 
> where did the vowels go? :)

Not sure. Unlike me ;-)

Ian.

  reply	other threads:[~2013-02-15 13:18 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-30 14:26 [PATCH 0/4 V6] xen: arm: parse modules from DT during early boot Ian Campbell
2013-01-30 14:26 ` [PATCH 1/4] dtb: correct handling of #address-cells and #size-cells Ian Campbell
2013-02-15 12:43   ` Stefano Stabellini
2013-02-15 13:18     ` Ian Campbell [this message]
2013-02-15 17:04       ` Ian Campbell
2013-02-18 13:11         ` Stefano Stabellini
2013-02-18 13:25           ` Ian Campbell
2013-02-18 11:22       ` Ian Campbell
2013-01-30 14:26 ` [PATCH 2/4] xen: arm: parse modules from DT during early boot Ian Campbell
2013-02-15 12:55   ` Stefano Stabellini
2013-01-30 14:26 ` [PATCH 3/4] xen: strip xen, multiboot-module nodes from dom0 device tree Ian Campbell
2013-02-15 12:53   ` Stefano Stabellini
2013-01-30 14:26 ` [PATCH 4/4] xen: arm: create dom0 DTB /hypervisor/ node dynamically Ian Campbell
2013-02-05 11:26   ` Anthony PERARD
2013-02-05 11:30     ` Ian Campbell
2013-02-18 14:04     ` Ian Campbell
2013-02-15 12:52   ` Stefano Stabellini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1360934328.31407.41.camel@zakaz.uk.xensource.com \
    --to=ian.campbell@citrix.com \
    --cc=anthony.perard@citrix.com \
    --cc=stefano.stabellini@eu.citrix.com \
    --cc=tim@xen.org \
    --cc=xen-devel@lists.xen.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.