Commit 4974b795 authored by Takashi Iwai's avatar Takashi Iwai

ALSA: usb-audio: Don't call usb_set_interface() at trigger callback

The PCM trigger callback is atomic, hence we must not call a function
like usb_set_interface() there.  Calling it from there would lead to a
kernel Oops.

Fix it by moving the usb_set_interface() call to set_sync_endpoint().

Also, apply the snd_usb_set_interface_quirk() for consistency, too.
Tested-by: default avatarKeith Milner <kamilner@superlative.org>
Tested-by: default avatarDylan Robinson <dylan_robinson@motu.com>
Link: https://lore.kernel.org/r/20201123085347.19667-3-tiwai@suse.deSigned-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent bc4e94aa
......@@ -232,21 +232,6 @@ static int start_endpoints(struct snd_usb_substream *subs)
!test_and_set_bit(SUBSTREAM_FLAG_SYNC_EP_STARTED, &subs->flags)) {
struct snd_usb_endpoint *ep = subs->sync_endpoint;
if (subs->data_endpoint->iface != subs->sync_endpoint->iface ||
subs->data_endpoint->altsetting != subs->sync_endpoint->altsetting) {
err = usb_set_interface(subs->dev,
subs->sync_endpoint->iface,
subs->sync_endpoint->altsetting);
if (err < 0) {
clear_bit(SUBSTREAM_FLAG_SYNC_EP_STARTED, &subs->flags);
dev_err(&subs->dev->dev,
"%d:%d: cannot set interface (%d)\n",
subs->sync_endpoint->iface,
subs->sync_endpoint->altsetting, err);
return -EIO;
}
}
dev_dbg(&subs->dev->dev, "Starting sync EP @%p\n", ep);
ep->sync_slave = subs->data_endpoint;
......@@ -530,6 +515,19 @@ static int set_sync_endpoint(struct snd_usb_substream *subs,
subs->data_endpoint->sync_master = subs->sync_endpoint;
if (subs->data_endpoint->iface != subs->sync_endpoint->iface ||
subs->data_endpoint->altsetting != subs->sync_endpoint->altsetting) {
err = usb_set_interface(subs->dev,
subs->sync_endpoint->iface,
subs->sync_endpoint->altsetting);
if (err < 0)
return err;
dev_dbg(&dev->dev, "setting usb interface %d:%d\n",
subs->sync_endpoint->iface,
subs->sync_endpoint->altsetting);
snd_usb_set_interface_quirk(dev);
}
return 0;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment