From nobody Mon Feb 9 03:15:55 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 080AA309F1F for ; Wed, 22 Oct 2025 14:34:03 +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=1761143646; cv=none; b=iPLvprQm+MLnwUAGjMtFhP/QR+Q9C1uow81oNie+dtUJ15DQdPoBBJKvIoslApuUBswKe8VLlSjmaJyCsbLN7ZNaAlvos7apQRdLVjwpNOBIxteqZgJOhscF6A1xrW/2y0/yDzMiKD+pT35WvLeJ/NK0BXbs41QrRg6eKuoTejk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761143646; c=relaxed/simple; bh=lhxTLcb/X+R0W0b3tDUVNgpKKlGRY+Qpo1UN7CrZMXE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=m0/swaUlEP0v/j5z2nPG7CLkafyCmsW19JsFyCJXwwuQP/wHDwDjBiZioIBDAgFofOINl72zPe+rEN1LdepkI7waSDEBxzKiHItzdZyRszWNdIywcckE2D5u4zY9bifb/gTVSP2dW8PSoSvFGmSW+y5dFCq9ESc2CE3cudwTknE= 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=dy30tpnQ; 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="dy30tpnQ" Received: from pps.filterd (m0279873.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 59MAcX5I026895 for ; Wed, 22 Oct 2025 14:34:03 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=QX+/j6ug5Bp ZFxeqiWYjDUw7viVbs6iAE/eqbzDRJuU=; b=dy30tpnQHfVD+4IuX6H+jk7NY8G ifaXmBJeoLpgm+oQ4Hs4mFbMNuKbmZ4+abxBOUnH+la7nSwXl9l71wc8LNwaLmcr PjRSfmAJZl770fBH1NzPelM9YFG78tqGIKjb0s/EYlfs78OTZ/GU1l+icZkgQXE/ uI1Z/8K+xasyiBWNwbeMOQ9hScWGXGinGCbsY02MMFnK3WxJmKuBwKhSWE3xXOok XV9pwN7AktzVcKH6mi14OKkRM6Br23Qewu2PvlIPtflUUYAyONazKQEVn7Ez/jsO 9Z+/IhbD8G9aUTi3k0jQ5U4l09odtfmOb32Sbj17MG14kCSLL+utnFIIMSQ== Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 49v08pn6eq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Wed, 22 Oct 2025 14:34:02 +0000 (GMT) Received: by mail-qt1-f198.google.com with SMTP id d75a77b69052e-4e89f4a502cso35835731cf.2 for ; Wed, 22 Oct 2025 07:34:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761143642; x=1761748442; 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=QX+/j6ug5BpZFxeqiWYjDUw7viVbs6iAE/eqbzDRJuU=; b=M5m6dFJOxZFIEZWipCuDl98jiVTka2CJBMzKSot/LfFCb33a1gMFbIfI1Bd2qPlNtS z3fefiHdAc1ISBhrBLfZ75/klIjBtvTHA2xxyME28LrU6LG3RSdE0xrWbdW65lw7upgc NHRtfm9NJW5tZLNbh8OPUxCadLkEuh30K4GwxyPZ47k1mBVikPva90HCT7FJ7V4W4GqU QnTAW/BHdPR72Y2xGK0XsHywDJZfAuXVRHEz2uivoaLeKDE5sEaWjUxzIzLGaOCjoTct RbXI2B8e4DdYnUKZY+em9fd0mwlufwyor+Hf8RfYZ+zH1DJJd3hdd91D0Ru9cC0rfMF1 8XUQ== X-Forwarded-Encrypted: i=1; AJvYcCVgCbVnS0ZNxWtgecvpGPUPu611K1+s8exX4+hku0gou/8lkA6ihy5Ym3FDwQYhQixuSdQlIqMq3UyhxtI=@vger.kernel.org X-Gm-Message-State: AOJu0Yze3zCvSRKEuEG2KMYdokJpoTmM52gY/ch8Bi5JdOo4xF0Tly3L S/Ff6AXW+JOHEuk+MhbP8IDRWpG0OqjPqPJVOHfgHnb9gXOddcuNXG81wv2EoGSWM0p6aGFOtC2 Lpl5hsW86/dE3Qbd8wPsGOGzklpU3Ydl6fpW9J3Az2jjr1W7kQoW9a9IuSSsq2kYNvN4= X-Gm-Gg: ASbGncuqM2745eJ1GoC5qbl5UNx86O5gpsLZLSfCg262zhOqpKgZE81INGuuyZlF4+8 A/wrw/OWyLx6uqbpRiUJ4L5RxbSUZVRievixtyl6baLteWpQeOVmFFaucUUiIWrthv2m/aI5vBQ WF7NQvzHgpQu6tsPSWZt9iXsZS2fhoH5uXfAqrFggf7rsl3lghi4SnHOxBS6KskR2YULgR1erbM N57bgLFbE7C7Nduepqpf8xioQApZMZqYlxNhyCAf10HLYeVHs8MNIBkZNMtJIWel7x2U618ug4f NrjxltbozJYuJT/dadekuoO5cbaVH0AoNNnzjpwZI6rSIOXlNxw7aovm0XXng79YhdrMe82YKbv fxN6+Wou5cEIt X-Received: by 2002:ac8:598b:0:b0:4e5:6cf8:289 with SMTP id d75a77b69052e-4e89d29bab9mr248332541cf.29.1761143641953; Wed, 22 Oct 2025 07:34:01 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGZXiC6dm1aJzPYIm80nJKiwk9U83kUHT9S3LNgQ5bVxeCwtXipr7lRzWEi+/7qed69ffam1w== X-Received: by 2002:ac8:598b:0:b0:4e5:6cf8:289 with SMTP id d75a77b69052e-4e89d29bab9mr248331991cf.29.1761143641431; Wed, 22 Oct 2025 07:34:01 -0700 (PDT) Received: from debian ([5.133.47.210]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-427f009a993sm25544910f8f.24.2025.10.22.07.34.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Oct 2025 07:34:01 -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, Steev Klimaszewski Subject: [PATCH v3 1/4] ASoC: qcom: sdw: fix memory leak for sdw_stream_runtime Date: Wed, 22 Oct 2025 15:33:46 +0100 Message-ID: <20251022143349.1081513-2-srinivas.kandagatla@oss.qualcomm.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251022143349.1081513-1-srinivas.kandagatla@oss.qualcomm.com> References: <20251022143349.1081513-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: AW1haW4tMjUxMDE4MDAwMCBTYWx0ZWRfXzpEAFMPWqNji Xjwy3IAciA1sbQ3rEYzPr6soOongiezF8tr+q3fBfSbWJ+ABJy2sGJmLjtYdfN3ptlbYeYQOhNf G+VP++Cpn9FOACeAUrCCBclDPYOln3OOOvjaBxuoncWtJwXpSCWFlZ9gSJfYJ8/aT1rhPmiDXEN udQshtndkvflVhtUMOPAXnp3Zeha90e5aLfwS+cPlyMJ1CpDHn6o685i4pj1jjAsxJkAx3WDZrD o8e098T4ToOpRb8hcnJB1QsXyyuX76BV9dGHxedYzKKMxiGiHZRko4/HjjnPKpJ96rOFSWxveba tLeIZ6RCoRpdvNIzGuhTUE/uBEi7uo8JQEFXoUwJWGYGZQQROBCa90fXMD5Gkm2d4eq3F08+bpl yiVDbqjrJZYAoBtHcWnOCKoDURpJcw== X-Proofpoint-GUID: 9udKwx1dqgGhgcfnoGLFwZSWI_FH4vHA X-Authority-Analysis: v=2.4 cv=Up1u9uwB c=1 sm=1 tr=0 ts=68f8eb5a cx=c_pps a=mPf7EqFMSY9/WdsSgAYMbA==:117 a=ZsC4DHZuhs/kKio7QBcDoQ==:17 a=x6icFKpwvdMA:10 a=VkNPw1HP01LnGYTKEx00:22 a=KKAkSRfTAAAA:8 a=VwQbUJbxAAAA:8 a=EUspDBNiAAAA:8 a=pGLkceISAAAA:8 a=N47DpUgmF8P8R7KZyx8A:9 a=dawVfQjAaf238kedN5IG:22 a=cvBusfyB2V15izCimMoJ:22 X-Proofpoint-ORIG-GUID: 9udKwx1dqgGhgcfnoGLFwZSWI_FH4vHA 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-22_06,2025-10-13_01,2025-03-28_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 adultscore=0 suspectscore=0 malwarescore=0 clxscore=1015 impostorscore=0 bulkscore=0 priorityscore=1501 spamscore=0 phishscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2510020000 definitions=main-2510180000 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 Mon Feb 9 03:15:55 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 58BA234C9A4 for ; Wed, 22 Oct 2025 14:34:05 +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=1761143648; cv=none; b=TXZ/d6PUjf4vBSURKvzBKP9YX8y2dBY2PztOYDAVcQxTxc6/uZEVGZxWJGs3ugX1G8jC5iSyBw3FpDSH7l8v7MDAuafDaob+ZjytjLeDYbtJ+fiVHKLKlv9JInog9MQnLvY/LJwS6AO/GgHkl5BXq5hSF4LSDmUtFcof270Y3zk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761143648; c=relaxed/simple; bh=aOzzSQvUu2O5D1NhZxoqCv1Pu8jkho1TPDsFdKGqrVY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dQhUIqhHgZP1ulMAJXrIadQ4tyBPyyMS65aHXmKTArj+HQMWcB27eyvmVPOJdVJ6HXYEQyMfi41rkCU0DyzxFs5U1BN76lKJgGQ1Y+ghOnsooLRVs8a+N0a53ETOxHVsN7I8oQH+21z7tZkx+gWy3F9kHSq5HaG7qcoROwIRGg4= 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=ULxR1EnE; 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="ULxR1EnE" Received: from pps.filterd (m0279871.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 59MBe5MZ029822 for ; Wed, 22 Oct 2025 14:34:04 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=tt1tRxJzz9y kCOmzfidVBNfag/M4e8YRcu9Y0ig1KZ8=; b=ULxR1EnEz3XALQpDgOHrTa21vf8 1Us42ElgjTZXgmj8KBMQOwmbl7ke2ZiPYH+aAFssTw6Fd07LjfvDG78BFPQBs5U0 k2BADxc6Q8KmdBIwqhd/SqKd2Nttw7Bx+4YwZajB05hLNEvL337ercPkBq8h6PrG i1ba/c9MEmEnulBzg+ivuGpmt04niBjtd66sNkqMtVdoqTnyapm6PMcEkcitICmv tKS+EE5qExGiw1Dyx/QUHPGENWvM4aFeYVVpI4N2zyrRANmfmmDBB7tKNQmQVuuk nYvyzPBgxITWUXj4bBzt1Mt+l1fhM4w4eai8LEGllQID81/k4hiIVHZJmiw== Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 49v2ge4x1c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Wed, 22 Oct 2025 14:34:04 +0000 (GMT) Received: by mail-qt1-f197.google.com with SMTP id d75a77b69052e-4e8a3d0fb09so17712091cf.1 for ; Wed, 22 Oct 2025 07:34:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761143643; x=1761748443; 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=tt1tRxJzz9ykCOmzfidVBNfag/M4e8YRcu9Y0ig1KZ8=; b=GXjSDXMvcY4QxTrGWKbUKEMnKPoJjkVW2q5omlzanNXU5thUdMrXUgI08XfjG/JdBw hm1bLHCpjqv4st+frzKEZWuXrtWpBjIwTCdGwBp1mwKeJpUI4oMYkQWCgdb5nlDRj+XM ZY/BNKu2eZJ3Ak/cXEWOMek0kP3TlKIjP9xN/y0f4ZMuSxT0mANYuydMe1N4gXQ2Qgxv hGGP0jmD05n7mnVS4LTHvbIV4wZXY4BGDLNIOVftE9LCPJnqeqgQDgUcma16upHyfKsy hJw3byvVpmolBTxrIomb/DbCzwwIKhnoT7sKvSnFN2btSUPad5PEjqTCsq+Y1GDBNgCn v0zw== X-Forwarded-Encrypted: i=1; AJvYcCXwvy4chadf3eWtEuOzqi6b1gBpuLeTA9FvmkSBK7Xv3aTBIR0j0ziz+UTd2ol4z8P4hBRGFmUmopzek/o=@vger.kernel.org X-Gm-Message-State: AOJu0YxjQuTvmBJNGoxi9t6+tn6/fRpYbKScjqzDhAYvbRLkkRnW2vLw Hn64N+fBEIVcOF8JlhByRdEh9DO7uTiShzChVG9NxJgRdo2QT/ZZwLPROQ3Nb55F0vQZpn4/0rh 3erZL6WQqs7icZsJrNzNwukO4Az5VL9M/anyL6cXMfYP7PdefW3AQX3p/r5RgI5W4jvw= X-Gm-Gg: ASbGncvOIHKvA9TtRjdTTeOEu744pBHDrfJX8bKnOUEQRctpPz604zC0EE/MnsixBk8 DxbdIHMS4qiq3Rk+eD1Xe6KpJOy6PsDKWHspgoqlxnckLLimFe+cs5KvpL8jIsRCoZGj9cY6Zhl 9WbYc1WnL3ExmZbe96bLPKL+XK7Vc6Qx4Q0gc6EAepFxpuIGYQmYUQLjF6g/+jX8c+h2KEqAloR Sf8SG+Wp6fEbXe4yTDmb72w3+wY2gXQA3fo7xUFb+NQR0K0K4Ed6qKTMR0Z/xHObzhN8sZNz6+e j8O4ATup9WcePvsjr6LPG/Z2vEQTkfc3C6nuoQ+Lr/NItAU3bfDkv36+4pvCNqLRIz0XpUYhaTX b+DZK46bTXrWH X-Received: by 2002:a05:622a:134a:b0:4e6:ef26:3152 with SMTP id d75a77b69052e-4e89d415399mr269121091cf.80.1761143643156; Wed, 22 Oct 2025 07:34:03 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH8Ohog4sO13eIB5GYi1WdYITJtgbxhmIZljiPYyETzVJdhdvKK1Z1JdxJ27Gt2pJLJCUyMlQ== X-Received: by 2002:a05:622a:134a:b0:4e6:ef26:3152 with SMTP id d75a77b69052e-4e89d415399mr269120481cf.80.1761143642465; Wed, 22 Oct 2025 07:34:02 -0700 (PDT) Received: from debian ([5.133.47.210]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-427f009a993sm25544910f8f.24.2025.10.22.07.34.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Oct 2025 07:34:01 -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 , Steev Klimaszewski Subject: [PATCH v3 2/4] ASoC: qcom: sdw: remove redundant code Date: Wed, 22 Oct 2025 15:33:47 +0100 Message-ID: <20251022143349.1081513-3-srinivas.kandagatla@oss.qualcomm.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251022143349.1081513-1-srinivas.kandagatla@oss.qualcomm.com> References: <20251022143349.1081513-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: AW1haW4tMjUxMDE4MDAyMCBTYWx0ZWRfXyAIfhkV2aRU0 BvSYQLo39DZxCsLwrsFpuKehhjoSbgJZuW0YNHQIkzIyJYxlGGpXypKwtHAWvKcC3CmMSyYreHx vaGqj4DMJyaxizmjGP0/A9faTY80tSHnYAyRkUk9iXsTwAAMiPhkvxSBFOo7CibBwvnM77a9u1X jXRpNeofhGM4YIxtGU05dmrM2NTPKtVaNwXEnFHbNgnGmXqIVNkK8vbP4PHVKiIlQbOrGbzHRyJ QT0dG1D2LjaK+6r8Hh3961jWnELDOqWWbg4YDhHQVph2iua8UR6i8IeTXG1gzkbqKr/QQmEEzOL +i+QKxdGo7Sr6gXioLcL5PyTodbAxxv/eny1eeWHoEW+XVBZMxKIhNO4dKiFMcPBOTqSYSgC8Cl 5I5DO4Cs/Q2j5YOPioTHB2JmIuYTCA== X-Authority-Analysis: v=2.4 cv=KqFAGGWN c=1 sm=1 tr=0 ts=68f8eb5c cx=c_pps a=EVbN6Ke/fEF3bsl7X48z0g==:117 a=ZsC4DHZuhs/kKio7QBcDoQ==:17 a=x6icFKpwvdMA:10 a=VkNPw1HP01LnGYTKEx00:22 a=EUspDBNiAAAA:8 a=pGLkceISAAAA:8 a=eS8ScSGqROhw0OgIVi4A:9 a=a_PwQJl-kcHnX1M80qC6:22 X-Proofpoint-GUID: DhiOW6IbYfuVNRudtuaQ4It-TGqGtK_- X-Proofpoint-ORIG-GUID: DhiOW6IbYfuVNRudtuaQ4It-TGqGtK_- 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-22_06,2025-10-13_01,2025-03-28_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 clxscore=1015 phishscore=0 malwarescore=0 impostorscore=0 lowpriorityscore=0 adultscore=0 priorityscore=1501 spamscore=0 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2510020000 definitions=main-2510180020 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 Tested-by: Steev Klimaszewski # Thinkpad X13s --- 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 Mon Feb 9 03:15:55 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 523DA34CFA0 for ; Wed, 22 Oct 2025 14:34:06 +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=1761143648; cv=none; b=I8JZMVv/NA1m7pKlHc0wBBdRzDDEsinz9y6Jp/9iuQb451Yv86s7IzJGUpexwShzpm3n01Rzhb4OWencBj+lpzKjxZG19No3bb5mHgB6Jt6lHPLPCiyyOOXHkeBQ+3DN8TWZN4QTNgyxyl80APiy5ZIA8L7cE3puE1feIxo0oXI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761143648; c=relaxed/simple; bh=N3ekUkk5r7V11hY0lO88UuCG6vkaZSYvwo4x85M1YwU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=j4aYitcDn+5yiwPdLLeGgTaoZsSzbzIzbGr+M8f1OuXz4j1tuU7z/o7jqHojEPvYMIcUxrI+Qy6Ni8Q1Dg35sU90UlumAy1k5ZwCV3PbBCOyZAJx24ZWnhywllnbjfJlW7Gi5HklrKIzvjQzlBN18yZcpM6RJtGvvKUn5Fbq00w= 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=kKXMumSK; 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="kKXMumSK" Received: from pps.filterd (m0279865.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 59MARjEJ001141 for ; Wed, 22 Oct 2025 14:34:05 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=LjQNhFIeUpf 5JssPbJ0qx1B6gPLm2FuVhAcXynJbBBc=; b=kKXMumSKlLkFbJhuPzeLE77hSlU gHup/Ffj5oRKkz2thtdUJsOpZRM0mpkusgfA/TasdirrHyrXEV5VYQE7LbWqMnZk qEmZNloGrMMNiFUL5dEFp/H7iBuvamFSTsHCjgZaVjPkL+a/oVUFIqP33At0pYYo dvNsZZKn1QCT/QGFo3PAQk52nSVfos0BrcQox5lwyo0s/tnWKZYP1sktePS1Wkmt pF/ANwuHd5XKLVvDLDRTYfUn1m5gZ/7DQioA2/tF+OPKGvACsHsy1//WL5pQPHIW T0H35PCncs5r9yaLQi1zeaZjCCXtco7YZn6G8lB82V6a69jAaVgaeAkrg5w== Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 49w08wak7j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Wed, 22 Oct 2025 14:34:05 +0000 (GMT) Received: by mail-qt1-f200.google.com with SMTP id d75a77b69052e-4e892f776d0so60535331cf.0 for ; Wed, 22 Oct 2025 07:34:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761143644; x=1761748444; 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=LjQNhFIeUpf5JssPbJ0qx1B6gPLm2FuVhAcXynJbBBc=; b=j9B4tEEZ1RttaUP0Mu/FzJ0g7+R9USHF9vfbpY2jH4gKCQYwggTGzFCkN1YkmlpHrK H9RhSx7t2siSgFn1zfuf+4LzUys1UZh7wqQjkJuyWdvNPCzSZcwGIeIG8VAleGbdsIlU 6LQ02DMl/mhfedJHOUuhWuVBy6zqiG0TPcKIN7o8J7DPhT2CPtMaeLjkLOboUnbVdxzV E/jv4k4gwuOYdtqs/JgIhNQ3ekR7ly+XO0FyhdkFveVir7ZJzAhi0aEV6sETSIaCaEKI FAzZ6s8+EEg8wa/Gq6Make4XwgUCcN7NbNoEHKyij9fLKaodDTUE1QETvIbfQkByiIRV nzqQ== X-Forwarded-Encrypted: i=1; AJvYcCUp3kpRsAMg2qXwYN/Huy4FeIN2+g76Z7FPCct+DIeOFCQh2qldbrI8acJVgmThTGHF0aZiRjW1ddNemXc=@vger.kernel.org X-Gm-Message-State: AOJu0YwPGifNLmmPtAGyogJXkcOcDGnCZ0Opbgi3/MlSGSserXuHyA9g Om4iDWgUHTRoI8SI6wwHMD0XxmE6uXugPyJch2iwoaPe5oD3BJfs8dmoRSySTvcpqmngCNIvuUz gkK+YzKZyPi3yHBMgPCduxwbUSMx8cjzZAMv3Yit4t7nI/uebD+OOfKk2wTTnvvC3fnQ= X-Gm-Gg: ASbGncvYMlfnYYAB50ZtsqI/8li4Z0Y2Z/RYyJTN3WeKxZ4G2DpuauDcbb4aw9710xu udhKDJKl+fpLKkA6rnKpxqDEQp2x27ixYbV1udcc/Pstbst5ExVxUTxnYlalZetn0HpX3KbNLqx aXGqMeSV7JE4P00IyzKxEC4N19fbbvvTTx7iFsrmcL/pXHgoBegliDvyLbc0TofgbEMOOLG3FFC 79hPx7WXGwmmMnTC4xWdM6My6toLwg3FnWgy2Hk4nEPd+utBzetLRlv8JrDFE2joNAEv++jblhL f9SCg48XYP6sij9t2+U2G8D+xJkMOfRsSe3KNEwutaI8WhV7zVlgnhnESTgrG3fjY7Fuu3+Bp2H lNvboIu+O2Qsl X-Received: by 2002:a05:622a:18a1:b0:4e8:ae23:588 with SMTP id d75a77b69052e-4e8ae230a33mr206904511cf.71.1761143644013; Wed, 22 Oct 2025 07:34:04 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFUURiqf2ZbYCHQYkeUwniA0/msOMU8UfHS5MceRvgrYZgwzEArKHXJ3RTzXptD3Cba0FFXJg== X-Received: by 2002:a05:622a:18a1:b0:4e8:ae23:588 with SMTP id d75a77b69052e-4e8ae230a33mr206903991cf.71.1761143643611; Wed, 22 Oct 2025 07:34:03 -0700 (PDT) Received: from debian ([5.133.47.210]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-427f009a993sm25544910f8f.24.2025.10.22.07.34.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Oct 2025 07:34:03 -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 , Steev Klimaszewski Subject: [PATCH v3 3/4] ASoC: qcom: sdm845: make use of common helpers Date: Wed, 22 Oct 2025 15:33:48 +0100 Message-ID: <20251022143349.1081513-4-srinivas.kandagatla@oss.qualcomm.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251022143349.1081513-1-srinivas.kandagatla@oss.qualcomm.com> References: <20251022143349.1081513-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: LGBir4Np0EuuXFI4dnY_CTUwzK70Dbxu X-Proofpoint-GUID: LGBir4Np0EuuXFI4dnY_CTUwzK70Dbxu X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMDE5MDA5MCBTYWx0ZWRfX6c60XJkKybiB 3E+lLVyAOENIVaKAVMwtmCva732lFsTzzOV/u9RP24jwXD2OSE8BtZR3C7lUcUGh4JSWO7vovKO /xGcI7S3dtFOAFBR0b7ztcUcR4Makgkz/bTu7k/lJOB9WzDhJgG1jaMjsV0NpWg1/O5k7gwGK2W I2nj9SImJqslCg+gkmxcvLIw3kCQseVDPCZad5NbWrgK/KuFckrjsGmaLvfMAiknoyR67zbqLNH D4DJp7c1GLTbeGKx5nnrnGvolUF2jMRrw4cjJhj794Pf/PhSIJQZeAdjIUWFtMxad9U6qpoOxWJ vCBmNmyXYWD71gzzfmXdRGNRgTvrfvO+sqBTUyQtkugjNmHB9BP9dj7fxVj4PLeVCNJrIZR1VwS NtvmumbirJ3DvbhCtvh20mDlYGD8/g== X-Authority-Analysis: v=2.4 cv=V5NwEOni c=1 sm=1 tr=0 ts=68f8eb5d cx=c_pps a=JbAStetqSzwMeJznSMzCyw==:117 a=ZsC4DHZuhs/kKio7QBcDoQ==:17 a=x6icFKpwvdMA:10 a=VkNPw1HP01LnGYTKEx00:22 a=EUspDBNiAAAA:8 a=pGLkceISAAAA:8 a=5b0IN9Hzzi15MECZVvAA:9 a=uxP6HrT_eTzRwkO_Te1X: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-22_06,2025-10-13_01,2025-03-28_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 malwarescore=0 adultscore=0 priorityscore=1501 lowpriorityscore=0 spamscore=0 suspectscore=0 clxscore=1015 phishscore=0 impostorscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2510020000 definitions=main-2510190090 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 Tested-by: Steev Klimaszewski # Thinkpad X13s --- 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 Mon Feb 9 03:15:55 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 26D4B3502BA for ; Wed, 22 Oct 2025 14:34:07 +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=1761143650; cv=none; b=HFF3NNEoSqRpeOVn0KlfRjSGCQPkeCIRfjK8tuetZw/IFbAP4QkN9AFKF9y+c2fdzjoSBXyiZimQYr6F7mMrQ/ijoA7D/eu30zx4Kx4b7Uxf3nqXsU/oH5iK/LFZSKaLWvIuI7TNzBa+96f/6k6/A9JQhFtHYdzbnHuhxxrMh4w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761143650; c=relaxed/simple; bh=Bz5dNjnWGJ72zU9lpe8lIcLxT6Mivkx50DoKVMYTicc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=efkkq3jb1Ys1Nte/nLYku5PDPjHoufplMPSj7qFCMnBJ5HbA6jqOvM+khM7IvBR4Zj91GcJsxaNL8Gyr8YA2JvRMKVha1sRKXkJa5Rrcz7Y5q5UPolUZf7MSPvJj9hfPS4KBdr169NtLdgYmpNp1zFF7alwkRHL30FN8pb1t2KM= 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=govKmZyy; 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="govKmZyy" Received: from pps.filterd (m0279862.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 59M9wEp3004550 for ; Wed, 22 Oct 2025 14:34:07 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=faQIz8fSwdO oA7CWAkNGtjSmqzRzKQ9HbO9f6ZOpKX8=; b=govKmZyybdeQGQigfBY6KIPoEXT pvMs2zdjtmwwitWHXIWAlpJpgJ2zcn2u2lmB0cFVBE2B0a8m7l9GzB7eZmDgNQ/m NYr/2ZixueYVufsrA9V65Sgow5Nas/VZwky7SI6IFMQYlTReh1TXJ14eoziEeDrU ooG6FtSufXQC3rWcxguvhiyAcd0kp13InCN6N/Me+H5SDMpTDbAnhJSFhj2OhG71 1Q4tSApkDvjavwti/vRaPsXQp40sLgdPjTcU6dA3r+UMt1wXByJEJHfx7qdkZz8D lqKXsu3pk6By/m/l5X54gQIY7zzR++Q5nlkTR7KZOe7R3Fybbtp7pUjXViQ== Received: from mail-qt1-f199.google.com (mail-qt1-f199.google.com [209.85.160.199]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 49v3nfmwv8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Wed, 22 Oct 2025 14:34:07 +0000 (GMT) Received: by mail-qt1-f199.google.com with SMTP id d75a77b69052e-4e8b8db4a35so32082251cf.1 for ; Wed, 22 Oct 2025 07:34:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761143646; x=1761748446; 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=faQIz8fSwdOoA7CWAkNGtjSmqzRzKQ9HbO9f6ZOpKX8=; b=JjRrNmxU5NsFOLsaomWFqs2Yj0bmmn7WYzQ36D0FCf2VZ9ToBXPswDRnDymN3s2BsT C+uBJJsmShA3jJWa4aaiMLQT9I5eMmbUpW7RxF6y/q5u9Isdzw19yjgYZ03dOpjgY/3G gdGQ836sAYYM+M2TH7l2SmOnG2YmNczWoH9bWZzCysN2805ljSYaUzVRYjd9XqCiX5F6 MpvYl7amEQ2aQhejqxGT4QbaSPg0JPqSAIeuJEG86JymwvwWcgTdHV//4P+ga68mCpZn rkwUYXqrHqf+20z/0UERL3VFAzs1D16rDGyKyFkNcd1xoE8CoE+4SCAEPVBt4NB3wKS3 vEdw== X-Forwarded-Encrypted: i=1; AJvYcCU3wVFomRXiLd1OUTaJ3/rLUCv2M/sbnj7aw8Shehj0HXqusiqTROmJX3+dXqmgXx5b3AJNNabxbyt43Qw=@vger.kernel.org X-Gm-Message-State: AOJu0Yy9A4G7RRQS9xeSEVCl40gPePl5X268wLyXSXL3NKEuT2nWviDk THXljRZDwaqMPv1Mh364YZZDa+ZyORQ4/EU/0cQPLtsHUdIBphm+qb6Ij5930AIFabE4P2zFiDM 2aATM3SYBCQUbghGhBykJeHkxpS0tnNcWLIqTe+780H5V4mMy56dNczYqR/RHR30tGVQ= X-Gm-Gg: ASbGnctkpm2O/qYhu0zPdJi42Hk4waAt7v+mVvK06FxzFtAFvJgfziTBeU5bThSIt6i /BnLz94qSE7lEOOij8bNWg5y2wnZBg2r1HX34Oqfm8/rcPfOI5t88lh3byijUzAYdjM22D35rWj NWedxFDl6C/5oNV+SW83nMBlgqG12yskJTrPpdjRww8Ou8D/RdUpAuIlkBRByCH/YOtnZDh9dvY ahc4O+4bCGhGCIn4LeQgO6yO5/mGGo1zjrpsGflEM62NAYLyxUGPmlbsOMdbfmQXmY3mVGjrzVD rVsh+Xi5Lv2wBH4nvc7fBYAtrB62TIB8JBwN1Qv72Z8IOKFrDWHmUIcahcfio1PHrCTBivLwIdI 17NXm+re4Y/wC X-Received: by 2002:ac8:7e88:0:b0:4eb:7669:6b91 with SMTP id d75a77b69052e-4eb76697856mr32466041cf.16.1761143645356; Wed, 22 Oct 2025 07:34:05 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGDK7D29Zp1dC9C3t8n2L6JThatH0XLulfavnkHZNj4oocbfOoVQymObbxt5nwrjNWlrqFgpA== X-Received: by 2002:ac8:7e88:0:b0:4eb:7669:6b91 with SMTP id d75a77b69052e-4eb76697856mr32465241cf.16.1761143644735; Wed, 22 Oct 2025 07:34:04 -0700 (PDT) Received: from debian ([5.133.47.210]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-427f009a993sm25544910f8f.24.2025.10.22.07.34.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Oct 2025 07:34:04 -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 , Steev Klimaszewski Subject: [PATCH v3 4/4] ASoC: qcom: sc7280: make use of common helpers Date: Wed, 22 Oct 2025 15:33:49 +0100 Message-ID: <20251022143349.1081513-5-srinivas.kandagatla@oss.qualcomm.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251022143349.1081513-1-srinivas.kandagatla@oss.qualcomm.com> References: <20251022143349.1081513-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: mE1o59DiTa_zcHsppt1VqwW3hNArG_31 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMDE4MDAyNyBTYWx0ZWRfX71+ck9BDWVlW w5aQX+GV9Y4Up18s5HRM7nD0zrjHmC07lcUhn2fHbHYnD2smDQW+1971wHJWwzonwckSAF88uT0 Ddh/v94w/2DwGNETAazdReZ6smniCeMvEgIC0dDhgBWkj6lFpITnVhLUapMPRtpIrt2WftVKTga km95SwS+vAa8OZ13yaV1Z1B8BTOxemZ7Jxdg3ncgxzXCrThI23OvN6CPegJExAdiH/hFrjL4MV1 e5djfDlkqDiSx4e0WsBWHThU1MFdysJ2TihMyFEQQhVmbcX4CMgN+vFkuPuHTsEu3fPE3lALKpO vA0HFwXFrkYiBonUiQ1K1Q4BsNAjlYxJXGwVrCWEdL1fGX8U0EtEB7oZfk88SoJmMOwwKkrbXYZ 7/3iD/ZOVzWqNvltRq17OtGYLCmmaA== X-Proofpoint-GUID: mE1o59DiTa_zcHsppt1VqwW3hNArG_31 X-Authority-Analysis: v=2.4 cv=EYjFgfmC c=1 sm=1 tr=0 ts=68f8eb5f cx=c_pps a=WeENfcodrlLV9YRTxbY/uA==:117 a=ZsC4DHZuhs/kKio7QBcDoQ==:17 a=x6icFKpwvdMA:10 a=VkNPw1HP01LnGYTKEx00:22 a=EUspDBNiAAAA:8 a=pGLkceISAAAA:8 a=xzVSZQTBi2W_vW4HIIQA:9 a=kacYvNCVWA4VmyqE58fU: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-22_06,2025-10-13_01,2025-03-28_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 clxscore=1015 spamscore=0 malwarescore=0 lowpriorityscore=0 priorityscore=1501 impostorscore=0 phishscore=0 adultscore=0 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2510020000 definitions=main-2510180027 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 Tested-by: Steev Klimaszewski # Thinkpad X13s --- sound/soc/qcom/sc7280.c | 67 ++--------------------------------------- sound/soc/qcom/sdw.c | 11 +++++++ 2 files changed, 14 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..6576b47a4c8c 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 @@ -35,6 +36,16 @@ static bool qcom_snd_is_sdw_dai(int id) break; } =20 + /* 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; + } + return false; } =20 --=20 2.51.0