Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp1214405rdb; Fri, 2 Feb 2024 19:09:46 -0800 (PST) X-Google-Smtp-Source: AGHT+IHM0yzs0Sg09P0xLJtrPi4aKp3xrGaIZcm3BJX/jNzO2Ikw5axRW5f1gMACxFle/AGdknZJ X-Received: by 2002:a17:903:25cb:b0:1d9:19a3:96f0 with SMTP id jc11-20020a17090325cb00b001d919a396f0mr6473101plb.57.1706929786182; Fri, 02 Feb 2024 19:09:46 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706929786; cv=pass; d=google.com; s=arc-20160816; b=pf1sGbWo9FiNAD4j63NbpSFUpvjGqUPP57BTJDO2I6TQdVB6ajTQaQRJ6t/VyrJqXA YsUGxL0mScllVWmqrE1h+jpYX9ioi/tI2gaM0zRamvx+kSfr0BBMjPjasGDPkx+7WyuW 5EtzwMRv0I6/Kss/ZlLuMbnerbWeg08i2yMZtK5eay3tWqT4jQhu6zvbbiqJ9u9pDUIL uYiDff1RlKBD9AfH4x0Sh6lL2RHJBCCpbuo9vATeuBH1RwTheKQ2VSGQj0pwiYz0ZC1s GsiMX5oLkKT9192J9H4KSkESHn/7AtuKsazhIIy1C5VZO9kJN+ZOJ5VKVaA+tFrob8m0 nECg== 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=SVSMgdAjjTowpxTVrKD26/Q+ClW5lUx/agkX1kG3sgo=; b=nj9gDfIk9EF+OvMtYW5LMDoz6utw9TlGs+D3504BdaPBUKO539hcRudyHaPGdqXaFD iltq51OTxGLVo3BYPNbHHBkr/NeGJVnwKIeCzuVp88zoMbLyndMN6z5b+0rRb+4BG6n/ 8uM78HJTH5cqJrgfb+B3lad2+E/uMedLO6FsZizEn/fgtDKHrFXEFWibAUfjmMFyj2PY iq6g/7OpyVj3qY0xlqsvLvaAeYrzL0Y4tERJEzrUEBkuhWJWsf4U7TF4qr2GcfV3N5ez ccigmJzXeoPm15yUGnVfE2/eBLCZN57w1h5kGKnZNoj4d+gv9f9mvFdyFklyvhAsX7m+ loIQ==; 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-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50876-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com X-Forwarded-Encrypted: i=1; AJvYcCXOzGax0zjUXmXC/N1QZIfVn3tVnVk0bOTBAezoFE6ZQXhns5rwNRu90GkkFJG0SA5VP/lcKMQl5aOGvNSCz2x/jwGZl5oEKZdUKeD0yQ== Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id c8-20020a170902d48800b001d8d05a5bbdsi2687113plg.272.2024.02.02.19.09.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 19:09:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-50876-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; 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-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50876-linux.lists.archive=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 sy.mirrors.kernel.org (Postfix) with ESMTPS id C5617B23082 for ; Sat, 3 Feb 2024 02:58:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 45A215C5F9; Sat, 3 Feb 2024 02:38:25 +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 Content-Type: text/plain 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 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: