Alan Stern wrote:

I like the way this idea is leading. We can have a global topology
semaphore protect all the children[] arrays and also the driver-model
lists, since the two data structure views should always be consistent. Then the ->serialize locks won't be needed for tree traversal.

Which "topology" do you mean though ... the physical (hubs, devices) or the logical (interfaces in current configurations)? Or were you thinking of combining those? (In which case the bus rwsem would seem to partly address the problem.)


Instead they can be used by the hub driver to ensure that only one thing happens on a hub at any time. When suspending or resetting a port, the rule should be to acquire the serialize lock on the child first, then on its parent hub. That matches the requirements of usb_reset_device(), and the new suspend code can easily be changed to comply.

That's what the current suspend code does ... the notion of acquiring locks going _up_ the physical tree bothers me, but so far it's sufficient.

There are also the "no device on that port yet" (no child)
and "root hub" (no parent) cases, where the hub's lock is
sufficient.


Whenever a thread executing in the hub driver acquires a hub's serialize lock, it should check that the hub device is still in USB_STATE_CONFIGURED. That will prevent problems with trying to manipulate suspended or disconnected hubs.

Or config 0 hubs.



The only loose end is usb_disconnect(). It can be made to work as follows: When disconnecting a hub first make sure the state is set to USB_STATE_DISCONNECTED, then acquire and release the serialize lock to synchronize with any other threads executing in the hub driver. Once that's done no more children can be added to that hub, so we can safely disconnect all the existing children, then acquire serialize again and unregister the hub itself.

I keep wanting a "mark this whole tree disconnected" stage in that process ...


This seems like a workable approach that solves all the problems I've been able to think up so far. Comments, anybody?

At this level of design, I'd agree.


- Dave



Alan Stern







-------------------------------------------------------
This SF.Net email is sponsored by: Oracle 10g
Get certified on the hottest thing ever to hit the market... Oracle 10g. Take an Oracle 10g class now, and we'll give you the exam FREE. http://ads.osdn.com/?ad_id=3149&alloc_id=8166&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