2023-07-13 10:08:05

by Peter Suti

[permalink] [raw]
Subject: [RFC PATCH] ASoC: soc-dai: don't call PCM audio ops if the stream is not supported

PCM audio ops may be called when the stream is not supported.
We should not call the ops in that case to avoid unexpected behavior.

hw_params is handled already in soc-pcm.c

[0] https://lore.kernel.org/alsa-devel/[email protected]/T/#t

Signed-off-by: Peter Suti <[email protected]>
---
Tested on 6.1 Compile tested on next/master
sound/soc/soc-dai.c | 11 +++++++++++
1 file changed, 11 insertions(+)

diff --git a/sound/soc/soc-dai.c b/sound/soc/soc-dai.c
index 02dd64dea179..73a97ac6ccb8 100644
--- a/sound/soc/soc-dai.c
+++ b/sound/soc/soc-dai.c
@@ -424,6 +424,9 @@ int snd_soc_dai_startup(struct snd_soc_dai *dai,
{
int ret = 0;

+ if (!snd_soc_dai_stream_valid(dai, substream->stream))
+ return 0;
+
if (dai->driver->ops &&
dai->driver->ops->startup)
ret = dai->driver->ops->startup(substream, dai);
@@ -439,6 +442,9 @@ void snd_soc_dai_shutdown(struct snd_soc_dai *dai,
struct snd_pcm_substream *substream,
int rollback)
{
+ if (!snd_soc_dai_stream_valid(dai, substream->stream))
+ return;
+
if (rollback && !soc_dai_mark_match(dai, substream, startup))
return;

@@ -603,6 +609,8 @@ int snd_soc_pcm_dai_prepare(struct snd_pcm_substream *substream)
int i, ret;

for_each_rtd_dais(rtd, i, dai) {
+ if (!snd_soc_dai_stream_valid(dai, substream->stream))
+ continue;
if (dai->driver->ops &&
dai->driver->ops->prepare) {
ret = dai->driver->ops->prepare(substream, dai);
@@ -619,6 +627,9 @@ static int soc_dai_trigger(struct snd_soc_dai *dai,
{
int ret = 0;

+ if (!snd_soc_dai_stream_valid(dai, substream->stream))
+ return 0;
+
if (dai->driver->ops &&
dai->driver->ops->trigger)
ret = dai->driver->ops->trigger(substream, cmd, dai);
--
2.34.1



2023-07-25 17:24:38

by Mark Brown

[permalink] [raw]
Subject: Re: [RFC PATCH] ASoC: soc-dai: don't call PCM audio ops if the stream is not supported

On Thu, 13 Jul 2023 11:52:58 +0200, Peter Suti wrote:
> PCM audio ops may be called when the stream is not supported.
> We should not call the ops in that case to avoid unexpected behavior.
>
> hw_params is handled already in soc-pcm.c
>
> [0] https://lore.kernel.org/alsa-devel/[email protected]/T/#t
>
> [...]

Applied to

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

Thanks!

[1/1] ASoC: soc-dai: don't call PCM audio ops if the stream is not supported
commit: 4005d1ba0a7e5cf32f669bf0014dca0dd12c2a44

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark