* [PATCH AUTOSEL 4.14 3/6] pinctrl: amd: Mask non-wake source pins with interrupt enabled at suspend [not found] <20231226002725.7471-1-sashal@kernel.org> @ 2023-12-26 0:27 ` Sasha Levin 2024-01-09 11:43 ` Pavel Machek 0 siblings, 1 reply; 3+ messages in thread From: Sasha Levin @ 2023-12-26 0:27 UTC (permalink / raw) To: linux-kernel, stable Cc: Mario Limonciello, Marcus Aram, Mark Herbert, Linus Walleij, Sasha Levin, Basavaraj.Natikar, Shyam-sundar.S-k, linux-gpio From: Mario Limonciello <mario.limonciello@amd.com> [ Upstream commit 2fff0b5e1a6b9c577b4dd4958902c877159c856b ] 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> Signed-off-by: Sasha Levin <sashal@kernel.org> --- drivers/pinctrl/pinctrl-amd.c | 9 +++++++++ drivers/pinctrl/pinctrl-amd.h | 5 +++++ 2 files changed, 14 insertions(+) diff --git a/drivers/pinctrl/pinctrl-amd.c b/drivers/pinctrl/pinctrl-amd.c index 509ba4bceefcb..a5cd88c5dd844 100644 --- a/drivers/pinctrl/pinctrl-amd.c +++ b/drivers/pinctrl/pinctrl-amd.c @@ -766,6 +766,15 @@ 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); } diff --git a/drivers/pinctrl/pinctrl-amd.h b/drivers/pinctrl/pinctrl-amd.h index 884f48f7a6a36..065419dabffb5 100644 --- a/drivers/pinctrl/pinctrl-amd.h +++ b/drivers/pinctrl/pinctrl-amd.h @@ -80,6 +80,11 @@ struct amd_pingroup { unsigned npins; }; +#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; -- 2.43.0 ^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH AUTOSEL 4.14 3/6] pinctrl: amd: Mask non-wake source pins with interrupt enabled at suspend 2023-12-26 0:27 ` [PATCH AUTOSEL 4.14 3/6] pinctrl: amd: Mask non-wake source pins with interrupt enabled at suspend Sasha Levin @ 2024-01-09 11:43 ` Pavel Machek 2024-01-14 18:59 ` Sasha Levin 0 siblings, 1 reply; 3+ messages in thread From: Pavel Machek @ 2024-01-09 11:43 UTC (permalink / raw) To: Sasha Levin Cc: linux-kernel, stable, Mario Limonciello, Marcus Aram, Mark Herbert, Linus Walleij, Basavaraj.Natikar, Shyam-sundar.S-k, linux-gpio [-- Attachment #1: Type: text/plain, Size: 667 bytes --] Hi! > From: Mario Limonciello <mario.limonciello@amd.com> > > [ Upstream commit 2fff0b5e1a6b9c577b4dd4958902c877159c856b ] > > 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. Not sure what is going on here, but it is queued for 6.6 and 4.14, but not for the kernels between them. Best regards, Pavel -- People of Russia, stop Putin before his war on Ukraine escalates. [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 195 bytes --] ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH AUTOSEL 4.14 3/6] pinctrl: amd: Mask non-wake source pins with interrupt enabled at suspend 2024-01-09 11:43 ` Pavel Machek @ 2024-01-14 18:59 ` Sasha Levin 0 siblings, 0 replies; 3+ messages in thread From: Sasha Levin @ 2024-01-14 18:59 UTC (permalink / raw) To: Pavel Machek Cc: linux-kernel, stable, Mario Limonciello, Marcus Aram, Mark Herbert, Linus Walleij, Basavaraj.Natikar, Shyam-sundar.S-k, linux-gpio On Tue, Jan 09, 2024 at 12:43:27PM +0100, Pavel Machek wrote: >Hi! > >> From: Mario Limonciello <mario.limonciello@amd.com> >> >> [ Upstream commit 2fff0b5e1a6b9c577b4dd4958902c877159c856b ] >> >> 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. > >Not sure what is going on here, but it is queued for 6.6 and 4.14, but >not for the kernels between them. Ack, it should have been dropped from 4.14. Thanks! -- Thanks, Sasha ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-01-14 18:59 UTC | newest] Thread overview: 3+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- [not found] <20231226002725.7471-1-sashal@kernel.org> 2023-12-26 0:27 ` [PATCH AUTOSEL 4.14 3/6] pinctrl: amd: Mask non-wake source pins with interrupt enabled at suspend Sasha Levin 2024-01-09 11:43 ` Pavel Machek 2024-01-14 18:59 ` Sasha Levin
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).