Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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

authored by

Krzysztof Kozlowski and committed by
Alexandre Belloni
d8f090db 05513a70

+18 -2
+18 -2
drivers/rtc/rtc-max77686.c
··· 805 805 #ifdef CONFIG_PM_SLEEP 806 806 static int max77686_rtc_suspend(struct device *dev) 807 807 { 808 + struct max77686_rtc_info *info = dev_get_drvdata(dev); 809 + int ret = 0; 810 + 808 811 if (device_may_wakeup(dev)) { 809 812 struct max77686_rtc_info *info = dev_get_drvdata(dev); 810 813 811 - return enable_irq_wake(info->virq); 814 + ret = enable_irq_wake(info->virq); 812 815 } 813 816 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; 815 827 } 816 828 817 829 static int max77686_rtc_resume(struct device *dev) 818 830 { 831 + struct max77686_rtc_info *info = dev_get_drvdata(dev); 832 + 833 + enable_irq(info->rtc_irq); 834 + 819 835 if (device_may_wakeup(dev)) { 820 836 struct max77686_rtc_info *info = dev_get_drvdata(dev); 821 837