All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/4] ASoC: wm8962: Hold a runtime PM reference while handling interrupts
@ 2014-01-31 15:29 Mark Brown
  2014-01-31 15:29 ` [PATCH 2/4] ASoC: wm8962: Check if we runtime resume the device when starting FLL Mark Brown
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Mark Brown @ 2014-01-31 15:29 UTC (permalink / raw)
  To: Liam Girdwood; +Cc: alsa-devel, patches, linaro-kernel, Mark Brown

From: Mark Brown <broonie@linaro.org>

If the device is runtime suspended then we can't interact with it as it
may have been powered off and the register map will be in cache only
mode.

Signed-off-by: Mark Brown <broonie@linaro.org>
---
 sound/soc/codecs/wm8962.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/sound/soc/codecs/wm8962.c b/sound/soc/codecs/wm8962.c
index 97db3b45b411..aa7ae76d5e28 100644
--- a/sound/soc/codecs/wm8962.c
+++ b/sound/soc/codecs/wm8962.c
@@ -3003,6 +3003,12 @@ static irqreturn_t wm8962_irq(int irq, void *data)
 	unsigned int active;
 	int reg, ret;
 
+	ret = pm_runtime_get_sync(dev);
+	if (ret < 0) {
+		dev_err(dev, "Failed to resume: %d\n", ret);
+		return ret;
+	}
+
 	ret = regmap_read(wm8962->regmap, WM8962_INTERRUPT_STATUS_2_MASK,
 			  &mask);
 	if (ret != 0) {
@@ -3019,8 +3025,10 @@ static irqreturn_t wm8962_irq(int irq, void *data)
 
 	active &= ~mask;
 
-	if (!active)
+	if (!active) {
+		pm_runtime_put(dev);
 		return IRQ_NONE;
+	}
 
 	/* Acknowledge the interrupts */
 	ret = regmap_write(wm8962->regmap, WM8962_INTERRUPT_STATUS_2, active);
@@ -3070,6 +3078,8 @@ static irqreturn_t wm8962_irq(int irq, void *data)
 				   msecs_to_jiffies(250));
 	}
 
+	pm_runtime_put(dev);
+
 	return IRQ_HANDLED;
 }
 
-- 
1.9.rc1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/4] ASoC: wm8962: Check if we runtime resume the device when starting FLL
  2014-01-31 15:29 [PATCH 1/4] ASoC: wm8962: Hold a runtime PM reference while handling interrupts Mark Brown
@ 2014-01-31 15:29 ` Mark Brown
  2014-01-31 15:30 ` [PATCH 3/4] ASoC: wm8962: Clean up error handling for failed FLL start Mark Brown
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Mark Brown @ 2014-01-31 15:29 UTC (permalink / raw)
  To: Liam Girdwood; +Cc: alsa-devel, patches, linaro-kernel, Mark Brown

From: Mark Brown <broonie@linaro.org>

Signed-off-by: Mark Brown <broonie@linaro.org>
---
 sound/soc/codecs/wm8962.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/sound/soc/codecs/wm8962.c b/sound/soc/codecs/wm8962.c
index aa7ae76d5e28..8eccf7afe9db 100644
--- a/sound/soc/codecs/wm8962.c
+++ b/sound/soc/codecs/wm8962.c
@@ -2886,7 +2886,11 @@ static int wm8962_set_fll(struct snd_soc_codec *codec, int fll_id, int source,
 
 	try_wait_for_completion(&wm8962->fll_lock);
 
-	pm_runtime_get_sync(codec->dev);
+	ret = pm_runtime_get_sync(codec->dev);
+	if (ret < 0) {
+		dev_err(codec->dev, "Failed to resume device: %d\n", ret);
+		return ret;
+	}
 
 	snd_soc_update_bits(codec, WM8962_FLL_CONTROL_1,
 			    WM8962_FLL_FRAC | WM8962_FLL_REFCLK_SRC_MASK |
-- 
1.9.rc1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 3/4] ASoC: wm8962: Clean up error handling for failed FLL start
  2014-01-31 15:29 [PATCH 1/4] ASoC: wm8962: Hold a runtime PM reference while handling interrupts Mark Brown
  2014-01-31 15:29 ` [PATCH 2/4] ASoC: wm8962: Check if we runtime resume the device when starting FLL Mark Brown
@ 2014-01-31 15:30 ` Mark Brown
  2014-01-31 15:30 ` [PATCH 4/4] ASoC: wm8962: Reinitialise the IRQ completion rather than just trying it Mark Brown
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Mark Brown @ 2014-01-31 15:30 UTC (permalink / raw)
  To: Liam Girdwood; +Cc: alsa-devel, patches, linaro-kernel, Mark Brown

From: Mark Brown <broonie@linaro.org>

Don't record the FLL as having started and leave the hardware disabled
ensuring we are in a better state if this does happen to be a transient
error and making debugging easier.

Signed-off-by: Mark Brown <broonie@linaro.org>
---
 sound/soc/codecs/wm8962.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/sound/soc/codecs/wm8962.c b/sound/soc/codecs/wm8962.c
index 8eccf7afe9db..55bf3f493dab 100644
--- a/sound/soc/codecs/wm8962.c
+++ b/sound/soc/codecs/wm8962.c
@@ -2898,8 +2898,6 @@ static int wm8962_set_fll(struct snd_soc_codec *codec, int fll_id, int source,
 
 	dev_dbg(codec->dev, "FLL configured for %dHz->%dHz\n", Fref, Fout);
 
-	ret = 0;
-
 	/* This should be a massive overestimate but go even
 	 * higher if we'll error out
 	 */
@@ -2913,14 +2911,17 @@ static int wm8962_set_fll(struct snd_soc_codec *codec, int fll_id, int source,
 
 	if (timeout == 0 && wm8962->irq) {
 		dev_err(codec->dev, "FLL lock timed out");
-		ret = -ETIMEDOUT;
+		snd_soc_update_bits(codec, WM8962_FLL_CONTROL_1,
+				    WM8962_FLL_ENA, 0);
+		pm_runtime_put(codec->dev);
+		return -ETIMEDOUT;
 	}
 
 	wm8962->fll_fref = Fref;
 	wm8962->fll_fout = Fout;
 	wm8962->fll_src = source;
 
-	return ret;
+	return 0;
 }
 
 static int wm8962_mute(struct snd_soc_dai *dai, int mute)
-- 
1.9.rc1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 4/4] ASoC: wm8962: Reinitialise the IRQ completion rather than just trying it
  2014-01-31 15:29 [PATCH 1/4] ASoC: wm8962: Hold a runtime PM reference while handling interrupts Mark Brown
  2014-01-31 15:29 ` [PATCH 2/4] ASoC: wm8962: Check if we runtime resume the device when starting FLL Mark Brown
  2014-01-31 15:30 ` [PATCH 3/4] ASoC: wm8962: Clean up error handling for failed FLL start Mark Brown
