aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation/usb
diff options
context:
space:
mode:
authorMing Lei <ming.lei@canonical.com>2013-07-03 10:53:08 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-08-12 14:43:48 -0400
commit85721d45261c4be684730c7509a59daa6cda30d8 (patch)
treec7a370c0c292a96443b8fdbee17423e8faaa7252 /Documentation/usb
parent94dfd7edfd5c9b605caf7b562de7a813d216e011 (diff)
USB: URB documentation: claim complete() will be run with IRQs enabled
There is no good reason to run complete() in hard interrupt disabled context. After switch to run complete() in tasklet, we will enable local IRQs when calling complete() since we can do it at that time. Even though we still disable IRQs now when calling complete() in tasklet, the URB documentation is updated to claim complete() will be run in tasklet context and local IRQs will be enabled, so that USB drivers can know the change and avoid one deadlock caused by: assume IRQs disabled in complete() and call spin_lock() to hold lock which might be acquired in interrupt context. Current spin_lock() usages in drivers' complete() will be cleaned up at the same time, and once the cleanup is finished, local IRQs will be enabled when calling complete() in tasklet. Also fix description about type of usb_complete_t, and remove the advice of running completion handler in tasklet for decreasing system latency. Cc: Oliver Neukum <oliver@neukum.org> Acked-by: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Ming Lei <ming.lei@canonical.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'Documentation/usb')
-rw-r--r--Documentation/usb/URB.txt21
1 files changed, 10 insertions, 11 deletions
diff --git a/Documentation/usb/URB.txt b/Documentation/usb/URB.txt
index 00d2c644068e..50da0d455444 100644
--- a/Documentation/usb/URB.txt
+++ b/Documentation/usb/URB.txt
@@ -195,13 +195,12 @@ by the completion handler.
195 195
196The handler is of the following type: 196The handler is of the following type:
197 197
198 typedef void (*usb_complete_t)(struct urb *, struct pt_regs *) 198 typedef void (*usb_complete_t)(struct urb *)
199 199
200I.e., it gets the URB that caused the completion call, plus the 200I.e., it gets the URB that caused the completion call. In the completion
201register values at the time of the corresponding interrupt (if any). 201handler, you should have a look at urb->status to detect any USB errors.
202In the completion handler, you should have a look at urb->status to 202Since the context parameter is included in the URB, you can pass
203detect any USB errors. Since the context parameter is included in the URB, 203information to the completion handler.
204you can pass information to the completion handler.
205 204
206Note that even when an error (or unlink) is reported, data may have been 205Note that even when an error (or unlink) is reported, data may have been
207transferred. That's because USB transfers are packetized; it might take 206transferred. That's because USB transfers are packetized; it might take
@@ -210,12 +209,12 @@ have transferred successfully before the completion was called.
210 209
211 210
212NOTE: ***** WARNING ***** 211NOTE: ***** WARNING *****
213NEVER SLEEP IN A COMPLETION HANDLER. These are normally called 212NEVER SLEEP IN A COMPLETION HANDLER. These are often called in atomic
214during hardware interrupt processing. If you can, defer substantial 213context.
215work to a tasklet (bottom half) to keep system latencies low. You'll
216probably need to use spinlocks to protect data structures you manipulate
217in completion handlers.
218 214
215In the current kernel, completion handlers run with local interrupts
216disabled, but in the future this will be changed, so don't assume that
217local IRQs are always disabled inside completion handlers.
219 218
2201.8. How to do isochronous (ISO) transfers? 2191.8. How to do isochronous (ISO) transfers?
221 220