Skip to content

Commit dd1b1fb

Browse files
krzkgregkh
authored andcommitted
ASoC: qcom: sc7280: Fix missing Soundwire runtime stream alloc
commit db7e59e upstream. Commit 15c7fab ("ASoC: qcom: Move Soundwire runtime stream alloc to soundcards") moved the allocation of Soundwire stream runtime from the Qualcomm Soundwire driver to each individual machine sound card driver, except that it forgot to update SC7280 card. Just like for other Qualcomm sound cards using Soundwire, the card driver should allocate and release the runtime. Otherwise sound playback will result in a NULL pointer dereference or other effect of uninitialized memory accesses (which was confirmed on SDM845 having similar issue). Cc: stable@vger.kernel.org Cc: Alexey Klimov <alexey.klimov@linaro.org> Cc: Steev Klimaszewski <steev@kali.org> Fixes: 15c7fab ("ASoC: qcom: Move Soundwire runtime stream alloc to soundcards") Link: https://lore.kernel.org/r/20241010054109.16938-1-krzysztof.kozlowski@linaro.org Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> Link: https://patch.msgid.link/20241012101108.129476-1-krzysztof.kozlowski@linaro.org Signed-off-by: Mark Brown <broonie@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 281bf02 commit dd1b1fb

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

sound/soc/qcom/Kconfig

+1
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ config SND_SOC_SC7280
208208
tristate "SoC Machine driver for SC7280 boards"
209209
depends on I2C && SOUNDWIRE
210210
select SND_SOC_QCOM_COMMON
211+
select SND_SOC_QCOM_SDW
211212
select SND_SOC_LPASS_SC7280
212213
select SND_SOC_MAX98357A
213214
select SND_SOC_WCD938X_SDW

sound/soc/qcom/sc7280.c

+9-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "common.h"
2424
#include "lpass.h"
2525
#include "qdsp6/q6afe.h"
26+
#include "sdw.h"
2627

2728
#define DEFAULT_MCLK_RATE 19200000
2829
#define RT5682_PLL_FREQ (48000 * 512)
@@ -316,6 +317,7 @@ static void sc7280_snd_shutdown(struct snd_pcm_substream *substream)
316317
struct snd_soc_card *card = rtd->card;
317318
struct sc7280_snd_data *data = snd_soc_card_get_drvdata(card);
318319
struct snd_soc_dai *cpu_dai = snd_soc_rtd_to_cpu(rtd, 0);
320+
struct sdw_stream_runtime *sruntime = data->sruntime[cpu_dai->id];
319321

320322
switch (cpu_dai->id) {
321323
case MI2S_PRIMARY:
@@ -333,6 +335,9 @@ static void sc7280_snd_shutdown(struct snd_pcm_substream *substream)
333335
default:
334336
break;
335337
}
338+
339+
data->sruntime[cpu_dai->id] = NULL;
340+
sdw_release_stream(sruntime);
336341
}
337342

338343
static int sc7280_snd_startup(struct snd_pcm_substream *substream)
@@ -347,6 +352,8 @@ static int sc7280_snd_startup(struct snd_pcm_substream *substream)
347352
switch (cpu_dai->id) {
348353
case MI2S_PRIMARY:
349354
ret = sc7280_rt5682_init(rtd);
355+
if (ret)
356+
return ret;
350357
break;
351358
case SECONDARY_MI2S_RX:
352359
codec_dai_fmt |= SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_I2S;
@@ -360,7 +367,8 @@ static int sc7280_snd_startup(struct snd_pcm_substream *substream)
360367
default:
361368
break;
362369
}
363-
return ret;
370+
371+
return qcom_snd_sdw_startup(substream);
364372
}
365373

366374
static const struct snd_soc_ops sc7280_ops = {

0 commit comments

Comments
 (0)