All of lore.kernel.org
 help / color / mirror / Atom feed
From: Benjamin Tissoires <benjamin.tissoires@redhat.com>
To: Lv Zheng <lv.zheng@intel.com>
Cc: Len Brown <len.brown@intel.com>,
	systemd-devel@lists.freedesktop.org,
	"Rafael J . Wysocki" <rafael.j.wysocki@intel.com>,
	"Rafael J . Wysocki" <rjw@rjwysocki.net>,
	linux-kernel@vger.kernel.org, Lv Zheng <zetalog@gmail.com>,
	linux-acpi@vger.kernel.org
Subject: Re: [RFC PATCH v6 2/5] ACPI: button: Add an optional workaround to fix an event missing issue for old userspace
Date: Fri, 23 Jun 2017 16:03:08 +0200	[thread overview]
Message-ID: <20170623140308.GP26073@mail.corp.redhat.com> (raw)
In-Reply-To: <14729dcd394f41facb871bd3cd3faf7fbf14231e.1498034513.git.lv.zheng@intel.com>

On Jun 21 2017 or thereabouts, Lv Zheng wrote:
> There are platform variations implementing ACPI lid device in different
> ways:
> 1. Some platforms send "open" events to OS and the events arrive before
>    button driver is resumed;
> 2. Some platforms send "open" events to OS, but the events arrive after
>    button driver is resumed, ex., Samsung N210+;
> 3. Some platforms never send "open" events to OS, but send "open" events to
>    update the cached _LID return value, and the update events arrive before
>    button driver is resumed;
> 4. Some platforms never send "open" events to OS, but send "open" events to
>    update the cached _LID return value, but the update events arrive after
>    button driver is resumed, ex., Surface Pro 3;
> 5. Some platforms never send "open" events, _LID returns value sticks to
>    "close", ex., Surface Pro 1.
> Currently, all cases work fine with systemd 233, but only case 1,2 work
> fine with systemd 229.
> 
> Case 3,4 can be treated as an event missing issue:
>    After seeing a LID "close" event, systemd 229 will wait several seconds
>    (HoldoffTimeoutSec) before suspending the platform. Thus on case 4
>    platforms, if users close lid, and re-open it during the
>    HoldoffTimeoutSec period, there is still no "open" events seen by the
>    userspace. Thus systemd still considers the last state as "close" and
>    suspends the platform after the HoldoffTimeoutSec times out.
> 
> Note that not only systemd 229, desktop managers (ex.,
> gnome-settings-daemon) also suffer from this issue.
> 
> This patch tries to fix this issue by periodically sending _LID return
> value to userspace, which ensures to trigger a SW_LID event when the
> underlying hardware state has changed. As adding a periodic timer is not a
> power friendly way, this patch prepares an option for users to enable on
> failure platforms for old userspace programs.
> 
> Users can configure update interval via button.lid_update_interval.
> This should be configured to a smaller value than HoldoffTimeoutSec in
> /etc/systemd/logind.conf.
> 
> Cc: <systemd-devel@lists.freedesktop.org>
> Cc: Benjamin Tissoires <benjamin.tissoires@redhat.com>
> Cc: Peter Hutterer <peter.hutterer@who-t.net>
> Signed-off-by: Lv Zheng <lv.zheng@intel.com>
> ---

NACK: what is the point if you just want to provide an event to user
space? We already explained to you that the events do not matter, only
the state is. If user space has an issue with a state not being in sync,
it's a user space bug and it has to be fixed in user space.

This patch could be useful if the purpose was to monitor the changes
while the state is unreliable (in case 4):
- if _LID returns a different value than right after suspend, it is
  expected to be something reliable, and so we could then re-create the
  input node and present it to user space
- if _LID still returns the same value after a somewhat long delay
  (10-20 seconds), then we can consider the value to be correct and
  re-create the input node.

Polling for polling and hoping user space will have more chances of
seeing an event for an EV_SW is moot.

Cheers,
Benjamin

