Re: [PATCH] Open Firmware device tree virtual filesystem

Benjamin Herrenschmidt
2007-01-02T04:04:00Z

On Sun, 2006-12-31 at 19:37 -0800, David Kahn wrote:
> Folks,
>
> If we reused the current code in fs/proc/proc_devtree.c
> and re-wrote the underlying of_* routines for i386 only,
> (in the hope of removing the complexity not needed for
> this implementation) would that be an acceptable
> implementation?
>
> In other words, the of_* routines continue to define the
> interface between kernel and the firmware/OS
> layer. Although that code in proc_devtree.c defining
> the functions duplicate_name() and fixup_name() is still
> troubling to me.

The main problem with the current powerpc interface to the device-tree
(though as I said earlier, it's very handy for drivers) is that
get_property() doesn't take a buffer pointer. Thus, it's not very
suitable for an interface that involves calling into OF to retreive the
properties. It's really an interface designed around the idea that the
tree is in kernel memory, and the lifetime of the properties is tied to
the lifetime of the node.

> IMHO, the directory entries in the filesystem
> should be in the form "node-name@unit-address" (eg: /pci@1f,0,
> "pci" is the node name, "@" is the separator character defined
> by IEEE 1275, and "1f,0" is the unit-address,
> which are always guaranteed to be unique.

They should be. The problem is buggy OF implementations. For example,
both IBM and Apple OFs have the nasty habit of having under the CPU
nodes an "l2-cache" node with no unit-address -and- a property with the
same name (which contains just a phandle to that l2-cache node btw).
There are other examples too (some pmacs have a duplicate i2c bus with
some one of the copies containing only a subset of the devices)

In general, we don't fabricate the @unit-address part, we use OF's own
package-to-path (unlike sparc which I think doesn't always have that
method), and thus we have to deal with implementations that return no
unit-address or duplicate names.

> It's
> not possible to have two ambiguously fully qualified nodes in the OFW
> device tree, otherwise you would never be able to select
> a specific one by name.

Well, it happens to be the case though. The code is to work around that.
A normal bug-free tree should never trigger the workarounds.

Ben.