On Thu, 25 Sep 2003, Oliver Neukum wrote:
> Am Donnerstag, 25. September 2003 18:02 schrieb David Brownell:
> >
> > So submit a patch to make reset_configuration() verify that the
> > device is present before that. That scenario is rather unlikely;
> > but it's of course worth handling correctly.
>
> Yes, exactly, but to do that you need to make sure that the state remains
> constant between test and changing the state. To do so, you need a lock.
> More specifically you race with code like this:
>
> + if (retval < 0) {
> + dev->state = USB_STATE_ADDRESS;
> + goto done;
> + }
>
> or this:
>
> + dev->actconfig = 0;
> + if (dev->state == USB_STATE_CONFIGURED)
> + dev->state = USB_STATE_ADDRESS;
To be consistent, we ought to make sure that all the synchronous changes
to dev->state are protected by the serialize mutex.
However, I think it won't hurt to have an unprotected asynchronous change
that sets the state to NOTATTACHED. If the value should get overwritten
because of a race, all that will happen is that some URBs will be sent to
the HCD instead of rejected immediately. But the device structure will
still get removed in the end.
Ideally we should set the state to NOTATTACHED as soon as we know the
device has disconnected, but I can't think of any way of learning that
before khubd reads the port status. Too bad we can't just inspect the
status codes of URBs returned from the HCD, but that won't work. There
are perfectly valid reasons for a device not to respond to a USB message.
Alan Stern
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel