Re: -ENOENT & -ECONNRESET question

Alan Stern <[email protected]>
Newsgroups gmane.linux.usb.devel
Message-ID <[email protected]>
On Thu, 7 Jun 2007, Curran, Dominic wrote:

> 
> In Documentation/usb/error-codes.txt it says:
> 
> -ENOENT                 URB was synchronously unlinked by usb_unlink_urb

This line is mistaken; it should say "unlinked by usb_kill_urb".

> -ECONNRESET             URB was asynchronously unlinked by
> usb_unlink_urb
> 
> What is the difference between a synchronously and an asynchronously
> unlink ?

With usb_unlink_urb, the subroutine call returns almost immediately but
the URB isn't fully unlinked until some time later, when its completion
handler runs.

With usb_kill_urb, you are guaranteed that the URB will be fully
unlinked and the completion handler will have run before the subroutine
call returns.

> My understanding from the answer to a previous question is that if you
> have the situation where 2 URBS are sent to the HCD:
> 1) URB  4K   URB_SHORT_NOT_OK
> 2) URB  8K   URB_SHORT_NOT_OK
> 
> If then only 1K of data is sent back from the Device (short packet) then
> the HCD would complete the 4K URB with:
>   actual_length=1024
>   status = -EREMOTEIO
> 
> The client driver should then call usb_unlink_urb() for the 8K URB which
> would then complete this URB with:
>   status = -ECONNRESET
> 
> So I assume that would be an example of an asynchronously
> unlink...although I'm not entirely sure I understand whats
> 'asynchronous' about it. 

It's asynchronous in the sense that the subroutine call doesn't wait
for the unlink to finish.  It _can't_ wait, because the caller (the
completion handler) runs in an interrupt context.

The timing of the subroutine call and the timing of the unlink aren't
synchronized -- hence they are "asynchronous".

> I don't think I understand what 'synchronous ' & 'asynchronous' mean in
> this context.

In general, "synchronous" means roughly "at the same time" or
"synchronized with".  A call is synchronous if all its actions have
finished by the time the call returns.  "Asynchronous" is the opposite
-- some of the actions may not have finished when the call returns.

Alan Stern


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
[email protected]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.