Am Sonntag, den 16.04.2017, 20:34 +0200 schrieb Rolf Evers-Fischer:
> Both functions are described in Documentation/usb/anchors.txt and I agree: It 
> is not stated clearly that we must always call the 
> "usb_wait_anchor_empty_timeout()" function before we can call the 
> "usb_kill_anchored_urbs()" function.
> 
> Probably Oliver Neukum, who has written these functions long time ago, can 
> explain shortly, if we can call the "usb_kill_anchored_urbs()" function 
> always - and if not, in which situation the "usb_wait_anchor_empty_timeout()" 
> function has to be called in advance.

You can call usb_kill_anchored_urbs() always. The intended function
of usb_wait_anchor_empty_timeout() was to wait for URBs you do not want
to kill. That is not always viable because you have no guarantee that
an URB (at least a bulk URB) finishes in a finite time. So eventually
you will need to kill.
Or if you no longer care for or actively do not want the URBs on an
anchor to be executed, you should call usb_kill_anchored_urbs() right
away.

The race between killing an URB and it finishing regularly
is fundamental. You are racing with the hardware. You cannot avoid it.
The only issue is the data structure being freed. The anchor API takes
care of that.
The correct algorithm is to deal with the race when it occurs. So your
problem is in XHCI, not in a higher layer.

        HTH
                Oliver

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to