[alsa-devel] [PATCH 2/2] ALSA: usb-audio: Fix missing autopm for MIDI input

Takashi Iwai tiwai at suse.de
Tue Dec 4 08:01:17 CET 2012


At Mon, 03 Dec 2012 21:47:48 +0100,
Clemens Ladisch wrote:
> 
> Takashi Iwai wrote:
> > The commit [88a8516a: ALSA: usbaudio: implement USB autosuspend] added
> > the support of autopm for USB MIDI output, but it didn't take the MIDI
> > input into account.
> >
> > This patch adds the following for fixing the autopm:
> > - Manage the URB start at the first MIDI input stream open, instead of
> >   the time of instance creation
> > - Move autopm code to the common substream_open()
> > - Make snd_usbmidi_input_start/_stop() more robust and add the running
> >   state check
> >
> > Cc: <stable at vger.kernel.org>
> > Signed-off-by: Takashi Iwai <tiwai at suse.de>
> > ...
> > +static int substream_open(struct snd_rawmidi_substream *substream, int dir,
> > +			  int open)
> >  {
> >  	struct snd_usb_midi* umidi = substream->rmidi->private_data;
> >  	struct snd_kcontrol *ctl;
> > +	int err;
> >
> >  	down_read(&umidi->disc_rwsem);
> >  	if (umidi->disconnected) {
> >  		up_read(&umidi->disc_rwsem);
> > +		return open ? -ENODEV : 0;
> >  	}
> >
> >  	mutex_lock(&umidi->mutex);
> >  	if (open) {
> > +		if (!umidi->opened[0] && !umidi->opened[1]) {
> > +			err = usb_autopm_get_interface(umidi->iface);
> > +			umidi->autopm_reference = err >= 0;
> > +			if (err < 0 && err != -EACCES) {
> > +				up_read(&umidi->disc_rwsem);
> > +				return -EIO;
> 
> umidi->mutex is still held here.

Right, fixed.

> Otherwise, for both patches:
> Reviewd-by: Clemens Ladisch <clemens at ladisch.de>
> Tested-by: Clemens Ladisch <clemens at ladisch.de>

OK, I merged the fixed patches and pushed out.

Thanks!


Takashi


More information about the Alsa-devel mailing list