linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rjw@sisk.pl>
To: Greg KH <gregkh@suse.de>
Cc: "davinci-linux-open-source@linux.davincidsp.com"
	<davinci-linux-open-source@linux.davincidsp.com>,
	"dbrownell@users.sourceforge.net"
	<dbrownell@users.sourceforge.net>,
	"sameo@linux.intel.com" <sameo@linux.intel.com>,
	"khilman@deeprootsystems.com" <khilman@deeprootsystems.com>,
	"linus.ml.walleij@gmail.com" <linus.ml.walleij@gmail.com>,
	"broonie@opensource.wolfsonmicro.com"
	<broonie@opensource.wolfsonmicro.com>,
	Grant Likely <grant.likely@secretlab.ca>,
	"rpurdie@rpsys.net" <rpurdie@rpsys.net>,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>,
	Cyril Chemparathy <cyril@ti.com>,
	"spi-devel-general@lists.sourceforge.net"
	<spi-devel-general@lists.sourceforge.net>,
	"akpm@linux-foundation.org" <akpm@linux-foundation.org>,
	"alan@lxorguk.ukuu.org.uk" <alan@lxorguk.ukuu.org.uk>,
	"lrg@slimlogic.co.uk" <lrg@slimlogic.co.uk>
Subject: Re: [PATCH v5 04/12] spi: add ti-ssp spi master driver
Date: Fri, 26 Nov 2010 00:32:37 +0100	[thread overview]
Message-ID: <201011260032.38154.rjw@sisk.pl> (raw)
In-Reply-To: <20101118054611.GB13567@suse.de>

On Thursday, November 18, 2010, Greg KH wrote:
> On Wed, Nov 17, 2010 at 09:11:30AM -0700, Grant Likely wrote:
> > Also, any dependency tracking must work across bus_types.  It is not
> > sufficient to only handle the platform_devices use-case.  All bus
> > types have this need.
> 
> Agreed.
> 
> > I see a few potential approaches.
> > 
> > Option 1: Add a list of prerequisite devices to struct device and
> > modify driver core so that it defers binding to a driver until all the
> > prerequisites are already bound.  This can probably be implemented
> > in a way that works for all bus types transparently.  Before binding
> > a driver, the driver core would increase the ref count on each of the
> > prereq devices, and decrease it again when the driver is removed.
> 
> I see loops happening easily that prevent any device from being bound.
> That could get tricky to debug :(
> 
> > Option 2: On a per-bus_type basis have a separate registration and the
> > bus type code would hold the device unregistered in a pending list.
> > This option would also add a prerequisites list to struct device.
> 
> When would we process the "pending list"?
> 
> I can see something like this working, up to a point.  Once device (or
> driver) registration is complete, we would walk the lists of busses and
> see if anything new wants to be bound again, now that something new has
> shown up, instead of just walking the single bus.
> 
> But then we have the issue of devices that never are bound to anything,
> it could get a little "noisy" with them never binding, but we can't rely
> on the fact that not all devices are not bound to know when to stop
> trying.
> 
> This might be the simplest to try out as we do almost all of this today
> in the driver core (walk the list and try to bind all unbound devices to
> a new driver.)  Just extend that walking to walk all other busses as
> well.  But this would require that the drivers know when they can't bind
> to a device due to something not being set up properly, which I don't
> know if is always true.
> 
> > Option 3: Don't try to handle it in the bus_type or driver core code
> > at all, but rather provide board support code with helpers to make
> > waiting for other devices easy.  Even in this case I think it is
> > probably still a good idea for the dependant devices to increment
> > the refcount of the prereq devices.

That's necessary IMO.

> > Perhaps something that is used like:
> > 
> > void do_second_registration(void)
> > {
> > 	/* register list of dependant devices */
> > }
> > 
> > and then in the primary registration function:
> > 	...
> > 	device_notify_when_bound(&prereq_pdev->dev,
> > 				 do_second_registration);
> > 	platform_device_add(prereq_pdev);
> > 	...
> > 
> > which would reduce the boilerplate, but remain flexible.  However,
> > while flexable, option 3 doesn't solve the dependency tracking
> > problem, and it still requires some gymnastics to handle multiple
> > dependencies.
> > 
> > On a related issue, it may also be desirable for each device to
> > maintain a list of devices that have claimed dependency on it for the
> > purpose of debugability.
> 
> That might be the simplest as each "board type" knows which devices it
> wants to register and in what order, right?

Ironically enough, we also have this problem in ACPI where there are power
resources that "regular" devices may depend on in pretty much the same way
as discussed here.  Those power resources are represented as devices, so the
problem is really analogous.

In ACPI, though, basically all devices are registered by the same routine that
walks the namespace (which is a tree-like structure) and registers all devices
it finds there.  Before registering a device it examines its properties and,
among other things, it finds what power resources the device depends on.  Then,
it may invoke itself in a recursive way to register those power resources before
registering the device (the recurrence is one-level only, because power
resources cannot depend on anything else).  Since the driver for power
resources has been already registered at that point, we know it will bind to
the power resource device objects as soon as they are registered.  This is done
in a patch series I posted yesterday, actaully.

I'm not sure if this approach can be generalized somehow, but in the ACPI
case it works just fine.

Thanks,
Rafael

  reply	other threads:[~2010-11-25 23:32 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-15 19:12 [PATCH v5 00/12] tnetv107x ssp drivers Cyril Chemparathy
     [not found] ` <1289848334-8695-1-git-send-email-cyril-l0cyMroinI0@public.gmane.org>
2010-11-15 19:12   ` [PATCH v5 01/12] misc: add driver for sequencer serial port Cyril Chemparathy
     [not found]     ` <1289848334-8695-2-git-send-email-cyril-l0cyMroinI0@public.gmane.org>
2010-11-16  7:10       ` Grant Likely
     [not found]         ` <20101116071047.GE4074-MrY2KI0G/OVr83L8+7iqerDks+cytr/Z@public.gmane.org>
2010-11-16 16:15           ` Cyril Chemparathy
     [not found]             ` <4CE2AE3C.4040805-l0cyMroinI0@public.gmane.org>
2010-11-16 20:35               ` Grant Likely
     [not found]                 ` <AANLkTik76EY8Xh01YP2Tep6k1ETPO+3idmNuk3pVikJG-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-11-16 21:19                   ` Cyril Chemparathy
2010-11-16 22:23                   ` Russell King - ARM Linux
     [not found]                     ` <20101116222340.GF21926-l+eeeJia6m9vn6HldHNs0ANdhmdF6hFW@public.gmane.org>
2010-11-16 23:57                       ` Grant Likely
2010-11-15 19:12   ` [PATCH v5 02/12] davinci: add tnetv107x ssp platform device Cyril Chemparathy
2010-11-15 19:12   ` [PATCH v5 03/12] davinci: add ssp config for tnetv107x evm board Cyril Chemparathy
2010-11-15 19:12   ` [PATCH v5 04/12] spi: add ti-ssp spi master driver Cyril Chemparathy
2010-11-15 21:59     ` Ryan Mallon
     [not found]     ` <1289848334-8695-5-git-send-email-cyril-l0cyMroinI0@public.gmane.org>
2010-11-16  7:22       ` Grant Likely
     [not found]         ` <20101116072225.GF4074-MrY2KI0G/OVr83L8+7iqerDks+cytr/Z@public.gmane.org>
2010-11-16  7:47           ` Grant Likely
2010-11-16 11:34             ` Mark Brown
     [not found]               ` <20101116113409.GH3338-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2010-11-16 20:45                 ` Grant Likely
     [not found]                   ` <20101116204554.GB5016-MrY2KI0G/OVr83L8+7iqerDks+cytr/Z@public.gmane.org>
2010-11-16 22:48                     ` Mark Brown
     [not found]             ` <AANLkTi=utWumLKo9QVWXpkC8WxpgaNJJs+dj=pa2eq-q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-11-17  0:17               ` Cyril Chemparathy
2010-11-17 13:31                 ` Mark Brown
     [not found]                   ` <20101117133136.GA19488-HF5t3jzXg/6ND3a5+9QAFujbO/Zr0HzV@public.gmane.org>
2010-11-17 15:25                     ` David Brownell
     [not found]                       ` <781931.83221.qm-g47maUHHHF+ORdMXk8NaZPu2YVrzzGjVVpNB7YpNyf8@public.gmane.org>
2010-11-17 17:54                         ` Cyril Chemparathy
     [not found]                 ` <4CE31F0E.7050103-l0cyMroinI0@public.gmane.org>
2010-11-17 16:11                   ` Grant Likely
     [not found]                     ` <20101117161130.GC5757-MrY2KI0G/OVr83L8+7iqerDks+cytr/Z@public.gmane.org>
2010-11-17 17:23                       ` Mark Brown
2010-11-17 17:35                       ` Cyril Chemparathy
2010-11-18  5:46                       ` Greg KH
2010-11-25 23:32                         ` Rafael J. Wysocki [this message]
2010-11-16 14:19           ` David Brownell
2010-11-15 19:12   ` [PATCH v5 05/12] davinci: add spi devices on tnetv107x evm Cyril Chemparathy
2010-11-15 19:12   ` [PATCH v5 06/12] regulator: add driver for tps6524x regulator Cyril Chemparathy
2010-11-15 19:12   ` [PATCH v5 07/12] davinci: add tnetv107x evm regulators Cyril Chemparathy
2010-11-15 19:12   ` [PATCH v5 08/12] gpio: add ti-ssp gpio driver Cyril Chemparathy
     [not found]     ` <1289848334-8695-9-git-send-email-cyril-l0cyMroinI0@public.gmane.org>
2010-11-15 22:38       ` Ryan Mallon
     [not found]         ` <4CE1B651.1060006-7Wk5F4Od5/oYd5yxfr4S2w@public.gmane.org>
2010-11-16 19:38           ` Cyril Chemparathy
2010-11-15 19:12   ` [PATCH v5 09/12] davinci: add tnetv107x evm ti-ssp gpio device Cyril Chemparathy
2010-11-15 19:12   ` [PATCH v5 10/12] backlight: add support for tps6116x controller Cyril Chemparathy
2010-11-15 19:12   ` [PATCH v5 11/12] davinci: add tnetv107x evm backlight device Cyril Chemparathy
2010-11-15 19:12   ` [PATCH v5 12/12] davinci: add tnetv107x evm i2c eeprom device Cyril Chemparathy

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=201011260032.38154.rjw@sisk.pl \
    --to=rjw@sisk.pl \
    --cc=akpm@linux-foundation.org \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=broonie@opensource.wolfsonmicro.com \
    --cc=cyril@ti.com \
    --cc=davinci-linux-open-source@linux.davincidsp.com \
    --cc=dbrownell@users.sourceforge.net \
    --cc=grant.likely@secretlab.ca \
    --cc=gregkh@suse.de \
    --cc=khilman@deeprootsystems.com \
    --cc=linus.ml.walleij@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=lrg@slimlogic.co.uk \
    --cc=rpurdie@rpsys.net \
    --cc=sameo@linux.intel.com \
    --cc=spi-devel-general@lists.sourceforge.net \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).