All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mario Limonciello <superm1@kernel.org>
To: Hans de Goede <hansg@kernel.org>,
	mario.limonciello@amd.com, Basavaraj.Natikar@amd.com,
	Shyam-sundar.S-k@amd.com, linus.walleij@linaro.org,
	dmitry.torokhov@gmail.com
Cc: linux-gpio@vger.kernel.org
Subject: Re: [PATCH] pinctrl: amd: Clear GPIO debounce for suspend
Date: Fri, 27 Jun 2025 09:45:58 -0500	[thread overview]
Message-ID: <17c2e439-b82f-49ee-85cd-874388d3be41@kernel.org> (raw)
In-Reply-To: <375eadfd-4ede-49ff-a75a-a39f68605277@kernel.org>

On 6/27/2025 3:04 AM, Hans de Goede wrote:
> Hi Mario,
> 
> On 27-Jun-25 12:14 AM, Mario Limonciello wrote:
>> From: Mario Limonciello <mario.limonciello@amd.com>
>>
>> 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.
> 
> 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).

> 
>> Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
>> Cc: Hans de Goede <hansg@kernel.org>
>> Fixes: 5c4fa2a6da7fb ("Input: soc_button_array - debounce the buttons")
>> Link: https://lore.kernel.org/linux-input/mkgtrb5gt7miyg6kvqdlbu4nj3elym6ijudobpdi26gp4xxay5@rsa6ytrjvj2q/
>> Link: https://lore.kernel.org/linux-input/20250625215813.3477840-1-superm1@kernel.org/
>> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
>> ---
>>   drivers/pinctrl/pinctrl-amd.c | 7 +++++++
>>   1 file changed, 7 insertions(+)
>>
>> diff --git a/drivers/pinctrl/pinctrl-amd.c b/drivers/pinctrl/pinctrl-amd.c
>> index 5cf3db6d78b79..4276bbe77e0e9 100644
>> --- a/drivers/pinctrl/pinctrl-amd.c
>> +++ b/drivers/pinctrl/pinctrl-amd.c
>> @@ -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.

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.

> 
> Regards,
> 
> Hans
> 
> 
> 
>>   		raw_spin_unlock_irqrestore(&gpio_dev->lock, flags);
>>   	}
>>   
> 


      reply	other threads:[~2025-06-27 14:46 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-26 22:14 [PATCH] pinctrl: amd: Clear GPIO debounce for suspend Mario Limonciello
2025-06-27  8:04 ` Hans de Goede
2025-06-27 14:45   ` Mario Limonciello [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=17c2e439-b82f-49ee-85cd-874388d3be41@kernel.org \
    --to=superm1@kernel.org \
    --cc=Basavaraj.Natikar@amd.com \
    --cc=Shyam-sundar.S-k@amd.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=hansg@kernel.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=mario.limonciello@amd.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.