From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.12]) (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 F25201B5ED3; Fri, 30 Aug 2024 10:13:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.12 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725012800; cv=none; b=qVOmjnTsxTMszfWvUyw6iadqUs2FvxWlgsa9pU5ekpbrHaoc3rFZd1tMOzV4m4iVwA6aXxhvmrRytxnS6U8B9DTLvPe89WYB2TxVWlwkmTzanxYhgF/40uOEfjimrTUi7WUsu4blpCGtSyhw63lKJe5+TFYKhZFBWPj8+368Rj0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725012800; c=relaxed/simple; bh=f6NQO+vGDvZOOd+xdAa0FYDOljjy4EtgGvlJs3wbZoI=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=qLeLbLtySUm0NOdIESiB4t/Fi77ammK/Nl/5hnGt4egSmYGIlKxGNcl3aGWsy5JzFmUQ8sHSlCcw7m+rQ6p/nmRpeJcTxneny1brKFPNgPmqUrdB6O0x9STab0BLXZ/nN32MQ4EbrXfcn6iHqa6b+mY4yXxkVhq1diJzxOGWXjs= 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=GHPeVKmz; arc=none smtp.client-ip=192.198.163.12 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="GHPeVKmz" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1725012800; x=1756548800; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=f6NQO+vGDvZOOd+xdAa0FYDOljjy4EtgGvlJs3wbZoI=; b=GHPeVKmzPJHKGcCAGl6L6RFeSk7l3Oyc+qKCBl9mMPY5RrechVJ6w6om 22fZp6dZEtIo6Jis3o4+gbn/6zZkml+k2HSkzgvJAdGRnq4eluJAyibN6 AS+uThk4tWiekHoIX976WwVXMX4bQol+GqwO3RbSXZaX6ZNqvjCwS3F0w 1F8iN0tednUwbLoAWhqslWL+vJOnUHSqwFUj02nxI8IuVHRs6ISgdihCi P1hrDkEg/7tZ+XYbx96tPsJju5bE+kEV6uy9r/OwxdPkdZ6OXk+4WgBNf lhZJr8gPkM9vGLY0LEUYcAFWt25m1QmlSUpIhg1Ou8qBOI329iPaoALtc g==; X-CSE-ConnectionGUID: oBPkdogqQN+lLQ3sbKX1bg== X-CSE-MsgGUID: pB/mpVPPR32Kxtav967z4g== X-IronPort-AV: E=McAfee;i="6700,10204,11179"; a="27526409" X-IronPort-AV: E=Sophos;i="6.10,188,1719903600"; d="scan'208";a="27526409" Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by fmvoesa106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Aug 2024 03:13:19 -0700 X-CSE-ConnectionGUID: FhkwSjYXThu8ZobS5lYOrg== X-CSE-MsgGUID: neR0RV08SLqplh/Oz7RLpw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.10,188,1719903600"; d="scan'208";a="68013144" Received: from ltuz-desk.ger.corp.intel.com (HELO [10.245.246.101]) ([10.245.246.101]) by fmviesa003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Aug 2024 03:13:13 -0700 Message-ID: <6e4e6e5f-dc55-4311-a658-5e2fcbeefab1@linux.intel.com> Date: Fri, 30 Aug 2024 11:55:20 +0200 Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v26 29/33] 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, dmitry.torokhov@gmail.com, corbet@lwn.net, broonie@kernel.org, lgirdwood@gmail.com, tiwai@suse.com, krzk+dt@kernel.org, Thinh.Nguyen@synopsys.com, bgoswami@quicinc.com, robh@kernel.org, gregkh@linuxfoundation.org Cc: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-sound@vger.kernel.org, linux-input@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: <20240829194105.1504814-1-quic_wcheng@quicinc.com> <20240829194105.1504814-30-quic_wcheng@quicinc.com> Content-Language: en-US From: Pierre-Louis Bossart In-Reply-To: <20240829194105.1504814-30-quic_wcheng@quicinc.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 8/29/24 21:41, 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. > > 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 e9f2fd6bbb41..0bd533f539e4 100644 > --- a/sound/usb/qcom/qc_audio_offload.c > +++ b/sound/usb/qcom/qc_audio_offload.c > @@ -1482,12 +1482,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, > @@ -1509,6 +1514,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) { > @@ -1532,6 +1542,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); > } > This sounds ok but I wonder why all this needs to be done in Qualcomm-specific layers instead of soc-usb?