@ 2014-01-31 15:30 ` Mark Brown
  2014-01-31 15:48 ` [PATCH 1/4] ASoC: wm8962: Hold a runtime PM reference while handling interrupts Charles Keepax
  2014-01-31 17:35 ` Takashi Iwai
  4 siblings, 0 replies; 7+ messages in thread
From: Mark Brown @ 2014-01-31 15:30 UTC (permalink / raw)
  To: Liam Girdwood; +Cc: alsa-devel, patches, linaro-kernel, Mark Brown

From: Mark Brown <broonie@linaro.org>

This is better practice.

Signed-off-by: Mark Brown <broonie@linaro.org>
---
 sound/soc/codecs/wm8962.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/soc/codecs/wm8962.c b/sound/soc/codecs/wm8962.c
index 55bf3f493dab..1663b6b6eb35 100644
--- a/sound/soc/codecs/wm8962.c
+++ b/sound/soc/codecs/wm8962.c
@@ -2884,7 +2884,7 @@ static int wm8962_set_fll(struct snd_soc_codec *codec, int fll_id, int source,
 	snd_soc_write(codec, WM8962_FLL_CONTROL_7, fll_div.lambda);
 	snd_soc_write(codec, WM8962_FLL_CONTROL_8, fll_div.n);
 
-	try_wait_for_completion(&wm8962->fll_lock);
+	reinit_completion(&wm8962->fll_lock);
 
 	ret = pm_runtime_get_sync(codec->dev);
 	if (ret < 0) {
-- 
1.9.rc1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/4] ASoC: wm8962: Hold a runtime PM reference while handling interrupts
  2014-01-31 15:29 [PATCH 1/4] ASoC: wm8962: Hold a runtime PM reference while handling interrupts Mark Brown
                   ` (2 preceding siblings ...)
  2014-01-31 15:30 ` [PATCH 4/4] ASoC: wm8962: Reinitialise the IRQ completion rather than just trying it Mark Brown
@ 2014-01-31 15:48 ` Charles Keepax
  2014-01-31 17:35 ` Takashi Iwai
  4 siblings, 0 replies; 7+ messages in thread
From: Charles Keepax @ 2014-01-31 15:48 UTC (permalink / raw)
  To: Mark Brown; +Cc: alsa-devel, patches, Liam Girdwood, linaro-kernel, Mark Brown

On Fri, Jan 31, 2014 at 03:29:58PM +0000, Mark Brown wrote:
> From: Mark Brown <broonie@linaro.org>
> 
> If the device is runtime suspended then we can't interact with it as it
> may have been powered off and the register map will be in cache only
> mode.
> 
> Signed-off-by: Mark Brown <broonie@linaro.org>

All look fine to me.

Acked-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>

Thanks,
Charles

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/4] ASoC: wm8962: Hold a runtime PM reference while handling interrupts
  2014-01-31 15:29 [PATCH 1/4] ASoC: wm8962: Hold a runtime PM reference while handling interrupts Mark Brown
                   ` (3 preceding siblings ...)
  2014-01-31 15:48 ` [PATCH 1/4] ASoC: wm8962: Hold a runtime PM reference while handling interrupts Charles Keepax
@ 2014-01-31 17:35 ` Takashi Iwai
  2014-01-31 17:40   ` Mark Brown
  4 siblings, 1 reply; 7+ messages in thread
From: Takashi Iwai @ 2014-01-31 17:35 UTC (permalink / raw)
  To: Mark Brown; +Cc: alsa-devel, patches, Liam Girdwood, linaro-kernel, Mark Brown

At Fri, 31 Jan 2014 15:29:58 +0000,
Mark Brown wrote:
> 
> From: Mark Brown <broonie@linaro.org>
> 
> If the device is runtime suspended then we can't interact with it as it
> may have been powered off and the register map will be in cache only
> mode.
> 
> Signed-off-by: Mark Brown <broonie@linaro.org>
> ---
>  sound/soc/codecs/wm8962.c | 12 +++++++++++-
>  1 file changed, 11 insertions(+), 1 deletion(-)
> 
> diff --git a/sound/soc/codecs/wm8962.c b/sound/soc/codecs/wm8962.c
> index 97db3b45b411..aa7ae76d5e28 100644
> --- a/sound/soc/codecs/wm8962.c
> +++ b/sound/soc/codecs/wm8962.c
> @@ -3003,6 +3003,12 @@ static irqreturn_t wm8962_irq(int irq, void *data)
>  	unsigned int active;
>  	int reg, ret;
>  
> +	ret = pm_runtime_get_sync(dev);
> +	if (ret < 0) {
> +		dev_err(dev, "Failed to resume: %d\n", ret);
> +		return ret;

Shouldn't here return IRQ_XXX?


Takashi

> +	}
> +
>  	ret = regmap_read(wm8962->regmap, WM8962_INTERRUPT_STATUS_2_MASK,
>  			  &mask);
>  	if (ret != 0) {
> @@ -3019,8 +3025,10 @@ static irqreturn_t wm8962_irq(int irq, void *data)
>  
>  	active &= ~mask;
>  
> -	if (!active)
> +	if (!active) {
> +		pm_runtime_put(dev);
>  		return IRQ_NONE;
> +	}
>  
>  	/* Acknowledge the interrupts */
>  	ret = regmap_write(wm8962->regmap, WM8962_INTERRUPT_STATUS_2, active);
> @@ -3070,6 +3078,8 @@ static irqreturn_t wm8962_irq(int irq, void *data)
>  				   msecs_to_jiffies(250));
>  	}
>  
> +	pm_runtime_put(dev);
> +
>  	return IRQ_HANDLED;
>  }
>  
> -- 
> 1.9.rc1
> 
> _______________________________________________
> 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 1/4] ASoC: wm8962: Hold a runtime PM reference while handling interrupts
  2014-01-31 17:35 ` Takashi Iwai
@ 2014-01-31 17:40   ` Mark Brown
  0 siblings, 0 replies; 7+ messages in thread
From: Mark Brown @ 2014-01-31 17:40 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: alsa-devel, patches, Liam Girdwood, linaro-kernel


[-- Attachment #1.1: Type: text/plain, Size: 245 bytes --]

On Fri, Jan 31, 2014 at 06:35:26PM +0100, Takashi Iwai wrote:

> > +	ret = pm_runtime_get_sync(dev);
> > +	if (ret < 0) {
> > +		dev_err(dev, "Failed to resume: %d\n", ret);
> > +		return ret;

> Shouldn't here return IRQ_XXX?

Yeah, it should.

[-- 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:[~2014-01-31 17:40 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-01-31 15:29 [PATCH 1/4] ASoC: wm8962: Hold a runtime PM reference while handling interrupts Mark Brown
2014-01-31 15:29 ` [PATCH 2/4] ASoC: wm8962: Check if we runtime resume the device when starting FLL Mark Brown
2014-01-31 15:30 ` [PATCH 3/4] ASoC: wm8962: Clean up error handling for failed FLL start Mark Brown
2014-01-31 15:30 ` [PATCH 4/4] ASoC: wm8962: Reinitialise the IRQ completion rather than just trying it Mark Brown
2014-01-31 15:48 ` [PATCH 1/4] ASoC: wm8962: Hold a runtime PM reference while handling interrupts Charles Keepax
2014-01-31 17:35 ` Takashi Iwai
2014-01-31 17:40   ` Mark Brown

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.