linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mfd: twl-core: disable irq while suspended
@ 2019-02-23 11:47 Andreas Kemnade
  2019-02-23 18:23 ` Tony Lindgren
  2019-04-02  3:52 ` Lee Jones
  0 siblings, 2 replies; 4+ messages in thread
From: Andreas Kemnade @ 2019-02-23 11:47 UTC (permalink / raw)
  To: tony, lee.jones, linux-omap, linux-kernel, Wolfram Sang,
	linux-i2c, Dave Gerlach, Grygorii Strashko, Keerthy, Tero Kristo,
	letux-kernel
  Cc: Andreas Kemnade

Since commit
6e2bd956936 ("i2c: omap: Use noirq system sleep pm ops to idle device for suspend")
on gta04 we have handle_twl4030_pih() called in situations where pm_runtime_get()
in i2c-omap.c returns -EACCES.
[   86.474365] Freezing remaining freezable tasks ... (elapsed 0.002 seconds) done.
[   86.485473] printk: Suspending console(s) (use no_console_suspend to debug)
[   86.555572] Disabling non-boot CPUs ...
[   86.555664] Successfully put all powerdomains to target state
[   86.563720] twl: Read failed (mod 1, reg 0x01 count 1)
[   86.563751] twl4030: I2C error -13 reading PIH ISR
[   86.563812] twl: Read failed (mod 1, reg 0x01 count 1)
[   86.563812] twl4030: I2C error -13 reading PIH ISR
[   86.563873] twl: Read failed (mod 1, reg 0x01 count 1)
[   86.563903] twl4030: I2C error -13 reading PIH ISR

This happens when we wakeup via something behing twl4030
(powerbutton or rtc alarm).
This goes on for minutes until the system is finally resumed.
Disable the irq on suspend and enable it on resume to avoid
having i2c access problems when the irq registers are checked.

Signed-off-by: Andreas Kemnade <andreas@kemnade.info>
---
 drivers/mfd/twl-core.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/drivers/mfd/twl-core.c b/drivers/mfd/twl-core.c
index 299016bc46d9..104477b512a2 100644
--- a/drivers/mfd/twl-core.c
+++ b/drivers/mfd/twl-core.c
@@ -1245,6 +1245,28 @@ twl_probe(struct i2c_client *client, const struct i2c_device_id *id)
 	return status;
 }
 
