The existing kerneldoc documentation for URB completion callbacks is incorrect about the context in which the callbacks occur; it is not always in_interrupt. State explicitly that a callback may occur in any context with no guarantees, and likewise for the status of CPU-local interrupts. Documentation update only; no code changes. Signed-off-by: Alan Stern --- drivers/usb/core/urb.c | 8 ++++++++ include/linux/usb.h | 7 ++++++- 2 files changed, 14 insertions(+), 1 deletion(-) Index: usb-devel/drivers/usb/core/urb.c =================================================================== --- usb-devel.orig/drivers/usb/core/urb.c +++ usb-devel/drivers/usb/core/urb.c @@ -254,6 +254,14 @@ EXPORT_SYMBOL_GPL(usb_urb_ep_type_check) * request. The completion handler may then immediately free or reuse that * URB. * + * The USB core makes no guarantees at all about the context in which + * the complete() callback is invoked. It may be in process context, + * interrupt context, BH context, or anything else. Also, local interrupts + * may be enabled or disabled. To deal with this, the callback routine + * must always use the _irqsave and _irqrestore variants of things like + * spin_lock(), and it must always use GFP_ATOMIC for its memory + * allocation flags. + * * With few exceptions, USB device drivers should never access URB fields * provided by usbcore or the HCD until its complete() is called. * The exceptions relate to periodic transfer scheduling. For both Index: usb-devel/include/linux/usb.h =================================================================== --- usb-devel.orig/include/linux/usb.h +++ usb-devel/include/linux/usb.h @@ -1605,7 +1605,12 @@ typedef void (*usb_complete_t)(struct ur * * Completion Callbacks: * - * The completion callback is made in_interrupt(), and one of the first + * The completion callback can occur in any context: process, interrupt, + * BH, or anything else. Also, interrupts may or may not be disabled on + * the local CPU when the callback runs. A completion handler routine + * must not depend on any particular properties of its environment. + * + * One of the first * things that a completion handler should do is check the status field. * The status field is provided for all URBs. It is used to report * unlinked URBs, and status for all non-ISO transfers. It should not