LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rjw@rjwysocki.net>
To: Ravi Chandra Sadineni <ravisadineni@chromium.org>
Cc: lenb@kernel.org, ravisadineni@google.com,
	dmitry.torokhov@gmail.com, tbroch@google.com,
	linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org,
	rajatja@google.com, bleung@google.com, furquan@chromium.org
Subject: Re: [PATCH V3] ACPI LID: increment wakeup count only when notified.
Date: Wed, 04 Jul 2018 12:39:08 +0200	[thread overview]
Message-ID: <1749498.FF42dzjKYz@aspire.rjw.lan> (raw)
In-Reply-To: <20180627175502.178725-1-ravisadineni@chromium.org>

On Wednesday, June 27, 2018 7:55:02 PM CEST Ravi Chandra Sadineni wrote:
> Because acpi_lid_initialize_state() is called on every system
> resume and it triggers acpi_lid_notify_state() which invokes
> acpi_pm_wakeup_event() for the lid device, the lid's wakeup count is
> incremented even if the lid was not the source of the event that woke up
> the system. That behavior confuses user space deamons using
> wakeup_count to identify the potential system wakeup source. To avoid
> the confusion, only trigger acpi_pm_wakeup_event() in the
> acpi_button_notify() path and don't do that in the
> acpi_lid_initialize_state() path.
> 
> Signed-off-by: Ravi Chandra Sadineni <ravisadineni@chromium.org>
> ---
>  v3:  Change is_notification to signal_wakeup
>  V2: Increment the wakeup count only when the lid is open.
> 
>  drivers/acpi/button.c | 13 +++++++------
>  1 file changed, 7 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/acpi/button.c b/drivers/acpi/button.c
> index 2345a5ee2dbbc..40ed3ec9fc94c 100644
> --- a/drivers/acpi/button.c
> +++ b/drivers/acpi/button.c
> @@ -235,9 +235,6 @@ static int acpi_lid_notify_state(struct acpi_device *device, int state)
>  		button->last_time = ktime_get();
>  	}
>  
> -	if (state)
> -		acpi_pm_wakeup_event(&device->dev);
> -
>  	ret = blocking_notifier_call_chain(&acpi_lid_notifier, state, device);
>  	if (ret == NOTIFY_DONE)
>  		ret = blocking_notifier_call_chain(&acpi_lid_notifier, state,
> @@ -366,7 +363,8 @@ int acpi_lid_open(void)
>  }
>  EXPORT_SYMBOL(acpi_lid_open);
>  
> -static int acpi_lid_update_state(struct acpi_device *device)
> +static int acpi_lid_update_state(struct acpi_device *device,
> +				 bool signal_wakeup)
>  {
>  	int state;
>  
> @@ -374,6 +372,9 @@ static int acpi_lid_update_state(struct acpi_device *device)
>  	if (state < 0)
>  		return state;
>  
> +	if (state && signal_wakeup)
> +		acpi_pm_wakeup_event(&device->dev);
> +
>  	return acpi_lid_notify_state(device, state);
>  }
>  
> @@ -384,7 +385,7 @@ static void acpi_lid_initialize_state(struct acpi_device *device)
>  		(void)acpi_lid_notify_state(device, 1);
>  		break;
>  	case ACPI_BUTTON_LID_INIT_METHOD:
> -		(void)acpi_lid_update_state(device);
> +		(void)acpi_lid_update_state(device, false);
>  		break;
>  	case ACPI_BUTTON_LID_INIT_IGNORE:
>  	default:
> @@ -409,7 +410,7 @@ static void acpi_button_notify(struct acpi_device *device, u32 event)
>  			users = button->input->users;
>  			mutex_unlock(&button->input->mutex);
>  			if (users)
> -				acpi_lid_update_state(device);
> +				acpi_lid_update_state(device, true);
>  		} else {
>  			int keycode;
>  
> 

Applied, thanks!



  reply	other threads:[~2018-07-04 10:40 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-04 18:26 [PATCH] " Ravi Chandra Sadineni
2018-06-04 19:19 ` Benson Leung
2018-06-06  7:00 ` Rafael J. Wysocki
2018-06-06 23:11   ` Benson Leung
2018-06-06 23:21     ` Rafael J. Wysocki
2018-06-11 17:57       ` [PATCH V2] " Ravi Chandra Sadineni
     [not found]         ` <CAOGSYL371YSqpqdzqHUC+UxvMtxTc0q=YFPRcT-SeSHO5Pepeg@mail.gmail.com>
2018-06-21 13:11           ` Rafael J. Wysocki
2018-06-26  9:55         ` Rafael J. Wysocki
2018-06-27 17:55           ` [PATCH V3] " Ravi Chandra Sadineni
2018-07-04 10:39             ` Rafael J. Wysocki [this message]
2018-06-11 17:59       ` [PATCH] " Ravi Chandra Sadineni

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=1749498.FF42dzjKYz@aspire.rjw.lan \
    --to=rjw@rjwysocki.net \
    --cc=bleung@google.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=furquan@chromium.org \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rajatja@google.com \
    --cc=ravisadineni@chromium.org \
    --cc=ravisadineni@google.com \
    --cc=tbroch@google.com \
    --subject='Re: [PATCH V3] ACPI LID: increment wakeup count only when notified.' \
    /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

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).