linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mfd: arizona: Use suspend_noirq inplace of suspend_late
@ 2016-08-30  9:33 Charles Keepax
  2016-08-31 12:44 ` Lee Jones
  0 siblings, 1 reply; 2+ messages in thread
From: Charles Keepax @ 2016-08-30  9:33 UTC (permalink / raw)
  To: lee.jones; +Cc: linux-kernel, patches

As runtime PM doesn't function whilst processing system suspend/resume
operations and the Arizona IRQ handlers need runtime PM to function
we must disable IRQs during these operations. Whilst this is
already done in the driver we are using suspend/suspend_late and
resume/resume_noirq to do so which has two problems. Firstly, as
suspend_late is before suspend_noirq that means we still have a
small window where an IRQ can cause issues.  Secondly, if another
suspend_late handler fails after ours has run then (as resume_noirq
will not run) we will make unbalanced calls to enable_irq.

This is all simply fixed by using the suspend_noirq callback rather
than suspend_late. Whilst we are doing this tidy the code up a little,
and use the appropriate helper macros.

Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
---
 drivers/mfd/arizona-core.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/mfd/arizona-core.c b/drivers/mfd/arizona-core.c
index 34a2c26..fe2277d 100644
--- a/drivers/mfd/arizona-core.c
+++ b/drivers/mfd/arizona-core.c
@@ -735,7 +735,7 @@ static int arizona_suspend(struct device *dev)
 	return 0;
 }
 
-static int arizona_suspend_late(struct device *dev)
+static int arizona_suspend_noirq(struct device *dev)
 {
 	struct arizona *arizona = dev_get_drvdata(dev);
 
@@ -759,7 +759,7 @@ static int arizona_resume(struct device *dev)
 {
 	struct arizona *arizona = dev_get_drvdata(dev);
 
-	dev_dbg(arizona->dev, "Late resume, reenabling IRQ\n");
+	dev_dbg(arizona->dev, "Resume, reenabling IRQ\n");
 	enable_irq(arizona->irq);
 
 	return 0;
@@ -771,10 +771,8 @@ const struct dev_pm_ops arizona_pm_ops = {
 			   arizona_runtime_resume,
 			   NULL)
 	SET_SYSTEM_SLEEP_PM_OPS(arizona_suspend, arizona_resume)
-#ifdef CONFIG_PM_SLEEP
-	.suspend_late = arizona_suspend_late,
-	.resume_noirq = arizona_resume_noirq,
-#endif
+	SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(arizona_suspend_noirq,
+				      arizona_resume_noirq)
 };
 EXPORT_SYMBOL_GPL(arizona_pm_ops);
 
-- 
2.1.4

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

* Re: [PATCH] mfd: arizona: Use suspend_noirq inplace of suspend_late
  2016-08-30  9:33 [PATCH] mfd: arizona: Use suspend_noirq inplace of suspend_late Charles Keepax
@ 2016-08-31 12:44 ` Lee Jones
  0 siblings, 0 replies; 2+ messages in thread
From: Lee Jones @ 2016-08-31 12:44 UTC (permalink / raw)
  To: Charles Keepax; +Cc: linux-kernel, patches

On Tue, 30 Aug 2016, Charles Keepax wrote:

> As runtime PM doesn't function whilst processing system suspend/resume
> operations and the Arizona IRQ handlers need runtime PM to function
> we must disable IRQs during these operations. Whilst this is
> already done in the driver we are using suspend/suspend_late and
> resume/resume_noirq to do so which has two problems. Firstly, as
> suspend_late is before suspend_noirq that means we still have a
> small window where an IRQ can cause issues.  Secondly, if another
> suspend_late handler fails after ours has run then (as resume_noirq
> will not run) we will make unbalanced calls to enable_irq.
> 
> This is all simply fixed by using the suspend_noirq callback rather
> than suspend_late. Whilst we are doing this tidy the code up a little,
> and use the appropriate helper macros.
> 
> Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
> ---
>  drivers/mfd/arizona-core.c | 10 ++++------
>  1 file changed, 4 insertions(+), 6 deletions(-)

Applied, thanks.

> diff --git a/drivers/mfd/arizona-core.c b/drivers/mfd/arizona-core.c
> index 34a2c26..fe2277d 100644
> --- a/drivers/mfd/arizona-core.c
> +++ b/drivers/mfd/arizona-core.c
> @@ -735,7 +735,7 @@ static int arizona_suspend(struct device *dev)
>  	return 0;
>  }
>  
> -static int arizona_suspend_late(struct device *dev)
> +static int arizona_suspend_noirq(struct device *dev)
>  {
>  	struct arizona *arizona = dev_get_drvdata(dev);
>  
> @@ -759,7 +759,7 @@ static int arizona_resume(struct device *dev)
>  {
>  	struct arizona *arizona = dev_get_drvdata(dev);
>  
> -	dev_dbg(arizona->dev, "Late resume, reenabling IRQ\n");
> +	dev_dbg(arizona->dev, "Resume, reenabling IRQ\n");
>  	enable_irq(arizona->irq);
>  
>  	return 0;
> @@ -771,10 +771,8 @@ const struct dev_pm_ops arizona_pm_ops = {
>  			   arizona_runtime_resume,
>  			   NULL)
>  	SET_SYSTEM_SLEEP_PM_OPS(arizona_suspend, arizona_resume)
> -#ifdef CONFIG_PM_SLEEP
> -	.suspend_late = arizona_suspend_late,
> -	.resume_noirq = arizona_resume_noirq,
> -#endif
> +	SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(arizona_suspend_noirq,
> +				      arizona_resume_noirq)
>  };
>  EXPORT_SYMBOL_GPL(arizona_pm_ops);
>  

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

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

end of thread, other threads:[~2016-08-31 12:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-30  9:33 [PATCH] mfd: arizona: Use suspend_noirq inplace of suspend_late Charles Keepax
2016-08-31 12:44 ` Lee Jones

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).