Skip to content

Commit 2fff0b5

Browse files
superm1linusw
authored andcommitted
pinctrl: amd: Mask non-wake source pins with interrupt enabled at suspend
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 <[email protected]> Reported-and-tested-by: Mark Herbert <[email protected]> Link: https://gitlab.freedesktop.org/drm/amd/-/issues/2812 Signed-off-by: Mario Limonciello <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Linus Walleij <[email protected]>
1 parent 5c584f1 commit 2fff0b5

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

drivers/pinctrl/pinctrl-amd.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -923,6 +923,15 @@ static int amd_gpio_suspend(struct device *dev)
923923

924924
raw_spin_lock_irqsave(&gpio_dev->lock, flags);
925925
gpio_dev->saved_regs[i] = readl(gpio_dev->base + pin * 4) & ~PIN_IRQ_PENDING;
926+
927+
/* mask any interrupts not intended to be a wake source */
928+
if (!(gpio_dev->saved_regs[i] & WAKE_SOURCE)) {
929+
writel(gpio_dev->saved_regs[i] & ~BIT(INTERRUPT_MASK_OFF),
930+
gpio_dev->base + pin * 4);
931+
pm_pr_dbg("Disabling GPIO #%d interrupt for suspend.\n",
932+
pin);
933+
}
934+
926935
raw_spin_unlock_irqrestore(&gpio_dev->lock, flags);
927936
}
928937

drivers/pinctrl/pinctrl-amd.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,11 @@
8080
#define FUNCTION_MASK GENMASK(1, 0)
8181
#define FUNCTION_INVALID GENMASK(7, 0)
8282

83+
#define WAKE_SOURCE (BIT(WAKE_CNTRL_OFF_S0I3) | \
84+
BIT(WAKE_CNTRL_OFF_S3) | \
85+
BIT(WAKE_CNTRL_OFF_S4) | \
86+
BIT(WAKECNTRL_Z_OFF))
87+
8388
struct amd_function {
8489
const char *name;
8590
const char * const groups[NSELECTS];

0 commit comments

Comments
 (0)