aboutsummaryrefslogtreecommitdiffstats
path: root/sound/usb/pcm.c
diff options
context:
space:
mode:
authorDaniel Mack <zonque@gmail.com>2012-08-29 07:17:05 -0400
committerTakashi Iwai <tiwai@suse.de>2012-08-30 01:46:27 -0400
commit015618b902ae8e28705b7af9b4668615fea48ddd (patch)
tree43832c8eeaad08cf294da8a438512815858cfa66 /sound/usb/pcm.c
parentc36b5b054aaf14d68261970e3769398110e636d8 (diff)
ALSA: snd-usb: Fix URB cancellation at stream start
Commit e9ba389c5 ("ALSA: usb-audio: Fix scheduling-while-atomic bug in PCM capture stream") fixed a scheduling-while-atomic bug that happened when snd_usb_endpoint_start was called from the trigger callback, which is an atmic context. However, the patch breaks the idea of the endpoints reference counting, which is the reason why the driver has been refactored lately. Revert that commit and let snd_usb_endpoint_start() take care of the URB cancellation again. As this function is called from both atomic and non-atomic context, add a flag to denote whether the function may sleep. Signed-off-by: Daniel Mack <zonque@gmail.com> Cc: stable@kernel.org [3.5+] Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/usb/pcm.c')
-rw-r--r--sound/usb/pcm.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/sound/usb/pcm.c b/sound/usb/pcm.c
index 62ec808ed792..1546577ae458 100644
--- a/sound/usb/pcm.c
+++ b/sound/usb/pcm.c
@@ -212,7 +212,7 @@ int snd_usb_init_pitch(struct snd_usb_audio *chip, int iface,
212 } 212 }
213} 213}
214 214
215static int start_endpoints(struct snd_usb_substream *subs) 215static int start_endpoints(struct snd_usb_substream *subs, int can_sleep)
216{ 216{
217 int err; 217 int err;
218 218
@@ -225,7 +225,7 @@ static int start_endpoints(struct snd_usb_substream *subs)
225 snd_printdd(KERN_DEBUG "Starting data EP @%p\n", ep); 225 snd_printdd(KERN_DEBUG "Starting data EP @%p\n", ep);
226 226
227 ep->data_subs = subs; 227 ep->data_subs = subs;
228 err = snd_usb_endpoint_start(ep); 228 err = snd_usb_endpoint_start(ep, can_sleep);
229 if (err < 0) { 229 if (err < 0) {
230 clear_bit(SUBSTREAM_FLAG_DATA_EP_STARTED, &subs->flags); 230 clear_bit(SUBSTREAM_FLAG_DATA_EP_STARTED, &subs->flags);
231 return err; 231 return err;
@@ -239,7 +239,7 @@ static int start_endpoints(struct snd_usb_substream *subs)
239 snd_printdd(KERN_DEBUG "Starting sync EP @%p\n", ep); 239 snd_printdd(KERN_DEBUG "Starting sync EP @%p\n", ep);
240 240
241 ep->sync_slave = subs->data_endpoint; 241 ep->sync_slave = subs->data_endpoint;
242 err = snd_usb_endpoint_start(ep); 242 err = snd_usb_endpoint_start(ep, can_sleep);
243 if (err < 0) { 243 if (err < 0) {
244 clear_bit(SUBSTREAM_FLAG_SYNC_EP_STARTED, &subs->flags); 244 clear_bit(SUBSTREAM_FLAG_SYNC_EP_STARTED, &subs->flags);
245 return err; 245 return err;
@@ -544,13 +544,10 @@ static int snd_usb_pcm_prepare(struct snd_pcm_substream *substream)
544 subs->last_frame_number = 0; 544 subs->last_frame_number = 0;
545 runtime->delay = 0; 545 runtime->delay = 0;
546 546
547 /* clear the pending deactivation on the target EPs */
548 deactivate_endpoints(subs);
549
550 /* for playback, submit the URBs now; otherwise, the first hwptr_done 547 /* for playback, submit the URBs now; otherwise, the first hwptr_done
551 * updates for all URBs would happen at the same time when starting */ 548 * updates for all URBs would happen at the same time when starting */
552 if (subs->direction == SNDRV_PCM_STREAM_PLAYBACK) 549 if (subs->direction == SNDRV_PCM_STREAM_PLAYBACK)
553 return start_endpoints(subs); 550 return start_endpoints(subs, 1);
554 551
555 return 0; 552 return 0;
556} 553}
@@ -1175,7 +1172,7 @@ static int snd_usb_substream_capture_trigger(struct snd_pcm_substream *substream
1175 1172
1176 switch (cmd) { 1173 switch (cmd) {
1177 case SNDRV_PCM_TRIGGER_START: 1174 case SNDRV_PCM_TRIGGER_START:
1178 err = start_endpoints(subs); 1175 err = start_endpoints(subs, 0);
1179 if (err < 0) 1176 if (err < 0)
1180 return err; 1177 return err;
1181 1178