>  drivers/acpi/button.c | 17 +++++++++++++++--
>  1 file changed, 15 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/acpi/button.c b/drivers/acpi/button.c
> index 67a0d78..a8b119e 100644
> --- a/drivers/acpi/button.c
> +++ b/drivers/acpi/button.c
> @@ -126,6 +126,14 @@ static unsigned long lid_notify_timeout __read_mostly = 10;
>  module_param(lid_notify_timeout, ulong, 0644);
>  MODULE_PARM_DESC(lid_notify_timeout, "Timeout (s) before receiving lid notification");
>  
> +static bool lid_periodic_update __read_mostly = false;
> +module_param(lid_periodic_update, bool, 0644);
> +MODULE_PARM_DESC(lid_periodic_update, "Periodically sending lid state updates");
> +
> +static unsigned long lid_update_interval __read_mostly = 1 * MSEC_PER_SEC;
> +module_param(lid_update_interval, ulong, 0644);
> +MODULE_PARM_DESC(lid_update_interval, "Interval (ms) between lid periodic updates");
> +
>  /* --------------------------------------------------------------------------
>                                FS Interface (/proc)
>     -------------------------------------------------------------------------- */
> @@ -395,6 +403,8 @@ static void acpi_lid_initialize_state(struct acpi_device *device)
>  		break;
>  	case ACPI_BUTTON_LID_INIT_METHOD:
>  		(void)acpi_lid_update_state(device);
> +		if (lid_periodic_update)
> +			acpi_lid_start_timer(device, lid_update_interval);
>  		break;
>  	case ACPI_BUTTON_LID_INIT_IGNORE:
>  	default:
> @@ -560,8 +570,11 @@ static int acpi_button_add(struct acpi_device *device)
>  		 * more we only care about the last one...
>  		 */
>  		lid_device = device;
> -		acpi_lid_start_timer(device,
> -			lid_notify_timeout * MSEC_PER_SEC);
> +		if (lid_periodic_update)
> +			acpi_lid_initialize_state(device);
> +		else
> +			acpi_lid_start_timer(device,
> +				lid_notify_timeout * MSEC_PER_SEC);
>  	}
>  
>  	printk(KERN_INFO PREFIX "%s [%s]\n", name, acpi_device_bid(device));
> -- 
> 2.7.4
> 
_______________________________________________
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel

WARNING: multiple messages have this Message-ID (diff)
From: Benjamin Tissoires <benjamin.tissoires@redhat.com>
To: Lv Zheng <lv.zheng@intel.com>
Cc: "Rafael J . Wysocki" <rafael.j.wysocki@intel.com>,
	"Rafael J . Wysocki" <rjw@rjwysocki.net>,
	Len Brown <len.brown@intel.com>, Lv Zheng <zetalog@gmail.com>,
	linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org,
	systemd-devel@lists.freedesktop.org,
	Peter Hutterer <peter.hutterer@who-t.net>
Subject: Re: [RFC PATCH v6 2/5] ACPI: button: Add an optional workaround to fix an event missing issue for old userspace
Date: Fri, 23 Jun 2017 16:03:08 +0200	[thread overview]
Message-ID: <20170623140308.GP26073@mail.corp.redhat.com> (raw)
In-Reply-To: <14729dcd394f41facb871bd3cd3faf7fbf14231e.1498034513.git.lv.zheng@intel.com>

