From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.21]) (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 F114B18E059; Thu, 1 Aug 2024 09:12:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.21 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722503531; cv=none; b=Rxed/kcDTGmfX7/ZA5znKYivDKrJtwVfCRJXmXo70gyOrq1/nCVIKuNMkgT+VA3hoJx4Yr2EAQ0TBC9wQIX/ILH8XZVmh0EAs2ovTUvuwdmbt+sRERMU6xN+menzEjRCq9mxw7a9sDl5BrF81LvK2zh/Oh57uhqLzRbj6qPTE8A= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722503531; c=relaxed/simple; bh=N/O38cSPMC8Lgjj4zxdXeCxlRhlPgDYWQiNhJMimuAc=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=mzz2JEw9/3bWnoKEeqTHsiIihVQfS4FmFeI1710tFXpUsuLnYlRFQI/FeL/8GOcQy4riaxe08Dd4La8lxZfC66aAiNYdHN5lbtrL1Xjre4DkfpU1Cmk8lGaN9y2LXKYORkntTbGhKXXfx4V9PbHcgyIURaoCGHxTrS52Vz3wVs0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=BK0PFaeo; arc=none smtp.client-ip=198.175.65.21 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="BK0PFaeo" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1722503531; x=1754039531; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=N/O38cSPMC8Lgjj4zxdXeCxlRhlPgDYWQiNhJMimuAc=; b=BK0PFaeonQpHCaM6/LzNLXHCKkmK2uJtFCXingfO+sIfrJIYn6rTbhoF WXty/rFrOlIc6s83s3Lh9twPse/pCV5nL395Fawz2PNOEfUi+FA2YUz/W qh+i4WCimEY/lx/+7aH9qjH70+y98XCppcc7HW6mBT9RbIwWBf+PIFF6B wyf+aqq8WYyPOVSbHiYWZcasEJ0Jd0VzE51ZMz5NZ8LFgjdg14wcAEPuY Mee9yve9uRPg9LRXgbwek5ke2wLJvjeIrVWTWX2K1wb8jHfJERZbwvxqS un0yk3BT5CnmhScJSabbTeS4NbsHTru6anAldYOASqpL+XVn6Xu7VB0ij Q==; X-CSE-ConnectionGUID: V+DRZ2BuSg2hlYR8H8XEMw== X-CSE-MsgGUID: 7enpbqYbShKyeo9z0AI83A== X-IronPort-AV: E=McAfee;i="6700,10204,11150"; a="20383656" X-IronPort-AV: E=Sophos;i="6.09,254,1716274800"; d="scan'208";a="20383656" Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by orvoesa113.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Aug 2024 02:12:10 -0700 X-CSE-ConnectionGUID: ppEKMHUATh6ElntSYpl8FQ== X-CSE-MsgGUID: 3Lh38z4lTkG8C3M6/pNUTQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.09,254,1716274800"; d="scan'208";a="59090171" Received: from lfiedoro-mobl.ger.corp.intel.com (HELO [10.245.246.220]) ([10.245.246.220]) by fmviesa003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Aug 2024 02:12:04 -0700 Message-ID: Date: Thu, 1 Aug 2024 10:57:28 +0200 Precedence: bulk X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v24 26/34] ALSA: usb-audio: qcom: Don't allow USB offload path if PCM device is in use To: Wesley Cheng , srinivas.kandagatla@linaro.org, mathias.nyman@intel.com, perex@perex.cz, conor+dt@kernel.org, corbet@lwn.net, broonie@kernel.org, lgirdwood@gmail.com, krzk+dt@kernel.org, Thinh.Nguyen@synopsys.com, bgoswami@quicinc.com, tiwai@suse.com, gregkh@linuxfoundation.org, robh@kernel.org Cc: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-sound@vger.kernel.org, linux-usb@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-doc@vger.kernel.org, alsa-devel@alsa-project.org References: <20240801011730.4797-1-quic_wcheng@quicinc.com> <20240801011730.4797-27-quic_wcheng@quicinc.com> Content-Language: en-US From: Pierre-Louis Bossart In-Reply-To: <20240801011730.4797-27-quic_wcheng@quicinc.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 8/1/24 03:17, Wesley Cheng wrote: > 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. It's a bit weird that the mutual exclusion between the standard path and the offloaded path is handled at the vendor level. I would think this needs to be handled in the soc_usb framework, no? > 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 8b0913b7256b..3b46d05f1421 100644 > --- a/sound/usb/qcom/qc_audio_offload.c > +++ b/sound/usb/qcom/qc_audio_offload.c > @@ -1460,12 +1460,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, > @@ -1487,6 +1492,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) { > @@ -1510,6 +1520,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: