Skip to content

Commit

Permalink
ALSA: usb-audio: Fix scheduling-while-atomic bug in PCM capture stream
Browse files Browse the repository at this point in the history
A PCM capture stream on usb-audio causes a scheduling-while-atomic
BUG, as reported in the bugzilla entry below.  It's because
snd_usb_endpoint_start() is called at first at trigger START for a
capture stream, and this function contains the left-over EP
deactivation codes.  The problem doesn't happen for a playback stream
because the function is called at PCM prepare time, which can sleep.

This patch fixes the BUG by moving the EP deactivation code into the
PCM prepare callback.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=46011
Cc: <stable@vger.kernel.org> [v3.5+]
Signed-off-by: Takashi Iwai <tiwai@suse.de>
  • Loading branch information
Takashi Iwai committed Aug 16, 2012
1 parent 3bdcff7 commit e9ba389
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
4 changes: 0 additions & 4 deletions sound/usb/endpoint.c
Original file line number Diff line number Diff line change
Expand Up @@ -821,10 +821,6 @@ int snd_usb_endpoint_start(struct snd_usb_endpoint *ep)
if (++ep->use_count != 1)
return 0;

/* just to be sure */
deactivate_urbs(ep, 0, 1);
wait_clear_urbs(ep);

ep->active_mask = 0;
ep->unlink_mask = 0;
ep->phase = 0;
Expand Down
3 changes: 3 additions & 0 deletions sound/usb/pcm.c
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,9 @@ static int snd_usb_pcm_prepare(struct snd_pcm_substream *substream)
subs->last_frame_number = 0;
runtime->delay = 0;

/* clear the pending deactivation on the target EPs */
deactivate_endpoints(subs);

/* for playback, submit the URBs now; otherwise, the first hwptr_done
* updates for all URBs would happen at the same time when starting */
if (subs->direction == SNDRV_PCM_STREAM_PLAYBACK)
Expand Down

0 comments on commit e9ba389

Please sign in to comment.