On Thu, 1 Jan 2004, David Brownell wrote:

> How about a lock tree?
> 
> Each interior node (hub) has a lock (dev->serialize?) and they're acquired
> from root to leaf.  Once you have a node's lock, you can release the parent
> lock ... to allow more parallelism.  When you're done updating the children
> (adding, naming, removing, etc) just release that node's lock.  (Or for a
> more advanced version:  node can have rwlocks not mutexes.)

> To add remove a node (hub or device), you must hold its parent's lock.
> (And not hold the usb subsystem rwsem; the driver model core grabs that
> to update sysfs and bind/unbind drivers.)
> 
> So whatever is removing the root hub would grab some bus-level lock and
> not let go.  And khubd would walk down the tree from that same root, but
> keep only the lock for the hub with the device it's adding.  One would
> grab that root lock first, and proceed; the other would wait till that
> lock was released.
> 
> That way you can do things like adding devices on one hub while removing
> them from another one -- concurrently.

I was playing around with a simpler idea...  Have the core notify khubd
whenever it's about to remove all the children of a hub.  Khubd guarantees
that after returning from the notification it will not access that hub's 
children[] array.  In principle this notification could simply take the 
form of a call to the hub driver's release() routine.

In other words, at each interior node of the tree have usb_disconnect() 
unbind the hub driver _before_ recursively disconnecting the child nodes 
and the hub node itself.

Any reason why this wouldn't work?  Or wouldn't be sufficiently general?

Alan Stern

P.S.: It's getting a bit late here, so it shouldn't be at all surprising 
if this plan has some glaring hole.



-------------------------------------------------------
This SF.net email is sponsored by: IBM Linux Tutorials.
Become an expert in LINUX or just sharpen your skills.  Sign up for IBM's
Free Linux Tutorials.  Learn everything from the bash shell to sys admin.
Click now! http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click
_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to