* [PATCH 0/3] ASoC: mxs-saif error handling
@ 2013-10-11 10:11 Markus Pargmann
2013-10-11 10:11 ` [PATCH 1/3] ASoC: snd_soc_dai_ops trigger function description Markus Pargmann
` (3 more replies)
0 siblings, 4 replies; 7+ messages in thread
From: Markus Pargmann @ 2013-10-11 10:11 UTC (permalink / raw)
To: Mark Brown; +Cc: kernel, alsa-devel, Liam Girdwood, linux-arm-kernel
Hi,
This series contains error handling patches for mxs-saif. The first patch is
a comment about the possible command sequence of trigger functions.
Regards,
Markus Pargmann
Markus Pargmann (3):
ASoC: snd_soc_dai_ops trigger function description
ASoC: mxs-saif: Store saif state
ASoC: mxs-saif: Handle errors in trigger function
include/sound/soc-dai.h | 7 +++++++
sound/soc/mxs/mxs-saif.c | 30 +++++++++++++++++++++++++-----
sound/soc/mxs/mxs-saif.h | 5 +++++
3 files changed, 37 insertions(+), 5 deletions(-)
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 1/3] ASoC: snd_soc_dai_ops trigger function description
2013-10-11 10:11 [PATCH 0/3] ASoC: mxs-saif error handling Markus Pargmann
@ 2013-10-11 10:11 ` Markus Pargmann
2013-10-11 10:11 ` [PATCH 2/3] ASoC: mxs-saif: Store saif state Markus Pargmann
` (2 subsequent siblings)
3 siblings, 0 replies; 7+ messages in thread
From: Markus Pargmann @ 2013-10-11 10:11 UTC (permalink / raw)
To: Mark Brown
Cc: kernel, Markus Pargmann, alsa-devel, Liam Girdwood,
linux-arm-kernel
Add a comment to the trigger function in snd_soc_dai_ops struct about
possible command sequences.
Signed-off-by: Markus Pargmann <mpa@pengutronix.de>
---
include/sound/soc-dai.h | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/include/sound/soc-dai.h b/include/sound/soc-dai.h
index ae9a227..0f2e5da 100644
--- a/include/sound/soc-dai.h
+++ b/include/sound/soc-dai.h
@@ -166,6 +166,13 @@ struct snd_soc_dai_ops {
struct snd_soc_dai *);
int (*prepare)(struct snd_pcm_substream *,
struct snd_soc_dai *);
+ /*
+ * NOTE: Commands passed to the trigger function are not necessarily
+ * compatible with the current state of the dai. For example this
+ * sequence of commands is possible: START STOP STOP.
+ * So do not unconditionally use refcounting functions in the trigger
+ * function, e.g. clk_enable/disable.
+ */
int (*trigger)(struct snd_pcm_substream *, int,
struct snd_soc_dai *);
int (*bespoke_trigger)(struct snd_pcm_substream *, int,
--
1.8.4.rc3
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 2/3] ASoC: mxs-saif: Store saif state
2013-10-11 10:11 [PATCH 0/3] ASoC: mxs-saif error handling Markus Pargmann
2013-10-11 10:11 ` [PATCH 1/3] ASoC: snd_soc_dai_ops trigger function description Markus Pargmann
@ 2013-10-11 10:11 ` Markus Pargmann
2013-10-11 10:31 ` Lothar Waßmann
2013-10-11 10:11 ` [PATCH 3/3] ASoC: mxs-saif: Handle errors in trigger function Markus Pargmann
2013-10-14 17:02 ` [PATCH 0/3] ASoC: mxs-saif error handling Mark Brown
3 siblings, 1 reply; 7+ messages in thread
From: Markus Pargmann @ 2013-10-11 10:11 UTC (permalink / raw)
To: Mark Brown
Cc: kernel, Markus Pargmann, alsa-devel, Liam Girdwood,
linux-arm-kernel
Trigger commands may be passed multiple times. To avoid errors with
clk_enable/disable, store the saif state and return if saif is already
running/stopped.
Signed-off-by: Markus Pargmann <mpa@pengutronix.de>
---
sound/soc/mxs/mxs-saif.c | 8 ++++++++
sound/soc/mxs/mxs-saif.h | 5 +++++
2 files changed, 13 insertions(+)
diff --git a/sound/soc/mxs/mxs-saif.c b/sound/soc/mxs/mxs-saif.c
index b56b8a0..c8ead01 100644
--- a/sound/soc/mxs/mxs-saif.c
+++ b/sound/soc/mxs/mxs-saif.c
@@ -503,6 +503,9 @@ static int mxs_saif_trigger(struct snd_pcm_substream *substream, int cmd,
case SNDRV_PCM_TRIGGER_START:
case SNDRV_PCM_TRIGGER_RESUME:
case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
+ if (saif->state == MXS_SAIF_STATE_RUNNING)
+ return 0;
+
dev_dbg(cpu_dai->dev, "start\n");
clk_enable(master_saif->clk);
@@ -543,6 +546,7 @@ static int mxs_saif_trigger(struct snd_pcm_substream *substream, int cmd,
}
master_saif->ongoing = 1;
+ saif->state = MXS_SAIF_STATE_RUNNING;
dev_dbg(saif->dev, "CTRL 0x%x STAT 0x%x\n",
__raw_readl(saif->base + SAIF_CTRL),
@@ -555,6 +559,9 @@ static int mxs_saif_trigger(struct snd_pcm_substream *substream, int cmd,
case SNDRV_PCM_TRIGGER_SUSPEND:
case SNDRV_PCM_TRIGGER_STOP:
case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
+ if (saif->state == MXS_SAIF_STATE_STOPPED)
+ return 0;
+
dev_dbg(cpu_dai->dev, "stop\n");
/* wait a while for the current sample to complete */
@@ -575,6 +582,7 @@ static int mxs_saif_trigger(struct snd_pcm_substream *substream, int cmd,
}
master_saif->ongoing = 0;
+ saif->state = MXS_SAIF_STATE_STOPPED;
break;
default:
diff --git a/sound/soc/mxs/mxs-saif.h b/sound/soc/mxs/mxs-saif.h
index 53eaa4b..fbaf7ba 100644
--- a/sound/soc/mxs/mxs-saif.h
+++ b/sound/soc/mxs/mxs-saif.h
@@ -124,6 +124,11 @@ struct mxs_saif {
u32 fifo_underrun;
u32 fifo_overrun;
+
+ enum {
+ MXS_SAIF_STATE_STOPPED,
+ MXS_SAIF_STATE_RUNNING,
+ } state;
};
extern int mxs_saif_put_mclk(unsigned int saif_id);
--
1.8.4.rc3
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 3/3] ASoC: mxs-saif: Handle errors in trigger function
2013-10-11 10:11 [PATCH 0/3] ASoC: mxs-saif error handling Markus Pargmann
2013-10-11 10:11 ` [PATCH 1/3] ASoC: snd_soc_dai_ops trigger function description Markus Pargmann
2013-10-11 10:11 ` [PATCH 2/3] ASoC: mxs-saif: Store saif state Markus Pargmann
@ 2013-10-11 10:11 ` Markus Pargmann
2013-10-14 17:02 ` [PATCH 0/3] ASoC: mxs-saif error handling Mark Brown
3 siblings, 0 replies; 7+ messages in thread
From: Markus Pargmann @ 2013-10-11 10:11 UTC (permalink / raw)
To: Mark Brown
Cc: kernel, Markus Pargmann, alsa-devel, Liam Girdwood,
linux-arm-kernel
Signed-off-by: Markus Pargmann <mpa@pengutronix.de>
---
sound/soc/mxs/mxs-saif.c | 22 +++++++++++++++++-----
1 file changed, 17 insertions(+), 5 deletions(-)
diff --git a/sound/soc/mxs/mxs-saif.c b/sound/soc/mxs/mxs-saif.c
index c8ead01..fc3d89b 100644
--- a/sound/soc/mxs/mxs-saif.c
+++ b/sound/soc/mxs/mxs-saif.c
@@ -494,6 +494,7 @@ static int mxs_saif_trigger(struct snd_pcm_substream *substream, int cmd,
struct mxs_saif *saif = snd_soc_dai_get_drvdata(cpu_dai);
struct mxs_saif *master_saif;
u32 delay;
+ int ret;
master_saif = mxs_saif_get_master(saif);
if (!master_saif)
@@ -508,21 +509,32 @@ static int mxs_saif_trigger(struct snd_pcm_substream *substream, int cmd,
dev_dbg(cpu_dai->dev, "start\n");
- clk_enable(master_saif->clk);
- if (!master_saif->mclk_in_use)
- __raw_writel(BM_SAIF_CTRL_RUN,
- master_saif->base + SAIF_CTRL + MXS_SET_ADDR);
+ ret = clk_enable(master_saif->clk);
+ if (ret) {
+ dev_err(saif->dev, "Failed to enable master clock\n");
+ return ret;
+ }
/*
* If the saif's master is not himself, we also need to enable
* itself clk for its internal basic logic to work.
*/
if (saif != master_saif) {
- clk_enable(saif->clk);
+ ret = clk_enable(saif->clk);
+ if (ret) {
+ dev_err(saif->dev, "Failed to enable master clock\n");
+ clk_disable(master_saif->clk);
+ return ret;
+ }
+
__raw_writel(BM_SAIF_CTRL_RUN,
saif->base + SAIF_CTRL + MXS_SET_ADDR);
}
+ if (!master_saif->mclk_in_use)
+ __raw_writel(BM_SAIF_CTRL_RUN,
+ master_saif->base + SAIF_CTRL + MXS_SET_ADDR);
+
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
/*
* write data to saif data register to trigger
--
1.8.4.rc3
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 2/3] ASoC: mxs-saif: Store saif state
2013-10-11 10:11 ` [PATCH 2/3] ASoC: mxs-saif: Store saif state Markus Pargmann
@ 2013-10-11 10:31 ` Lothar Waßmann
2013-10-11 10:46 ` Markus Pargmann
0 siblings, 1 reply; 7+ messages in thread
From: Lothar Waßmann @ 2013-10-11 10:31 UTC (permalink / raw)
To: Markus Pargmann
Cc: linux-arm-kernel, alsa-devel, Mark Brown, Liam Girdwood, kernel
Hi,
> Trigger commands may be passed multiple times. To avoid errors with
> clk_enable/disable, store the saif state and return if saif is already
> running/stopped.
>
> Signed-off-by: Markus Pargmann <mpa@pengutronix.de>
> ---
> sound/soc/mxs/mxs-saif.c | 8 ++++++++
> sound/soc/mxs/mxs-saif.h | 5 +++++
> 2 files changed, 13 insertions(+)
>
> diff --git a/sound/soc/mxs/mxs-saif.c b/sound/soc/mxs/mxs-saif.c
> index b56b8a0..c8ead01 100644
> --- a/sound/soc/mxs/mxs-saif.c
> +++ b/sound/soc/mxs/mxs-saif.c
> @@ -503,6 +503,9 @@ static int mxs_saif_trigger(struct snd_pcm_substream *substream, int cmd,
> case SNDRV_PCM_TRIGGER_START:
> case SNDRV_PCM_TRIGGER_RESUME:
> case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
> + if (saif->state == MXS_SAIF_STATE_RUNNING)
> + return 0;
> +
> dev_dbg(cpu_dai->dev, "start\n");
>
> clk_enable(master_saif->clk);
> @@ -543,6 +546,7 @@ static int mxs_saif_trigger(struct snd_pcm_substream *substream, int cmd,
> }
>
> master_saif->ongoing = 1;
> + saif->state = MXS_SAIF_STATE_RUNNING;
>
It seems to me that you could use the already existing variable
'ongoing' that already reflects the state like you need it.
Lothar Waßmann
--
___________________________________________________________
Ka-Ro electronics GmbH | Pascalstraße 22 | D - 52076 Aachen
Phone: +49 2408 1402-0 | Fax: +49 2408 1402-10
Geschäftsführer: Matthias Kaussen
Handelsregistereintrag: Amtsgericht Aachen, HRB 4996
www.karo-electronics.de | info@karo-electronics.de
___________________________________________________________
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 2/3] ASoC: mxs-saif: Store saif state
2013-10-11 10:31 ` Lothar Waßmann
@ 2013-10-11 10:46 ` Markus Pargmann
0 siblings, 0 replies; 7+ messages in thread
From: Markus Pargmann @ 2013-10-11 10:46 UTC (permalink / raw)
To: Lothar Waßmann
Cc: linux-arm-kernel, alsa-devel, Mark Brown, Liam Girdwood, kernel
Hi,
On Fri, Oct 11, 2013 at 12:31:46PM +0200, Lothar Waßmann wrote:
> Hi,
>
> > Trigger commands may be passed multiple times. To avoid errors with
> > clk_enable/disable, store the saif state and return if saif is already
> > running/stopped.
> >
> > Signed-off-by: Markus Pargmann <mpa@pengutronix.de>
> > ---
> > sound/soc/mxs/mxs-saif.c | 8 ++++++++
> > sound/soc/mxs/mxs-saif.h | 5 +++++
> > 2 files changed, 13 insertions(+)
> >
> > diff --git a/sound/soc/mxs/mxs-saif.c b/sound/soc/mxs/mxs-saif.c
> > index b56b8a0..c8ead01 100644
> > --- a/sound/soc/mxs/mxs-saif.c
> > +++ b/sound/soc/mxs/mxs-saif.c
> > @@ -503,6 +503,9 @@ static int mxs_saif_trigger(struct snd_pcm_substream *substream, int cmd,
> > case SNDRV_PCM_TRIGGER_START:
> > case SNDRV_PCM_TRIGGER_RESUME:
> > case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
> > + if (saif->state == MXS_SAIF_STATE_RUNNING)
> > + return 0;
> > +
> > dev_dbg(cpu_dai->dev, "start\n");
> >
> > clk_enable(master_saif->clk);
> > @@ -543,6 +546,7 @@ static int mxs_saif_trigger(struct snd_pcm_substream *substream, int cmd,
> > }
> >
> > master_saif->ongoing = 1;
> > + saif->state = MXS_SAIF_STATE_RUNNING;
> >
> It seems to me that you could use the already existing variable
> 'ongoing' that already reflects the state like you need it.
'ongoing' can only be used if master_saif == saif. Otherwise this
variable does not reflect the state of the saif. For example there could
be parallel audio playback and recording, setting the variable only on
the master_saif->ongoing but not for the second saif.
Regards,
Markus Pargmann
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 0/3] ASoC: mxs-saif error handling
2013-10-11 10:11 [PATCH 0/3] ASoC: mxs-saif error handling Markus Pargmann
` (2 preceding siblings ...)
2013-10-11 10:11 ` [PATCH 3/3] ASoC: mxs-saif: Handle errors in trigger function Markus Pargmann
@ 2013-10-14 17:02 ` Mark Brown
3 siblings, 0 replies; 7+ messages in thread
From: Mark Brown @ 2013-10-14 17:02 UTC (permalink / raw)
To: Markus Pargmann; +Cc: kernel, alsa-devel, Liam Girdwood, linux-arm-kernel
[-- Attachment #1.1: Type: text/plain, Size: 252 bytes --]
On Fri, Oct 11, 2013 at 12:11:01PM +0200, Markus Pargmann wrote:
> Hi,
>
> This series contains error handling patches for mxs-saif. The first patch is
> a comment about the possible command sequence of trigger functions.
Applied all, thanks.
[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
[-- Attachment #2: Type: text/plain, Size: 0 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2013-10-14 17:02 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-11 10:11 [PATCH 0/3] ASoC: mxs-saif error handling Markus Pargmann
2013-10-11 10:11 ` [PATCH 1/3] ASoC: snd_soc_dai_ops trigger function description Markus Pargmann
2013-10-11 10:11 ` [PATCH 2/3] ASoC: mxs-saif: Store saif state Markus Pargmann
2013-10-11 10:31 ` Lothar Waßmann
2013-10-11 10:46 ` Markus Pargmann
2013-10-11 10:11 ` [PATCH 3/3] ASoC: mxs-saif: Handle errors in trigger function Markus Pargmann
2013-10-14 17:02 ` [PATCH 0/3] ASoC: mxs-saif error handling Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).