Sound/ARM/i.MX/SSI: fix SDMA starvation
Subsystems (3)
In cases when capturing is already running and someone enables also playback, the SDMA unit of the i.MX SoC does not see an edge on its TX DMA request line. This is due to the TX FIFOs are empty, and this request line is active all the time, when the CCSR_SSI_SIER_TDMAE bit is set.
In this case also the TX FIFO underrun interrupt will flood the system forever.
To ensure the first edge happens after enabling the TX side of the SSI unit and to trigger the SDMA unit successfully enable the CCSR_SSI_SIER_TDMAE on demand only. To be sure, this patch does the same for the CCSR_SSI_SIER_RDMAE (RX side) bit.
--- sound/soc/fsl/fsl_ssi.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-)
sound/soc/fsl/fsl_ssi.c +16 -8
@@ -86,10 +86,9 @@ static inline void write_ssi_mask(u32 __#endif /* SIER bitflag of interrupts to enable */ -#define SIER_FLAGS (CCSR_SSI_SIER_TFRC_EN | CCSR_SSI_SIER_TDMAE | \ - CCSR_SSI_SIER_TIE | CCSR_SSI_SIER_TUE0_EN | \ - CCSR_SSI_SIER_TUE1_EN | CCSR_SSI_SIER_RFRC_EN | \ - CCSR_SSI_SIER_RDMAE | CCSR_SSI_SIER_RIE | \ +#define SIER_FLAGS (CCSR_SSI_SIER_TFRC_EN | CCSR_SSI_SIER_TIE | \ + CCSR_SSI_SIER_TUE0_EN | CCSR_SSI_SIER_TUE1_EN | \ + CCSR_SSI_SIER_RFRC_EN | CCSR_SSI_SIER_RIE | \ CCSR_SSI_SIER_ROE0_EN | CCSR_SSI_SIER_ROE1_EN)/**
@@ -489,6 +488,9 @@ static int fsl_ssi_hw_params(struct snd_* * The DMA channel is in external master start and pause mode, which * means the SSI completely controls the flow of data. +* +* To use the i.MX's SDMA unit it is important to create an edge on the +* corresponding request line. Otherwise the request will be ignored! */ static int fsl_ssi_trigger (struct snd_pcm_substream *substream,int cmd,struct snd_soc_dai *dai)
@@ -500,20 +502,26 @@ static int fsl_ssi_trigger(struct snd_pcswitch (cmd) {case SNDRV_PCM_TRIGGER_START :case SNDRV_PCM_TRIGGER_PAUSE_RELEASE : -if (substream->stream ==SNDRV_PCM_STREAM_PLAYBACK ) +if (substream->stream ==SNDRV_PCM_STREAM_PLAYBACK ) {write_ssi_mask (&ssi->scr,0 ,CCSR_SSI_SCR_SSIEN |CCSR_SSI_SCR_TE ); -else +write_ssi_mask (&ssi->sier,0 ,CCSR_SSI_SIER_TDMAE ); + }else {write_ssi_mask (&ssi->scr,0 ,CCSR_SSI_SCR_SSIEN |CCSR_SSI_SCR_RE ); +write_ssi_mask (&ssi->sier,0 ,CCSR_SSI_SIER_RDMAE ); + }break ;case SNDRV_PCM_TRIGGER_STOP :case SNDRV_PCM_TRIGGER_PAUSE_PUSH : -if (substream->stream ==SNDRV_PCM_STREAM_PLAYBACK ) +if (substream->stream ==SNDRV_PCM_STREAM_PLAYBACK ) {write_ssi_mask (&ssi->scr,CCSR_SSI_SCR_TE ,0 ); -else +write_ssi_mask (&ssi->sier,CCSR_SSI_SIER_TDMAE ,0 ); + }else {write_ssi_mask (&ssi->scr,CCSR_SSI_SCR_RE ,0 ); +write_ssi_mask (&ssi->sier,CCSR_SSI_SIER_RDMAE ,0 ); + }break ;default :
Signature · 2 lines
Pengutronix e.K. | Juergen Beisert | Linux Solutions for Science and Industry | http://www.pengutronix.de/ |
Quoted 67 lines · Juergen Beisert
In cases when capturing is already running and someone enables also playback, the SDMA unit of the i.MX SoC does not see an edge on its TX DMA request line. This is due to the TX FIFOs are empty, and this request line is active all the time, when the
CCSR_SSI_SIER_TDMAEbit is set. In this case also the TX FIFO underrun interrupt will flood the system forever.To ensure the first edge happens after enabling the TX side of the SSI unit and to trigger the SDMA unit successfully enable the
CCSR_SSI_SIER_TDMAEon demand only. To be sure, this patch does the same for theCCSR_SSI_SIER_RDMAE(RX side) bit.Signed-off-by Juergen Beisert <[email protected]>--- sound/soc/fsl/fsl_ssi.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-)Index:
linux.git/sound/soc/fsl/fsl_ssi.c
===================================================================sound/soc/fsl/fsl_ssi.c +12
-7@@ -86,10 +86,9 @@ static inline void write_ssi_mask(u32 __#endif /* SIER bitflag of interrupts to enable */ -#define SIER_FLAGS (CCSR_SSI_SIER_TFRC_EN | CCSR_SSI_SIER_TDMAE | \ - CCSR_SSI_SIER_TIE | CCSR_SSI_SIER_TUE0_EN | \ - CCSR_SSI_SIER_TUE1_EN | CCSR_SSI_SIER_RFRC_EN | \ - CCSR_SSI_SIER_RDMAE | CCSR_SSI_SIER_RIE | \ +#define SIER_FLAGS (CCSR_SSI_SIER_TFRC_EN | CCSR_SSI_SIER_TIE | \ + CCSR_SSI_SIER_TUE0_EN | CCSR_SSI_SIER_TUE1_EN | \ + CCSR_SSI_SIER_RFRC_EN | CCSR_SSI_SIER_RIE | \ CCSR_SSI_SIER_ROE0_EN | CCSR_SSI_SIER_ROE1_EN)/** @@ -489,6 +488,9 @@ static int fsl_ssi_hw_params(struct snd_* * The DMA channel is in external master start and pause mode, which * means the SSI completely controls the flow of data. +* +* To use the i.MX's SDMA unit it is important to create an edge on the +* corresponding request line. Otherwise the request will be ignored! */ static int fsl_ssi_trigger (struct snd_pcm_substream *substream,int cmd,struct snd_soc_dai *dai)@@ -500,20 +502,26 @@ static int fsl_ssi_trigger(struct snd_pcswitch (cmd) {case SNDRV_PCM_TRIGGER_START :case SNDRV_PCM_TRIGGER_PAUSE_RELEASE : -if (substream->stream ==SNDRV_PCM_STREAM_PLAYBACK ) +if (substream->stream ==SNDRV_PCM_STREAM_PLAYBACK ) {write_ssi_mask (&ssi->scr,0 ,CCSR_SSI_SCR_SSIEN |CCSR_SSI_SCR_TE ); -else +write_ssi_mask (&ssi->sier,0 ,CCSR_SSI_SIER_TDMAE ); + }else {write_ssi_mask (&ssi->scr,0 ,CCSR_SSI_SCR_SSIEN |CCSR_SSI_SCR_RE ); +write_ssi_mask (&ssi->sier,0 ,CCSR_SSI_SIER_RDMAE ); + }break ;case SNDRV_PCM_TRIGGER_STOP :case SNDRV_PCM_TRIGGER_PAUSE_PUSH : -if (substream->stream ==SNDRV_PCM_STREAM_PLAYBACK ) +if (substream->stream ==SNDRV_PCM_STREAM_PLAYBACK ) {
sound/soc/fsl/fsl_ssi.c static int fsl_ssi_trigger(struct snd_pc · line 527
Quoted 10 lines
sound/soc/fsl/fsl_ssi.c +4
-1write_ssi_mask (&ssi->scr,CCSR_SSI_SCR_TE ,0 ); - else +write_ssi_mask (&ssi->sier,CCSR_SSI_SIER_TDMAE ,0 ); + }else {write_ssi_mask (&ssi->scr,CCSR_SSI_SCR_RE ,0 ); +write_ssi_mask (&ssi->sier,CCSR_SSI_SIER_RDMAE ,0 ); + }break ;default :
Any comments on this patch?
jbe
Signature · 4 lines
Pengutronix e.K. | Juergen Beisert | Linux Solutions for Science and Industry | Phone: +49-5121-206917-5128 | Peiner Str. 6-8, 31137 Hildesheim, Germany | Fax: +49-5121-206917-5555 | Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de/ |
Shawn Guo
Acked-byThanks for the fix, Juergen.
The patch subject could be written in a better form with a proper prefix added. "git log sound/soc/fsl/fsl_ssi.c" should give example. To have the patch get in sooner, you should copy Mark Brown on it.
Also MAINTAINERS file gives the following, so you still do not have the right list copied.
SOUND - SOC LAYER / DYNAMIC AUDIO POWER MANAGEMENT (ASoC)
M: Liam Girdwood <[email protected]> M: Mark Brown <[email protected]> T: git git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git L: [email protected] (moderated for non-subscribers) W: http://alsa-project.org/main/index.php/ASoC S: Supported F: sound/soc/ F: include/sound/soc*
Quoted 8 lines · Juergen Beisert
Quoted 7 lines · Juergen Beisert
In cases when capturing is already running and someone enables also playback, the SDMA unit of the i.MX SoC does not see an edge on its TX DMA request line. This is due to the TX FIFOs are empty, and this request line is active all the time, when the
CCSR_SSI_SIER_TDMAEbit is set. In this case also the TX FIFO underrun interrupt will flood the system forever.
Quoted 6 lines
Quoted 6 lines
To ensure the first edge happens after enabling the TX side of the SSI unit and to trigger the SDMA unit successfully enable the
CCSR_SSI_SIER_TDMAEon demand only. To be sure, this patch does the same for theCCSR_SSI_SIER_RDMAE(RX side) bit.Signed-off-by Juergen Beisert <[email protected]>
I can see the patch does fix the problem. A small comment below, otherwise
Quoted 12 lines
Quoted 12 lines
--- sound/soc/fsl/fsl_ssi.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-)Index:
linux.git/sound/soc/fsl/fsl_ssi.c
===================================================================sound/soc/fsl/fsl_ssi.c +0
-0@@ -86,10 +86,9 @@ static inline void write_ssi_mask(u32 __#endif
Quoted 8 lines
sound/soc/fsl/fsl_ssi.c static inline void write_ssi_mask(u32 __ · line 91
Quoted 8 lines
sound/soc/fsl/fsl_ssi.c +3
-4/* SIER bitflag of interrupts to enable */ -#define SIER_FLAGS (CCSR_SSI_SIER_TFRC_EN | CCSR_SSI_SIER_TDMAE | \ - CCSR_SSI_SIER_TIE | CCSR_SSI_SIER_TUE0_EN | \ - CCSR_SSI_SIER_TUE1_EN | CCSR_SSI_SIER_RFRC_EN | \ - CCSR_SSI_SIER_RDMAE | CCSR_SSI_SIER_RIE | \ +#define SIER_FLAGS (CCSR_SSI_SIER_TFRC_EN | CCSR_SSI_SIER_TIE | \ + CCSR_SSI_SIER_TUE0_EN | CCSR_SSI_SIER_TUE1_EN | \ + CCSR_SSI_SIER_RFRC_EN | CCSR_SSI_SIER_RIE | \
It takes me sometime to see the real change here is to remove flags CCSR_SSI_SIER_TDMAE and CCSR_SSI_SIER_RDMAE. Then the changes below should look less dramatic and ease the reviewers a little bit, I think.
Shawn
--8<---
@@ -86,10 +86,9 @@ static inline void write_ssi_mask(u32 __iomem *addr, u32 clear, u32 set)
#endif
/* SIER bitflag of interrupts to enable */
-#define SIER_FLAGS (CCSR_SSI_SIER_TFRC_EN | CCSR_SSI_SIER_TDMAE | \
+#define SIER_FLAGS (CCSR_SSI_SIER_TFRC_EN | CCSR_SSI_SIER_RIE | \
CCSR_SSI_SIER_TIE | CCSR_SSI_SIER_TUE0_EN | \
CCSR_SSI_SIER_TUE1_EN | CCSR_SSI_SIER_RFRC_EN | \
- CCSR_SSI_SIER_RDMAE | CCSR_SSI_SIER_RIE | \
CCSR_SSI_SIER_ROE0_EN | CCSR_SSI_SIER_ROE1_EN)Quoted 59 lines
Quoted 34 lines
sound/soc/fsl/fsl_ssi.c +9
-3CCSR_SSI_SIER_ROE0_EN | CCSR_SSI_SIER_ROE1_EN)/** @@ -489,6 +488,9 @@ static int fsl_ssi_hw_params(struct snd_* * The DMA channel is in external master start and pause mode, which * means the SSI completely controls the flow of data. +* +* To use the i.MX's SDMA unit it is important to create an edge on the +* corresponding request line. Otherwise the request will be ignored! */ static int fsl_ssi_trigger (struct snd_pcm_substream *substream,int cmd,struct snd_soc_dai *dai)@@ -500,20 +502,26 @@ static int fsl_ssi_trigger(struct snd_pcswitch (cmd) {case SNDRV_PCM_TRIGGER_START :case SNDRV_PCM_TRIGGER_PAUSE_RELEASE : -if (substream->stream ==SNDRV_PCM_STREAM_PLAYBACK ) +if (substream->stream ==SNDRV_PCM_STREAM_PLAYBACK ) {write_ssi_mask (&ssi->scr,0 ,CCSR_SSI_SCR_SSIEN |CCSR_SSI_SCR_TE ); -else +write_ssi_mask (&ssi->sier,0 ,CCSR_SSI_SIER_TDMAE ); + }else {write_ssi_mask (&ssi->scr,0 ,CCSR_SSI_SCR_SSIEN |CCSR_SSI_SCR_RE ); +write_ssi_mask (&ssi->sier,0 ,CCSR_SSI_SIER_RDMAE ); + }break ;case SNDRV_PCM_TRIGGER_STOP :case SNDRV_PCM_TRIGGER_PAUSE_PUSH : -if (substream->stream ==SNDRV_PCM_STREAM_PLAYBACK ) +if (substream->stream ==SNDRV_PCM_STREAM_PLAYBACK ) {sound/soc/fsl/fsl_ssi.c static int fsl_ssi_trigger(struct snd_pc · line 527
Quoted 10 lines
sound/soc/fsl/fsl_ssi.c +4
-1write_ssi_mask (&ssi->scr,CCSR_SSI_SCR_TE ,0 ); - else +write_ssi_mask (&ssi->sier,CCSR_SSI_SIER_TDMAE ,0 ); + }else {write_ssi_mask (&ssi->scr,CCSR_SSI_SCR_RE ,0 ); +write_ssi_mask (&ssi->sier,CCSR_SSI_SIER_RDMAE ,0 ); + }break ;default :Any comments on this patch?
jbe
Signature · 9 lines
Pengutronix e.K. | Juergen Beisert | Linux Solutions for Science and Industry | Phone: +49-5121-206917-5128 | Peiner Str. 6-8, 31137 Hildesheim, Germany | Fax: +49-5121-206917-5555 | Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de/ | _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Shawn Guo
Acked-byThanks for the fix, Juergen.
The patch subject could be written in a better form with a proper prefix added. "git log sound/soc/fsl/fsl_ssi.c" should give example. To have the patch get in sooner, you should copy Mark Brown on it.
Also MAINTAINERS file gives the following, so you still do not have the right list copied.
SOUND - SOC LAYER / DYNAMIC AUDIO POWER MANAGEMENT (ASoC)
M: Liam Girdwood <[email protected]> M: Mark Brown <[email protected]> T: git git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git L: alsa-devel at alsa-project.org (moderated for non-subscribers) W: http://alsa-project.org/main/index.php/ASoC S: Supported F: sound/soc/ F: include/sound/soc*
Quoted 8 lines · Juergen Beisert
Quoted 7 lines · Juergen Beisert
In cases when capturing is already running and someone enables also playback, the SDMA unit of the i.MX SoC does not see an edge on its TX DMA request line. This is due to the TX FIFOs are empty, and this request line is active all the time, when the
CCSR_SSI_SIER_TDMAEbit is set. In this case also the TX FIFO underrun interrupt will flood the system forever.
Quoted 6 lines
Quoted 6 lines
To ensure the first edge happens after enabling the TX side of the SSI unit and to trigger the SDMA unit successfully enable the
CCSR_SSI_SIER_TDMAEon demand only. To be sure, this patch does the same for theCCSR_SSI_SIER_RDMAE(RX side) bit.Signed-off-by Juergen Beisert <[email protected]>
I can see the patch does fix the problem. A small comment below, otherwise
Quoted 12 lines
Quoted 12 lines
--- sound/soc/fsl/fsl_ssi.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-)Index:
linux.git/sound/soc/fsl/fsl_ssi.c
===================================================================sound/soc/fsl/fsl_ssi.c +0
-0@@ -86,10 +86,9 @@ static inline void write_ssi_mask(u32 __#endif
Quoted 8 lines
sound/soc/fsl/fsl_ssi.c static inline void write_ssi_mask(u32 __ · line 91
Quoted 8 lines
sound/soc/fsl/fsl_ssi.c +3
-4/* SIER bitflag of interrupts to enable */ -#define SIER_FLAGS (CCSR_SSI_SIER_TFRC_EN | CCSR_SSI_SIER_TDMAE | \ - CCSR_SSI_SIER_TIE | CCSR_SSI_SIER_TUE0_EN | \ - CCSR_SSI_SIER_TUE1_EN | CCSR_SSI_SIER_RFRC_EN | \ - CCSR_SSI_SIER_RDMAE | CCSR_SSI_SIER_RIE | \ +#define SIER_FLAGS (CCSR_SSI_SIER_TFRC_EN | CCSR_SSI_SIER_TIE | \ + CCSR_SSI_SIER_TUE0_EN | CCSR_SSI_SIER_TUE1_EN | \ + CCSR_SSI_SIER_RFRC_EN | CCSR_SSI_SIER_RIE | \
It takes me sometime to see the real change here is to remove flags CCSR_SSI_SIER_TDMAE and CCSR_SSI_SIER_RDMAE. Then the changes below should look less dramatic and ease the reviewers a little bit, I think.
Shawn
--8<---
@@ -86,10 +86,9 @@ static inline void write_ssi_mask(u32 __iomem *addr, u32 clear, u32 set)
#endif
/* SIER bitflag of interrupts to enable */
-#define SIER_FLAGS (CCSR_SSI_SIER_TFRC_EN | CCSR_SSI_SIER_TDMAE | \
+#define SIER_FLAGS (CCSR_SSI_SIER_TFRC_EN | CCSR_SSI_SIER_RIE | \
CCSR_SSI_SIER_TIE | CCSR_SSI_SIER_TUE0_EN | \
CCSR_SSI_SIER_TUE1_EN | CCSR_SSI_SIER_RFRC_EN | \
- CCSR_SSI_SIER_RDMAE | CCSR_SSI_SIER_RIE | \
CCSR_SSI_SIER_ROE0_EN | CCSR_SSI_SIER_ROE1_EN)Quoted 59 lines
Quoted 34 lines
sound/soc/fsl/fsl_ssi.c +9
-3CCSR_SSI_SIER_ROE0_EN | CCSR_SSI_SIER_ROE1_EN)/** @@ -489,6 +488,9 @@ static int fsl_ssi_hw_params(struct snd_* * The DMA channel is in external master start and pause mode, which * means the SSI completely controls the flow of data. +* +* To use the i.MX's SDMA unit it is important to create an edge on the +* corresponding request line. Otherwise the request will be ignored! */ static int fsl_ssi_trigger (struct snd_pcm_substream *substream,int cmd,struct snd_soc_dai *dai)@@ -500,20 +502,26 @@ static int fsl_ssi_trigger(struct snd_pcswitch (cmd) {case SNDRV_PCM_TRIGGER_START :case SNDRV_PCM_TRIGGER_PAUSE_RELEASE : -if (substream->stream ==SNDRV_PCM_STREAM_PLAYBACK ) +if (substream->stream ==SNDRV_PCM_STREAM_PLAYBACK ) {write_ssi_mask (&ssi->scr,0 ,CCSR_SSI_SCR_SSIEN |CCSR_SSI_SCR_TE ); -else +write_ssi_mask (&ssi->sier,0 ,CCSR_SSI_SIER_TDMAE ); + }else {write_ssi_mask (&ssi->scr,0 ,CCSR_SSI_SCR_SSIEN |CCSR_SSI_SCR_RE ); +write_ssi_mask (&ssi->sier,0 ,CCSR_SSI_SIER_RDMAE ); + }break ;case SNDRV_PCM_TRIGGER_STOP :case SNDRV_PCM_TRIGGER_PAUSE_PUSH : -if (substream->stream ==SNDRV_PCM_STREAM_PLAYBACK ) +if (substream->stream ==SNDRV_PCM_STREAM_PLAYBACK ) {sound/soc/fsl/fsl_ssi.c static int fsl_ssi_trigger(struct snd_pc · line 527
Quoted 10 lines
sound/soc/fsl/fsl_ssi.c +4
-1write_ssi_mask (&ssi->scr,CCSR_SSI_SCR_TE ,0 ); - else +write_ssi_mask (&ssi->sier,CCSR_SSI_SIER_TDMAE ,0 ); + }else {write_ssi_mask (&ssi->scr,CCSR_SSI_SCR_RE ,0 ); +write_ssi_mask (&ssi->sier,CCSR_SSI_SIER_RDMAE ,0 ); + }break ;default :Any comments on this patch?
jbe
Signature · 9 lines
Pengutronix e.K. | Juergen Beisert | Linux Solutions for Science and Industry | Phone: +49-5121-206917-5128 | Peiner Str. 6-8, 31137 Hildesheim, Germany | Fax: +49-5121-206917-5555 | Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de/ | _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel at lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel