Skip to content

Commit d8f090d

Browse files
krzkalexandrebelloni
authored andcommitted
rtc: max77686: Do not allow interrupt to fire before system resume
The rtc-max77686 device shares the main interrupt line with parent MFD device (max77686 driver). During the system suspend, the parent MFD device disables this IRQ to prevent an early event happening before resuming I2C bus controller. The same should be done by rtc-max77686 driver because otherwise the interrupt handler max77686_rtc_alarm_irq() will be called before its resume function (max77686_rtc_resume()). Such issue is not fatal but disabling shared IRQ by all users ensures correct behavior. Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Link: https://lore.kernel.org/r/20200615161455.4420-1-krzk@kernel.org
1 parent 05513a7 commit d8f090d

1 file changed

Lines changed: 18 additions & 2 deletions

File tree

drivers/rtc/rtc-max77686.c

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -805,17 +805,33 @@ static int max77686_rtc_remove(struct platform_device *pdev)
805805
#ifdef CONFIG_PM_SLEEP
806806
static int max77686_rtc_suspend(struct device *dev)
807807
{
808+
struct max77686_rtc_info *info = dev_get_drvdata(dev);
809+
int ret = 0;
810+
808811
if (device_may_wakeup(dev)) {
809812
struct max77686_rtc_info *info = dev_get_drvdata(dev);
810813

811-
return enable_irq_wake(info->virq);
814+
ret = enable_irq_wake(info->virq);
812815
}
813816

814-
return 0;
817+
/*
818+
* Main IRQ (not virtual) must be disabled during suspend because if it
819+
* happens while suspended it will be handled before resuming I2C.
820+
*
821+
* Since Main IRQ is shared, all its users should disable it to be sure
822+
* it won't fire while one of them is still suspended.
823+
*/
824+
disable_irq(info->rtc_irq);
825+
826+
return ret;
815827
}
816828

817829
static int max77686_rtc_resume(struct device *dev)
818830
{
831+
struct max77686_rtc_info *info = dev_get_drvdata(dev);
832+
833+
enable_irq(info->rtc_irq);
834+
819835
if (device_may_wakeup(dev)) {
820836
struct max77686_rtc_info *info = dev_get_drvdata(dev);
821837

0 commit comments

Comments
 (0)