* [PATCH] ALSA: ASoC: fix PXA SSP port resume
@ 2010-01-28 10:34 Daniel Mack
2010-01-29 10:13 ` Mark Brown
0 siblings, 1 reply; 8+ messages in thread
From: Daniel Mack @ 2010-01-28 10:34 UTC (permalink / raw)
To: alsa-devel; +Cc: Mark Brown, Eric Miao, Philipp Zabel
Invalidate the cached hardware format on resume for PXA SSP ports.
Otherwise hw_params() will bail out early at the next stream start,
leaving the registers in a bogus state.
Signed-off-by: Daniel Mack <daniel@caiaq.de>
Cc: Eric Miao <eric.y.miao@gmail.com>
Cc: Mark Brown <broonie@opensource.wolfsonmicro.com>
Cc: Philipp Zabel <philipp.zabel@gmail.com>
---
sound/soc/pxa/pxa-ssp.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/sound/soc/pxa/pxa-ssp.c b/sound/soc/pxa/pxa-ssp.c
index 3bd7712..ebde673 100644
--- a/sound/soc/pxa/pxa-ssp.c
+++ b/sound/soc/pxa/pxa-ssp.c
@@ -146,6 +146,9 @@ static int pxa_ssp_resume(struct snd_soc_dai *cpu_dai)
{
struct ssp_priv *priv = cpu_dai->private_data;
+ /* the cached format information is invalid now */
+ priv->dai_fmt = (unsigned int) -1;
+
if (!cpu_dai->active)
return 0;
--
1.6.3.3
^ permalink raw reply related [flat|nested] 8+ messages in thread* Re: [PATCH] ALSA: ASoC: fix PXA SSP port resume
2010-01-28 10:34 [PATCH] ALSA: ASoC: fix PXA SSP port resume Daniel Mack
@ 2010-01-29 10:13 ` Mark Brown
2010-01-29 11:08 ` Daniel Mack
0 siblings, 1 reply; 8+ messages in thread
From: Mark Brown @ 2010-01-29 10:13 UTC (permalink / raw)
To: Daniel Mack; +Cc: alsa-devel, Eric Miao, Philipp Zabel
On Thu, Jan 28, 2010 at 06:34:18PM +0800, Daniel Mack wrote:
> Invalidate the cached hardware format on resume for PXA SSP ports.
> Otherwise hw_params() will bail out early at the next stream start,
> leaving the registers in a bogus state.
Would it not be better to write the cached state back to the hardware?
Putting an invalid value in the cache seems like asking for trouble.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] ALSA: ASoC: fix PXA SSP port resume
2010-01-29 10:13 ` Mark Brown
@ 2010-01-29 11:08 ` Daniel Mack
2010-01-29 14:00 ` Mark Brown
0 siblings, 1 reply; 8+ messages in thread
From: Daniel Mack @ 2010-01-29 11:08 UTC (permalink / raw)
To: Mark Brown; +Cc: alsa-devel, Eric Miao, Philipp Zabel
On Fri, Jan 29, 2010 at 10:13:08AM +0000, Mark Brown wrote:
> On Thu, Jan 28, 2010 at 06:34:18PM +0800, Daniel Mack wrote:
> > Invalidate the cached hardware format on resume for PXA SSP ports.
> > Otherwise hw_params() will bail out early at the next stream start,
> > leaving the registers in a bogus state.
>
> Would it not be better to write the cached state back to the hardware?
> Putting an invalid value in the cache seems like asking for trouble.
Hmm. I considered that, but the reason why the system failed to resume
in my case was that the ssp port was not active at this time. Otherwise,
the suspend/resume code would have already done the right thing.
And as the next client will indirectly call hw_params() again, the code
there will do the right thing with the invalidated cache.
Restoring the register values from priv->dai_fmt would imply adding code
to do everything what the other bit-fiddling functions do in a reverse
manner. Which is something I'd like to avoid :)
Another idea is to unconditionally save and restore the register set,
and deal with possible side-effects. Not sure what's really better.
Daniel
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] ALSA: ASoC: fix PXA SSP port resume
2010-01-29 11:08 ` Daniel Mack
@ 2010-01-29 14:00 ` Mark Brown
2010-02-02 3:32 ` Daniel Mack
0 siblings, 1 reply; 8+ messages in thread
From: Mark Brown @ 2010-01-29 14:00 UTC (permalink / raw)
To: Daniel Mack; +Cc: alsa-devel, Eric Miao, Philipp Zabel
On Fri, Jan 29, 2010 at 12:08:36PM +0100, Daniel Mack wrote:
> And as the next client will indirectly call hw_params() again, the code
> there will do the right thing with the invalidated cache.
Yeah, I know the code is actually reasonably safe - it just doesn't give
me the warm and fuzzies to do the invalidation by programming a random
value in there simply on the off chance that at some point in the future
that winds up being a valid value and so the same problem recurs.
> Restoring the register values from priv->dai_fmt would imply adding code
> to do everything what the other bit-fiddling functions do in a reverse
> manner. Which is something I'd like to avoid :)
Oh, right. I'd forgotten that that was what it was actually storing.
> Another idea is to unconditionally save and restore the register set,
> and deal with possible side-effects. Not sure what's really better.
I think that'd be the the most robust solution with the way things are
structured in the driver.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH] ALSA: ASoC: fix PXA SSP port resume
2010-01-29 14:00 ` Mark Brown
@ 2010-02-02 3:32 ` Daniel Mack
2010-02-02 10:51 ` Liam Girdwood
0 siblings, 1 reply; 8+ messages in thread
From: Daniel Mack @ 2010-02-02 3:32 UTC (permalink / raw)
To: alsa-devel; +Cc: Mark Brown, Eric Miao, Philipp Zabel
Unconditionally save the register states in resume and restore them
again at resume time. Register contents are not preserved over suspend,
and the driver takes false assumptions about them otherwise.
The clock must be enabled to access the register block.
Signed-off-by: Daniel Mack <daniel@caiaq.de>
Cc: Eric Miao <eric.y.miao@gmail.com>
Cc: Mark Brown <broonie@opensource.wolfsonmicro.com>
Cc: Philipp Zabel <philipp.zabel@gmail.com>
---
sound/soc/pxa/pxa-ssp.c | 12 +++++++-----
1 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/sound/soc/pxa/pxa-ssp.c b/sound/soc/pxa/pxa-ssp.c
index 3bd7712..e69397f 100644
--- a/sound/soc/pxa/pxa-ssp.c
+++ b/sound/soc/pxa/pxa-ssp.c
@@ -135,10 +135,11 @@ static int pxa_ssp_suspend(struct snd_soc_dai *cpu_dai)
struct ssp_priv *priv = cpu_dai->private_data;
if (!cpu_dai->active)
- return 0;
+ clk_enable(priv->dev.ssp->clk);
ssp_save_state(&priv->dev, &priv->state);
clk_disable(priv->dev.ssp->clk);
+
return 0;
}
@@ -146,12 +147,13 @@ static int pxa_ssp_resume(struct snd_soc_dai *cpu_dai)
{
struct ssp_priv *priv = cpu_dai->private_data;
- if (!cpu_dai->active)
- return 0;
-
clk_enable(priv->dev.ssp->clk);
ssp_restore_state(&priv->dev, &priv->state);
- ssp_enable(&priv->dev);
+
+ if (cpu_dai->active)
+ ssp_enable(&priv->dev);
+ else
+ clk_disable(priv->dev.ssp->clk);
return 0;
}
--
1.6.3.3
^ permalink raw reply related [flat|nested] 8+ messages in thread* Re: [PATCH] ALSA: ASoC: fix PXA SSP port resume
2010-02-02 3:32 ` Daniel Mack
@ 2010-02-02 10:51 ` Liam Girdwood
2010-02-02 10:45 ` Daniel Mack
0 siblings, 1 reply; 8+ messages in thread
From: Liam Girdwood @ 2010-02-02 10:51 UTC (permalink / raw)
To: Daniel Mack; +Cc: alsa-devel, Mark Brown, Eric Miao, Philipp Zabel
Looks fine except for commit message (sorry to nitpick).
On Tue, 2010-02-02 at 11:32 +0800, Daniel Mack wrote:
> Unconditionally save the register states in resume
I assume you mean suspend here ?
> and restore them
> again at resume time. Register contents are not preserved over suspend,
were not being preserved
> and the driver takes false assumptions about them otherwise.
>
Thanks
Liam
--
Freelance Developer, SlimLogic Ltd
ASoC and Voltage Regulator Maintainer.
http://www.slimlogic.co.uk
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH] ALSA: ASoC: fix PXA SSP port resume
2010-02-02 10:51 ` Liam Girdwood
@ 2010-02-02 10:45 ` Daniel Mack
2010-02-02 11:41 ` Mark Brown
0 siblings, 1 reply; 8+ messages in thread
From: Daniel Mack @ 2010-02-02 10:45 UTC (permalink / raw)
To: alsa-devel; +Cc: Mark Brown, Eric Miao, Philipp Zabel
Unconditionally save the register states when suspending and restore
them again at resume time. Register contents were not preserved over
suspend, and hence the driver takes false assumptions about them.
The clock must be enabled to access the register block.
Signed-off-by: Daniel Mack <daniel@caiaq.de>
Cc: Eric Miao <eric.y.miao@gmail.com>
Cc: Mark Brown <broonie@opensource.wolfsonmicro.com>
Cc: Philipp Zabel <philipp.zabel@gmail.com>
---
sound/soc/pxa/pxa-ssp.c | 12 +++++++-----
1 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/sound/soc/pxa/pxa-ssp.c b/sound/soc/pxa/pxa-ssp.c
index 3bd7712..e69397f 100644
--- a/sound/soc/pxa/pxa-ssp.c
+++ b/sound/soc/pxa/pxa-ssp.c
@@ -135,10 +135,11 @@ static int pxa_ssp_suspend(struct snd_soc_dai *cpu_dai)
struct ssp_priv *priv = cpu_dai->private_data;
if (!cpu_dai->active)
- return 0;
+ clk_enable(priv->dev.ssp->clk);
ssp_save_state(&priv->dev, &priv->state);
clk_disable(priv->dev.ssp->clk);
+
return 0;
}
@@ -146,12 +147,13 @@ static int pxa_ssp_resume(struct snd_soc_dai *cpu_dai)
{
struct ssp_priv *priv = cpu_dai->private_data;
- if (!cpu_dai->active)
- return 0;
-
clk_enable(priv->dev.ssp->clk);
ssp_restore_state(&priv->dev, &priv->state);
- ssp_enable(&priv->dev);
+
+ if (cpu_dai->active)
+ ssp_enable(&priv->dev);
+ else
+ clk_disable(priv->dev.ssp->clk);
return 0;
}
--
1.6.3.3
^ permalink raw reply related [flat|nested] 8+ messages in thread* Re: [PATCH] ALSA: ASoC: fix PXA SSP port resume
2010-02-02 10:45 ` Daniel Mack
@ 2010-02-02 11:41 ` Mark Brown
0 siblings, 0 replies; 8+ messages in thread
From: Mark Brown @ 2010-02-02 11:41 UTC (permalink / raw)
To: Daniel Mack; +Cc: alsa-devel, Eric Miao, Philipp Zabel
On Tue, Feb 02, 2010 at 06:45:27PM +0800, Daniel Mack wrote:
> Unconditionally save the register states when suspending and restore
> them again at resume time. Register contents were not preserved over
> suspend, and hence the driver takes false assumptions about them.
>
> The clock must be enabled to access the register block.
Applied, thanks.
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2010-02-02 11:41 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-01-28 10:34 [PATCH] ALSA: ASoC: fix PXA SSP port resume Daniel Mack
2010-01-29 10:13 ` Mark Brown
2010-01-29 11:08 ` Daniel Mack
2010-01-29 14:00 ` Mark Brown
2010-02-02 3:32 ` Daniel Mack
2010-02-02 10:51 ` Liam Girdwood
2010-02-02 10:45 ` Daniel Mack
2010-02-02 11:41 ` 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).