From patchwork Sat Feb 3 02:36:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wesley Cheng X-Patchwork-Id: 196178 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:9bc1:b0:106:209c:c626 with SMTP id op1csp821393dyc; Fri, 2 Feb 2024 18:59:02 -0800 (PST) X-Google-Smtp-Source: AGHT+IEBowOCWQkRAhsH9AS0kn7ZaCegWT3WmG2tdDnYaYyUfj0fF2Uwwjv8Mgh88J9bVEIXu92U X-Received: by 2002:a17:906:3295:b0:a37:5da:46cd with SMTP id 21-20020a170906329500b00a3705da46cdmr2494035ejw.21.1706929141892; Fri, 02 Feb 2024 18:59:01 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706929141; cv=pass; d=google.com; s=arc-20160816; b=riuk10dD5DfB5D+87dXhDYwxXRzut82BBIxDinxhivFYl6kLS/AAtNqBhhM8cHCB57 zSClIv7gLnEOJn0bpqD4PseiOCjmcDhOUJJrbvFtiQWPNaym+BtriULfaGZ6Sog20EUe 7uWrJ0jKEcEwlTPPGXztBw2Ktol/GfVKHcRzS0bFHJabIuXvUcklYZUQ4DGzV6iZ+wLT WRclhandv5mgJHTdyok3fl74ty6mV4aUv7/4Xp+GI3zYshGYVQIZFQ2w53e3gy3r9KCj P82NTifHET1ibH7rKYpcM4DqmwUJqUuKNckHx52DELe4Y1owPl8bEl9C4NJmhN2x9jP6 uTVA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=wGyjbtwBQ0jltPebsxqOvKMXQoPB3aFFrhoSoalXCkM=; fh=ZX8JHxC8qOxOh8S+eFsKgr7En4HXxUZbucwrmVVBaB8=; b=Do05LrcxvZteaGBnCCkaUeyUrYrAp3knNUtEQiXKTBetnGGYS4NK4lfcRBqyS6/R3Y jvL4pzqlhpSQmL8ORLlUm0JsuK0cblgo5ZMfAxSTr46wN4ax1+yu4/bFky+IntrGcmqM tQAnE2d1fvJMa41562J8JTc7pHZjdvHriqxlf87la1hU+osDnbBT/alIPDufLIhVNp0C ZphpWagjrSKCIh8p6nde2vK4+sWsbjfMFvcmh5JTPx6YzLvqkTGqpn2S22jrNmpMJSAP N8QXeXbON18KY5tvgoizti6hNRJa1EhaSJDO9uTL58DtOLNG4f5bieRz1v9wSDGSZbvi z6Cw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=FWzg0pod; arc=pass (i=1 spf=pass spfdomain=quicinc.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-kernel+bounces-50876-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50876-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com X-Forwarded-Encrypted: i=1; AJvYcCVfHzna9VbX5BW2/dusmPypObzNoD1GTf3ID2dpB7r/ZfyuuVuDMU2vwm7QshocHF5EXgGm12d7SoZfnAtjdyI4KnHoGg== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id xo18-20020a170907bb9200b00a3173b881absi1388657ejc.636.2024.02.02.18.59.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 18:59:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-50876-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=FWzg0pod; arc=pass (i=1 spf=pass spfdomain=quicinc.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-kernel+bounces-50876-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50876-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 698D91F25816 for ; Sat, 3 Feb 2024 02:59:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 732965C91C; Sat, 3 Feb 2024 02:38:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="FWzg0pod" Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 95E4147F60; Sat, 3 Feb 2024 02:38:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706927904; cv=none; b=ZLuGBV2IBLwzl7XAFEFWPoTec0QrEOALKE4s0svAEM1Ick6eim9tOfIRsy3a+kAH/k8o584KVssXLnFAG/Ty9sJsScQJxC+tL8YpnqC5v4qHfvT7o4/RiPWdiPLIDZkhnQjQXEXdgqOBJE99f554KJW5/J7ERjhAFEpAmcH03Zs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706927904; c=relaxed/simple; bh=px268WXk+l3B9SlGv+cxMo3ljNfa2rsGXtf1IZjb19I=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=K8Uc91PWe3VkbMcy+X5pSTXX2VwD1M9mPmpp8p6MmySmGFgZTF015yeak2GZlhVE6/VuQl5f8A2OvtlaVK/Gn+kv4DmC6lBrTzHFDCA7jO1NNXl7Lw9nORF4b6i+ACOasXUA5+c8LFxUM7mSc8sU29DHI37Bs2PLNnkO6gGmJyk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=FWzg0pod; arc=none smtp.client-ip=205.220.180.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Received: from pps.filterd (m0279871.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 4132KVlp024994; Sat, 3 Feb 2024 02:38:06 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type; s=qcppdkim1; bh=wGyjbtwBQ0jltPebsxqO vKMXQoPB3aFFrhoSoalXCkM=; b=FWzg0podmnmDgQYJL7A1K/UyccMSNOMABde2 1O5jHGFzkt5pvnG8vRSW6savzj1K5ytwwwzWJRf317zK2tYDSG2rn6unegnKv5YD b7Hwp1w2MKGvq1eXkBXm5MbB8HevI0FRXBUvUs7oS6iukj8SlXOFsatHbnWo+Gzi Dm1IH89SPmPC16GinGd+sLYUrMcMkLcO9JsDfmQXBmmsyA5QzTp+IXww39eu7xHv Ck+e+bnuKf9wK/9A9ZQNucI2jCTQzj08dS+cr7jGPieIW0DDuhI4t/4Oq/rpjyy8 v1tV4fhE/pjZoB+SqP+v1cV2Pjd/udwTWMA4OQqzgu8i7W4RhA== Received: from nalasppmta05.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3w0pwjjuj7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 03 Feb 2024 02:38:06 +0000 (GMT) Received: from nalasex01b.na.qualcomm.com (nalasex01b.na.qualcomm.com [10.47.209.197]) by NALASPPMTA05.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 4132bSMQ003585 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 3 Feb 2024 02:37:28 GMT Received: from hu-wcheng-lv.qualcomm.com (10.49.16.6) by nalasex01b.na.qualcomm.com (10.47.209.197) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Fri, 2 Feb 2024 18:37:28 -0800 From: Wesley Cheng To: , , , , , , , , , , , , , , CC: , , , , , , , Wesley Cheng Subject: [PATCH v13 36/53] ALSA: usb-audio: Do not allow USB offload path if PCM device is in use Date: Fri, 2 Feb 2024 18:36:28 -0800 Message-ID: <20240203023645.31105-37-quic_wcheng@quicinc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240203023645.31105-1-quic_wcheng@quicinc.com> References: <20240203023645.31105-1-quic_wcheng@quicinc.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: nalasex01b.na.qualcomm.com (10.47.209.197) To nalasex01b.na.qualcomm.com (10.47.209.197) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: 025IcKm9yVfucWlT-OZtLTnLe8-5foLC X-Proofpoint-ORIG-GUID: 025IcKm9yVfucWlT-OZtLTnLe8-5foLC X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-02-02_16,2024-01-31_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 lowpriorityscore=0 clxscore=1015 mlxscore=0 phishscore=0 mlxlogscore=960 malwarescore=0 suspectscore=0 adultscore=0 priorityscore=1501 spamscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2401310000 definitions=main-2402030015 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789844932024313508 X-GMAIL-MSGID: 1789844932024313508 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 --- 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: