ALSA: ASoC: fix PXA SSP port resume
Subsystems (3)
PATCH 1/1 ALSA: ASoC: fix PXA SSP port resume
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.
--- sound/soc/pxa/pxa-ssp.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)
sound/soc/pxa/pxa-ssp.c +3 -0
@@ -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 ;
Signature · 1 line
1.6.3.3
Quoted 3 lines · Daniel Mack
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.
Quoted 7 lines · Mark Brown
Quoted 3 lines · Daniel Mack
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
Quoted 2 lines · Daniel Mack
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.
Quoted 3 lines
Restoring the register values from
priv->dai_fmtwould 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.
Quoted 2 lines
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.
PATCH 1/1 ALSA: ASoC: fix PXA SSP port resume
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.
--- sound/soc/pxa/pxa-ssp.c | 12 +++++++----- 1 files changed, 7 insertions(+), 5 deletions(-)
sound/soc/pxa/pxa-ssp.c +7 -5
@@ -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 ; }
Signature · 1 line
1.6.3.3
Looks fine except for commit message (sorry to nitpick).
Quoted 1 line · Daniel Mack
Unconditionally save the register states in resume
I assume you mean suspend here ?
Quoted 2 lines
and restore them
again at resume time. Register contents are not preserved over suspend,
were not being preserved
Quoted 2 lines
and the driver takes false assumptions about them otherwise.
Thanks
Liam
Signature · 3 lines
Freelance Developer, SlimLogic Ltd ASoC and Voltage Regulator Maintainer. http://www.slimlogic.co.uk
PATCH 1/1 ALSA: ASoC: fix PXA SSP port resume
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.
--- sound/soc/pxa/pxa-ssp.c | 12 +++++++----- 1 files changed, 7 insertions(+), 5 deletions(-)
sound/soc/pxa/pxa-ssp.c +7 -5
@@ -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 ; }
Signature · 1 line
1.6.3.3
Mark Brown
AppliedQuoted 5 lines · Daniel Mack
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.