sound: usb: Clear in_use if wait_event fails while disconnect
Commit 02ec74e631
("sound: usb: Ensure proper cleanup of uaudio_dev
under all scenarios") fixed cyclic dependency between uaudio_dev_release
and uaudio_dev_cleanup by allowing dev_cleanup to happen if wait_event
of in_use to be cleared fails. Instead, clear in_use in disconnect_cb
if wait_event fails and don't rely on dev_release to happen, to maintain
the serialization of these calls.
Change-Id: If779dffd972334e050686a1865ed8f63b8e8655d
Signed-off-by: Pratham Pratap <prathampratap@codeaurora.org>
This commit is contained in:
parent
55100ee065
commit
2733ec307c
1 changed files with 15 additions and 14 deletions
|
@ -894,10 +894,13 @@ static void uaudio_disconnect_cb(struct snd_usb_audio *chip)
|
|||
ret = wait_event_interruptible_timeout(dev->disconnect_wq,
|
||||
!atomic_read(&dev->in_use),
|
||||
msecs_to_jiffies(DEV_RELEASE_WAIT_TIMEOUT));
|
||||
if (!ret)
|
||||
if (!ret) {
|
||||
uaudio_err("timeout while waiting for dev_release\n");
|
||||
else if (ret < 0)
|
||||
atomic_set(&dev->in_use, 0);
|
||||
} else if (ret < 0) {
|
||||
uaudio_err("failed with ret %d\n", ret);
|
||||
atomic_set(&dev->in_use, 0);
|
||||
}
|
||||
|
||||
mutex_lock(&chip->dev_lock);
|
||||
}
|
||||
|
@ -1156,18 +1159,16 @@ static void handle_uaudio_stream_req(struct qmi_handle *handle,
|
|||
mutex_unlock(&chip->dev_lock);
|
||||
|
||||
response:
|
||||
if (!req_msg->enable && ret != -EINVAL) {
|
||||
if (ret != -ENODEV) {
|
||||
if (info_idx >= 0) {
|
||||
mutex_lock(&chip->dev_lock);
|
||||
info = &uadev[pcm_card_num].info[info_idx];
|
||||
uaudio_dev_intf_cleanup(
|
||||
uadev[pcm_card_num].udev,
|
||||
info);
|
||||
uaudio_dbg("release resources: intf# %d card# %d\n",
|
||||
subs->interface, pcm_card_num);
|
||||
mutex_unlock(&chip->dev_lock);
|
||||
}
|
||||
if (!req_msg->enable && (ret != -EINVAL || ret != -ENODEV)) {
|
||||
if (info_idx >= 0) {
|
||||
mutex_lock(&chip->dev_lock);
|
||||
info = &uadev[pcm_card_num].info[info_idx];
|
||||
uaudio_dev_intf_cleanup(
|
||||
uadev[pcm_card_num].udev,
|
||||
info);
|
||||
uaudio_dbg("release resources: intf# %d card# %d\n",
|
||||
subs->interface, pcm_card_num);
|
||||
mutex_unlock(&chip->dev_lock);
|
||||
}
|
||||
if (atomic_read(&uadev[pcm_card_num].in_use))
|
||||
kref_put(&uadev[pcm_card_num].kref,
|
||||
|
|
Loading…
Reference in a new issue