On Jun 21 2017 or thereabouts, Lv Zheng wrote:
> There are platform variations implementing ACPI lid device in different
> ways:
> 1. Some platforms send "open" events to OS and the events arrive before
>    button driver is resumed;
> 2. Some platforms send "open" events to OS, but the events arrive after
>    button driver is resumed, ex., Samsung N210+;
> 3. Some platforms never send "open" events to OS, but send "open" events to
>    update the cached _LID return value, and the update events arrive before
>    button driver is resumed;
> 4. Some platforms never send "open" events to OS, but send "open" events to
>    update the cached _LID return value, but the update events arrive after
>    button driver is resumed, ex., Surface Pro 3;
> 5. Some platforms never send "open" events, _LID returns value sticks to
>    "close", ex., Surface Pro 1.
> Currently, all cases work fine with systemd 233, but only case 1,2 work
> fine with systemd 229.
> 
> Case 3,4 can be treated as an event missing issue:
>    After seeing a LID "close" event, systemd 229 will wait several seconds
>    (HoldoffTimeoutSec) before suspending the platform. Thus on case 4
>    platforms, if users close lid, and re-open it during the
>    HoldoffTimeoutSec period, there is still no "open" events seen by the
>    userspace. Thus systemd still considers the last state as "close" and
>    suspends the platform after the HoldoffTimeoutSec times out.
> 
> Note that not only systemd 229, desktop managers (ex.,
> gnome-settings-daemon) also suffer from this issue.
> 
> This patch tries to fix this issue by periodically sending _LID return
> value to userspace, which ensures to trigger a SW_LID event when the
> underlying hardware state has changed. As adding a periodic timer is not a
> power friendly way, this patch prepares an option for users to enable on
> failure platforms for old userspace programs.
> 
> Users can configure update interval via button.lid_update_interval.
> This should be configured to a smaller value than HoldoffTimeoutSec in
> /etc/systemd/logind.conf.
> 
> Cc: <systemd-devel@lists.freedesktop.org>
> Cc: Benjamin Tissoires <benjamin.tissoires@redhat.com>
> Cc: Peter Hutterer <peter.hutterer@who-t.net>
> Signed-off-by: Lv Zheng <lv.zheng@intel.com>
> ---

NACK: what is the point if you just want to provide an event to user
space? We already explained to you that the events do not matter, only
the state is. If user space has an issue with a state not being in sync,
it's a user space bug and it has to be fixed in user space.

This patch could be useful if the purpose was to monitor the changes
while the state is unreliable (in case 4):
- if _LID returns a different value than right after suspend, it is
  expected to be something reliable, and so we could then re-create the
  input node and present it to user space
- if _LID still returns the same value after a somewhat long delay
  (10-20 seconds), then we can consider the value to be correct and
  re-create the input node.

Polling for polling and hoping user space will have more chances of
seeing an event for an EV_SW is moot.

Cheers,
Benjamin

>  drivers/acpi/button.c | 17 +++++++++++++++--
>  1 file changed, 15 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/acpi/button.c b/drivers/acpi/button.c
> index 67a0d78..a8b119e 100644
> --- a/drivers/acpi/button.c
> +++ b/drivers/acpi/button.c
> @@ -126,6 +126,14 @@ static unsigned long lid_notify_timeout __read_mostly = 10;
>  module_param(lid_notify_timeout, ulong, 0644);
>  MODULE_PARM_DESC(lid_notify_timeout, "Timeout (s) before receiving lid notification");
>  
> +static bool lid_periodic_update __read_mostly = false;
> +module_param(lid_periodic_update, bool, 0644);
> +MODULE_PARM_DESC(lid_periodic_update, "Periodically sending lid state updates");
> +
> +static unsigned long lid_update_interval __read_mostly = 1 * MSEC_PER_SEC;
> +module_param(lid_update_interval, ulong, 0644);
> +MODULE_PARM_DESC(lid_update_interval, "Interval (ms) between lid periodic updates");
> +
>  /* --------------------------------------------------------------------------
>                                FS Interface (/proc)
>     -------------------------------------------------------------------------- */
> @@ -395,6 +403,8 @@ static void acpi_lid_initialize_state(struct acpi_device *device)
>  		break;
>  	case ACPI_BUTTON_LID_INIT_METHOD:
>  		(void)acpi_lid_update_state(device);
> +		if (lid_periodic_update)
> +			acpi_lid_start_timer(device, lid_update_interval);
>  		break;
>  	case ACPI_BUTTON_LID_INIT_IGNORE:
>  	default:
> @@ -560,8 +570,11 @@ static int acpi_button_add(struct acpi_device *device)
>  		 * more we only care about the last one...
>  		 */
>  		lid_device = device;
> -		acpi_lid_start_timer(device,
> -			lid_notify_timeout * MSEC_PER_SEC);
> +		if (lid_periodic_update)
> +			acpi_lid_initialize_state(device);
> +		else
> +			acpi_lid_start_timer(device,
> +				lid_notify_timeout * MSEC_PER_SEC);
>  	}
>  
>  	printk(KERN_INFO PREFIX "%s [%s]\n", name, acpi_device_bid(device));
> -- 
> 2.7.4
> 

  reply	other threads:[~2017-06-23 14:03 UTC|newest]

