[SLOF] [PATCH slof v5 3/6] fdt: Pass the resulting device tree to QEMU

Segher Boessenkool segher at kernel.crashing.org
Mon Oct 16 23:27:45 AEDT 2017

On Mon, Oct 16, 2017 at 11:06:15PM +1100, Alexey Kardashevskiy wrote:
> On 16/10/17 20:07, Segher Boessenkool wrote:
> > Maybe something like
> > 
> > 
> > VARIABLE chosen-cpu-phandle
> > VARIABLE chosen-cpu-ihandle
> > : set-chosen-cpu ( -- )
> >    s" /cpus" find-node  dup 0= ABORT" /cpus not found"
> >    child                dup 0= ABORT" /cpus/cpu not found"
> >    dup chosen-cpu-phandle !  0 0 rot open-node
> >    dup chosen-cpu-ihandle !  encode-int s" cpu" set-chosen ;
> > 
> > 
> > and then you can use   chosen-cpu-ihandle @   etc.?
> I can do that but what is the exact benefit of doing it this way? It is
> going to be used once really, and why would we need to cache both ihandle
> and phandle but not reg (which we really care about here), for example?

It's not caching: this is the "real" data, what is in the device tree
is just some external representation.  Reading things back from the
device tree is extremely slow at best, and very harmful in worse cases.
Just say no!

You can of course choose to not keep the phandle or ihandle around,
instead just the unit address, for example.

The point is to use find-node etc. instead of find-device etc. -- easier
to use and it does not clobber the current packages, etc.  And, of course,
don't read /chosen data back from the device tree.


More information about the SLOF mailing list