Re: [PATCH v2 0/3] introduce External Connector Class (extcon)

From: NeilBrown
Date: Tue Dec 20 2011 - 00:59:34 EST


On Tue, 20 Dec 2011 01:01:09 +0000 Mark Brown
<broonie@xxxxxxxxxxxxxxxxxxxxxxxxxxx> wrote:

> On Sun, Dec 18, 2011 at 06:15:50PM +1100, NeilBrown wrote:
> > On Thu, 15 Dec 2011 14:51:55 +0800 Mark Brown
>
> > > Grant has a proposal for this which revolves around devices trying to
> > > acquire their resources and returning a "please retry" error code if
> > > they don't have all their dependencies. Half the problem here is that
>
> > A possibility I have been thinking about is to multithread do_initcalls() and
> > have the various request functions (gpio_request, regulator_get, request_irq,
> > etc) optionally block if the resource isn't available.
>
> That seems to be logically the same in terms of what it actually does
> but introduces concurrency which wasn't there before which means that
> things could get reordered for random reasons. That seems like it'd not
> be great for robustness.

Logically similar..

One important difference is that (if I understand it correctly), the "please
retry" error need to be propagated up a lot further than it currently is so
that would be quite intrusive.

While my approach does introduce concurrency which wasn't there before, any
driver that can be built as a module must allow for concurrency in the init
function so I suspect (or hope) people normally make that code thread-safe.

I have some code that almost works (will post when it does work). The only
real issue I have found (apart from personal incompetence) is that we really
need to know up-front what resources are going to be available so we know
whether to wait or to fail (waiting until 'everything is finished' won't work
as there could be several things still waiting at the end and we don't know if
one is waiting for another, of if they are waiting for things that won't
appear).

I imagine that ultimately we can depend on a device-tree file to list every
resource (gpio, irq, regulator) that is relevant here and can write the code
to wait-or-fail accordingly.

>
> > Do we need to talk about devices that haven't been enumerated yet? or was
> > that just if we wanted to create an explicit dependency graph?
>
> You need to know about devices that aren't enumerated yet.

I'm still not quite sure what you mean. In my (limited) experience you need
to know about resources, not devices, and they have names.
And there is some precedent in regulator supply lists for naming devices
before they are enumerated. So I'm not seeing the problem that you are
seeing.

Thanks,
NeilBrown

Attachment: signature.asc
Description: PGP signature