Thread overview: 81+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-05  2:39 [PATCH 1/5] Revert "ACPI / button: Remove lid_init_state=method mode" Lv Zheng
2017-05-05  2:39 ` [PATCH 2/5] ACPI: button: Add button.lid_init_state=close Lv Zheng
2017-05-05  2:39 ` [PATCH 3/5] ACPI: button: Fix lid notification Lv Zheng
2017-05-05  2:39 ` [PATCH 4/5] ACPI: button: Always notify kernel space using _LID returning value Lv Zheng
2017-05-05  2:40 ` [PATCH 5/5] ACPI: button: Obselete acpi_lid_open() invocations Lv Zheng
2017-05-09  1:21   ` Julian Wiedmann
2017-05-09  6:19     ` Zheng, Lv
2017-05-09  1:22 ` [PATCH 1/5] Revert "ACPI / button: Remove lid_init_state=method mode" Julian Wiedmann
2017-05-09  6:17   ` Zheng, Lv
2017-05-09  7:02 ` [PATCH v2 " Lv Zheng
2017-05-09  7:02 ` [PATCH v2 2/5] ACPI: button: Add button.lid_init_state=close Lv Zheng
2017-05-11 10:20   ` Benjamin Tissoires
2017-05-12  1:31     ` Zheng, Lv
2017-05-12  9:55       ` Benjamin Tissoires
2017-05-15  1:44         ` Zheng, Lv
2017-05-09  7:02 ` [PATCH v2 3/5] ACPI: button: Fix lid notification Lv Zheng
2017-05-11 10:21   ` Benjamin Tissoires
2017-05-09  7:02 ` [PATCH v2 4/5] ACPI: button: Always notify kernel space using _LID returning value Lv Zheng
2017-05-11 10:28   ` Benjamin Tissoires
2017-05-12  1:22     ` Zheng, Lv
2017-05-12 10:06       ` Benjamin Tissoires
2017-05-15  2:11         ` Zheng, Lv
2017-05-09  7:02 ` [PATCH v2 5/5] ACPI: button: Obselete acpi_lid_open() invocations Lv Zheng
2017-05-10 10:30   ` [Intel-gfx] " Jani Nikula
2017-05-11 10:33   ` Benjamin Tissoires
2017-05-12  1:25     ` Zheng, Lv
2017-05-12  6:08       ` Zheng, Lv
2017-05-12 10:20         ` Benjamin Tissoires
2017-05-15  3:55           ` Zheng, Lv
2017-05-15  7:12             ` Benjamin Tissoires
2017-05-15  8:42               ` Jani Nikula
2017-05-15  9:21                 ` [Intel-gfx] " Benjamin Tissoires
2017-05-15  9:41                   ` Jani Nikula
2017-05-26 23:42 ` [RFC PATCH v3 1/5] ACPI: button: Add indication of BIOS notification and faked events Lv Zheng
2017-05-26 23:42   ` Lv Zheng
2017-05-29 16:04   ` Benjamin Tissoires
2017-05-31  8:57     ` Zheng, Lv
2017-05-31  8:57       ` Zheng, Lv
2017-05-26 23:42 ` [RFC PATCH v3 2/5] ACPI: button: Extends complement switch event support for all modes Lv Zheng
2017-05-26 23:42   ` Lv Zheng
2017-05-26 23:42 ` [RFC PATCH v3 3/5] ACPI: button: Add lid event type debugging messages Lv Zheng
2017-05-26 23:42   ` Lv Zheng
2017-05-26 23:42 ` [RFC PATCH v3 4/5] ACPI: button: Fix lid notification Lv Zheng
2017-05-26 23:42   ` Lv Zheng
     [not found] ` <2a779ae8c280c968b3237ac4a3d9580df7262a46.1493951798.git.lv.zheng-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2017-05-26 23:42   ` [RFC PATCH v3 5/5] ACPI: button: Always notify kernel space using _LID returning value Lv Zheng
2017-05-26 23:42     ` Lv Zheng
2017-05-29 16:08     ` Benjamin Tissoires
2017-05-31  8:59       ` Zheng, Lv
2017-05-31  9:41 ` [RFC PATCH v4 1/5] ACPI: button: Add indication of BIOS notification and faked events Lv Zheng
2017-05-31  9:41 ` [RFC PATCH v4 2/5] ACPI: button: Extends complement switch event support for all modes Lv Zheng
2017-05-31  9:41   ` Lv Zheng
2017-05-31  9:42 ` [RFC PATCH v4 3/5] ACPI: button: Add lid event type debugging messages Lv Zheng
2017-05-31  9:42 ` [RFC PATCH v4 4/5] ACPI: button: Fix lid notification locks Lv Zheng
2017-05-31  9:42 ` [RFC PATCH v4 5/5] ACPI: button: Cleanup lid notification logics Lv Zheng
2017-06-07  9:43 ` [RFC PATCH 0/2] ACPI: button: Fix button.lid_init_state=method mode Lv Zheng
2017-06-07  9:43   ` [RFC PATCH v5 1/2] ACPI: button: Fix issue that button notify cannot report stateful SW_LID state Lv Zheng
2017-06-07  9:43     ` Lv Zheng
2017-06-13  6:17     ` [lkp-robot] [ACPI] 4d0c35c1af: BUG:scheduling_while_atomic kernel test robot
2017-06-13  6:17       ` kernel test robot
2017-06-13  6:17       ` kernel test robot
2017-06-07  9:43   ` [RFC PATCH v5 2/2] ACPI: button: Add a quirk mode for Surface Pro 1 like laptop Lv Zheng
2017-06-07  9:43     ` Lv Zheng
2017-06-21  8:54 ` [RFC PATCH v6 0/5] ACPI: button: Fix button.lid_init_state=method mode Lv Zheng
2017-06-21  8:55   ` [RFC PATCH v6 1/5] ACPI: button: Add a workaround to fix an order issue for old userspace Lv Zheng
2017-06-21  8:55     ` Lv Zheng
2017-06-23 14:02     ` Benjamin Tissoires
2017-06-23 14:02       ` Benjamin Tissoires
2017-06-30  1:34     ` [lkp-robot] [ACPI] c4a9ff748c: BUG:scheduling_while_atomic kernel test robot
2017-06-30  1:34       ` kernel test robot
2017-06-30  1:34       ` kernel test robot
2017-06-21  8:55   ` [RFC PATCH v6 2/5] ACPI: button: Add an optional workaround to fix an event missing issue for old userspace Lv Zheng
2017-06-21  8:55     ` Lv Zheng
2017-06-23 14:03     ` Benjamin Tissoires [this message]
2017-06-23 14:03       ` Benjamin Tissoires
2017-06-21  8:55   ` [RFC PATCH v6 3/5] ACPI: button: Rework lid_init_state=ignore mode Lv Zheng
2017-06-21  8:55     ` Lv Zheng
2017-06-23 14:03     ` Benjamin Tissoires
2017-06-23 14:03       ` Benjamin Tissoires
2017-06-21  8:55   ` [RFC PATCH v6 4/5] ACPI: button: extract input creation/destruction helpers Lv Zheng
2017-06-21  8:55   ` [RFC PATCH v6 5/5] ACPI: button: Add an optional workaround to fix a persistent close issue for old userspace Lv Zheng
2017-06-23 14:03     ` Benjamin Tissoires

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=20170623140308.GP26073@mail.corp.redhat.com \
    --to=benjamin.tissoires@redhat.com \
    --cc=len.brown@intel.com \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lv.zheng@intel.com \
    --cc=rafael.j.wysocki@intel.com \
    --cc=rjw@rjwysocki.net \
    --cc=systemd-devel@lists.freedesktop.org \
    --cc=zetalog@gmail.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.