Skip to content

Commit ee9a4ae

Browse files
Sebastian Andrzej SiewiorFelipe Balbi
authored andcommitted
usb: usbtest: use irqsave() in USB's complete callback
The USB completion callback does not disable interrupts while acquiring the lock. We want to remove the local_irq_disable() invocation from __usb_hcd_giveback_urb() and therefore it is required for the callback handler to disable the interrupts while acquiring the lock. The callback may be invoked either in IRQ or BH context depending on the USB host controller. Use the _irqsave() variant of the locking primitives. Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Acked-by: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
1 parent bf594c1 commit ee9a4ae

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

drivers/usb/misc/usbtest.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1082,11 +1082,12 @@ static void ctrl_complete(struct urb *urb)
10821082
struct usb_ctrlrequest *reqp;
10831083
struct subcase *subcase;
10841084
int status = urb->status;
1085+
unsigned long flags;
10851086

10861087
reqp = (struct usb_ctrlrequest *)urb->setup_packet;
10871088
subcase = container_of(reqp, struct subcase, setup);
10881089

1089-
spin_lock(&ctx->lock);
1090+
spin_lock_irqsave(&ctx->lock, flags);
10901091
ctx->count--;
10911092
ctx->pending--;
10921093

@@ -1185,7 +1186,7 @@ static void ctrl_complete(struct urb *urb)
11851186
/* signal completion when nothing's queued */
11861187
if (ctx->pending == 0)
11871188
complete(&ctx->complete);
1188-
spin_unlock(&ctx->lock);
1189+
spin_unlock_irqrestore(&ctx->lock, flags);
11891190
}
11901191

11911192
static int
@@ -1917,8 +1918,9 @@ struct transfer_context {
19171918
static void complicated_callback(struct urb *urb)
19181919
{
19191920
struct transfer_context *ctx = urb->context;
1921+
unsigned long flags;
19201922

1921-
spin_lock(&ctx->lock);
1923+
spin_lock_irqsave(&ctx->lock, flags);
19221924
ctx->count--;
19231925

19241926
ctx->packet_count += urb->number_of_packets;
@@ -1958,7 +1960,7 @@ static void complicated_callback(struct urb *urb)
19581960
complete(&ctx->done);
19591961
}
19601962
done:
1961-
spin_unlock(&ctx->lock);
1963+
spin_unlock_irqrestore(&ctx->lock, flags);
19621964
}
19631965

19641966
static struct urb *iso_alloc_urb(

0 commit comments

Comments
 (0)