Re: Questions about USB core reset behavior

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 26 Apr 2011, Oliver Neukum wrote:

> Am Montag, 25. April 2011, 23:30:38 schrieb Alan Stern:
> > On Mon, 25 Apr 2011, Sarah Sharp wrote:
> > 
> > > On Mon, Apr 25, 2011 at 03:18:46PM -0400, Alan Stern wrote:
> > > > On Mon, 25 Apr 2011, Sarah Sharp wrote:
> > > > 
> > > > > Random question time. :)
> > > > > 
> > > > > Do USB device drivers have to cancel all URBs that are pending for a
> > > > > device before calling usb_reset_device?  Will the drivers have to wait
> > > > > for the URBs to complete before resetting the device?
> > > > 
> > > > There is no requirement that drivers cancel all URBs before a reset 
> > > > occurs.  Indeed, some drivers can't because they have no way to know 
> > > > when another driver bound to another interface on the same device wants 
> > > > to do a reset, i.e., they have no pre_reset callback.
> > > 
> > > Ah, ok.  Apparently Windows recommends canceling all outstanding
> > > transfers before issuing a port reset, which was apparently what the
> > > chipset folks were hoping Linux also suggested.  Oh well.
> > 
> > I don't know offhand of any drivers that leave URBs active while doing
> > a reset.  But there's no recommendation about it.
> 
> Then we should add it.
> If a driver does not implement pre_reset() we call disconnect() which
> does require termination of all IO.
> 
> If we call pre_reset() any further IO is unreliable. The assumption they
> are making are quite reasonable.

I suppose so.  How does this look?

Alan Stern



Index: usb-2.6/include/linux/usb.h
===================================================================
--- usb-2.6.orig/include/linux/usb.h
+++ usb-2.6/include/linux/usb.h
@@ -806,8 +806,10 @@ struct usbdrv_wrap {
  * @resume: Called when the device is being resumed by the system.
  * @reset_resume: Called when the suspended device has been reset instead
  *	of being resumed.
- * @pre_reset: Called by usb_reset_device() when the device
- *	is about to be reset.
+ * @pre_reset: Called by usb_reset_device() when the device is about to be
+ *	reset.  This routine must not return until the driver has no active
+ *	URBs for the device, and no more URBs may be submitted until the
+ *	post_reset method is called.
  * @post_reset: Called by usb_reset_device() after the device
  *	has been reset
  * @id_table: USB drivers use ID table to support hotplugging.
Index: usb-2.6/Documentation/usb/callbacks.txt
===================================================================
--- usb-2.6.orig/Documentation/usb/callbacks.txt
+++ usb-2.6/Documentation/usb/callbacks.txt
@@ -95,9 +95,11 @@ pre_reset
 
 int (*pre_reset)(struct usb_interface *intf);
 
-Another driver or user space is triggering a reset on the device which
-contains the interface passed as an argument. Cease IO and save any
-device state you need to restore.
+A driver or user space is triggering a reset on the device which
+contains the interface passed as an argument. Cease IO, wait for all
+outstanding URBs to complete, and save any device state you need to
+restore.  No more URBs may be submitted until the post_reset method
+is called.
 
 If you need to allocate memory here, use GFP_NOIO or GFP_ATOMIC, if you
 are in atomic context.

--
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


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux