Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2733ec30 authored by Pratham Pratap's avatar Pratham Pratap Committed by Gerrit - the friendly Code Review server
Browse files

sound: usb: Clear in_use if wait_event fails while disconnect



Commit 02ec74e6 ("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: default avatarPratham Pratap <prathampratap@codeaurora.org>
parent 55100ee0
Loading
Loading
Loading
Loading
+15 −14
Original line number Original line Diff line number Diff line
@@ -894,10 +894,13 @@ static void uaudio_disconnect_cb(struct snd_usb_audio *chip)
		ret = wait_event_interruptible_timeout(dev->disconnect_wq,
		ret = wait_event_interruptible_timeout(dev->disconnect_wq,
				!atomic_read(&dev->in_use),
				!atomic_read(&dev->in_use),
				msecs_to_jiffies(DEV_RELEASE_WAIT_TIMEOUT));
				msecs_to_jiffies(DEV_RELEASE_WAIT_TIMEOUT));
		if (!ret)
		if (!ret) {
			uaudio_err("timeout while waiting for dev_release\n");
			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);
			uaudio_err("failed with ret %d\n", ret);
			atomic_set(&dev->in_use, 0);
		}


		mutex_lock(&chip->dev_lock);
		mutex_lock(&chip->dev_lock);
	}
	}
@@ -1156,8 +1159,7 @@ static void handle_uaudio_stream_req(struct qmi_handle *handle,
	mutex_unlock(&chip->dev_lock);
	mutex_unlock(&chip->dev_lock);


response:
response:
	if (!req_msg->enable && ret != -EINVAL) {
	if (!req_msg->enable && (ret != -EINVAL || ret != -ENODEV)) {
		if (ret != -ENODEV) {
		if (info_idx >= 0) {
		if (info_idx >= 0) {
			mutex_lock(&chip->dev_lock);
			mutex_lock(&chip->dev_lock);
			info = &uadev[pcm_card_num].info[info_idx];
			info = &uadev[pcm_card_num].info[info_idx];
@@ -1168,7 +1170,6 @@ static void handle_uaudio_stream_req(struct qmi_handle *handle,
					subs->interface, pcm_card_num);
					subs->interface, pcm_card_num);
			mutex_unlock(&chip->dev_lock);
			mutex_unlock(&chip->dev_lock);
		}
		}
		}
		if (atomic_read(&uadev[pcm_card_num].in_use))
		if (atomic_read(&uadev[pcm_card_num].in_use))
			kref_put(&uadev[pcm_card_num].kref,
			kref_put(&uadev[pcm_card_num].kref,
					uaudio_dev_release);
					uaudio_dev_release);