Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp2789039rdb; Mon, 12 Feb 2024 17:35:07 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUg/myVPsN2k5f6PUekexpRU5Ao1HptlLLz+4XxC3d+srH/uh7XD3Wroau5pQMVsTAQj8otFf03oBB3sL2qcHOZAzbI01HTtfxqb5qOcw== X-Google-Smtp-Source: AGHT+IHMHE40eiDwce/oOEK2vnjRBl01Khd1SUZ5f+OLOT0f8BEiq391xO/dmmEZlPWxP6jxztG7 X-Received: by 2002:a9d:7dd5:0:b0:6e2:eb55:f063 with SMTP id k21-20020a9d7dd5000000b006e2eb55f063mr3573475otn.27.1707788107047; Mon, 12 Feb 2024 17:35:07 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707788107; cv=pass; d=google.com; s=arc-20160816; b=uKz+N87QQyrCKBQ/YDwJST7QvTVTo3bKND4BlJ0bOOTFMXHvDdRNdeg5CmPpy/dzBZ c3KOccEZPzIhu+Ftae+CF0w+4ZXaly9+lD54E/r+78tsuaKmU8ZrmXGjZ7HcQQn9JHyB Aydv8w19SOVOgf3M2PZdWFooU1e0ACcq+ffgZQiTyER1Srac6cQSOpJ99pzoIEEgk6zv IngcI22bQn/QU7HZZhl63HVB279CIbCaY2AqfigXbAatCvdwOAFMSFo8hVy/VimyNeuf S+xBZyRjjyVf9y5u7IH33Gya7JGMOjVjKYNRfk+Zuvxmigwf7kWY7oMKVkB3SNs7pJsn 2stA== 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=FxDJL2eOPFZluy3YR7EZQuQ/DJKZ/AO5wP7wDQo2Os4=; b=vjaXCvToqTJZwOQT9DKz1cSACNU39fBAtk2LRJvYbkX/+dv2XkvCZlVX3PgnGldDMn 4er96+KqsSq2vf4zIh0oxgJjkrsEFuYf6kNY6ylWN7piM1yisFb4EEk7+jWT/b0F9Wt3 OI+tgyuxGeLww62gVgK38RUpxOcoAqUNFW/n1fhsfsc88X8RmLXVYFVfdMD2RtWRuaUb m7EKXqyLMpBkFbWSGmzMAx9+tBnDnPidqNfn4svAIK1+x67deddKnvvRJ565bRdMTNrY 8CQAHyiAkJSNjcQhH65lOuIM5EQguQ86ECP8PfeFqzJFjB2FYlRe6G3XEvcv/TScaGX/ TCSg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=kQFH+Wp6; 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-62786-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-62786-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com X-Forwarded-Encrypted: i=2; AJvYcCX//2ShZQoaVQtxptXblDwnBBIf9/fXiZLxfs1PQP+ClU9FmIYS9yvlu0eZHLyPRpnhRpdlld48l4NSUh+atkqtn/qQTrY5oIrnhsA2dw== Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id o22-20020a637e56000000b005c6b59c91bbsi1123375pgn.654.2024.02.12.17.35.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 17:35:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-62786-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=kQFH+Wp6; 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-62786-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-62786-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id D46A7287F5A for ; Tue, 13 Feb 2024 01:25:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F369F58212; Tue, 13 Feb 2024 00:55:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="kQFH+Wp6" 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 526AE224C2; Tue, 13 Feb 2024 00:54:56 +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=1707785698; cv=none; b=nUCHOno07c3EsrBMGynTddYKI93qALG0mb9om2EeonRV/1a5Ap5Ob7Nf5FfZ4oA9zsb3vMUrsqPSSGUkUevdvpNJRel4euOgUPlcKjcgnGrrOlhs+mVrqOddAzlM+qp98v9GXMhucz6LxYHZsw/73GLZUVb7KOr5OsNhx6yImZ0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707785698; c=relaxed/simple; bh=px268WXk+l3B9SlGv+cxMo3ljNfa2rsGXtf1IZjb19I=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ogyfgMZh1c0f5JiFLgSX8Rrk3mb0XJmtxu8jBa/ECgLZRhOLUmWmkai1ASz8FiHhsbMy1YUJBo4w3PG/SlI2XRQR0yo6x9cU3dHUoBK7awo8rQU/dxjM6F/YHgHBX2fh87vZorxlTuRbRa8j+U72mMYPB9XrFe4jf9ln1cisW8Q= 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=kQFH+Wp6; 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 (m0279873.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 41D0r8NU005428; Tue, 13 Feb 2024 00:54:43 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=kQFH+Wp6btDxu13Ls4XlW+feVzR8ls1mvWjG GFgIgk6Or0hmYUWn0m4mRIo4X40iYoeOOsUZA5jZqtxRwk2jBDGOxMiVb2pCnW7n 9hTNw3VD83C+yWtTL9zRX1go8Iww1q1bmQYU4gN08mnMkzI2oNAuFKTpI+SndE2V aISikBE8tPK5/zHviGfd03qXestegCJIeg1/tF3d+l1AFQgIdCOdkr38qOQqfWXZ mv+NMzPMw9TGx/yUCZ6yva0ceQw1XOOtzwgcWDO2PiCPBiDobaato4MKW2O4zGd2 wlsaEf0+kPo0jxRdooIB/7UOXkjX8O1a0SFV0fBZy92DMRBoYg== Received: from nalasppmta01.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3w62kt4tym-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 13 Feb 2024 00:54:43 +0000 (GMT) Received: from nalasex01b.na.qualcomm.com (nalasex01b.na.qualcomm.com [10.47.209.197]) by NALASPPMTA01.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 41D0sgWj016291 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 13 Feb 2024 00:54:42 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; Mon, 12 Feb 2024 16:54:42 -0800 From: Wesley Cheng To: , , , , , , , , , , , , , , CC: , , , , , , , Wesley Cheng Subject: [PATCH v15 34/50] ALSA: usb-audio: Do not allow USB offload path if PCM device is in use Date: Mon, 12 Feb 2024 16:54:06 -0800 Message-ID: <20240213005422.3121-35-quic_wcheng@quicinc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240213005422.3121-1-quic_wcheng@quicinc.com> References: <20240213005422.3121-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: tHFlHBEFnTWLCrkIbGP9XDBLxMqXO3rh X-Proofpoint-ORIG-GUID: tHFlHBEFnTWLCrkIbGP9XDBLxMqXO3rh 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-12_20,2024-02-12_03,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 impostorscore=0 bulkscore=0 suspectscore=0 phishscore=0 priorityscore=1501 mlxscore=0 mlxlogscore=963 spamscore=0 malwarescore=0 adultscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2401310000 definitions=main-2402130005 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: