pinctrl: amd: Clear GPIO debounce for suspend
Subsystems (3)
PATCH 1/1 pinctrl: amd: Clear GPIO debounce for suspend
From: Mario Limonciello <[email protected]>
soc-button-array hardcodes a debounce value by means of gpio_keys which uses pinctrl-amd as a backend to program debounce for a GPIO.
This hardcoded value doesn't match what the firmware intended to be programmed in _AEI. The hardcoded debounce leads to problems waking from suspend. There isn't appetite to conditionalize the behavior in soc-button-array or gpio-keys so clear it when the system suspends to avoid problems with being able to resume.
--- drivers/pinctrl/pinctrl-amd.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/pinctrl/pinctrl-amd.c +7 -0
@@ -979,6 +979,13 @@ static int amd_gpio_suspend_hibernate_common(struct device *dev, bool is_suspend pin, is_suspend ? "suspend" : "hibernate"); } +/* clear debounce */ +if (gpio_dev->saved_regs[i] & (DB_CNTRl_MASK <<DB_CNTRL_OFF )) { +amd_gpio_set_debounce (gpio_dev, pin,0 ); +pm_pr_dbg ("Clearing debounce for GPIO #%d during %s.\n" , + pin, is_suspend ?"suspend" :"hibernate" ); + } +raw_spin_unlock_irqrestore (&gpio_dev->lock, flags); }
Signature · 1 line
2.43.0
Hi Mario,
Quoted 10 lines · Mario Limonciello
From: Mario Limonciello <[email protected]>
soc-button-array hardcodes a debounce value by means of
gpio_keyswhich uses pinctrl-amd as a backend to program debounce for a GPIO.This hardcoded value doesn't match what the firmware intended to be programmed in
_AEI. The hardcoded debounce leads to problems waking from suspend. There isn't appetite to conditionalize the behavior in soc-button-array or gpio-keys so clear it when the system suspends to avoid problems with being able to resume.
Nice I do think this is a better solution then disabling hw-debounce in soc-button-array as we did before.
Quoted 15 lines
Cc Dmitry Torokhov <[email protected]>Cc Hans de Goede <[email protected]>Fixes 5c4fa2a6da7fb ("Input: soc_button_array - debounce the buttons")Link https://lore.kernel.org/linux-input/mkgtrb5gt7miyg6kvqdlbu4nj3elym6ijudobpdi26gp4xxay5@rsa6ytrjvj2q/ open hereSigned-off-by Mario Limonciello <[email protected]>--- drivers/pinctrl/pinctrl-amd.c | 7 +++++++ 1 file changed, 7 insertions(+)drivers/pinctrl/pinctrl-amd.c +0
-0
drivers/pinctrl/pinctrl-amd.c static int amd_gpio_suspend_hibernate_common(struct device *dev, bool is_suspend · line 988
Quoted 10 lines
drivers/pinctrl/pinctrl-amd.c +7
-0@@ -979,6 +979,13 @@ static int amd_gpio_suspend_hibernate_common(struct device *dev, bool is_suspend pin, is_suspend ? "suspend" : "hibernate"); } +/* clear debounce */ +if (gpio_dev->saved_regs[i] & (DB_CNTRl_MASK <<DB_CNTRL_OFF )) { +amd_gpio_set_debounce (gpio_dev, pin,0 ); +pm_pr_dbg ("Clearing debounce for GPIO #%d during %s.\n" , + pin, is_suspend ?"suspend" :"hibernate" ); + } +
I notice that the if () { } block above this checks if a pin is not configured to be a wakeup src. Since we only need this for wakeup sources maybe put this in an else block of the if () { } block above this ?
I've not strong preference for doing this change, just something which I noticed while looking at the code.
Either way this should probably have a comment on why the clearing is done here.
Regards,
Hans
Quoted 3 lines
drivers/pinctrl/pinctrl-amd.c +0
-0raw_spin_unlock_irqrestore (&gpio_dev->lock, flags); }
Quoted 8 lines · Hans de Goede
Hi Mario,
Quoted 5 lines · Mario Limonciello
From: Mario Limonciello <[email protected]>
soc-button-array hardcodes a debounce value by means of
gpio_keyswhich uses pinctrl-amd as a backend to program debounce for a GPIO.
Quoted 8 lines
Quoted 5 lines
This hardcoded value doesn't match what the firmware intended to be programmed in
_AEI. The hardcoded debounce leads to problems waking from suspend. There isn't appetite to conditionalize the behavior in soc-button-array or gpio-keys so clear it when the system suspends to avoid problems with being able to resume.Nice I do think this is a better solution then disabling hw-debounce in soc-button-array as we did before.
Although it helps this issue and should be harmless I intend to land it I do want to note we still have a difference in behavior for Windows and Linux in that Windows never programs the hardware debounce for the ACPI0011 device.
I think we should still consider a way to keep compatibility of behavior (my previous v3 3/4 seemed to do that just fine).
Quoted 32 lines
Quoted 16 lines
Cc Dmitry Torokhov <[email protected]>Cc Hans de Goede <[email protected]>Fixes 5c4fa2a6da7fb ("Input: soc_button_array - debounce the buttons")Link https://lore.kernel.org/linux-input/mkgtrb5gt7miyg6kvqdlbu4nj3elym6ijudobpdi26gp4xxay5@rsa6ytrjvj2q/ open hereSigned-off-by Mario Limonciello <[email protected]>--- drivers/pinctrl/pinctrl-amd.c | 7 +++++++ 1 file changed, 7 insertions(+)drivers/pinctrl/pinctrl-amd.c +0
-0drivers/pinctrl/pinctrl-amd.c static int amd_gpio_suspend_hibernate_common(struct device *dev, bool is_suspend · line 988
Quoted 10 lines
drivers/pinctrl/pinctrl-amd.c +7
-0@@ -979,6 +979,13 @@ static int amd_gpio_suspend_hibernate_common(struct device *dev, bool is_suspend pin, is_suspend ? "suspend" : "hibernate"); } +/* clear debounce */ +if (gpio_dev->saved_regs[i] & (DB_CNTRl_MASK <<DB_CNTRL_OFF )) { +amd_gpio_set_debounce (gpio_dev, pin,0 ); +pm_pr_dbg ("Clearing debounce for GPIO #%d during %s.\n" , + pin, is_suspend ?"suspend" :"hibernate" ); + } +I notice that the if () { } block above this checks if a pin is not configured to be a wakeup src. Since we only need this for wakeup sources maybe put this in an else block of the if () { } block above this ?
Quoted 4 lines
I've not strong preference for doing this change, just something which I noticed while looking at the code.
Either way this should probably have a comment on why the clearing is done here.
I'll respin with an updated comment. I would rather keep the blocks separate so it's clearer in debug logs when multiple workarounds are enacted.
Quoted 11 lines
Regards,
Hans
Quoted 3 lines
drivers/pinctrl/pinctrl-amd.c +0
-0raw_spin_unlock_irqrestore (&gpio_dev->lock, flags); }