[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240203023645.31105-37-quic_wcheng@quicinc.com>
Date: Fri, 2 Feb 2024 18:36:28 -0800
From: Wesley Cheng <quic_wcheng@...cinc.com>
To: <srinivas.kandagatla@...aro.org>, <mathias.nyman@...el.com>,
<perex@...ex.cz>, <conor+dt@...nel.org>, <corbet@....net>,
<lgirdwood@...il.com>, <andersson@...nel.org>,
<krzysztof.kozlowski+dt@...aro.org>, <gregkh@...uxfoundation.org>,
<Thinh.Nguyen@...opsys.com>, <broonie@...nel.org>,
<bgoswami@...cinc.com>, <tiwai@...e.com>, <robh+dt@...nel.org>,
<konrad.dybcio@...aro.org>
CC: <linux-kernel@...r.kernel.org>, <devicetree@...r.kernel.org>,
<linux-sound@...r.kernel.org>, <linux-usb@...r.kernel.org>,
<linux-arm-msm@...r.kernel.org>, <linux-doc@...r.kernel.org>,
<alsa-devel@...a-project.org>, Wesley Cheng <quic_wcheng@...cinc.com>
Subject: [PATCH v13 36/53] ALSA: usb-audio: Do not allow USB offload path if PCM device is in use
Add proper checks and updates to the USB substream once receiving a USB QMI
stream enable request. If the substream is already in use from the non
offload path, reject the stream enable request. In addition, update the
USB substream opened parameter when enabling the offload path, so the
non offload path can be blocked.
Signed-off-by: Wesley Cheng <quic_wcheng@...cinc.com>
---
sound/usb/qcom/qc_audio_offload.c | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/sound/usb/qcom/qc_audio_offload.c b/sound/usb/qcom/qc_audio_offload.c
index af67d219fbec..31c0cf5916a0 100644
--- a/sound/usb/qcom/qc_audio_offload.c
+++ b/sound/usb/qcom/qc_audio_offload.c
@@ -1448,12 +1448,17 @@ static void handle_uaudio_stream_req(struct qmi_handle *handle,
goto response;
}
+ mutex_lock(&chip->mutex);
if (req_msg->enable) {
- if (info_idx < 0 || chip->system_suspend) {
+ if (info_idx < 0 || chip->system_suspend || subs->opened) {
ret = -EBUSY;
+ mutex_unlock(&chip->mutex);
+
goto response;
}
+ subs->opened = 1;
}
+ mutex_unlock(&chip->mutex);
if (req_msg->service_interval_valid) {
ret = get_data_interval_from_si(subs,
@@ -1475,6 +1480,11 @@ static void handle_uaudio_stream_req(struct qmi_handle *handle,
if (!ret)
ret = prepare_qmi_response(subs, req_msg, &resp,
info_idx);
+ if (ret < 0) {
+ mutex_lock(&chip->mutex);
+ subs->opened = 0;
+ mutex_unlock(&chip->mutex);
+ }
} else {
info = &uadev[pcm_card_num].info[info_idx];
if (info->data_ep_pipe) {
@@ -1498,6 +1508,9 @@ static void handle_uaudio_stream_req(struct qmi_handle *handle,
}
disable_audio_stream(subs);
+ mutex_lock(&chip->mutex);
+ subs->opened = 0;
+ mutex_unlock(&chip->mutex);
}
response:
Powered by blists - more mailing lists