linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Hans de Goede <hdegoede@redhat.com>
To: Samuel Holland <samuel@sholland.org>,
	Dmitry Torokhov <dmitry.torokhov@gmail.com>,
	Chen-Yu Tsai <wens@csie.org>
Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-sunxi@googlegroups.com
Subject: Re: [PATCH 1/3] Input: axp20x-pek - Remove unique wakeup event handling
Date: Mon, 13 Jan 2020 11:41:49 +0100	[thread overview]
Message-ID: <6c876812-6ec1-cf28-8ce4-7732c5cf67da@redhat.com> (raw)
In-Reply-To: <20200113032032.38709-1-samuel@sholland.org>

Hi,

On 13-01-2020 04:20, Samuel Holland wrote:
> This driver attempts to avoid reporting wakeup events to userspace by
> clearing a possible pending IRQ before IRQs are enabled during resume.
> The assumption seems to be that userspace cannot cope with a KEY_POWER
> press during resume. However, no other input driver does this, so it
> would be a bug that such events are missing with this driver.
> 
> Furthermore, for PMICs connected via I2C or RSB, it is not possible to
> update the regmap during the noirq resume phase, because the bus
> controller drivers require IRQs to perform bus transactions. And the
> resume hook cannot move to a later phase, because then it would race
> with the power key IRQ handler.
> 
> So the best solution seems to be simply removing the hook.

Hmm, I'm not sure this is a good idea, let me give you some background
info on this:

This hook was handled because on X86 systems/laptops when waking
them up typically the power-button does not send a KEY_POWER press event
when the system was woken up through the power-button.

So normal (e.g. Debian, Fedora) userspace does not expect this event
and will directly go to sleep again because that is the default behavior
on a KEY_POWER event.

On x86 axp20x-pek is only used for the power-button on Bay Trail devices
with a AXP288 PMIC. On Cherry Trail devices with an AXP288 PMIC the
power-button is also connected directly to a GPIO on the SoC and that
is used (also see the axp20x_pek_should_register_input function).

So after writing this patch, when doing hw-enablement for the power-button
on the Cherry Trail devices I learned that the gpio_keys driver does
send userspace a KEY_POWER event when woken up with the power-button.

I wrote a patch for gpio-keys to not do this, as that is what normal
Linux userspace expects, but that was nacked, because under e.g.
Android the KEY_POWER event is actually desirable / necessary to avoid
Android immediately re-suspending the system again. Since my "fix" to
the gpio-keys devices was nacked I have instead wroked around this in
userspace, but *only* for the GNOME3 desktop environment, by teaching
GNOME3 to ignore KEY_POWER events for the first couple of seconds after
a resume.

So your suggested change, which will cause KEY_POWER to be send on
Bay Trail devices after a wake-up by the power button, should be
fine for recent GNOME3 versions, but for other desktop environments
this may cause a regression where they respond to the new KEY_POWER
event by immediately going back to sleep again.

As for this not working with the i2c bus, it does on X86 because
the PMIC is also directly accessed by the power-management HW of
the SoC and to make this work the i2c-controller is never suspended
and its irq is marked IRQF_NO_SUSPEND. But this is X86 special
sauce.

Summarizing:

I'm personally fine with remove the magic I added to suppress
the KEY_POWER press reporting as in hindsight given the gpio-keys
story I should have never added it. But I'm worried about this
causing regressions for some Bay Trail users. OTOH making this
change would be good for Android X86 users.

Another IMHO better fix would be to drop the __maybe_unused and
instead wrap both the axp20x_pek_resume_noirq function and the
init of the  .resume_noirq struct member with:

#if defined X86 && defined CONFIG_PM_SLEEP

This keeps the current behavior on Bay Trail machines, while
I assume it should also fix the issues this was causing for
your setup.

Regards,

Hans








> Signed-off-by: Samuel Holland <samuel@sholland.org>
> ---
>   drivers/input/misc/axp20x-pek.c | 25 -------------------------
>   1 file changed, 25 deletions(-)
> 
> diff --git a/drivers/input/misc/axp20x-pek.c b/drivers/input/misc/axp20x-pek.c
> index 17c1cca74498..7d0ee5bececb 100644
> --- a/drivers/input/misc/axp20x-pek.c
> +++ b/drivers/input/misc/axp20x-pek.c
> @@ -352,30 +352,6 @@ static int axp20x_pek_probe(struct platform_device *pdev)
>   	return 0;
>   }
>   
> -static int __maybe_unused axp20x_pek_resume_noirq(struct device *dev)
> -{
> -	struct axp20x_pek *axp20x_pek = dev_get_drvdata(dev);
> -
> -	if (axp20x_pek->axp20x->variant != AXP288_ID)
> -		return 0;
> -
> -	/*
> -	 * Clear interrupts from button presses during suspend, to avoid
> -	 * a wakeup power-button press getting reported to userspace.
> -	 */
> -	regmap_write(axp20x_pek->axp20x->regmap,
> -		     AXP20X_IRQ1_STATE + AXP288_IRQ_POKN / 8,
> -		     BIT(AXP288_IRQ_POKN % 8));
> -
> -	return 0;
> -}
> -
> -static const struct dev_pm_ops axp20x_pek_pm_ops = {
> -#ifdef CONFIG_PM_SLEEP
> -	.resume_noirq = axp20x_pek_resume_noirq,
> -#endif
> -};
> -
>   static const struct platform_device_id axp_pek_id_match[] = {
>   	{
>   		.name = "axp20x-pek",
> @@ -394,7 +370,6 @@ static struct platform_driver axp20x_pek_driver = {
>   	.id_table	= axp_pek_id_match,
>   	.driver		= {
>   		.name		= "axp20x-pek",
> -		.pm		= &axp20x_pek_pm_ops,
>   		.dev_groups	= axp20x_groups,
>   	},
>   };
> 


  parent reply	other threads:[~2020-01-13 10:41 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-13  3:20 [PATCH 1/3] Input: axp20x-pek - Remove unique wakeup event handling Samuel Holland
2020-01-13  3:20 ` [PATCH 2/3] Input: axp20x-pek - Respect userspace wakeup configuration Samuel Holland
2020-01-13  4:47   ` kbuild test robot
2020-01-13 10:48   ` Hans de Goede
2020-01-13 21:38     ` Dmitry Torokhov
2020-01-14  4:50   ` kbuild test robot
2020-01-13  3:20 ` [PATCH 3/3] Input: axp20x-pek - Enable wakeup for all AXP variants Samuel Holland
2020-01-13 10:48   ` Hans de Goede
2020-01-13 21:26   ` Dmitry Torokhov
2020-01-14  9:07     ` Hans de Goede
2020-01-15  4:45       ` Samuel Holland
2020-01-13 10:41 ` Hans de Goede [this message]
2020-01-13 10:58   ` [PATCH 1/3] Input: axp20x-pek - Remove unique wakeup event handling Hans de Goede
2020-01-15  4:29     ` [linux-sunxi] " Samuel Holland

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=6c876812-6ec1-cf28-8ce4-7732c5cf67da@redhat.com \
    --to=hdegoede@redhat.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sunxi@googlegroups.com \
    --cc=samuel@sholland.org \
    --cc=wens@csie.org \
    /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 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).