Skip to content

Commit 179db19

Browse files
superm1rafaeljw
authored andcommitted
pinctrl: amd: Add an LPS0 check() callback
During suspend the pinctrl_amd driver disables the interrupts for any GPIOs that are not marked as wake sources. This however does not prevent them from changing the wake status bit during suspend, it just stops the system from waking. If the system wakes from hardware sleep for another reason (such as plugging in the AC adapter) this wake bits might be active. This could potentially cause problems with going back to hardware sleep. Add an extra debugging message when PM debugging is enabled to help identify if this is happening. Acked-by: Linus Walleij <[email protected]> Link: https://gitlab.freedesktop.org/drm/amd/-/issues/3929 Signed-off-by: Mario Limonciello <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent e1bdbbc commit 179db19

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

drivers/pinctrl/pinctrl-amd.c

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737
#include "pinctrl-utils.h"
3838
#include "pinctrl-amd.h"
3939

40+
static struct amd_gpio *pinctrl_dev;
41+
4042
static int amd_gpio_get_direction(struct gpio_chip *gc, unsigned offset)
4143
{
4244
unsigned long flags;
@@ -909,6 +911,31 @@ static bool amd_gpio_should_save(struct amd_gpio *gpio_dev, unsigned int pin)
909911
return false;
910912
}
911913

914+
#ifdef CONFIG_ACPI
915+
static void amd_gpio_check_pending(void)
916+
{
917+
struct amd_gpio *gpio_dev = pinctrl_dev;
918+
struct pinctrl_desc *desc = gpio_dev->pctrl->desc;
919+
int i;
920+
921+
if (!pm_debug_messages_on)
922+
return;
923+
924+
for (i = 0; i < desc->npins; i++) {
925+
int pin = desc->pins[i].number;
926+
u32 tmp;
927+
928+
tmp = readl(gpio_dev->base + pin * 4);
929+
if (tmp & PIN_IRQ_PENDING)
930+
pm_pr_dbg("%s: GPIO %d is active: 0x%x.\n", __func__, pin, tmp);
931+
}
932+
}
933+
934+
static struct acpi_s2idle_dev_ops pinctrl_amd_s2idle_dev_ops = {
935+
.check = amd_gpio_check_pending,
936+
};
937+
#endif
938+
912939
static int amd_gpio_suspend_hibernate_common(struct device *dev, bool is_suspend)
913940
{
914941
struct amd_gpio *gpio_dev = dev_get_drvdata(dev);
@@ -942,6 +969,7 @@ static int amd_gpio_suspend_hibernate_common(struct device *dev, bool is_suspend
942969

943970
static int amd_gpio_suspend(struct device *dev)
944971
{
972+
pinctrl_dev = dev_get_drvdata(dev);
945973
return amd_gpio_suspend_hibernate_common(dev, true);
946974
}
947975

@@ -1181,6 +1209,9 @@ static int amd_gpio_probe(struct platform_device *pdev)
11811209

11821210
platform_set_drvdata(pdev, gpio_dev);
11831211
acpi_register_wakeup_handler(gpio_dev->irq, amd_gpio_check_wake, gpio_dev);
1212+
#ifdef CONFIG_ACPI
1213+
acpi_register_lps0_dev(&pinctrl_amd_s2idle_dev_ops);
1214+
#endif
11841215

11851216
dev_dbg(&pdev->dev, "amd gpio driver loaded\n");
11861217
return ret;
@@ -1199,6 +1230,9 @@ static void amd_gpio_remove(struct platform_device *pdev)
11991230

12001231
gpiochip_remove(&gpio_dev->gc);
12011232
acpi_unregister_wakeup_handler(amd_gpio_check_wake, gpio_dev);
1233+
#ifdef CONFIG_ACPI
1234+
acpi_unregister_lps0_dev(&pinctrl_amd_s2idle_dev_ops);
1235+
#endif
12021236
}
12031237

12041238
#ifdef CONFIG_ACPI

0 commit comments

Comments
 (0)