i2c: busses: i2c-tegra: Using suspend_noirq()/resume_noirq() for suspend/resume
PATCH 1/1 i2c: busses: i2c-tegra: Using suspend_noirq()/resume_noirq() for suspend/resume
From: Wei Ni <[email protected]>
When use rtc-tps6586x wakealarm to suspend/resume,
it will show a lot error messages:
"tps6586x 4-0034: failed to read interrupt status
tps6586x 4-0034: failed reading from 0xb5"
After resume, the system will call tps6586x_irq() because of the alarm interrupt. This irq handle will read tps6586x interrupt status (0xb5), but at that time the i2c driver didn't resume yet, the system didn't call the tegra_i2c_resume(), so the reading will be failed.
I2C driver needs to be suspended late and resumed early than other drivers. So, I2C driver uses the suspend_noirq/resume_noirq callbacks of struct dev_pm_ops for early/late power management system.
--- drivers/i2c/busses/i2c-tegra.c | 19 +++++++++++++------ 1 files changed, 13 insertions(+), 6 deletions(-)
drivers/i2c/busses/i2c-tegra.c +13 -6
@@ -636,8 +636,9 @@ static int tegra_i2c_remove(struct platform_device *pdev) }#ifdef CONFIG_PM -static int tegra_i2c_suspend (struct platform_device *pdev,pm_message_t state) +static int tegra_i2c_suspend_noirq (struct device *dev) { +struct platform_device *pdev =to_platform_device (dev);struct tegra_i2c_dev *i2c_dev =platform_get_drvdata (pdev);i2c_lock_adapter (&i2c_dev->adapter);
@@ -647,8 +648,9 @@ static int tegra_i2c_suspend(struct platform_device *pdev, pm_message_t state)return 0 ; } -static int tegra_i2c_resume (struct platform_device *pdev) +static int tegra_i2c_resume_noirq (struct device *dev) { +struct platform_device *pdev =to_platform_device (dev);struct tegra_i2c_dev *i2c_dev =platform_get_drvdata (pdev);int ret;
@@ -667,18 +669,23 @@ static int tegra_i2c_resume(struct platform_device *pdev) return 0; } + +static const struct dev_pm_ops tegra_i2c_dev_pm_ops = { + .suspend_noirq = tegra_i2c_suspend_noirq, + .resume_noirq = tegra_i2c_resume_noirq, +}; +#define TEGRA_I2C_DEV_PM_OPS (&tegra_i2c_dev_pm_ops) +#else +#define TEGRA_I2C_DEV_PM_OPS NULL#endif static struct platform_driver tegra_i2c_driver = { .probe = tegra_i2c_probe, .remove = tegra_i2c_remove, -#ifdef CONFIG_PM - .suspend = tegra_i2c_suspend, - .resume = tegra_i2c_resume, -#endif .driver = { .name ="tegra-i2c" , .owner =THIS_MODULE , + .pm =TEGRA_I2C_DEV_PM_OPS , }, };
Signature · 1 line
1.7.0
Quoted 13 lines · On Sun, Mar 27, 2011 at 11:22 PM, <[email protected]…
From: Wei Ni <[email protected]>
When use rtc-tps6586x wakealarm to suspend/resume,
it will show a lot error messages:
"tps6586x 4-0034: failed to read interrupt status
tps6586x 4-0034: failed reading from0xb5"
After resume, the system will calltps6586x_irq()because of the alarm interrupt. This irq handle will read tps6586x interrupt status (0xb5), but at that time the i2c driver didn't resume yet, the system didn't call thetegra_i2c_resume(), so the reading will be failed.
I2C driver needs to be suspended late and resumed early than other drivers. So, I2C driver uses the suspend_noirq/resume_noirq callbacks of structdev_pm_opsfor early/late power management system.
This sounds like a bug in rtc-tps6586x. I think you need to call disable_irq in the rtc-tps6586x suspend function and an enable_irq in the resume function, which will delay the delivery of the wake irq until the rtc driver (and its parent, the i2c driver) has been resumed.
Hi, Colin
The irq in rtc-tps6586x is the alarm interrupt, I had tried to disable/enable it as you said, but the system couldn't be resumed by wakealarm.
I think it's better to change the i2c-tegra.c
Thanks
Wei.
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Colin Cross
Sent: Monday, March 28, 2011 2:34 PM
To: Wei Ni
Cc: [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH] i2c: busses: i2c-tegra: Using suspend_noirq()/resume_noirq() for suspend/resume
Quoted 13 lines · On Sun, Mar 27, 2011 at 11:22 PM, <[email protected]…
From: Wei Ni <[email protected]>
When use rtc-tps6586x wakealarm to suspend/resume,
it will show a lot error messages:
"tps6586x 4-0034: failed to read interrupt status
tps6586x 4-0034: failed reading from0xb5"
After resume, the system will calltps6586x_irq()because of the alarm interrupt. This irq handle will read tps6586x interrupt status (0xb5), but at that time the i2c driver didn't resume yet, the system didn't call thetegra_i2c_resume(), so the reading will be failed.
I2C driver needs to be suspended late and resumed early than other drivers. So, I2C driver uses the suspend_noirq/resume_noirq callbacks of structdev_pm_opsfor early/late power management system.
This sounds like a bug in rtc-tps6586x. I think you need to call disable_irq in the rtc-tps6586x suspend function and an enable_irq in the resume function, which will delay the delivery of the wake irq until the rtc driver (and its parent, the i2c driver) has been resumed.
Quoted 4 lines · Wei Ni
Hi, Colin
The irq in rtc-tps6586x is the alarm interrupt, I had tried to disable/enable it as you said, but the system couldn't be resumed by wakealarm.
I think it's better to change thei2c-tegra.c
Disabling an interrupt does not prevent waking from suspend on that interrupt if enable_irq_wake has also been called.
Hi, Cross
Sorry, I made some confusion.
In my description for this upstream, I said the tps6586x_irq() will try to read register before i2c resume. In here, the tps6586x_irq() is from drivers/mfd/tps6586x.c, not drivers/rtc/rtc-tps6586x.c I had tried to add disable/enable in suspend/resume for this mfd tps6586x driver, it also can fix this issue. So does there mean we should change the /drivers/mfd/tps6586x.c ?
Thanks
Wei.
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Colin Cross
Sent: Monday, March 28, 2011 3:05 PM
To: Wei Ni
Cc: [email protected]; [email protected]; [email protected]; [email protected]; Varun Wadekar
Subject: Re: [PATCH] i2c: busses: i2c-tegra: Using suspend_noirq()/resume_noirq() for suspend/resume
Quoted 4 lines · Wei Ni
Hi, Colin
The irq in rtc-tps6586x is the alarm interrupt, I had tried to disable/enable it as you said, but the system couldn't be resumed by wakealarm.
I think it's better to change thei2c-tegra.c
Disabling an interrupt does not prevent waking from suspend on that interrupt if enable_irq_wake has also been called.
Quoted 1 line
So does there mean we should change the /drivers/mfd/tps6586x.c ?
Yes, that seems a reasonable thing to do.
-----Original Message-----
From: Wei Ni
Sent: Monday, March 28, 2011 3:26 PM
To: 'Colin Cross'
Cc: [email protected]; [email protected]; [email protected]; [email protected]; Varun Wadekar
Subject: RE: [PATCH] i2c: busses: i2c-tegra: Using suspend_noirq()/resume_noirq() for suspend/resume
Hi, Cross
Sorry, I made some confusion.
In my description for this upstream, I said the tps6586x_irq() will try to read register before i2c resume. In here, the tps6586x_irq() is from drivers/mfd/tps6586x.c, not drivers/rtc/rtc-tps6586x.c I had tried to add disable/enable in suspend/resume for this mfd tps6586x driver, it also can fix this issue. So does there mean we should change the /drivers/mfd/tps6586x.c ?
Thanks
Wei.
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Colin Cross
Sent: Monday, March 28, 2011 3:05 PM
To: Wei Ni
Cc: [email protected]; [email protected]; [email protected]; [email protected]; Varun Wadekar
Subject: Re: [PATCH] i2c: busses: i2c-tegra: Using suspend_noirq()/resume_noirq() for suspend/resume
Quoted 4 lines · Wei Ni
Hi, Colin
The irq in rtc-tps6586x is the alarm interrupt, I had tried to disable/enable it as you said, but the system couldn't be resumed by wakealarm.
I think it's better to change thei2c-tegra.c
Disabling an interrupt does not prevent waking from suspend on that interrupt if enable_irq_wake has also been called.