* [PATCH v3] ASoC: fsl_sai: Force a software reset when starting in consumer mode
@ 2025-06-26 11:52 Arun Raghavan
2025-06-26 11:58 ` Fabio Estevam
0 siblings, 1 reply; 4+ messages in thread
From: Arun Raghavan @ 2025-06-26 11:52 UTC (permalink / raw)
To: Shengjiu Wang, Xiubo Li
Cc: Fabio Estevam, Nicolin Chen, Liam Girdwood, Mark Brown,
Jaroslav Kysela, Takashi Iwai, Pieterjan Camerlynck, linux-sound,
linuxppc-dev, linux-kernel, Arun Raghavan
From: Arun Raghavan <arun@asymptotic.io>
On an imx8mm platform with an external clock provider, when running the
receiver (arecord) and triggering an xrun with xrun_injection, we see a
channel swap/offset. This happens sometimes when running only the
receiver, but occurs reliably if a transmitter (aplay) is also
concurrently running.
It seems that the SAI loses track of frame sync during the trigger stop
-> trigger start cycle that occurs during an xrun. Doing just a FIFO
reset in this case does not suffice, and only a software reset seems to
get it back on track.
This looks like the same h/w bug that is already handled for the
producer case, so we now do the reset unconditionally on config disable.
Signed-off-by: Arun Raghavan <arun@asymptotic.io>
Reported-by: Pieterjan Camerlynck <p.camerlynck@televic.com>
---
v3
- Incorporate feedback from Shengjiu Wang to consolidate with the
existing handling of this issue in producer mode
sound/soc/fsl/fsl_sai.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/sound/soc/fsl/fsl_sai.c b/sound/soc/fsl/fsl_sai.c
index af1a168d35e3..50af6b725670 100644
--- a/sound/soc/fsl/fsl_sai.c
+++ b/sound/soc/fsl/fsl_sai.c
@@ -803,13 +803,15 @@ static void fsl_sai_config_disable(struct fsl_sai *sai, int dir)
* anymore. Add software reset to fix this issue.
* This is a hardware bug, and will be fix in the
* next sai version.
+ *
+ * In consumer mode, this can happen even after a
+ * single open/close, especially if both tx and rx
+ * are running concurrently.
*/
- if (!sai->is_consumer_mode[tx]) {
- /* Software Reset */
- regmap_write(sai->regmap, FSL_SAI_xCSR(tx, ofs), FSL_SAI_CSR_SR);
- /* Clear SR bit to finish the reset */
- regmap_write(sai->regmap, FSL_SAI_xCSR(tx, ofs), 0);
- }
+ /* Software Reset */
+ regmap_write(sai->regmap, FSL_SAI_xCSR(tx, ofs), FSL_SAI_CSR_SR);
+ /* Clear SR bit to finish the reset */
+ regmap_write(sai->regmap, FSL_SAI_xCSR(tx, ofs), 0);
}
static int fsl_sai_trigger(struct snd_pcm_substream *substream, int cmd,
--
2.49.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v3] ASoC: fsl_sai: Force a software reset when starting in consumer mode
2025-06-26 11:52 [PATCH v3] ASoC: fsl_sai: Force a software reset when starting in consumer mode Arun Raghavan
@ 2025-06-26 11:58 ` Fabio Estevam
2025-06-26 12:27 ` Arun Raghavan
0 siblings, 1 reply; 4+ messages in thread
From: Fabio Estevam @ 2025-06-26 11:58 UTC (permalink / raw)
To: Arun Raghavan
Cc: Shengjiu Wang, Xiubo Li, Nicolin Chen, Liam Girdwood, Mark Brown,
Jaroslav Kysela, Takashi Iwai, Pieterjan Camerlynck, linux-sound,
linuxppc-dev, linux-kernel, Arun Raghavan
Hi Arun,
On Thu, Jun 26, 2025 at 8:52 AM Arun Raghavan <arun@arunraghavan.net> wrote:
>
> From: Arun Raghavan <arun@asymptotic.io>
>
> On an imx8mm platform with an external clock provider, when running the
> receiver (arecord) and triggering an xrun with xrun_injection, we see a
> channel swap/offset. This happens sometimes when running only the
> receiver, but occurs reliably if a transmitter (aplay) is also
> concurrently running.
>
> It seems that the SAI loses track of frame sync during the trigger stop
> -> trigger start cycle that occurs during an xrun. Doing just a FIFO
> reset in this case does not suffice, and only a software reset seems to
> get it back on track.
>
> This looks like the same h/w bug that is already handled for the
> producer case, so we now do the reset unconditionally on config disable.
>
> Signed-off-by: Arun Raghavan <arun@asymptotic.io>
> Reported-by: Pieterjan Camerlynck <p.camerlynck@televic.com>
What about adding a Fixes tag and Cc stable so that it gets backported
to the stable trees?
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v3] ASoC: fsl_sai: Force a software reset when starting in consumer mode
2025-06-26 11:58 ` Fabio Estevam
@ 2025-06-26 12:27 ` Arun Raghavan
2025-06-26 12:51 ` Fabio Estevam
0 siblings, 1 reply; 4+ messages in thread
From: Arun Raghavan @ 2025-06-26 12:27 UTC (permalink / raw)
To: Fabio Estevam
Cc: Shengjiu Wang, Xiubo Li, Nicolin Chen, Liam Girdwood, Mark Brown,
Jaroslav Kysela, Takashi Iwai, Pieterjan Camerlynck, linux-sound,
linuxppc-dev, linux-kernel, Arun Raghavan
On Thu, 26 Jun 2025, at 7:58 AM, Fabio Estevam wrote:
> Hi Arun,
>
> On Thu, Jun 26, 2025 at 8:52 AM Arun Raghavan
> <arun@arunraghavan.net> wrote:
>>
>> From: Arun Raghavan <arun@asymptotic.io>
>>
>> On an imx8mm platform with an external clock provider, when running
>> the receiver (arecord) and triggering an xrun with xrun_injection, we
>> see a channel swap/offset. This happens sometimes when running only
>> the receiver, but occurs reliably if a transmitter (aplay) is also
>> concurrently running.
>>
>> It seems that the SAI loses track of frame sync during the trigger
>> stop -> trigger start cycle that occurs during an xrun. Doing just a
>> FIFO reset in this case does not suffice, and only a software reset
>> seems to get it back on track.
>>
>> This looks like the same h/w bug that is already handled for the
>> producer case, so we now do the reset unconditionally on config
>> disable.
>>
>> Signed-off-by: Arun Raghavan <arun@asymptotic.io> Reported-by:
>> Pieterjan Camerlynck <p.camerlynck@televic.com>
>
> What about adding a Fixes tag and Cc stable so that it gets backported
> to the stable trees?
Sure! Will send in a v4 with both of these.
The commit that added the initial fix (3e3f8bd56955 ("ASoC: fsl_sai: fix
no frame clk in master mode")) refers to an errata, but I could find
anything in a couple of imx8* errata I checked.
I was wondering if there's any public documentation of this that I can
refer (and link) to?
Cheers,
Arun
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v3] ASoC: fsl_sai: Force a software reset when starting in consumer mode
2025-06-26 12:27 ` Arun Raghavan
@ 2025-06-26 12:51 ` Fabio Estevam
0 siblings, 0 replies; 4+ messages in thread
From: Fabio Estevam @ 2025-06-26 12:51 UTC (permalink / raw)
To: Arun Raghavan
Cc: Shengjiu Wang, Xiubo Li, Nicolin Chen, Liam Girdwood, Mark Brown,
Jaroslav Kysela, Takashi Iwai, Pieterjan Camerlynck, linux-sound,
linuxppc-dev, linux-kernel, Arun Raghavan
On Thu, Jun 26, 2025 at 9:28 AM Arun Raghavan <arun@arunraghavan.net> wrote:
> Sure! Will send in a v4 with both of these.
>
> The commit that added the initial fix (3e3f8bd56955 ("ASoC: fsl_sai: fix
> no frame clk in master mode")) refers to an errata, but I could find
> anything in a couple of imx8* errata I checked.
>
> I was wondering if there's any public documentation of this that I can
> refer (and link) to?
I'm not aware of any public errata for this issue.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-06-26 12:51 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-06-26 11:52 [PATCH v3] ASoC: fsl_sai: Force a software reset when starting in consumer mode Arun Raghavan
2025-06-26 11:58 ` Fabio Estevam
2025-06-26 12:27 ` Arun Raghavan
2025-06-26 12:51 ` Fabio Estevam
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®