Re: [RFC PATCH 0/9] dt: dependencies (for deterministic driver initialization order based on the DT)

From: Thierry Reding
Date: Tue Aug 26 2014 - 10:17:34 EST

On Tue, Aug 26, 2014 at 08:58:34AM -0500, Jon Loeliger wrote:
> > >>
> > >> Drivers don't provide that information (dependencies) in any usable way. And
> > >> as you said yourself, it's already contained in phandles. So what we are
> > >> discussing here about? The proposal to use phandles for that is already on
> > >> the table since several month. ;)
> > >>
> > >> Sorry, but I don't understand what you want to propose.
> > >
> > > In many cases we simply don't know where phandles are stored since we
> > > don't have the type information in DT. But drivers already know the type
> > > of a specific phandle and where to get it from, so the proposal is to
> > > make that knowledge more generally useful so that it can be used for
> > > dependency resolution.
> >
> > How?
> Is the issue around which we are dancing here the timing of
> topsort and the probing? When the driver is probed, sure, it
> touches and resolves a bunch of phandles and references other
> nodes and devices. But that is at probe time, and it only has
> the context of itself then.
> I think we need to do the complete topsort *before* we attempt
> to do any probing. So three steps:
> 1) Graph Construction
> Add a new "emit dependencies" function to driver bindings.
> Iterate over known devices or nodes in the DT in any order.
> Call the "emit dependencies" function. It adds all
> dependency edges to a global graph by knowing what
> phandles or other pieces it will need.
> A driver with no "emit dependencies" function can be
> added to the graph anywhere without loss of generality.
> Add any additional edges for whatever reason.
> 2) Topsort the generated driver graph
> 3) Call probe for real in topsort order

Yes, I think that makes a lot of sense. We need to provide a way to make
the dependency information available before probe time, otherwise we
don't gain anything. Whether we provide that in a form of a function
call or a table is an implementation detail.

I do think that requiring drivers to provide a function is going to make
things more complicated than necessary since that "emit dependencies"
function would need to copy a lot of the things that .probe() does
already. Sharing this information in a table sounds like a good idea. An
"emit dependencies" function in the core can use that data to resolve
dependencies whereas the driver core can equally use that information to
request the devices so that the drivers don't have to do so.


Attachment: pgptiwLg8oSPw.pgp
Description: PGP signature