On Fri, 16 Jan 2004, Oliver Neukum wrote:

> 
> > This lock should not see much contention.  It will be held only very 
> > briefly in any path where a state gets changed.  Something like this:
> > 
> >     spin_lock_irq(&global_state_lock);
> >     if (usbdev->state != USB_STATE_NOTATTACHED)
> >             usbdev->state = USB_STATE_CONFIGURED;
> >     else
> >             notattached = 1;
> >     spin_unlock_irq(&global_state_lock);
> >     if (notattached) ...
> 
> Ehm. You have to check the state in usb_submit_urb().

True, but that doesn't require grabbing the spinlock since all you want to 
know is whether the state is NOTATTACHED or not.  You're not changing the 
state.


> > > >         struct usb_device->serialize will become a read-write semaphore.
> 
> The only reason to go for an rw-semaphore is contention. If contention is
> low, there's no point in going for the extra overhead of such a lock.

No, there can be other reasons too.  For example, suppose one routine that 
gets a read lock calls another that does the same thing.  That works well 
with rw-semaphores but not with regular ones.  That's not contention, it's 
something else (poor design perhaps -- but Duncan has his reasons).


[talking about blocking URB submissions and unlinking URBs in flight...]
> > Ah -- we do it when the device is unplugged.  So far as I can see, we 
> > don't do it when usb_deregister() is called.  Nor do we set the interfaces
> 
> Nor must we ever do this, unless it's in the interval between unbinding
> and reprobe. But from a viewpoint of correctness a blockages that exists
> only for an arbitrarily low amount of time doesn't exist at all.

This wouldn't be for an arbitrarily short period of time; it would last 
during the entire call to disconnect().  And yes, certainly it would stop 
before re-probe().

Alan Stern



-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to