On Wed, 25 Jan 2012, Sebastian Andrzej Siewior wrote: > >Since the data and status phases can be sent from different endpoints, > >there's no guarantee of ordering of completed transfers. The xHC host > >could chose to put the event for the status transfer on the event ring > >before the data transfer event. (In practice it probably won't, but it > >could happen.) So receiving a status URB completion before the data URB > >completion doesn't necessarily mean the device has skipped the data > >phase. > The confusing part here that your status/sense URB arrives with status=0 > (in sense) and sdb->resid maybe set to sdb->length which could confuse > the scsi stack (everything went fine but I received no data). In theory this could be correct. Certainly it can happen that you get sense status = 0 and residue > 0; that means the device sent less data than you asked for. In fact, this happens all the time with MODE SENSE commands. > >I think your patch will still work in this case. The status URB > >completion will attempt to unlink the data URBs, but the xHCI driver > >will probably give back the data URB before the stop endpoint command > >will be serviced by the host controller. Will the data URB completion > >see the URB canceled status in urb->status? What should it do in that > >case? Hopefully it won't give back the SCSI command with an error, > >since technically the command did complete. > > As I wrote, if urb->actual_length is 0 you come up with an error. The > status is not considered, only the length is updated. So you should not > update actual_length unless the hcd moved some data. The only confusing > part is (I think) if sense repored that everything went fine and no data > arrived. > > In the diagram in UASP_rev1.0 in "5.4.3 Data-in transfer" the deviceis > waiting for in-ack (DATA-in). So I think the device has to wait until > the data is sent to the host. So that might be enough buffer to avoid > the race you were talking about. You should not depend on this. However, the uas driver should not consider an unlinked data URB to indicate an error -- even if actual_length is 0. > On Data-out side the ERDY (Stat) is sent right after ACK (Data-out) but > the device needs probably save the new data before it sends the STAT. Alan Stern -- 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