PCI hotplug + EEH issues

Todd Inglett tinglett at vnet.ibm.com
Thu Sep 12 04:11:57 EST 2002

On Wed, 2002-09-11 at 09:49, Benjamin Herrenschmidt wrote:
> >So should I make a stab at defining the of_* functions, or has someone
> >already done this?  One thing in particular I've never liked are the
> >find_* funcs that link stuff in ->next lists (or ->allnext lists in case
> >you need that 2nd query....).

The more I think about locking the more fun this gets :).

Here's what I'd expect we'd do to iterate over, say, "pci" nodes:

for (dn = of_find_next(NULL, "pci"); dn; of_find_next(dn, "pci")) {
	/* Do something with dn */

I suppose it could be written cleaner like this (same API):

dn = NULL;
while ((dn = of_find_next(dn, "pci")) != NULL) {
	/* Do something with dn */

The trouble of course is that dn could be deleted by hotplug (or some
other clever code), so we still need locking.

We could make the caller hold a big device-tree lock, but then the
caller would need to hold the lock for as long as it uses dn.  This
might be ok, but then no code can hold a ptr to the device node for any
length of time.

Another possibility is to use reference counting on the nodes (still
using a lock to traverse from one node to the next and bump the count),
but at least the caller will not need to hold a lock while *using* a
node.  I'm not sure I like the complexity of this idea considering the
details of deleting a node while a traversal is in process somewhere



** Sent via the linuxppc64-dev mail list. See http://lists.linuxppc.org/

More information about the Linuxppc64-dev mailing list