Patch "ASoC: soc-pcm: test if a BE can be prepared" has been added to the 5.15-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    ASoC: soc-pcm: test if a BE can be prepared

to the 5.15-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     asoc-soc-pcm-test-if-a-be-can-be-prepared.patch
and it can be found in the queue-5.15 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit fe5b21d5745653ff5c9732a6b60212e40a921163
Author: Ranjani Sridharan <ranjani.sridharan@xxxxxxxxxxxxxxx>
Date:   Wed May 17 13:57:31 2023 -0500

    ASoC: soc-pcm: test if a BE can be prepared
    
    [ Upstream commit e123036be377ddf628226a7c6d4f9af5efd113d3 ]
    
    In the BE hw_params configuration, the existing code checks if any of the
    existing FEs are prepared, running, paused or suspended - and skips the
    configuration in those cases. This allows multiple calls of hw_params
    which the ALSA state machine supports.
    
    This check is not handled for the prepare stage, which can lead to the
    same BE being prepared multiple times. This patch adds a check similar to
    that of the hw_params, with the main difference being that the suspended
    state is allowed: the ALSA state machine allows a transition from
    suspended to prepared with hw_params skipped.
    
    This problem was detected on Intel IPC4/SoundWire devices, where the BE
    dailink .prepare stage is used to configure the SoundWire stream with a
    bank switch. Multiple .prepare calls lead to conflicts with the .trigger
    operation with IPC4 configurations. This problem was not detected earlier
    on Intel devices, HDaudio BE dailinks detect that the link is already
    prepared and skip the configuration, and for IPC3 devices there is no BE
    trigger.
    
    Link: https://github.com/thesofproject/sof/issues/7596
    Signed-off-by: Ranjani Sridharan <ranjani.sridharan@xxxxxxxxxxxxxxx
    Signed-off-by: Bard Liao <yung-chuan.liao@xxxxxxxxxxxxxxx
    Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@xxxxxxxxxxxxxxx
    Link: https://lore.kernel.org/r/20230517185731.487124-1-pierre-louis.bossart@xxxxxxxxxxxxxxx
    Signed-off-by: Mark Brown <broonie@xxxxxxxxxx
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/include/sound/soc-dpcm.h b/include/sound/soc-dpcm.h
index d963f3b608489..4bb3ebfdaa45e 100644
--- a/include/sound/soc-dpcm.h
+++ b/include/sound/soc-dpcm.h
@@ -123,6 +123,10 @@ int snd_soc_dpcm_can_be_free_stop(struct snd_soc_pcm_runtime *fe,
 int snd_soc_dpcm_can_be_params(struct snd_soc_pcm_runtime *fe,
 		struct snd_soc_pcm_runtime *be, int stream);
 
+/* can this BE perform prepare */
+int snd_soc_dpcm_can_be_prepared(struct snd_soc_pcm_runtime *fe,
+				 struct snd_soc_pcm_runtime *be, int stream);
+
 /* is the current PCM operation for this FE ? */
 int snd_soc_dpcm_fe_can_update(struct snd_soc_pcm_runtime *fe, int stream);
 
diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
index 76c807372ef50..6ec248778e2fc 100644
--- a/sound/soc/soc-pcm.c
+++ b/sound/soc/soc-pcm.c
@@ -2398,6 +2398,9 @@ int dpcm_be_dai_prepare(struct snd_soc_pcm_runtime *fe, int stream)
 		if (!snd_soc_dpcm_be_can_update(fe, be, stream))
 			continue;
 
+		if (!snd_soc_dpcm_can_be_prepared(fe, be, stream))
+			continue;
+
 		if ((be->dpcm[stream].state != SND_SOC_DPCM_STATE_HW_PARAMS) &&
 		    (be->dpcm[stream].state != SND_SOC_DPCM_STATE_STOP) &&
 		    (be->dpcm[stream].state != SND_SOC_DPCM_STATE_SUSPEND) &&
@@ -3047,3 +3050,20 @@ int snd_soc_dpcm_can_be_params(struct snd_soc_pcm_runtime *fe,
 	return snd_soc_dpcm_check_state(fe, be, stream, state, ARRAY_SIZE(state));
 }
 EXPORT_SYMBOL_GPL(snd_soc_dpcm_can_be_params);
+
+/*
+ * We can only prepare a BE DAI if any of it's FE are not prepared,
+ * running or paused for the specified stream direction.
+ */
+int snd_soc_dpcm_can_be_prepared(struct snd_soc_pcm_runtime *fe,
+				 struct snd_soc_pcm_runtime *be, int stream)
+{
+	const enum snd_soc_dpcm_state state[] = {
+		SND_SOC_DPCM_STATE_START,
+		SND_SOC_DPCM_STATE_PAUSED,
+		SND_SOC_DPCM_STATE_PREPARE,
+	};
+
+	return snd_soc_dpcm_check_state(fe, be, stream, state, ARRAY_SIZE(state));
+}
+EXPORT_SYMBOL_GPL(snd_soc_dpcm_can_be_prepared);



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux