]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
pinctrl: amd: Mask non-wake source pins with interrupt enabled at suspend
authorMario Limonciello <mario.limonciello@amd.com>
Sun, 3 Dec 2023 03:24:31 +0000 (21:24 -0600)
committerLinus Walleij <linus.walleij@linaro.org>
Mon, 4 Dec 2023 14:46:02 +0000 (15:46 +0100)
If a pin isn't marked as a wake source processing any interrupts is
just going to destroy battery life.  The APU may wake up from a hardware
sleep state to process the interrupt but not return control to the OS.

Mask interrupt for all non-wake source pins at suspend. They'll be
re-enabled at resume.

Reported-and-tested-by: Marcus Aram <marcus+oss@oxar.nl>
Reported-and-tested-by: Mark Herbert <mark.herbert42@gmail.com>
Link: https://gitlab.freedesktop.org/drm/amd/-/issues/2812
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
Link: https://lore.kernel.org/r/20231203032431.30277-3-mario.limonciello@amd.com
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
drivers/pinctrl/pinctrl-amd.c
drivers/pinctrl/pinctrl-amd.h

index fb58acb843d90a94088f27736bebe7a5c1c577b1..03ecb3d1aaf60da974f32bb344203b418969064f 100644 (file)
@@ -923,6 +923,15 @@ static int amd_gpio_suspend(struct device *dev)
 
                raw_spin_lock_irqsave(&gpio_dev->lock, flags);
                gpio_dev->saved_regs[i] = readl(gpio_dev->base + pin * 4) & ~PIN_IRQ_PENDING;
+
+               /* mask any interrupts not intended to be a wake source */
+               if (!(gpio_dev->saved_regs[i] & WAKE_SOURCE)) {
+                       writel(gpio_dev->saved_regs[i] & ~BIT(INTERRUPT_MASK_OFF),
+                              gpio_dev->base + pin * 4);
+                       pm_pr_dbg("Disabling GPIO #%d interrupt for suspend.\n",
+                                 pin);
+               }
+
                raw_spin_unlock_irqrestore(&gpio_dev->lock, flags);
        }
 
index 34c5c3e71fb261cdeb8c6c5ffdfe59c126db8ae0..cf59089f277639629f80928e956b024b30fb6351 100644 (file)
 #define FUNCTION_MASK          GENMASK(1, 0)
 #define FUNCTION_INVALID       GENMASK(7, 0)
 
+#define WAKE_SOURCE    (BIT(WAKE_CNTRL_OFF_S0I3) | \
+                        BIT(WAKE_CNTRL_OFF_S3)   | \
+                        BIT(WAKE_CNTRL_OFF_S4)   | \
+                        BIT(WAKECNTRL_Z_OFF))
+
 struct amd_function {
        const char *name;
        const char * const groups[NSELECTS];