From patchwork Tue Feb 13 00:54:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wesley Cheng X-Patchwork-Id: 200146 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:bc8a:b0:106:860b:bbdd with SMTP id dn10csp271340dyb; Mon, 12 Feb 2024 17:36:24 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVi5xE/G7dPDW0ey8PxfQCchzSkrsv4FVkzT9SkvmJmt6B9AisLhQ4u47PGTY+Ml/JO2cp537TsdKbQHozFPscdfrf3BA== X-Google-Smtp-Source: AGHT+IELk4NKmqqSeIEqw1Gxojvdm+9aP6FA37tngGHnG6NVRQVtZDRJDQlVZNINNuFZ8HjVGzrF X-Received: by 2002:a05:651c:617:b0:2d0:a90b:e4e3 with SMTP id k23-20020a05651c061700b002d0a90be4e3mr4381905lje.27.1707788184369; Mon, 12 Feb 2024 17:36:24 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707788184; cv=pass; d=google.com; s=arc-20160816; b=c+7VqtRSl0JTSwK6Kv8cJbFdlmFyhKvL6ljMj/iybGQUkhnqRbeapuaGByQh22Esy5 eAeWvtCQZ0ipZvY2YoPmdjOxuMauWZAGi0Wxnqf/y15iU13WGmUV4Kooq5VBcfPhbbnj ta5/wf8Lx2KSnv9hnW4NTRLBLUkZvBi/noWXAl2OCi46YoBbukE9zmAMnGXeE+l9JSuO TvrCkbqa7h0+tqkNFDZkELmQXjEXeVdwzXZ3f14E5KkGj6GYbyDwuOk+3AlJ2TQBqMBV 0VbWJTPJjc+PGx5h2yn/WBWw2TDZbOP5KoXK9iOl69tgTZxgoC38thlLYwUqYAhHgEyo iTQQ== 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=fOSr/U9yIdaf5DyuAwbcWomNGQ2Z4nIimXJUR8A0ndI=; b=fjG1ukVKI2amhGvdLdT8eqMJGU3fkk+xRwFvpl4dB2nRtvdUz68rwCcUq/bGvIY1Dl us7+1PYLKBNldDznhgjDdWQ/NlwwzLeExKLKJIwNmJatcoORiNpQZRz3+vMr7dAG8aTR 4y6hqWUYboDUtW4vmKlw089MVPTy6c6kHKfItSxQ5vB8ob2Puk3CjSHpIDIKsVENd0dT +otnmoCSiUaMJMUmgcwTnjRF7MD/00XtOMrq40kJTagiMybB0i4ZQSIiHX/1wXR/TxT+ VsQMkGcRcpCbos4Alp4G7GnKpMgtJnWwSrtHvpanerY298LJqr7tFbB9vfL1WxgWodBa /gwQ==; 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-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-62786-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com X-Forwarded-Encrypted: i=2; AJvYcCU1BRnqFwRH4iGtmQmC+3yBt7PbINCPABQ+WeUSBBCbKXFhhYLrk9Z42Op8u0TIpJRfNr1V7i4oG9Nz2wOFVBvDvPtY4g== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id qu13-20020a170907110d00b00a3c04bf62f7si751820ejb.479.2024.02.12.17.36.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 17:36:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-62786-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=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-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-62786-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 BB6641F28C3C for ; Tue, 13 Feb 2024 01:27:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4AA605EE71; Tue, 13 Feb 2024 00:55:11 +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 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790745703113254308 X-GMAIL-MSGID: 1790745703113254308 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: