On Wed, Aug 19, 2009 at 09:25:40PM +0200, Oliver Neukum wrote: > Am Mittwoch, 19. August 2009 20:33:38 schrieb Sarah Sharp: > > > > +int usb_free_streams(struct usb_driver *driver, > > > > > > What is a driver supposed to do if this returns an error? This will > > > have to be used in disconnect(), which cannot fail. > > > > I see. I can make sure there will be a spot on the command ring for the > > command to remove the stream rings. Unfortunately, the host controller > > can fail that command if it runs out of bandwidth or resources. > > Deallocating streams shouldn't change the bandwidth allocation (unless > > the host controller is broken), but I can't prevent the host controller > > from running out of internal resources. > > > > What should the xHCI driver do in that case? Wait a while and re-submit > > the command? I'm not sure if it's wise to tie up a disconnect() > > function with command resubmissions, so perhaps usb_free_streams() > > should only guarantee that the streams will be freed sometime in the > > future? > > The problem arises if you have a soft disconnect, for example through > sysfs or a failing reset. > In this case the next call to probe() will expect that no streams are > allocated for its interface's endpoints. That expectation has to be met. > It is not enough to guarantee that the streams will be freed at an > unspecified time in the future. I think this needs a hook in usbcore. Hmm, yes that is a problem. Ok, say that xhci_free_streams() always guarantees that there's room on the command ring, and it retries the command twice. Say that still fails when a driver is being unbound during reset. usb_reset_device() can look at the number of streams enabled for each endpoint after an unbind and do something if it's non-zero. What should it do? Disable the port and deallocate the device? At that point we're probably dealing with a busted host controller that doesn't implement internal resource counting or bandwidth allocation properly. Or did you have a different hook in mind for the USB core? Sarah -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html