Linux kernel and device drivers for NXP i.MX platforms
 help / color / mirror / Atom feed
From: Frank Li <Frank.li@nxp.com>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: Jacky Bai <ping.bai@nxp.com>, Jason Liu <jason.hui.liu@nxp.com>,
	Peng Fan <peng.fan@nxp.com>,
	"open list:INPUT (KEYBOARD, MOUSE, JOYSTICK,
	TOUCHSCREEN)..." <linux-input@vger.kernel.org>,
	open list <linux-kernel@vger.kernel.org>,
	imx@lists.linux.dev
Subject: Re: [PATCH 1/1] input: bbnsm_pwrkey: Fix missed key press after suspend
Date: Fri, 12 Jul 2024 19:17:11 -0400	[thread overview]
Message-ID: <ZpG5d1/EsOU4eJEj@lizhi-Precision-Tower-5810> (raw)
In-Reply-To: <ZpG2fNQ9-inLN8-Q@google.com>

On Fri, Jul 12, 2024 at 04:04:28PM -0700, Dmitry Torokhov wrote:
> Hi Frank,
> 
> On Fri, Jul 12, 2024 at 06:43:51PM -0400, Frank Li wrote:
> > From: Jacky Bai <ping.bai@nxp.com>
> > 
> > Report input event directly on wakeup to ensure no press event is missed
> > when resuming from suspend.
> > 
> > Signed-off-by: Jacky Bai <ping.bai@nxp.com>
> > Reviewed-by: Peng Fan <peng.fan@nxp.com>
> > Acked-by: Jason Liu <jason.hui.liu@nxp.com>
> > Signed-off-by: Frank Li <Frank.Li@nxp.com>
> > ---
> >  drivers/input/misc/nxp-bbnsm-pwrkey.c | 36 +++++++++++++++++++++++++++
> >  1 file changed, 36 insertions(+)
> > 
> > diff --git a/drivers/input/misc/nxp-bbnsm-pwrkey.c b/drivers/input/misc/nxp-bbnsm-pwrkey.c
> > index 1d99206dd3a8b..9675717ecbdfe 100644
> > --- a/drivers/input/misc/nxp-bbnsm-pwrkey.c
> > +++ b/drivers/input/misc/nxp-bbnsm-pwrkey.c
> > @@ -38,6 +38,7 @@ struct bbnsm_pwrkey {
> >  	int irq;
> >  	int keycode;
> >  	int keystate;  /* 1:pressed */
> > +	bool suspended;
> >  	struct timer_list check_timer;
> >  	struct input_dev *input;
> >  };
> > @@ -70,6 +71,7 @@ static irqreturn_t bbnsm_pwrkey_interrupt(int irq, void *dev_id)
> >  {
> >  	struct platform_device *pdev = dev_id;
> >  	struct bbnsm_pwrkey *bbnsm = platform_get_drvdata(pdev);
> > +	struct input_dev *input = bbnsm->input;
> >  	u32 event;
> >  
> >  	regmap_read(bbnsm->regmap, BBNSM_EVENTS, &event);
> > @@ -81,6 +83,16 @@ static irqreturn_t bbnsm_pwrkey_interrupt(int irq, void *dev_id)
> >  	mod_timer(&bbnsm->check_timer,
> >  		   jiffies + msecs_to_jiffies(DEBOUNCE_TIME));
> >  
> > +	/*
> > +	 * Directly report key event after resume to make sure key press
> > +	 * event is never missed.
> > +	 */
> 
> How do you know that wakeup was caused by the key press on this device?
> As far as I can see the driver requests the interrupt as shared, so we
> could end up in bbnsm_pwrkey_interrupt() even if button was not pressed.
> 

In bbnsm_pwrky_interrupt()
{	...
	regmap_read(bbnsm->regmap, BBNSM_EVENTS, &event);                                           
        	if (!(event & BBNSM_BTN_OFF))                                                               
                	return IRQ_NONE;

	...
}

If wakeup was not caused by pwr key,  irq will do nothing, code will not
reach to here.

Frank

> Thanks.
> 
> -- 
> Dmitry

  reply	other threads:[~2024-07-12 23:17 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-12 22:43 [PATCH 1/1] input: bbnsm_pwrkey: Fix missed key press after suspend Frank Li
2024-07-12 23:04 ` Dmitry Torokhov
2024-07-12 23:17   ` Frank Li [this message]
2024-07-13  0:11     ` Dmitry Torokhov

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=ZpG5d1/EsOU4eJEj@lizhi-Precision-Tower-5810 \
    --to=frank.li@nxp.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=imx@lists.linux.dev \
    --cc=jason.hui.liu@nxp.com \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peng.fan@nxp.com \
    --cc=ping.bai@nxp.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox