Skip to content

Commit 273925c

Browse files
Sebastian Andrzej Siewiorgregkh
authored andcommitted
media: em28xx-audio: 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: Mauro Carvalho Chehab <[email protected]> Signed-off-by: Sebastian Andrzej Siewior <[email protected]> Acked-by: Mauro Carvalho Chehab <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 5736184 commit 273925c

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

drivers/media/usb/em28xx/em28xx-audio.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ static void em28xx_audio_isocirq(struct urb *urb)
116116
stride = runtime->frame_bits >> 3;
117117

118118
for (i = 0; i < urb->number_of_packets; i++) {
119+
unsigned long flags;
119120
int length =
120121
urb->iso_frame_desc[i].actual_length / stride;
121122
cp = (unsigned char *)urb->transfer_buffer +
@@ -137,7 +138,7 @@ static void em28xx_audio_isocirq(struct urb *urb)
137138
length * stride);
138139
}
139140

140-
snd_pcm_stream_lock(substream);
141+
snd_pcm_stream_lock_irqsave(substream, flags);
141142

142143
dev->adev.hwptr_done_capture += length;
143144
if (dev->adev.hwptr_done_capture >=
@@ -153,7 +154,7 @@ static void em28xx_audio_isocirq(struct urb *urb)
153154
period_elapsed = 1;
154155
}
155156

156-
snd_pcm_stream_unlock(substream);
157+
snd_pcm_stream_unlock_irqrestore(substream, flags);
157158
}
158159
if (period_elapsed)
159160
snd_pcm_period_elapsed(substream);

drivers/media/usb/em28xx/em28xx-core.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -777,6 +777,7 @@ EXPORT_SYMBOL_GPL(em28xx_set_mode);
777777
static void em28xx_irq_callback(struct urb *urb)
778778
{
779779
struct em28xx *dev = urb->context;
780+
unsigned long flags;
780781
int i;
781782

782783
switch (urb->status) {
@@ -793,9 +794,9 @@ static void em28xx_irq_callback(struct urb *urb)
793794
}
794795

795796
/* Copy data from URB */
796-
spin_lock(&dev->slock);
797+
spin_lock_irqsave(&dev->slock, flags);
797798
dev->usb_ctl.urb_data_copy(dev, urb);
798-
spin_unlock(&dev->slock);
799+
spin_unlock_irqrestore(&dev->slock, flags);
799800

800801
/* Reset urb buffers */
801802
for (i = 0; i < urb->number_of_packets; i++) {

0 commit comments

Comments
 (0)