From nobody Sun Feb 8 21:21:21 2026 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.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 CF1092FF66A for ; Tue, 21 Oct 2025 10:40:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761043218; cv=none; b=Uv8+Yd4Nhoeuf9v2Yk6IOOJB5oRUt/1uZvDCSE1F+WcpnqV4ndq5EDrtWQ93vXQW62Nb+YBjR3BiQ5bNnrUo9JOcugBobp1iGcHCqP251nzgiyHx3D8tU+MJCkzZkYw2EA4G8fhDNYoDJYOcWt18R5VIwqUeB/F7FBEKi3aWkNQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761043218; c=relaxed/simple; bh=FGgM/h/Nl0fe1KfWFbs1h0vZjvAmT5bJ7lsP2RH/hsw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=A/ly+Nzi5aG6HS79Iqs0OTPZCqgV6tZQxyYe1633tWDAMQZii1yKLOP56jJBffyvfmaVFtpfYb9By+2AIUod0xkUC+WIeCTEFizD0B3g38l3YoTaJMPwtk5RlSv2OCodl9pkMKaIjlnsolkQThI+owR83iaxNAXrjfQQ76bqZ9A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=KnjZ4JXU; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="KnjZ4JXU" Received: from pps.filterd (m0279867.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 59L8MSsX029400 for ; Tue, 21 Oct 2025 10:40:15 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=qcppdkim1; bh=+9Ah8tbJTOj w8bPwKE9oPJwMMDi4lE0dwETBQg6knh0=; b=KnjZ4JXUakFrDnVTcpINKjN+TMW 0R5dIbfA612/g6BKZ5L7Ze4/iWJ8qFGpNBkHZyX1VjwrOi+NWJaJo0IIctxEES4l fyEKpawcxm9X6Q82lOyIraJIF4AKuWuUqfzalRUszAvVk05Xsj6GSXF5kYbUqxF9 ud4ro2x9wk8DoJB2wURXQU9/rkCa8T1kNACP6E+kGoimAI1yw/4NxDb58QLONijs dgLic2cGJW2CRDuT0+pgFub17ajR/m4N9gl9EmZje1eOsKMwk2M8LIbNUeAOoqo6 atWm8yUT+aqtIwMdWhTRlYVwY7eGy7TMxcEYzlAi6l/Xj41TqsOPx8AOMbw== Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 49wswntrgq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Tue, 21 Oct 2025 10:40:15 +0000 (GMT) Received: by mail-qv1-f69.google.com with SMTP id 6a1803df08f44-818bf399f8aso265235346d6.2 for ; Tue, 21 Oct 2025 03:40:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761043208; x=1761648008; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+9Ah8tbJTOjw8bPwKE9oPJwMMDi4lE0dwETBQg6knh0=; b=o/g8JM6UyldSq4unX1qtY8w/8KNX9wywQ0DeqDqzdv5LMTq/YI8vImJhuayqF8FLri SOWwYr7q/qLoPQqJSw3r/EuSgbUI/TeRyNqJjEIbrxflFxNJB8kZMwTLIJno1FsjXLA6 yZuYmgwxKUOzN3VNA6k7SD5XQ7K46DrCDbnHDClZV851IzVT/nnv2eavxsqdPTCEbpEG AX2eNPFemXNlTlKHycxUtFAUPtLJOdjAnwHCIDSn7a1ZKNxmnmubKDAwTKYuQSIMRTVh o8fczdec354ATGXjGBPO0OD/TNB246QDghg8NOsfnK+WAEqU/liIBX6vf9orziScVSEo QNSA== X-Forwarded-Encrypted: i=1; AJvYcCULH6lpqVX4Fg1NhO7xrNR12MOwgmgeIZiPO/9GdLYEe7O4kbnNi5jiwmz/5yrRqv5K/gvoozrNzYwqwUw=@vger.kernel.org X-Gm-Message-State: AOJu0Yx8gKEqYD+BN6zibR2iFdMS42fbkK2BKeDOkIS/5cL7WwTdXXGU 7VDZCZPyb/k9aFeH56AaDUaNHydeWrV4K4lPRCSPY9MIAHb9P2XOJpVO8RQbmfovtYvcwuxf2QG vBAsfoyw5cmDsGC3lZ2Yof+XGWeEjg3FLUFDABw3xnjJtOXeQv16dno8/3iERkuVBRWk= X-Gm-Gg: ASbGncvm3H244zu6B7nr5stPIKRRkx8ltQwzXYwKrVjuV7NeL14RU71n4z3I8DeDv4C 55CiQ+SiwMB/FKvqniS3luQsiezHP5Fi2ie4q+ZLCJFUJ4U8TyDtggR6inff+zzVEX5YERL8Tx6 6ku11YuUO1CjoBFUhQNwZTHssLPvyAFpwu+JGbarmu3tibPK5ScDeXSVAnuSm+1Y8x+FuI3gDz9 PrOwwslxRpX1oz9B9vQq6ci5wA5siHto5wl3o+fcEpRrym1Ja9bYlpqXgJzfSnfd8gy3IHc86Ro 4nxTZFgAvTTZ/DBogpvx5atUaLCA2rBPHS+CxIdwseMbydtnlhyZd3+N/xE49yoJBiTjcyhSdAs +YKIH6Fg2AVxe X-Received: by 2002:a05:622a:1a24:b0:4da:155a:76fc with SMTP id d75a77b69052e-4e89d21be0dmr229753741cf.16.1761043208121; Tue, 21 Oct 2025 03:40:08 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHazcELOTt+E+T3i2/ToyI5wizEDJzBBjmFtFWnpeZf3zGb9GIyKGPsj4eFnXMx5scrjcgWKw== X-Received: by 2002:a05:622a:1a24:b0:4da:155a:76fc with SMTP id d75a77b69052e-4e89d21be0dmr229753511cf.16.1761043207558; Tue, 21 Oct 2025 03:40:07 -0700 (PDT) Received: from debian ([5.133.47.210]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-427f009a976sm20087938f8f.32.2025.10.21.03.40.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Oct 2025 03:40:06 -0700 (PDT) From: Srinivas Kandagatla To: broonie@kernel.org Cc: perex@perex.cz, tiwai@suse.com, srini@kernel.org, alexey.klimov@linaro.org, linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Srinivas Kandagatla , Krzysztof Kozlowski , Stable@vger.kernel.org Subject: [PATCH v2 1/4] ASoC: qcom: sdw: fix memory leak for sdw_stream_runtime Date: Tue, 21 Oct 2025 11:39:59 +0100 Message-ID: <20251021104002.249745-2-srinivas.kandagatla@oss.qualcomm.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251021104002.249745-1-srinivas.kandagatla@oss.qualcomm.com> References: <20251021104002.249745-1-srinivas.kandagatla@oss.qualcomm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-GUID: Xns5yIYP05ELmEuheIZ6RMNb7YqrNprr X-Authority-Analysis: v=2.4 cv=Maxhep/f c=1 sm=1 tr=0 ts=68f7630f cx=c_pps a=wEM5vcRIz55oU/E2lInRtA==:117 a=ZsC4DHZuhs/kKio7QBcDoQ==:17 a=x6icFKpwvdMA:10 a=VkNPw1HP01LnGYTKEx00:22 a=KKAkSRfTAAAA:8 a=VwQbUJbxAAAA:8 a=EUspDBNiAAAA:8 a=N47DpUgmF8P8R7KZyx8A:9 a=OIgjcC2v60KrkQgK7BGD:22 a=cvBusfyB2V15izCimMoJ:22 X-Proofpoint-ORIG-GUID: Xns5yIYP05ELmEuheIZ6RMNb7YqrNprr X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMDIwMDE0OCBTYWx0ZWRfX+VQW6+jXgg99 gn2TvOnOsPg33YnO6ksfiErD9BlIW9QZw6tcpOYMu+d6tA/GWNSq4yB1klfoaZXfAF9jJfzfWYy /2gXe4uN349Lc8p2dDFnaVOyyA8thlftbav8/AlM8si5/Po4Y/VHu61hjP0qnnRi2CzJTcvPPt3 ttmpQcp1Z84XlYcHe4g7XQnQxJFb+k0by5HeDEGR1HZUlVr3sY83OGLCMtXHKTu/1ZbboS4PL06 zujHDhYTfYwF/ZwR7N7GwxTIrAVX4NpI6980TqNi8E+ReWOXomqqnOVs1rluJyum1lbWgHRlM42 WpEMqRlPPvGyTsA4IMH3ZH7n3xkk0JdQ9blAMrwWByNBErtXIasOpFJAHAq8U0e1QyY9O+6prwd Qxdj78OOgIFXEwloSeOieJS2zdTC5g== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.80.40 definitions=2025-10-21_01,2025-10-13_01,2025-03-28_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 adultscore=0 priorityscore=1501 lowpriorityscore=0 phishscore=0 suspectscore=0 impostorscore=0 clxscore=1015 malwarescore=0 bulkscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2510020000 definitions=main-2510200148 Content-Type: text/plain; charset="utf-8" For some reason we endedup allocating sdw_stream_runtime for every cpu dai, this has two issues. 1. we never set snd_soc_dai_set_stream for non soundwire dai, which means there is no way that we can free this, resulting in memory leak 2. startup and shutdown callbacks can be called without hw_params callback called. This combination results in memory leak because machine driver sruntime array pointer is only set in hw_params callback. Fix this by 1. adding a helper function to get sdw_runtime for substream which can be used by shutdown callback to get hold of sruntime to free. 2. only allocate sdw_runtime for soundwire dais. Fixes: d32bac9cb09c ("ASoC: qcom: Add helper for allocating Soundwire strea= m runtime") Cc: Krzysztof Kozlowski Cc: Signed-off-by: Srinivas Kandagatla Tested-by: Steev Klimaszewski # Thinkpad X13s --- sound/soc/qcom/sc7280.c | 2 +- sound/soc/qcom/sc8280xp.c | 2 +- sound/soc/qcom/sdw.c | 105 +++++++++++++++++++++----------------- sound/soc/qcom/sdw.h | 1 + sound/soc/qcom/sm8250.c | 2 +- sound/soc/qcom/x1e80100.c | 2 +- 6 files changed, 64 insertions(+), 50 deletions(-) diff --git a/sound/soc/qcom/sc7280.c b/sound/soc/qcom/sc7280.c index af412bd0c89f..c444dae563c7 100644 --- a/sound/soc/qcom/sc7280.c +++ b/sound/soc/qcom/sc7280.c @@ -317,7 +317,7 @@ static void sc7280_snd_shutdown(struct snd_pcm_substrea= m *substream) struct snd_soc_card *card =3D rtd->card; struct sc7280_snd_data *data =3D snd_soc_card_get_drvdata(card); struct snd_soc_dai *cpu_dai =3D snd_soc_rtd_to_cpu(rtd, 0); - struct sdw_stream_runtime *sruntime =3D data->sruntime[cpu_dai->id]; + struct sdw_stream_runtime *sruntime =3D qcom_snd_sdw_get_stream(substream= ); =20 switch (cpu_dai->id) { case MI2S_PRIMARY: diff --git a/sound/soc/qcom/sc8280xp.c b/sound/soc/qcom/sc8280xp.c index 78e327bc2f07..9ba536dff667 100644 --- a/sound/soc/qcom/sc8280xp.c +++ b/sound/soc/qcom/sc8280xp.c @@ -73,7 +73,7 @@ static void sc8280xp_snd_shutdown(struct snd_pcm_substrea= m *substream) struct snd_soc_pcm_runtime *rtd =3D snd_soc_substream_to_rtd(substream); struct snd_soc_dai *cpu_dai =3D snd_soc_rtd_to_cpu(rtd, 0); struct sc8280xp_snd_data *pdata =3D snd_soc_card_get_drvdata(rtd->card); - struct sdw_stream_runtime *sruntime =3D pdata->sruntime[cpu_dai->id]; + struct sdw_stream_runtime *sruntime =3D qcom_snd_sdw_get_stream(substream= ); =20 pdata->sruntime[cpu_dai->id] =3D NULL; sdw_release_stream(sruntime); diff --git a/sound/soc/qcom/sdw.c b/sound/soc/qcom/sdw.c index 7d7981d4295b..7b2cae92c812 100644 --- a/sound/soc/qcom/sdw.c +++ b/sound/soc/qcom/sdw.c @@ -7,6 +7,37 @@ #include #include "sdw.h" =20 +static bool qcom_snd_is_sdw_dai(int id) +{ + switch (id) { + case WSA_CODEC_DMA_RX_0: + case WSA_CODEC_DMA_TX_0: + case WSA_CODEC_DMA_RX_1: + case WSA_CODEC_DMA_TX_1: + case WSA_CODEC_DMA_TX_2: + case RX_CODEC_DMA_RX_0: + case TX_CODEC_DMA_TX_0: + case RX_CODEC_DMA_RX_1: + case TX_CODEC_DMA_TX_1: + case RX_CODEC_DMA_RX_2: + case TX_CODEC_DMA_TX_2: + case RX_CODEC_DMA_RX_3: + case TX_CODEC_DMA_TX_3: + case RX_CODEC_DMA_RX_4: + case TX_CODEC_DMA_TX_4: + case RX_CODEC_DMA_RX_5: + case TX_CODEC_DMA_TX_5: + case RX_CODEC_DMA_RX_6: + case RX_CODEC_DMA_RX_7: + case SLIMBUS_0_RX...SLIMBUS_6_TX: + return true; + default: + break; + } + + return false; +} + /** * qcom_snd_sdw_startup() - Helper to start Soundwire stream for SoC audio= card * @substream: The PCM substream from audio, as passed to snd_soc_ops->sta= rtup() @@ -29,6 +60,9 @@ int qcom_snd_sdw_startup(struct snd_pcm_substream *substr= eam) u32 rx_ch_cnt =3D 0, tx_ch_cnt =3D 0; int ret, i, j; =20 + if (!qcom_snd_is_sdw_dai(cpu_dai->id)) + return 0; + sruntime =3D sdw_alloc_stream(cpu_dai->name, SDW_STREAM_PCM); if (!sruntime) return -ENOMEM; @@ -89,19 +123,8 @@ int qcom_snd_sdw_prepare(struct snd_pcm_substream *subs= tream, if (!sruntime) return 0; =20 - switch (cpu_dai->id) { - case WSA_CODEC_DMA_RX_0: - case WSA_CODEC_DMA_RX_1: - case RX_CODEC_DMA_RX_0: - case RX_CODEC_DMA_RX_1: - case TX_CODEC_DMA_TX_0: - case TX_CODEC_DMA_TX_1: - case TX_CODEC_DMA_TX_2: - case TX_CODEC_DMA_TX_3: - break; - default: + if (!qcom_snd_is_sdw_dai(cpu_dai->id)) return 0; - } =20 if (*stream_prepared) return 0; @@ -129,9 +152,7 @@ int qcom_snd_sdw_prepare(struct snd_pcm_substream *subs= tream, } EXPORT_SYMBOL_GPL(qcom_snd_sdw_prepare); =20 -int qcom_snd_sdw_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *params, - struct sdw_stream_runtime **psruntime) +struct sdw_stream_runtime *qcom_snd_sdw_get_stream(struct snd_pcm_substrea= m *substream) { struct snd_soc_pcm_runtime *rtd =3D snd_soc_substream_to_rtd(substream); struct snd_soc_dai *codec_dai; @@ -139,21 +160,23 @@ int qcom_snd_sdw_hw_params(struct snd_pcm_substream *= substream, struct sdw_stream_runtime *sruntime; int i; =20 - switch (cpu_dai->id) { - case WSA_CODEC_DMA_RX_0: - case RX_CODEC_DMA_RX_0: - case RX_CODEC_DMA_RX_1: - case TX_CODEC_DMA_TX_0: - case TX_CODEC_DMA_TX_1: - case TX_CODEC_DMA_TX_2: - case TX_CODEC_DMA_TX_3: - for_each_rtd_codec_dais(rtd, i, codec_dai) { - sruntime =3D snd_soc_dai_get_stream(codec_dai, substream->stream); - if (sruntime !=3D ERR_PTR(-ENOTSUPP)) - *psruntime =3D sruntime; - } - break; + if (!qcom_snd_is_sdw_dai(cpu_dai->id)) + return NULL; + + for_each_rtd_codec_dais(rtd, i, codec_dai) { + sruntime =3D snd_soc_dai_get_stream(codec_dai, substream->stream); + if (sruntime !=3D ERR_PTR(-ENOTSUPP)) + return sruntime; } + return NULL; +} +EXPORT_SYMBOL_GPL(qcom_snd_sdw_get_stream); + +int qcom_snd_sdw_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params, + struct sdw_stream_runtime **psruntime) +{ + *psruntime =3D qcom_snd_sdw_get_stream(substream); =20 return 0; =20 @@ -166,23 +189,13 @@ int qcom_snd_sdw_hw_free(struct snd_pcm_substream *su= bstream, struct snd_soc_pcm_runtime *rtd =3D snd_soc_substream_to_rtd(substream); struct snd_soc_dai *cpu_dai =3D snd_soc_rtd_to_cpu(rtd, 0); =20 - switch (cpu_dai->id) { - case WSA_CODEC_DMA_RX_0: - case WSA_CODEC_DMA_RX_1: - case RX_CODEC_DMA_RX_0: - case RX_CODEC_DMA_RX_1: - case TX_CODEC_DMA_TX_0: - case TX_CODEC_DMA_TX_1: - case TX_CODEC_DMA_TX_2: - case TX_CODEC_DMA_TX_3: - if (sruntime && *stream_prepared) { - sdw_disable_stream(sruntime); - sdw_deprepare_stream(sruntime); - *stream_prepared =3D false; - } - break; - default: - break; + if (!qcom_snd_is_sdw_dai(cpu_dai->id)) + return 0; + + if (sruntime && *stream_prepared) { + sdw_disable_stream(sruntime); + sdw_deprepare_stream(sruntime); + *stream_prepared =3D false; } =20 return 0; diff --git a/sound/soc/qcom/sdw.h b/sound/soc/qcom/sdw.h index 392e3455f1b1..b8bc5beb0522 100644 --- a/sound/soc/qcom/sdw.h +++ b/sound/soc/qcom/sdw.h @@ -10,6 +10,7 @@ int qcom_snd_sdw_startup(struct snd_pcm_substream *substr= eam); int qcom_snd_sdw_prepare(struct snd_pcm_substream *substream, struct sdw_stream_runtime *runtime, bool *stream_prepared); +struct sdw_stream_runtime *qcom_snd_sdw_get_stream(struct snd_pcm_substrea= m *stream); int qcom_snd_sdw_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct sdw_stream_runtime **psruntime); diff --git a/sound/soc/qcom/sm8250.c b/sound/soc/qcom/sm8250.c index f5b75a06e5bd..ce5b0059207f 100644 --- a/sound/soc/qcom/sm8250.c +++ b/sound/soc/qcom/sm8250.c @@ -117,7 +117,7 @@ static void sm8250_snd_shutdown(struct snd_pcm_substrea= m *substream) struct snd_soc_pcm_runtime *rtd =3D snd_soc_substream_to_rtd(substream); struct snd_soc_dai *cpu_dai =3D snd_soc_rtd_to_cpu(rtd, 0); struct sm8250_snd_data *data =3D snd_soc_card_get_drvdata(rtd->card); - struct sdw_stream_runtime *sruntime =3D data->sruntime[cpu_dai->id]; + struct sdw_stream_runtime *sruntime =3D qcom_snd_sdw_get_stream(substream= ); =20 data->sruntime[cpu_dai->id] =3D NULL; sdw_release_stream(sruntime); diff --git a/sound/soc/qcom/x1e80100.c b/sound/soc/qcom/x1e80100.c index 444f2162889f..2e3599516aa2 100644 --- a/sound/soc/qcom/x1e80100.c +++ b/sound/soc/qcom/x1e80100.c @@ -55,7 +55,7 @@ static void x1e80100_snd_shutdown(struct snd_pcm_substrea= m *substream) struct snd_soc_pcm_runtime *rtd =3D snd_soc_substream_to_rtd(substream); struct snd_soc_dai *cpu_dai =3D snd_soc_rtd_to_cpu(rtd, 0); struct x1e80100_snd_data *data =3D snd_soc_card_get_drvdata(rtd->card); - struct sdw_stream_runtime *sruntime =3D data->sruntime[cpu_dai->id]; + struct sdw_stream_runtime *sruntime =3D qcom_snd_sdw_get_stream(substream= ); =20 data->sruntime[cpu_dai->id] =3D NULL; sdw_release_stream(sruntime); --=20 2.51.0 From nobody Sun Feb 8 21:21:21 2026 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.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 B4C25261B9A for ; Tue, 21 Oct 2025 10:40:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761043217; cv=none; b=jRsS+KV+3lppycPw/F3qlipDCKOJrXitAh5RNC+EAB6zLiYQnjRgR+qnu/l66Fjd61x4InUa4mv6y1dghj2rhEdEXwiBWgM4IUGFyYuQQy1LY26mMGOKchemQoukNatUS2khiyz0uhaeaAHT//aEsFAgJmC/75zoiZlwQZbH+t4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761043217; c=relaxed/simple; bh=itSE7mogahuOOrGJibQ0XgBOmlVMa/YfZdK5eiRuhXY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VsqnsxtyFLrUze4gLSzOYxSFp/x6sWN7C2o3PVAXgSoKjH0Sy2R2WAePvv2e03xOIUFcvGC+kX3j+4s03JuVGEm7VOAZbIzHJjY7ZameGPTmlJxPYUM6GsGXwb9KAO3l8l0Q9zfOKQu+EAGE/DtuiwJa3ibiNEeZOs7wecHyW0Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=Jy8gG2RZ; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="Jy8gG2RZ" Received: from pps.filterd (m0279863.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 59L8BZvm020237 for ; Tue, 21 Oct 2025 10:40:15 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=qcppdkim1; bh=fRrHFA9Y7bm fyzeB3ooislqNqHa7k97OHrK/nUajLjo=; b=Jy8gG2RZQyisr6K+8IJEaLNUB35 /l5VfUzv1BHcseQ932XipmgYfDyB5El8k7MbsMkJTzYAHSLFlHuQkbDbQm+TD2cw 9ZlE7Jsoj9l1S+UKLvJ0Yn5zdE0BeIuWqOT19hxXL09zaRzG2csqbjPk9Lv7udhQ r89PHQnNAVS9V1uxZtEm7y3TgVX39uY3HRlxQfn3eTC/qOSN3dkS8VDj4uECxi/w 49bgR4D+wyYCmCGMIOKc1KAhZln/gkR6IMhyq9QG8XjI+X2e7By/B09AVFzMMZDq ocb6SIROlaAMhDpcztuT1QcAcyrauxtDsxtWuFIjboYYdvWlb4arqR0G0Hw== Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 49v3440cct-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Tue, 21 Oct 2025 10:40:14 +0000 (GMT) Received: by mail-qk1-f200.google.com with SMTP id af79cd13be357-85dd8633b1bso2574475385a.1 for ; Tue, 21 Oct 2025 03:40:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761043209; x=1761648009; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=fRrHFA9Y7bmfyzeB3ooislqNqHa7k97OHrK/nUajLjo=; b=HgBJvHkV6otCtXvV9nPLC3gzwr0DBJ/friT2t9MSEExI1f2gQz578vy/lF1a9sJl4r Oyc3tHajgWnI7c+Zlh2wLPJrZGgfA+4cn7UlywoR1QRutbRDL/wxDwfUykwy+hVgubcw fhwkf4avtMvb3InIB2+LK+daw42B4edxhhkUiV83p8MyeE+pPnqdU93rM4n0GYZrlezm gJ8KBGLAq5mnEfDfZurJXTe5khglRKyChtnMjsCdTHepvCYBZyTcWepm3UtZU1na9Yaq kdKrrtznEPl6+y+qY9b2BaE1VifLeNUT0WjB6Tl30GK76xFBRg7bqYpegQ48gwGvpHqW 87Xg== X-Forwarded-Encrypted: i=1; AJvYcCVotlc8G7Y23BdzJB7W85G2+tQdnouhjsKoZ6WFMRkWPmAC7WpJw9RVF5fCvOPIYMXLWd6TfweBqLIxnk0=@vger.kernel.org X-Gm-Message-State: AOJu0YxFCTnU2OGHFFnlcmAtZK3qXNOFb+DLGGVbwTGN34XCBSA5GsZq Ngg5OATjBakZhN+CMMJelfMmM91fJE3UAuK1QWnXYRgH3GAOG8mbOFrnu4rJlbevLldCiOydYPJ lp9FYu0/Tyii9sntYBrUzrW3HBT30jYnXnrJkL2eOLmXK585PJBAfTTJ1lCTsvkOCaqk= X-Gm-Gg: ASbGncuK9TA7j3uY+3Qj2icNaIpg7WuiROn2RIetd6cio5J8trCq9bCcH1fhYOVsLUw 7QUxfLXaW0XQw1UDANXPMBJ/+RFEFxg/rKnH42Qq66kvOqy5d3GXE4tlvGEszH37tSS16+m0HEB c4S9iWlfvn1dhwyMllrPpZKUC19GQQGBffLzmK0T3hyGNuOxQcPgZKVqYFesR5+0keDksgdwjrz WBmJ8hmfOxCqFgw1h3x+Q8+2prkcyUskiRceIChO6yX5CtrcmvNQf08hhzTjpV5NXoTtvxc9zDo rwhDwVwQ9yZ29dNFKCSGXZA9kF5RE1L4vFqzo83txI95LYgkl5tZ48zcu17pMQlHjil2pWPUSe1 LPTT0yg2z0VeW X-Received: by 2002:a05:622a:243:b0:4e8:a090:abc1 with SMTP id d75a77b69052e-4e8a090af5dmr157425201cf.15.1761043209273; Tue, 21 Oct 2025 03:40:09 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGyZJGtMwkJKZOfnRdHp08i6kzLiRsBAJ6kIaedoDcJarTmtk66rdnHVgLuqBxhTCIzRVxd5A== X-Received: by 2002:a05:622a:243:b0:4e8:a090:abc1 with SMTP id d75a77b69052e-4e8a090af5dmr157425001cf.15.1761043208758; Tue, 21 Oct 2025 03:40:08 -0700 (PDT) Received: from debian ([5.133.47.210]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-427f009a976sm20087938f8f.32.2025.10.21.03.40.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Oct 2025 03:40:08 -0700 (PDT) From: Srinivas Kandagatla To: broonie@kernel.org Cc: perex@perex.cz, tiwai@suse.com, srini@kernel.org, alexey.klimov@linaro.org, linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Srinivas Kandagatla Subject: [PATCH v2 2/4] ASoC: qcom: sdw: remove redundant code Date: Tue, 21 Oct 2025 11:40:00 +0100 Message-ID: <20251021104002.249745-3-srinivas.kandagatla@oss.qualcomm.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251021104002.249745-1-srinivas.kandagatla@oss.qualcomm.com> References: <20251021104002.249745-1-srinivas.kandagatla@oss.qualcomm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-GUID: pItDI8Dka20mukLU1cSERjF0gH_Fi_G1 X-Proofpoint-ORIG-GUID: pItDI8Dka20mukLU1cSERjF0gH_Fi_G1 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMDE4MDAyMyBTYWx0ZWRfX2d4vqKS3S+JQ nyMtaiZc6VEJ0+manLGj5HSfmYg8+JOoX1CAouNoFjANh+nznyc+cxnlbYrR2S/yN6lyKJ7//Gp hpY2QYsJXtvlOzLa/suITmPJKIv8KaOXuKA4I8FpZLhGnukzDLG5S8iiddIU24T6tO+jMJFHIzZ hyRx6M7uSDxposr3OYXQ/msdCI1qcEgsvTpOmbfh2TDZ/pUacUhvij0C3FOgnivvT/FJV9mgtsf s6BO3juuEkGE+PVbXwqySqGfi68Weq/4g7BE5k7otuGYnq8isgAHfoU+MTcozs62xl9tmw/MsrM HCPsbLGkmQ1e3Tmb9fHtUm2GIMJxrVamk4PvcgO/wQsZpRvFm+28POeiWqtnHAn/2T6/hli3S9l A+e2tjBmiYTODM2TZ1br0DSMKQ7v/g== X-Authority-Analysis: v=2.4 cv=E/vAZKdl c=1 sm=1 tr=0 ts=68f7630f cx=c_pps a=hnmNkyzTK/kJ09Xio7VxxA==:117 a=ZsC4DHZuhs/kKio7QBcDoQ==:17 a=x6icFKpwvdMA:10 a=VkNPw1HP01LnGYTKEx00:22 a=EUspDBNiAAAA:8 a=eS8ScSGqROhw0OgIVi4A:9 a=PEH46H7Ffwr30OY-TuGO:22 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.80.40 definitions=2025-10-21_01,2025-10-13_01,2025-03-28_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 spamscore=0 priorityscore=1501 bulkscore=0 suspectscore=0 lowpriorityscore=0 clxscore=1015 adultscore=0 phishscore=0 malwarescore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2510020000 definitions=main-2510180023 Content-Type: text/plain; charset="utf-8" remove redundant code and pointers to handle sdw_stream_runtime by making use of qcom_snd_sdw_get_stream(). This removes need of machine specific shutdown and hw_params sdw callbacks and also need to store sdw_stream_runtime pointers in machine drivers. Signed-off-by: Srinivas Kandagatla --- sound/soc/qcom/sc8280xp.c | 33 +++------------------------------ sound/soc/qcom/sdw.c | 24 ++++++++++++------------ sound/soc/qcom/sdw.h | 6 +----- sound/soc/qcom/sm8250.c | 33 +++------------------------------ sound/soc/qcom/x1e80100.c | 33 +++------------------------------ 5 files changed, 22 insertions(+), 107 deletions(-) diff --git a/sound/soc/qcom/sc8280xp.c b/sound/soc/qcom/sc8280xp.c index 9ba536dff667..5bd8e8aa1853 100644 --- a/sound/soc/qcom/sc8280xp.c +++ b/sound/soc/qcom/sc8280xp.c @@ -18,7 +18,6 @@ struct sc8280xp_snd_data { bool stream_prepared[AFE_PORT_MAX]; struct snd_soc_card *card; - struct sdw_stream_runtime *sruntime[AFE_PORT_MAX]; struct snd_soc_jack jack; struct snd_soc_jack dp_jack[8]; bool jack_setup; @@ -68,17 +67,6 @@ static int sc8280xp_snd_init(struct snd_soc_pcm_runtime = *rtd) return qcom_snd_wcd_jack_setup(rtd, &data->jack, &data->jack_setup); } =20 -static void sc8280xp_snd_shutdown(struct snd_pcm_substream *substream) -{ - struct snd_soc_pcm_runtime *rtd =3D snd_soc_substream_to_rtd(substream); - struct snd_soc_dai *cpu_dai =3D snd_soc_rtd_to_cpu(rtd, 0); - struct sc8280xp_snd_data *pdata =3D snd_soc_card_get_drvdata(rtd->card); - struct sdw_stream_runtime *sruntime =3D qcom_snd_sdw_get_stream(substream= ); - - pdata->sruntime[cpu_dai->id] =3D NULL; - sdw_release_stream(sruntime); -} - static int sc8280xp_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, struct snd_pcm_hw_params *params) { @@ -108,25 +96,13 @@ static int sc8280xp_be_hw_params_fixup(struct snd_soc_= pcm_runtime *rtd, return 0; } =20 -static int sc8280xp_snd_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *params) -{ - struct snd_soc_pcm_runtime *rtd =3D snd_soc_substream_to_rtd(substream); - struct snd_soc_dai *cpu_dai =3D snd_soc_rtd_to_cpu(rtd, 0); - struct sc8280xp_snd_data *pdata =3D snd_soc_card_get_drvdata(rtd->card); - - return qcom_snd_sdw_hw_params(substream, params, &pdata->sruntime[cpu_dai= ->id]); -} - static int sc8280xp_snd_prepare(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd =3D snd_soc_substream_to_rtd(substream); struct snd_soc_dai *cpu_dai =3D snd_soc_rtd_to_cpu(rtd, 0); struct sc8280xp_snd_data *data =3D snd_soc_card_get_drvdata(rtd->card); - struct sdw_stream_runtime *sruntime =3D data->sruntime[cpu_dai->id]; =20 - return qcom_snd_sdw_prepare(substream, sruntime, - &data->stream_prepared[cpu_dai->id]); + return qcom_snd_sdw_prepare(substream, &data->stream_prepared[cpu_dai->id= ]); } =20 static int sc8280xp_snd_hw_free(struct snd_pcm_substream *substream) @@ -134,16 +110,13 @@ static int sc8280xp_snd_hw_free(struct snd_pcm_substr= eam *substream) struct snd_soc_pcm_runtime *rtd =3D snd_soc_substream_to_rtd(substream); struct sc8280xp_snd_data *data =3D snd_soc_card_get_drvdata(rtd->card); struct snd_soc_dai *cpu_dai =3D snd_soc_rtd_to_cpu(rtd, 0); - struct sdw_stream_runtime *sruntime =3D data->sruntime[cpu_dai->id]; =20 - return qcom_snd_sdw_hw_free(substream, sruntime, - &data->stream_prepared[cpu_dai->id]); + return qcom_snd_sdw_hw_free(substream, &data->stream_prepared[cpu_dai->id= ]); } =20 static const struct snd_soc_ops sc8280xp_be_ops =3D { .startup =3D qcom_snd_sdw_startup, - .shutdown =3D sc8280xp_snd_shutdown, - .hw_params =3D sc8280xp_snd_hw_params, + .shutdown =3D qcom_snd_sdw_shutdown, .hw_free =3D sc8280xp_snd_hw_free, .prepare =3D sc8280xp_snd_prepare, }; diff --git a/sound/soc/qcom/sdw.c b/sound/soc/qcom/sdw.c index 7b2cae92c812..c44659deea01 100644 --- a/sound/soc/qcom/sdw.c +++ b/sound/soc/qcom/sdw.c @@ -113,19 +113,21 @@ int qcom_snd_sdw_startup(struct snd_pcm_substream *su= bstream) EXPORT_SYMBOL_GPL(qcom_snd_sdw_startup); =20 int qcom_snd_sdw_prepare(struct snd_pcm_substream *substream, - struct sdw_stream_runtime *sruntime, bool *stream_prepared) { struct snd_soc_pcm_runtime *rtd =3D snd_soc_substream_to_rtd(substream); struct snd_soc_dai *cpu_dai =3D snd_soc_rtd_to_cpu(rtd, 0); + struct sdw_stream_runtime *sruntime; int ret; =20 - if (!sruntime) - return 0; =20 if (!qcom_snd_is_sdw_dai(cpu_dai->id)) return 0; =20 + sruntime =3D qcom_snd_sdw_get_stream(substream); + if (!sruntime) + return 0; + if (*stream_prepared) return 0; =20 @@ -172,26 +174,24 @@ struct sdw_stream_runtime *qcom_snd_sdw_get_stream(st= ruct snd_pcm_substream *sub } EXPORT_SYMBOL_GPL(qcom_snd_sdw_get_stream); =20 -int qcom_snd_sdw_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *params, - struct sdw_stream_runtime **psruntime) +void qcom_snd_sdw_shutdown(struct snd_pcm_substream *substream) { - *psruntime =3D qcom_snd_sdw_get_stream(substream); - - return 0; + struct sdw_stream_runtime *sruntime =3D qcom_snd_sdw_get_stream(substream= ); =20 + sdw_release_stream(sruntime); } -EXPORT_SYMBOL_GPL(qcom_snd_sdw_hw_params); +EXPORT_SYMBOL_GPL(qcom_snd_sdw_shutdown); =20 -int qcom_snd_sdw_hw_free(struct snd_pcm_substream *substream, - struct sdw_stream_runtime *sruntime, bool *stream_prepared) +int qcom_snd_sdw_hw_free(struct snd_pcm_substream *substream, bool *stream= _prepared) { struct snd_soc_pcm_runtime *rtd =3D snd_soc_substream_to_rtd(substream); struct snd_soc_dai *cpu_dai =3D snd_soc_rtd_to_cpu(rtd, 0); + struct sdw_stream_runtime *sruntime; =20 if (!qcom_snd_is_sdw_dai(cpu_dai->id)) return 0; =20 + sruntime =3D qcom_snd_sdw_get_stream(substream); if (sruntime && *stream_prepared) { sdw_disable_stream(sruntime); sdw_deprepare_stream(sruntime); diff --git a/sound/soc/qcom/sdw.h b/sound/soc/qcom/sdw.h index b8bc5beb0522..061a63f1ac52 100644 --- a/sound/soc/qcom/sdw.h +++ b/sound/soc/qcom/sdw.h @@ -7,14 +7,10 @@ #include =20 int qcom_snd_sdw_startup(struct snd_pcm_substream *substream); +void qcom_snd_sdw_shutdown(struct snd_pcm_substream *substream); int qcom_snd_sdw_prepare(struct snd_pcm_substream *substream, - struct sdw_stream_runtime *runtime, bool *stream_prepared); struct sdw_stream_runtime *qcom_snd_sdw_get_stream(struct snd_pcm_substrea= m *stream); -int qcom_snd_sdw_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *params, - struct sdw_stream_runtime **psruntime); int qcom_snd_sdw_hw_free(struct snd_pcm_substream *substream, - struct sdw_stream_runtime *sruntime, bool *stream_prepared); #endif diff --git a/sound/soc/qcom/sm8250.c b/sound/soc/qcom/sm8250.c index ce5b0059207f..203a8705a42f 100644 --- a/sound/soc/qcom/sm8250.c +++ b/sound/soc/qcom/sm8250.c @@ -21,7 +21,6 @@ struct sm8250_snd_data { bool stream_prepared[AFE_PORT_MAX]; struct snd_soc_card *card; - struct sdw_stream_runtime *sruntime[AFE_PORT_MAX]; struct snd_soc_jack jack; struct snd_soc_jack usb_offload_jack; bool usb_offload_jack_setup; @@ -112,36 +111,13 @@ static int sm8250_snd_startup(struct snd_pcm_substrea= m *substream) return qcom_snd_sdw_startup(substream); } =20 -static void sm8250_snd_shutdown(struct snd_pcm_substream *substream) -{ - struct snd_soc_pcm_runtime *rtd =3D snd_soc_substream_to_rtd(substream); - struct snd_soc_dai *cpu_dai =3D snd_soc_rtd_to_cpu(rtd, 0); - struct sm8250_snd_data *data =3D snd_soc_card_get_drvdata(rtd->card); - struct sdw_stream_runtime *sruntime =3D qcom_snd_sdw_get_stream(substream= ); - - data->sruntime[cpu_dai->id] =3D NULL; - sdw_release_stream(sruntime); -} - -static int sm8250_snd_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *params) -{ - struct snd_soc_pcm_runtime *rtd =3D snd_soc_substream_to_rtd(substream); - struct snd_soc_dai *cpu_dai =3D snd_soc_rtd_to_cpu(rtd, 0); - struct sm8250_snd_data *pdata =3D snd_soc_card_get_drvdata(rtd->card); - - return qcom_snd_sdw_hw_params(substream, params, &pdata->sruntime[cpu_dai= ->id]); -} - static int sm8250_snd_prepare(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd =3D snd_soc_substream_to_rtd(substream); struct snd_soc_dai *cpu_dai =3D snd_soc_rtd_to_cpu(rtd, 0); struct sm8250_snd_data *data =3D snd_soc_card_get_drvdata(rtd->card); - struct sdw_stream_runtime *sruntime =3D data->sruntime[cpu_dai->id]; =20 - return qcom_snd_sdw_prepare(substream, sruntime, - &data->stream_prepared[cpu_dai->id]); + return qcom_snd_sdw_prepare(substream, &data->stream_prepared[cpu_dai->id= ]); } =20 static int sm8250_snd_hw_free(struct snd_pcm_substream *substream) @@ -149,16 +125,13 @@ static int sm8250_snd_hw_free(struct snd_pcm_substrea= m *substream) struct snd_soc_pcm_runtime *rtd =3D snd_soc_substream_to_rtd(substream); struct sm8250_snd_data *data =3D snd_soc_card_get_drvdata(rtd->card); struct snd_soc_dai *cpu_dai =3D snd_soc_rtd_to_cpu(rtd, 0); - struct sdw_stream_runtime *sruntime =3D data->sruntime[cpu_dai->id]; =20 - return qcom_snd_sdw_hw_free(substream, sruntime, - &data->stream_prepared[cpu_dai->id]); + return qcom_snd_sdw_hw_free(substream, &data->stream_prepared[cpu_dai->id= ]); } =20 static const struct snd_soc_ops sm8250_be_ops =3D { .startup =3D sm8250_snd_startup, - .shutdown =3D sm8250_snd_shutdown, - .hw_params =3D sm8250_snd_hw_params, + .shutdown =3D qcom_snd_sdw_shutdown, .hw_free =3D sm8250_snd_hw_free, .prepare =3D sm8250_snd_prepare, }; diff --git a/sound/soc/qcom/x1e80100.c b/sound/soc/qcom/x1e80100.c index 2e3599516aa2..a3f4785c4bbe 100644 --- a/sound/soc/qcom/x1e80100.c +++ b/sound/soc/qcom/x1e80100.c @@ -18,7 +18,6 @@ struct x1e80100_snd_data { bool stream_prepared[AFE_PORT_MAX]; struct snd_soc_card *card; - struct sdw_stream_runtime *sruntime[AFE_PORT_MAX]; struct snd_soc_jack jack; struct snd_soc_jack dp_jack[8]; bool jack_setup; @@ -50,17 +49,6 @@ static int x1e80100_snd_init(struct snd_soc_pcm_runtime = *rtd) return qcom_snd_wcd_jack_setup(rtd, &data->jack, &data->jack_setup); } =20 -static void x1e80100_snd_shutdown(struct snd_pcm_substream *substream) -{ - struct snd_soc_pcm_runtime *rtd =3D snd_soc_substream_to_rtd(substream); - struct snd_soc_dai *cpu_dai =3D snd_soc_rtd_to_cpu(rtd, 0); - struct x1e80100_snd_data *data =3D snd_soc_card_get_drvdata(rtd->card); - struct sdw_stream_runtime *sruntime =3D qcom_snd_sdw_get_stream(substream= ); - - data->sruntime[cpu_dai->id] =3D NULL; - sdw_release_stream(sruntime); -} - static int x1e80100_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, struct snd_pcm_hw_params *params) { @@ -85,16 +73,6 @@ static int x1e80100_be_hw_params_fixup(struct snd_soc_pc= m_runtime *rtd, return 0; } =20 -static int x1e80100_snd_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *params) -{ - struct snd_soc_pcm_runtime *rtd =3D snd_soc_substream_to_rtd(substream); - struct snd_soc_dai *cpu_dai =3D snd_soc_rtd_to_cpu(rtd, 0); - struct x1e80100_snd_data *data =3D snd_soc_card_get_drvdata(rtd->card); - - return qcom_snd_sdw_hw_params(substream, params, &data->sruntime[cpu_dai-= >id]); -} - static int x1e80100_snd_hw_map_channels(unsigned int *ch_map, int num) { switch (num) { @@ -128,7 +106,6 @@ static int x1e80100_snd_prepare(struct snd_pcm_substrea= m *substream) struct snd_soc_pcm_runtime *rtd =3D snd_soc_substream_to_rtd(substream); struct snd_soc_dai *cpu_dai =3D snd_soc_rtd_to_cpu(rtd, 0); struct x1e80100_snd_data *data =3D snd_soc_card_get_drvdata(rtd->card); - struct sdw_stream_runtime *sruntime =3D data->sruntime[cpu_dai->id]; unsigned int channels =3D substream->runtime->channels; unsigned int rx_slot[4]; int ret; @@ -149,8 +126,7 @@ static int x1e80100_snd_prepare(struct snd_pcm_substrea= m *substream) break; } =20 - return qcom_snd_sdw_prepare(substream, sruntime, - &data->stream_prepared[cpu_dai->id]); + return qcom_snd_sdw_prepare(substream, &data->stream_prepared[cpu_dai->id= ]); } =20 static int x1e80100_snd_hw_free(struct snd_pcm_substream *substream) @@ -158,16 +134,13 @@ static int x1e80100_snd_hw_free(struct snd_pcm_substr= eam *substream) struct snd_soc_pcm_runtime *rtd =3D snd_soc_substream_to_rtd(substream); struct x1e80100_snd_data *data =3D snd_soc_card_get_drvdata(rtd->card); struct snd_soc_dai *cpu_dai =3D snd_soc_rtd_to_cpu(rtd, 0); - struct sdw_stream_runtime *sruntime =3D data->sruntime[cpu_dai->id]; =20 - return qcom_snd_sdw_hw_free(substream, sruntime, - &data->stream_prepared[cpu_dai->id]); + return qcom_snd_sdw_hw_free(substream, &data->stream_prepared[cpu_dai->id= ]); } =20 static const struct snd_soc_ops x1e80100_be_ops =3D { .startup =3D qcom_snd_sdw_startup, - .shutdown =3D x1e80100_snd_shutdown, - .hw_params =3D x1e80100_snd_hw_params, + .shutdown =3D qcom_snd_sdw_shutdown, .hw_free =3D x1e80100_snd_hw_free, .prepare =3D x1e80100_snd_prepare, }; --=20 2.51.0 From nobody Sun Feb 8 21:21:21 2026 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 C78B232D451 for ; Tue, 21 Oct 2025 10:40:21 +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=1761043223; cv=none; b=GpA5hQHp2uasoWeLplGX7xvJo1Zvm/Q/n/ISOU5eu/kZiZ8kPK/gXobU8aIe9qw6WKfhcez/Mcqq1hNzxbz/xwaFcsEHwG7QQ4WW1K+WVPUnrLhaDpCtnyQP8ExEvhMjKnlP9xkxLlEdaicFroEzK2HVwqWSXi2KLUoL8hNjg7E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761043223; c=relaxed/simple; bh=9Yzea+GEBCp3vC14uyqotsmH4Z9Whw1KznKC/UswPf4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nCve19C6QZhoCv5q93MaqHGX55dq62u/4OCpGhf57FQQ/KLKr1DP8X/+MdcgETrxIg4293HQ3yTHtyQN380MgedPaud+ajlwrj7wF8vJwd1E9DqEhQ0omIyCm0lpCBKoOxdstbN9ce5yPnd0OoU2zxBhMmXbIAIgXsTHeqMFPto= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=gR1GfUzy; arc=none smtp.client-ip=205.220.180.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="gR1GfUzy" Received: from pps.filterd (m0279868.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 59L8Lv4d027450 for ; Tue, 21 Oct 2025 10:40:20 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=qcppdkim1; bh=9AVB6C9MIvz 52Jr3ZtdLA9E94f5FNRcURNEPb2LyudU=; b=gR1GfUzyMoN8DNVtiBuVCnEqc3A YcvvbgefWdYvJ5OXLubEXxX82R83E8yUrNv6+7KvwsbuIVsoTZMs5n3LbIJcvyk/ 2nU6i++/Dj9AsDj9LjQRAmq6F9/iMe/FQUd0F5fsXjW4v1TszHUiL+4GD027eEUt 4/y9+ppZDTPybmjObHk53f5+crnUhLG+HEK6jZq3iGrYTJRogo6GuVSu8z4tYoi8 Q2cP43wKfvSxCMjLhMYAsUvNSP2W0w3mCwlmZDzSyCUuZeYtXEo13AWiDBFpsmV6 zRAKQgi3fwtMtku4OckBpu2s6OJ/+xg7mhBVoyCcGXPflszchxQsPC8nzdQ== Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 49v27j0dem-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Tue, 21 Oct 2025 10:40:20 +0000 (GMT) Received: by mail-qk1-f198.google.com with SMTP id af79cd13be357-8910b0fb780so762267885a.3 for ; Tue, 21 Oct 2025 03:40:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761043210; x=1761648010; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9AVB6C9MIvz52Jr3ZtdLA9E94f5FNRcURNEPb2LyudU=; b=UudgFRbOWa+Lw9MdMwAYozYTR8+5hPeQVybTJ0oC2O4rhZQsqOzWAgcsQuKTVphI/R EQUIzVxiMxPxrshHQDYEbiK04zNwAs19WdzFc8FymZ5bQgEuJkajGysDU9Fur1Ct08jQ XaciWkPZ/Qcso3dieEFWr58ZIx0f4gxg615TPVi/bPwfGhd6787Fchcrzaq7D1MU51dk Yl4ZHz+zwFwUy27MYanHIhF0j6h/NVAeQ07DuiUkhONmrzJU4EEkCGa9oho+H5LHxbqw LWqqHfeNMsFudSAihBtJkUCTBE8niiLwDOB/KIGbsxs42hGgxO3+AtM/7xgkaY6hi7gi kepw== X-Forwarded-Encrypted: i=1; AJvYcCVB77CQ84ULwH/4ZXuDasipNj2UwE60e0AfzmtY8e+0AvXuYNJ5YBclf/GAq98+1BUMunb5rXFW4xcsoB0=@vger.kernel.org X-Gm-Message-State: AOJu0YyMWWa9bmhIQOo3puZIpvLSXVdaNUXVfJNOJSAa1DYhWYArYyrh lvGEbB9POUmZndKuioRBnag+nEV23UxI+7GzWWueIhNCxSWLT3yD/Dyw2c8l11lpMjmR6IVXKNm uXIrWyzxBY3gQP6f1sgE7wcPHcRuWSITKerf5V4MEZLp4x3ZZqJoRyATo4/bGwz2n9fA= X-Gm-Gg: ASbGncvDrVUgUbI7QI/UsZtp4lDpBdQipPdDRtDgr9lnot1pdyl3+iaqYRc4PbvkcWc JE9esd4wh9Q+9jsNefadQR859we4Aznqcefe4fVF+Yg6yLnFZaYMwcFuoo0eTvOD+YGXWYizKjg MmSPd/ALz97rry06rOElD39t40+7CYFYukrnS8+I7qcOjdyoXbFVUzo3WvZAqCg9xQfclixEEKD ptnflCitChftFyndAE19no3B24z6D5jNM4XPvN4M3AWFPMpzPK69HtK/8Y7Vp/FyLIyrSdLlc9f B/Z1rGlfXepYhk+ku1GrncMRaj3cY+TTemofFVV3y1lc76HN54Kxa//I5y6xvfJiMNlMEdmmUPe lSF3lcXz2Qauz X-Received: by 2002:a05:622a:1899:b0:4e8:971d:10 with SMTP id d75a77b69052e-4e89d209944mr206517481cf.12.1761043210310; Tue, 21 Oct 2025 03:40:10 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFSGENTASX4ZCUyVauFbu72tSoTDiq9c99JISaWvIGYxlRh8iPGVUjzGg07n0JZACEeGKQgWA== X-Received: by 2002:a05:622a:1899:b0:4e8:971d:10 with SMTP id d75a77b69052e-4e89d209944mr206517211cf.12.1761043209826; Tue, 21 Oct 2025 03:40:09 -0700 (PDT) Received: from debian ([5.133.47.210]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-427f009a976sm20087938f8f.32.2025.10.21.03.40.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Oct 2025 03:40:09 -0700 (PDT) From: Srinivas Kandagatla To: broonie@kernel.org Cc: perex@perex.cz, tiwai@suse.com, srini@kernel.org, alexey.klimov@linaro.org, linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Srinivas Kandagatla Subject: [PATCH v2 3/4] ASoC: qcom: sdm845: make use of common helpers Date: Tue, 21 Oct 2025 11:40:01 +0100 Message-ID: <20251021104002.249745-4-srinivas.kandagatla@oss.qualcomm.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251021104002.249745-1-srinivas.kandagatla@oss.qualcomm.com> References: <20251021104002.249745-1-srinivas.kandagatla@oss.qualcomm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMDE4MDAxOCBTYWx0ZWRfX5CKUbmembAkV a3U4iRxqdkbItuOo06tgcu8GN0sz3cMXvM0JMu7POLfPh+5xA2y/vLNyhQ/WaRpAO+H0iXd2a9x icfu4QouPRQYDaVRh4L33z5eZ0dpkB1ZjN3hy2p+7Z6pHXX0/ZAzm3ys9Zo1nNpOQwBz+5cX8Oy cDTY1tNNXOphfaX7RwwCx4AvlaEbw0/Kkj0qO501jgLLhaVgtUhSdoZxTo0ZSAdIBD2MhifYJQL b98yKWi3cKm5VdSP7uLGWM60eP0wywYwRaVTL0YsSXXHn8u3l99pCTAsdTcMkksYqT4fYqVpXvg mbLRR1lU6y4rxYupYHrRq9dLrfDC8ZPnELerABLqdO5IrShe0kh9F6/tbH17RD9cH7sCEXnw0Dr BX+1SP0F2zvqhWKrGIgrdqaBNWsd5w== X-Authority-Analysis: v=2.4 cv=G4UR0tk5 c=1 sm=1 tr=0 ts=68f76314 cx=c_pps a=qKBjSQ1v91RyAK45QCPf5w==:117 a=ZsC4DHZuhs/kKio7QBcDoQ==:17 a=x6icFKpwvdMA:10 a=VkNPw1HP01LnGYTKEx00:22 a=EUspDBNiAAAA:8 a=5b0IN9Hzzi15MECZVvAA:9 a=NFOGd7dJGGMPyQGDc5-O:22 X-Proofpoint-GUID: 13q370_Lh68IL3djeZtV5dpSwlbeJkX5 X-Proofpoint-ORIG-GUID: 13q370_Lh68IL3djeZtV5dpSwlbeJkX5 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.80.40 definitions=2025-10-21_01,2025-10-13_01,2025-03-28_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 lowpriorityscore=0 malwarescore=0 bulkscore=0 priorityscore=1501 spamscore=0 suspectscore=0 adultscore=0 clxscore=1015 phishscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2510020000 definitions=main-2510180018 Content-Type: text/plain; charset="utf-8" sdm845 machine driver can make use of common sdw functions to do most of the soundwire related operations. Remove such redundant code from sdm845 driver. Signed-off-by: Srinivas Kandagatla --- sound/soc/qcom/sdm845.c | 53 +++-------------------------------------- 1 file changed, 3 insertions(+), 50 deletions(-) diff --git a/sound/soc/qcom/sdm845.c b/sound/soc/qcom/sdm845.c index a233b80049ee..e18a8e44f2db 100644 --- a/sound/soc/qcom/sdm845.c +++ b/sound/soc/qcom/sdm845.c @@ -40,7 +40,6 @@ struct sdm845_snd_data { uint32_t pri_mi2s_clk_count; uint32_t sec_mi2s_clk_count; uint32_t quat_tdm_clk_count; - struct sdw_stream_runtime *sruntime[AFE_PORT_MAX]; }; =20 static struct snd_soc_jack_pin sdm845_jack_pins[] =3D { @@ -62,18 +61,11 @@ static int sdm845_slim_snd_hw_params(struct snd_pcm_sub= stream *substream, struct snd_soc_pcm_runtime *rtd =3D snd_soc_substream_to_rtd(substream); struct snd_soc_dai *cpu_dai =3D snd_soc_rtd_to_cpu(rtd, 0); struct snd_soc_dai *codec_dai; - struct sdm845_snd_data *pdata =3D snd_soc_card_get_drvdata(rtd->card); u32 rx_ch[SLIM_MAX_RX_PORTS], tx_ch[SLIM_MAX_TX_PORTS]; - struct sdw_stream_runtime *sruntime; u32 rx_ch_cnt =3D 0, tx_ch_cnt =3D 0; int ret =3D 0, i; =20 for_each_rtd_codec_dais(rtd, i, codec_dai) { - sruntime =3D snd_soc_dai_get_stream(codec_dai, - substream->stream); - if (sruntime !=3D ERR_PTR(-ENOTSUPP)) - pdata->sruntime[cpu_dai->id] =3D sruntime; - ret =3D snd_soc_dai_get_channel_map(codec_dai, &tx_ch_cnt, tx_ch, &rx_ch_cnt, rx_ch); =20 @@ -430,7 +422,6 @@ static void sdm845_snd_shutdown(struct snd_pcm_substre= am *substream) struct snd_soc_card *card =3D rtd->card; struct sdm845_snd_data *data =3D snd_soc_card_get_drvdata(card); struct snd_soc_dai *cpu_dai =3D snd_soc_rtd_to_cpu(rtd, 0); - struct sdw_stream_runtime *sruntime =3D data->sruntime[cpu_dai->id]; =20 switch (cpu_dai->id) { case PRIMARY_MI2S_RX: @@ -471,8 +462,7 @@ static void sdm845_snd_shutdown(struct snd_pcm_substre= am *substream) break; } =20 - data->sruntime[cpu_dai->id] =3D NULL; - sdw_release_stream(sruntime); + qcom_snd_sdw_shutdown(substream); } =20 static int sdm845_snd_prepare(struct snd_pcm_substream *substream) @@ -480,38 +470,8 @@ static int sdm845_snd_prepare(struct snd_pcm_substream= *substream) struct snd_soc_pcm_runtime *rtd =3D snd_soc_substream_to_rtd(substream); struct sdm845_snd_data *data =3D snd_soc_card_get_drvdata(rtd->card); struct snd_soc_dai *cpu_dai =3D snd_soc_rtd_to_cpu(rtd, 0); - struct sdw_stream_runtime *sruntime =3D data->sruntime[cpu_dai->id]; - int ret; - - if (!sruntime) - return 0; - - if (data->stream_prepared[cpu_dai->id]) { - sdw_disable_stream(sruntime); - sdw_deprepare_stream(sruntime); - data->stream_prepared[cpu_dai->id] =3D false; - } =20 - ret =3D sdw_prepare_stream(sruntime); - if (ret) - return ret; - - /** - * NOTE: there is a strict hw requirement about the ordering of port - * enables and actual WSA881x PA enable. PA enable should only happen - * after soundwire ports are enabled if not DC on the line is - * accumulated resulting in Click/Pop Noise - * PA enable/mute are handled as part of codec DAPM and digital mute. - */ - - ret =3D sdw_enable_stream(sruntime); - if (ret) { - sdw_deprepare_stream(sruntime); - return ret; - } - data->stream_prepared[cpu_dai->id] =3D true; - - return ret; + return qcom_snd_sdw_prepare(substream, &data->stream_prepared[cpu_dai->id= ]); } =20 static int sdm845_snd_hw_free(struct snd_pcm_substream *substream) @@ -519,15 +479,8 @@ static int sdm845_snd_hw_free(struct snd_pcm_substream= *substream) struct snd_soc_pcm_runtime *rtd =3D snd_soc_substream_to_rtd(substream); struct sdm845_snd_data *data =3D snd_soc_card_get_drvdata(rtd->card); struct snd_soc_dai *cpu_dai =3D snd_soc_rtd_to_cpu(rtd, 0); - struct sdw_stream_runtime *sruntime =3D data->sruntime[cpu_dai->id]; - - if (sruntime && data->stream_prepared[cpu_dai->id]) { - sdw_disable_stream(sruntime); - sdw_deprepare_stream(sruntime); - data->stream_prepared[cpu_dai->id] =3D false; - } =20 - return 0; + return qcom_snd_sdw_hw_free(substream, &data->stream_prepared[cpu_dai->id= ]); } =20 static const struct snd_soc_ops sdm845_be_ops =3D { --=20 2.51.0 From nobody Sun Feb 8 21:21:21 2026 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 10EFF2EA17D for ; Tue, 21 Oct 2025 10:40:13 +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=1761043218; cv=none; b=k9bgc1TdoQ5mXSCkPjcj8qSJKb0aUV6L/MmNi3uHrxy0/Iqtfawr2HvQ6WQNzWDjnriwy1SmUHn+QrVq7wFbID7jlY2QkkT57PXe4HvR2HpqIBH//YQIju+MG+zXAOeab819YET2iWCehJqPKvBZsJgm7joT3RqU8V/P7qZ/OBI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761043218; c=relaxed/simple; bh=UYyYRnQbXnCvAIlE1ZdNvY1IRbRxEMbOF2tV79AsSe0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TY5v3cexiJEM54NRXGrSojCjEsv7G40UbPO9zZ5bioIyD2tyNiNezlVc55hOmK599wH32hhXbQJAqoe+bDuSgnNB87tEfjeRHNrA5Qi9z/lLoGvHcbzC6wxX8xK+CEL/HuGz9bOIBwOQEWGRiIc1Un+hHnUdybnFj3jzH46F86I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=Tmxvpvew; arc=none smtp.client-ip=205.220.180.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="Tmxvpvew" Received: from pps.filterd (m0279872.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 59L8OOIn012691 for ; Tue, 21 Oct 2025 10:40:13 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=qcppdkim1; bh=jNy+kcNV6c4 PBhObCb2utKXHWJKznzQtqH7XbZIO9js=; b=Tmxvpvewo8LvbZOVtTldkjiOM67 bzWL/BC0F9VycNUffsUgy3R5nbf05R/nN0yAiVA5o6mzid83Mw9s+zwpvpGEI3Ev ptON+BDbgCXZJ8XQsBtLgZzEFmmIBF4GINZ810qG6hEyTnyPHg2nPHl70ZWdge2W iIILGHaEHQHqjLTYE0T1ZVE97TGeBca9Xc9aFtPyZGIPx128VebLDDhWf7ryTWuC faJXufmOxrbETKLaevgxtWypJHnF+xtxXtVHQLA4rQ/dUnlCq+98/YfEbYJkvDwG hg1aKUGpPNEgnG4RhZT1aaQ9FV05G80IVKXg2KwaKYlwoNtqlpav6WKLE5w== Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 49wtgetme0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Tue, 21 Oct 2025 10:40:12 +0000 (GMT) Received: by mail-qk1-f200.google.com with SMTP id af79cd13be357-88fec61f826so1917996885a.1 for ; Tue, 21 Oct 2025 03:40:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761043212; x=1761648012; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=jNy+kcNV6c4PBhObCb2utKXHWJKznzQtqH7XbZIO9js=; b=EEP+Onw0dS5JUhkVqEd+rjcqvqA/iBhgEZQm74WlPtl/LL3lirV35t6xmWDCthWtuT qYElztGjHbh9PPpXlWIMDe+WR+tK8PGNCBWn/nG3wXXYm22a+ftQ2zf9vU/DUQMI0GIS 5f4u2pL2+n+ha+TclBZ2lGWv7WMFLLMcZiF5zw7mSuz1BdrRPPQYUoPPO4eDTmNoSNjl yfMl78dtZ8Fm2x4+epZ9jrDBvLFIspMOpy3nAV9zOzsSZxhr39UMJ1fujz6BYkh3H3r5 z+4nwgfw296RXcFcKAYKYzUXNI7d4JEWcw2EtuVolVAnOPZ6NMvLlRo1FshWfDKlEmqA Msqg== X-Forwarded-Encrypted: i=1; AJvYcCXXIo2DX6WaM+w6iWAq9d7aE0NGgya8HwsgFAnYw81pC0+Recuxp8SU+bJToV5lKFrgLwXTHzw3g9GSnV0=@vger.kernel.org X-Gm-Message-State: AOJu0YwvJOckY9iquqGWQkAIdEwqBUV1R4iqlDAiI7j8Iuvlaj0w6A65 kT7zjwNXGgu2K+yCUxoowVdC4oS3zXKxbM31BB8IsnONw7wVaRTq8XHT2YJ+pvdFzN8vY7rnn6y k/IHqGe4DP6KQec5vzu78fdtNrTgxaIwbUA33RKYqSV2xrEijbR4IUczTGytuLDLOREI= X-Gm-Gg: ASbGnctE4OnjS/F4zGrwUjxIRqg4uqE+5iuAAGObZMeg9vlNNbV/g0NBeyEbS1bmkIh lFXZ1dQvxg/ykEsvcrnH5OZRBmuwqo09/+BvjScyDDAPKclWQx4lIX3r2/wRYx8QUK1+cRYBg3C 42FGkKX57YAXI+yJ2WKvX+kBi/KunkqMpI3ExK1lvfyFNxtx15A2ymFMMSdM5i/EnqzX2EiZSXZ 4f6GdUr9EyamGjpnNSLODutOMJxDQbfmUR3bc9jmZJviPVR2XSGN+r0Hx+u12y49p8Rg1ONtnaf 419M3FhY7tHF2beMUTfMJ0SVPjIf3wc2FaDC8H/X3Xnh27oK0Af8+6CM1hCoXi3kIosO7st2ZFO hP6+e311L6OdX X-Received: by 2002:ac8:5a88:0:b0:4b7:9506:efd1 with SMTP id d75a77b69052e-4e89d1fa8f4mr160054631cf.15.1761043212081; Tue, 21 Oct 2025 03:40:12 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGNwpGr5uC6St5tQQjzTYAMWepTpl6VdBTuEO/ILCKO7RvOLdLTGwCCKckadeZvFJxgQmGWJA== X-Received: by 2002:ac8:5a88:0:b0:4b7:9506:efd1 with SMTP id d75a77b69052e-4e89d1fa8f4mr160054401cf.15.1761043211552; Tue, 21 Oct 2025 03:40:11 -0700 (PDT) Received: from debian ([5.133.47.210]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-427f009a976sm20087938f8f.32.2025.10.21.03.40.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Oct 2025 03:40:10 -0700 (PDT) From: Srinivas Kandagatla To: broonie@kernel.org Cc: perex@perex.cz, tiwai@suse.com, srini@kernel.org, alexey.klimov@linaro.org, linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Srinivas Kandagatla Subject: [PATCH v2 4/4] ASoC: qcom: sc7280: make use of common helpers Date: Tue, 21 Oct 2025 11:40:02 +0100 Message-ID: <20251021104002.249745-5-srinivas.kandagatla@oss.qualcomm.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251021104002.249745-1-srinivas.kandagatla@oss.qualcomm.com> References: <20251021104002.249745-1-srinivas.kandagatla@oss.qualcomm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-ORIG-GUID: MwYVO9y2uCnYLthxoLPdVbb9fjOFXZl1 X-Authority-Analysis: v=2.4 cv=JeaxbEKV c=1 sm=1 tr=0 ts=68f7630c cx=c_pps a=hnmNkyzTK/kJ09Xio7VxxA==:117 a=ZsC4DHZuhs/kKio7QBcDoQ==:17 a=x6icFKpwvdMA:10 a=VkNPw1HP01LnGYTKEx00:22 a=EUspDBNiAAAA:8 a=xzVSZQTBi2W_vW4HIIQA:9 a=PEH46H7Ffwr30OY-TuGO:22 X-Proofpoint-GUID: MwYVO9y2uCnYLthxoLPdVbb9fjOFXZl1 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMDIwMDE1NCBTYWx0ZWRfX8BQHq/cP49OX +Jk5UMY80wpzs9NI0gcwod/hQf79d8XkDoBQKv7S6JFcUoGrBMIeLwQepC+pC1LrJhaa1dTywkk Dwvkom6/O4Py5C6xkd4ClPbsvBBWZxiKdOSfIKZ2rvfOerNKNtCt6sUFtOyT1LXAyjez1Hzq82H qzO+B09yrKE0rGZ86jfTSCu68d0reApndLTuFJnxgy9ny/i6FdSxUW0S//Y5HpwGlRlGSuDGgme fcIw41Z6nvLtvaAwcU/5S4ov5a3xU9m2+Xr9L9fWzl5axGzyJr9iZgdjhFJTXkjy1mbSzSq3AwA TfjUdCR7EXZ7CJtIO00rYZF+t+5wA2ymc5FX0TFSOeec2D2xZjGChqeOKXebduwSPo0rqQ6VgKC kcc2JLNmUgpAFO5k4dKU5V7TPU6gPQ== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.80.40 definitions=2025-10-21_01,2025-10-13_01,2025-03-28_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 clxscore=1015 malwarescore=0 impostorscore=0 spamscore=0 bulkscore=0 suspectscore=0 priorityscore=1501 lowpriorityscore=0 adultscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2510020000 definitions=main-2510200154 Content-Type: text/plain; charset="utf-8" sc7280 machine driver can make use of common sdw functions to do most of the soundwire related operations. Remove such redundant code from sc7280 driver. Signed-off-by: Srinivas Kandagatla --- sound/soc/qcom/sc7280.c | 67 ++--------------------------------------- sound/soc/qcom/sdw.c | 10 ++++++ 2 files changed, 13 insertions(+), 64 deletions(-) diff --git a/sound/soc/qcom/sc7280.c b/sound/soc/qcom/sc7280.c index c444dae563c7..abdd58c1d0a4 100644 --- a/sound/soc/qcom/sc7280.c +++ b/sound/soc/qcom/sc7280.c @@ -31,7 +31,6 @@ =20 struct sc7280_snd_data { struct snd_soc_card card; - struct sdw_stream_runtime *sruntime[LPASS_MAX_PORTS]; u32 pri_mi2s_clk_count; struct snd_soc_jack hs_jack; struct snd_soc_jack hdmi_jack; @@ -207,32 +206,12 @@ static int sc7280_snd_hw_params(struct snd_pcm_substr= eam *substream, { struct snd_pcm_runtime *runtime =3D substream->runtime; struct snd_soc_pcm_runtime *rtd =3D snd_soc_substream_to_rtd(substream); - struct snd_soc_dai *codec_dai; - const struct snd_soc_dai *cpu_dai =3D snd_soc_rtd_to_cpu(rtd, 0); - struct sc7280_snd_data *pdata =3D snd_soc_card_get_drvdata(rtd->card); - struct sdw_stream_runtime *sruntime; - int i; =20 if (!rtd->dai_link->no_pcm) { snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_CHANNELS, 2, 2); snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_RATE, 48000, 48= 000); } =20 - switch (cpu_dai->id) { - case LPASS_CDC_DMA_TX3: - case LPASS_CDC_DMA_RX0: - case RX_CODEC_DMA_RX_0: - case SECONDARY_MI2S_RX: - case TX_CODEC_DMA_TX_3: - case VA_CODEC_DMA_TX_0: - for_each_rtd_codec_dais(rtd, i, codec_dai) { - sruntime =3D snd_soc_dai_get_stream(codec_dai, substream->stream); - if (sruntime !=3D ERR_PTR(-ENOTSUPP)) - pdata->sruntime[cpu_dai->id] =3D sruntime; - } - break; - } - return 0; } =20 @@ -241,30 +220,8 @@ static int sc7280_snd_swr_prepare(struct snd_pcm_subst= ream *substream) struct snd_soc_pcm_runtime *rtd =3D snd_soc_substream_to_rtd(substream); const struct snd_soc_dai *cpu_dai =3D snd_soc_rtd_to_cpu(rtd, 0); struct sc7280_snd_data *data =3D snd_soc_card_get_drvdata(rtd->card); - struct sdw_stream_runtime *sruntime =3D data->sruntime[cpu_dai->id]; - int ret; =20 - if (!sruntime) - return 0; - - if (data->stream_prepared[cpu_dai->id]) { - sdw_disable_stream(sruntime); - sdw_deprepare_stream(sruntime); - data->stream_prepared[cpu_dai->id] =3D false; - } - - ret =3D sdw_prepare_stream(sruntime); - if (ret) - return ret; - - ret =3D sdw_enable_stream(sruntime); - if (ret) { - sdw_deprepare_stream(sruntime); - return ret; - } - data->stream_prepared[cpu_dai->id] =3D true; - - return ret; + return qcom_snd_sdw_prepare(substream, &data->stream_prepared[cpu_dai->id= ]); } =20 static int sc7280_snd_prepare(struct snd_pcm_substream *substream) @@ -291,24 +248,8 @@ static int sc7280_snd_hw_free(struct snd_pcm_substream= *substream) struct snd_soc_pcm_runtime *rtd =3D snd_soc_substream_to_rtd(substream); struct sc7280_snd_data *data =3D snd_soc_card_get_drvdata(rtd->card); const struct snd_soc_dai *cpu_dai =3D snd_soc_rtd_to_cpu(rtd, 0); - struct sdw_stream_runtime *sruntime =3D data->sruntime[cpu_dai->id]; =20 - switch (cpu_dai->id) { - case LPASS_CDC_DMA_RX0: - case LPASS_CDC_DMA_TX3: - case RX_CODEC_DMA_RX_0: - case TX_CODEC_DMA_TX_3: - case VA_CODEC_DMA_TX_0: - if (sruntime && data->stream_prepared[cpu_dai->id]) { - sdw_disable_stream(sruntime); - sdw_deprepare_stream(sruntime); - data->stream_prepared[cpu_dai->id] =3D false; - } - break; - default: - break; - } - return 0; + return qcom_snd_sdw_hw_free(substream, &data->stream_prepared[cpu_dai->id= ]); } =20 static void sc7280_snd_shutdown(struct snd_pcm_substream *substream) @@ -317,7 +258,6 @@ static void sc7280_snd_shutdown(struct snd_pcm_substrea= m *substream) struct snd_soc_card *card =3D rtd->card; struct sc7280_snd_data *data =3D snd_soc_card_get_drvdata(card); struct snd_soc_dai *cpu_dai =3D snd_soc_rtd_to_cpu(rtd, 0); - struct sdw_stream_runtime *sruntime =3D qcom_snd_sdw_get_stream(substream= ); =20 switch (cpu_dai->id) { case MI2S_PRIMARY: @@ -336,8 +276,7 @@ static void sc7280_snd_shutdown(struct snd_pcm_substrea= m *substream) break; } =20 - data->sruntime[cpu_dai->id] =3D NULL; - sdw_release_stream(sruntime); + qcom_snd_sdw_shutdown(substream); } =20 static int sc7280_snd_startup(struct snd_pcm_substream *substream) diff --git a/sound/soc/qcom/sdw.c b/sound/soc/qcom/sdw.c index c44659deea01..16bf09db29f5 100644 --- a/sound/soc/qcom/sdw.c +++ b/sound/soc/qcom/sdw.c @@ -2,6 +2,7 @@ // Copyright (c) 2018-2023, Linaro Limited. // Copyright (c) 2018, The Linux Foundation. All rights reserved. =20 +#include #include #include #include @@ -30,6 +31,15 @@ static bool qcom_snd_is_sdw_dai(int id) case RX_CODEC_DMA_RX_6: case RX_CODEC_DMA_RX_7: case SLIMBUS_0_RX...SLIMBUS_6_TX: + default: + break; + } + + /* DSP Bypass usecase, cpu dai index overlaps with DSP dai ids, + * DO NOT MERGE into top switch case */ + switch (id) { + case LPASS_CDC_DMA_TX3: + case LPASS_CDC_DMA_RX0: return true; default: break; --=20 2.51.0