Skip to content

Commit e449397

Browse files
Kai-Heng Fenggregkh
authored andcommitted
ALSA: usb-audio: Disable USB autosuspend properly in setup_disable_autosuspend()
commit 9799110 upstream. Rear audio on Lenovo ThinkStation P620 stops working after commit 1965c43 ("ALSA: usb-audio: Disable autosuspend for Lenovo ThinkStation P620"): [ 6.013526] usbcore: registered new interface driver snd-usb-audio [ 6.023064] usb 3-6: cannot get ctl value: req = 0x81, wValue = 0x100, wIndex = 0x0, type = 1 [ 6.023083] usb 3-6: cannot get ctl value: req = 0x81, wValue = 0x202, wIndex = 0x0, type = 4 [ 6.023090] usb 3-6: cannot get ctl value: req = 0x81, wValue = 0x100, wIndex = 0x0, type = 1 [ 6.023098] usb 3-6: cannot get ctl value: req = 0x81, wValue = 0x202, wIndex = 0x0, type = 4 [ 6.023103] usb 3-6: cannot get ctl value: req = 0x81, wValue = 0x100, wIndex = 0x0, type = 1 [ 6.023110] usb 3-6: cannot get ctl value: req = 0x81, wValue = 0x202, wIndex = 0x0, type = 4 [ 6.045846] usb 3-6: cannot get ctl value: req = 0x81, wValue = 0x100, wIndex = 0x0, type = 1 [ 6.045866] usb 3-6: cannot get ctl value: req = 0x81, wValue = 0x202, wIndex = 0x0, type = 4 [ 6.045877] usb 3-6: cannot get ctl value: req = 0x81, wValue = 0x100, wIndex = 0x0, type = 1 [ 6.045886] usb 3-6: cannot get ctl value: req = 0x81, wValue = 0x202, wIndex = 0x0, type = 4 [ 6.045894] usb 3-6: cannot get ctl value: req = 0x81, wValue = 0x100, wIndex = 0x0, type = 1 [ 6.045908] usb 3-6: cannot get ctl value: req = 0x81, wValue = 0x202, wIndex = 0x0, type = 4 I overlooked the issue because when I was working on the said commit, only the front audio is tested. Apology for that. Changing supports_autosuspend in driver is too late for disabling autosuspend, because it was already used by USB probe routine, so it can break the balance on the following code that depends on supports_autosuspend. Fix it by using usb_disable_autosuspend() helper, and balance the suspend count in disconnect callback. Fixes: 1965c43 ("ALSA: usb-audio: Disable autosuspend for Lenovo ThinkStation P620") Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com> Cc: <stable@vger.kernel.org> Link: https://lore.kernel.org/r/20210304043419.287191-1-kai.heng.feng@canonical.com Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 144ebd0 commit e449397

3 files changed

Lines changed: 7 additions & 1 deletion

File tree

‎sound/usb/card.c‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -830,6 +830,8 @@ static int usb_audio_probe(struct usb_interface *intf,
830830
snd_media_device_create(chip, intf);
831831
}
832832

833+
chip->quirk_type = quirk->type;
834+
833835
usb_chip[chip->index] = chip;
834836
chip->intf[chip->num_interfaces] = intf;
835837
chip->num_interfaces++;
@@ -912,6 +914,9 @@ static void usb_audio_disconnect(struct usb_interface *intf)
912914
} else {
913915
mutex_unlock(&register_mutex);
914916
}
917+
918+
if (chip->quirk_type & QUIRK_SETUP_DISABLE_AUTOSUSPEND)
919+
usb_enable_autosuspend(interface_to_usbdev(intf));
915920
}
916921

917922
/* lock the shutdown (disconnect) task and autoresume */

‎sound/usb/quirks.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,7 @@ static int setup_disable_autosuspend(struct snd_usb_audio *chip,
523523
struct usb_driver *driver,
524524
const struct snd_usb_audio_quirk *quirk)
525525
{
526-
driver->supports_autosuspend = 0;
526+
usb_disable_autosuspend(interface_to_usbdev(iface));
527527
return 1; /* Continue with creating streams and mixer */
528528
}
529529

‎sound/usb/usbaudio.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ struct snd_usb_audio {
2727
struct snd_card *card;
2828
struct usb_interface *intf[MAX_CARD_INTERFACES];
2929
u32 usb_id;
30+
uint16_t quirk_type;
3031
struct mutex mutex;
3132
unsigned int system_suspend;
3233
atomic_t active;

0 commit comments

Comments
 (0)