+static int __maybe_unused twl_suspend(struct device *dev)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+
+	if (client->irq)
+		disable_irq(client->irq);
+
+	return 0;
+}
+
+static int __maybe_unused twl_resume(struct device *dev)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+
+	if (client->irq)
+		enable_irq(client->irq);
+
+	return 0;
+}
+
+static SIMPLE_DEV_PM_OPS(twl_dev_pm_ops, twl_suspend, twl_resume);
+
 static const struct i2c_device_id twl_ids[] = {
 	{ "twl4030", TWL4030_VAUX2 },	/* "Triton 2" */
 	{ "twl5030", 0 },		/* T2 updated */
@@ -1262,6 +1284,7 @@ static const struct i2c_device_id twl_ids[] = {
 /* One Client Driver , 4 Clients */
 static struct i2c_driver twl_driver = {
 	.driver.name	= DRIVER_NAME,
+	.driver.pm	= &twl_dev_pm_ops,
 	.id_table	= twl_ids,
 	.probe		= twl_probe,
 	.remove		= twl_remove,
-- 
2.11.0


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

* Re: [PATCH] mfd: twl-core: disable irq while suspended
  2019-02-23 11:47 [PATCH] mfd: twl-core: disable irq while suspended Andreas Kemnade
@ 2019-02-23 18:23 ` Tony Lindgren
  2019-03-01  6:45   ` Andreas Kemnade
  2019-04-02  3:52 ` Lee Jones
  1 sibling, 1 reply; 4+ messages in thread
From: Tony Lindgren @ 2019-02-23 18:23 UTC (permalink / raw)
  To: Andreas Kemnade
  Cc: lee.jones, linux-omap, linux-kernel, Wolfram Sang, linux-i2c,
	Dave Gerlach, Grygorii Strashko, Keerthy, Tero Kristo,
	letux-kernel

* Andreas Kemnade <andreas@kemnade.info> [190223 11:48]:
> Since commit
> 6e2bd956936 ("i2c: omap: Use noirq system sleep pm ops to idle device for suspend")
> on gta04 we have handle_twl4030_pih() called in situations where pm_runtime_get()
> in i2c-omap.c returns -EACCES.
> [   86.474365] Freezing remaining freezable tasks ... (elapsed 0.002 seconds) done.
> [   86.485473] printk: Suspending console(s) (use no_console_suspend to debug)
> [   86.555572] Disabling non-boot CPUs ...
> [   86.555664] Successfully put all powerdomains to target state
> [   86.563720] twl: Read failed (mod 1, reg 0x01 count 1)
> [   86.563751] twl4030: I2C error -13 reading PIH ISR
> [   86.563812] twl: Read failed (mod 1, reg 0x01 count 1)
> [   86.563812] twl4030: I2C error -13 reading PIH ISR
> [   86.563873] twl: Read failed (mod 1, reg 0x01 count 1)
> [   86.563903] twl4030: I2C error -13 reading PIH ISR
> 
> This happens when we wakeup via something behing twl4030
> (powerbutton or rtc alarm).
> This goes on for minutes until the system is finally resumed.
> Disable the irq on suspend and enable it on resume to avoid
> having i2c access problems when the irq registers are checked.

Thanks for fixing this, still works fine for me for rtcwake:

Tested-by: Tony Lindgren <tony@atomide.com>

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

* Re: [PATCH] mfd: twl-core: disable irq while suspended
  2019-02-23 18:23 ` Tony Lindgren
@ 2019-03-01  6:45   ` Andreas Kemnade
  0 siblings, 0 replies; 4+ messages in thread
From: Andreas Kemnade @ 2019-03-01  6:45 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: lee.jones, linux-omap, linux-kernel, Wolfram Sang, linux-i2c,
	Dave Gerlach, Grygorii Strashko, Keerthy, Tero Kristo,
	letux-kernel

[-- Attachment #1: Type: text/plain, Size: 1741 bytes --]

Hi,

On Sat, 23 Feb 2019 10:23:23 -0800
Tony Lindgren <tony@atomide.com> wrote:

> * Andreas Kemnade <andreas@kemnade.info> [190223 11:48]:
> > Since commit
> > 6e2bd956936 ("i2c: omap: Use noirq system sleep pm ops to idle device for suspend")
> > on gta04 we have handle_twl4030_pih() called in situations where pm_runtime_get()
> > in i2c-omap.c returns -EACCES.
> > [   86.474365] Freezing remaining freezable tasks ... (elapsed 0.002 seconds) done.
> > [   86.485473] printk: Suspending console(s) (use no_console_suspend to debug)
> > [   86.555572] Disabling non-boot CPUs ...
> > [   86.555664] Successfully put all powerdomains to target state
> > [   86.563720] twl: Read failed (mod 1, reg 0x01 count 1)
> > [   86.563751] twl4030: I2C error -13 reading PIH ISR
> > [   86.563812] twl: Read failed (mod 1, reg 0x01 count 1)
> > [   86.563812] twl4030: I2C error -13 reading PIH ISR
> > [   86.563873] twl: Read failed (mod 1, reg 0x01 count 1)
> > [   86.563903] twl4030: I2C error -13 reading PIH ISR
> > 
> > This happens when we wakeup via something behing twl4030
> > (powerbutton or rtc alarm).
> > This goes on for minutes until the system is finally resumed.
> > Disable the irq on suspend and enable it on resume to avoid
> > having i2c access problems when the irq registers are checked.  
> 
> Thanks for fixing this, still works fine for me for rtcwake:
> 
> Tested-by: Tony Lindgren <tony@atomide.com>
> 
hmm, in which version we will see this regression fixed?

I consider this whole thing as a reminder to finally
improve my automated test facilities and finally add the suspend/power
consumption test scripts I have to it so I can catch such things earlier.

Regards,
Andreas

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH] mfd: twl-core: disable irq while suspended
  2019-02-23 11:47 [PATCH] mfd: twl-core: disable irq while suspended Andreas Kemnade
  2019-02-23 18:23 ` Tony Lindgren
@ 2019-04-02  3:52 ` Lee Jones
  1 sibling, 0 replies; 4+ messages in thread
From: Lee Jones @ 2019-04-02  3:52 UTC (permalink / raw)
  To: Andreas Kemnade
  Cc: tony, linux-omap, linux-kernel, Wolfram Sang, linux-i2c,
	Dave Gerlach, Grygorii Strashko, Keerthy, Tero Kristo,
	letux-kernel

On Sat, 23 Feb 2019, Andreas Kemnade wrote:

> Since commit
> 6e2bd956936 ("i2c: omap: Use noirq system sleep pm ops to idle device for suspend")
> on gta04 we have handle_twl4030_pih() called in situations where pm_runtime_get()
> in i2c-omap.c returns -EACCES.
> [   86.474365] Freezing remaining freezable tasks ... (elapsed 0.002 seconds) done.
> [   86.485473] printk: Suspending console(s) (use no_console_suspend to debug)
> [   86.555572] Disabling non-boot CPUs ...
> [   86.555664] Successfully put all powerdomains to target state
> [   86.563720] twl: Read failed (mod 1, reg 0x01 count 1)
> [   86.563751] twl4030: I2C error -13 reading PIH ISR
> [   86.563812] twl: Read failed (mod 1, reg 0x01 count 1)
> [   86.563812] twl4030: I2C error -13 reading PIH ISR
> [   86.563873] twl: Read failed (mod 1, reg 0x01 count 1)
> [   86.563903] twl4030: I2C error -13 reading PIH ISR
> 
> This happens when we wakeup via something behing twl4030
> (powerbutton or rtc alarm).
> This goes on for minutes until the system is finally resumed.
> Disable the irq on suspend and enable it on resume to avoid
> having i2c access problems when the irq registers are checked.
> 
> Signed-off-by: Andreas Kemnade <andreas@kemnade.info>
> ---
>  drivers/mfd/twl-core.c | 23 +++++++++++++++++++++++
>  1 file changed, 23 insertions(+)

Applied, thanks.

-- 
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

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

end of thread, other threads:[~2019-04-02  3:52 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-23 11:47 [PATCH] mfd: twl-core: disable irq while suspended Andreas Kemnade
2019-02-23 18:23 ` Tony Lindgren
2019-03-01  6:45   ` Andreas Kemnade
2019-04-02  3:52 ` 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).