linux/sound/usb
Ioan-Adrian Ratiu 1d0f953086 ALSA: usb-audio: Fix irq/process data synchronization
Commit 16200948d8 ("ALSA: usb-audio: Fix race at stopping the stream") was
incomplete causing another more severe kernel panic, so it got reverted.
This fixes both the original problem and its fallout kernel race/crash.

The original fix is to move the endpoint member NULL clearing logic inside
wait_clear_urbs() so the irq triggering the urb completion doesn't call
retire_capture/playback_urb() after the NULL clearing and generate a panic.

However this creates a new race between snd_usb_endpoint_start()'s call
to wait_clear_urbs() and the irq urb completion handler which again calls
retire_capture/playback_urb() leading to a new NULL dereference.

We keep the EP deactivation code in snd_usb_endpoint_start() because
removing it will break the EP reference counting (see [1] [2] for info),
however we don't need the "can_sleep" mechanism anymore because a new
function was introduced (snd_usb_endpoint_sync_pending_stop()) which
synchronizes pending stops and gets called inside the pcm prepare callback.

It also makes sense to remove can_sleep because it was also removed from
deactivate_urbs() signature in [3] so we benefit from more simplification.

[1] commit 015618b90 ("ALSA: snd-usb: Fix URB cancellation at stream start")
[2] commit e9ba389c5 ("ALSA: usb-audio: Fix scheduling-while-atomic bug in PCM capture stream")
[3] commit ccc1696d5 ("ALSA: usb-audio: simplify endpoint deactivation code")

Fixes: f8114f8583 ("Revert "ALSA: usb-audio: Fix race at stopping the stream"")

Signed-off-by: Ioan-Adrian Ratiu <adi@adirat.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2017-01-05 07:35:00 +01:00
..
6fire treewide: Fix typos in printk 2015-12-08 14:59:19 +01:00
bcd2000 ALSA: bcd2000: Make local data static 2015-05-26 13:00:01 +02:00
caiaq ALSA: usb: caiaq: audio: don't print error when allocating urb fails 2016-08-11 23:05:57 +02:00
hiface ALSA: hiface: Fix M2Tech hiFace driver sampling rate change 2016-12-12 22:46:43 +01:00
line6 ALSA: line6: Claim pod x3 usb data interface 2016-11-29 22:16:14 +01:00
misc ALSA: ua101: replace le16_to_cpu() with usb_endpoint_maxp() 2015-11-16 09:03:06 +01:00
usx2y ALSA: usx2y: fix inconsistent indenting on if statement 2015-12-02 18:03:24 +01:00
card.c ALSA: usb-audio: Fix bogus error return in snd_usb_create_stream() 2016-11-29 22:28:40 +01:00
card.h ALSA: usb: use TEAC UD-H01 quirk for more devices 2016-08-22 11:39:56 +02:00
clock.c ALSA: usb-audio: Limit retrying sample rate reads 2016-04-29 11:49:04 +02:00
clock.h ALSA: usb-audio: UAC2: do clock validity check earlier 2013-04-04 08:30:59 +02:00
debug.h ALSA: usb-audio: make hwc_debug a noop in case HW_CONST_DEBUG is not set 2011-05-18 11:44:35 +02:00
endpoint.c ALSA: usb-audio: Fix irq/process data synchronization 2017-01-05 07:35:00 +01:00
endpoint.h ALSA: usb-audio: Fix irq/process data synchronization 2017-01-05 07:35:00 +01:00
format.c ALSA: usb-audio: rmove print for failure of kmalloc 2016-08-22 11:41:02 +02:00
format.h ALSA: usb-audio: store protocol version in struct audioformat 2013-06-27 21:59:47 +02:00
helper.c ALSA: usb-audio: correct speed checking 2016-05-08 11:42:04 +02:00
helper.h ALSA: usb-audio: increase control transfer timeout 2011-09-27 09:21:48 +02:00
Kconfig [media] Revert "[media] sound/usb: Use Media Controller API to share media resources" 2016-03-31 15:02:33 -03:00
Makefile [media] Revert "[media] sound/usb: Use Media Controller API to share media resources" 2016-03-31 15:02:33 -03:00
midi.c ALSA: usb-midi: correct speed checking 2016-05-08 11:42:30 +02:00
midi.h ALSA: usb-audio: Refer to chip->usb_id for quirks and MIDI creation 2016-01-29 07:36:10 +01:00
mixer.c ALSA: usb-audio: Add QuickCam Communicate Deluxe/S7500 to volume_control_quirks 2016-12-09 11:21:02 +01:00
mixer.h [media] Revert "[media] sound/usb: Use Media Controller API to share media resources" 2016-03-31 15:02:33 -03:00
mixer_maps.c ALSA: usb-audio: Change structure initialisation to C99 style 2016-06-17 16:58:41 +02:00
mixer_quirks.c ALSA: usb-audio: Extend DragonFly dB scale quirk to cover other variants 2016-09-23 08:32:18 +02:00
mixer_quirks.h ALSA: usb-audio: Add a more accurate volume quirk for AudioQuest DragonFly 2015-12-14 10:13:17 +01:00
mixer_scarlett.c ALSA: usb-audio: Fix Scarlett 6i6 initialization typo 2014-12-18 08:39:17 +01:00
mixer_scarlett.h ALSA: usb-audio: Scarlett mixer interface for 6i6, 18i6, 18i8 and 18i20 2014-11-13 07:32:39 +01:00
pcm.c ALSA: usb-audio: Fix irq/process data synchronization 2017-01-05 07:35:00 +01:00
pcm.h ALSA: usb: refine delay information with USB frame counter 2011-09-12 10:30:20 +02:00
power.h ALSA: usbaudio: implement USB autosuspend 2011-03-11 14:59:29 +01:00
proc.c ALSA: usb-audio: Avoid nested autoresume calls 2015-08-26 15:38:25 +02:00
proc.h ALSA: usb-audio: refactor code 2010-03-05 08:17:14 +01:00
quirks-table.h ALSA: usb-audio: Add quirk for Syntek STK1160 2016-10-27 12:07:19 +02:00
quirks.c ALSA: usb-audio: Add native DSD support for TEAC 501/503 DAC 2016-12-12 22:42:33 +01:00
quirks.h ALSA: usb-audio: Refer to chip->usb_id for quirks and MIDI creation 2016-01-29 07:36:10 +01:00
stream.c media fixes for v4.6-rc2 2016-04-05 06:47:50 -07:00
stream.h ALSA: snd-usb: re-order code 2011-09-14 17:07:02 +02:00
usbaudio.h Merge branch 'for-linus' into for-next 2016-05-10 16:06:04 +02:00