Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1436934 > unrolled thread

[PATCH 0/5] ACPI: ACPI documentations and trivial fixes

Started byLv Zheng <lv.zheng@intel.com>
First post2016-07-05 13:20 +0200
Last post2016-07-07 09:20 +0200
Articles 10 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH 0/5] ACPI: ACPI documentations and trivial fixes Lv Zheng <lv.zheng@intel.com> - 2016-07-05 13:20 +0200
    [PATCH v2 3/4] ACPI / button: Add SW_ACPI_LID for new usage model Lv Zheng <lv.zheng@intel.com> - 2016-07-07 09:20 +0200
      Re: [PATCH v2 3/4] ACPI / button: Add SW_ACPI_LID for new usage model Benjamin Tissoires <benjamin.tissoires@gmail.com> - 2016-07-08 11:30 +0200
        Re: [PATCH v2 3/4] ACPI / button: Add SW_ACPI_LID for new usage model Dmitry Torokhov <dmitry.torokhov@gmail.com> - 2016-07-08 20:00 +0200
    [PATCH v2 0/4] ACPI: ACPI documentation Lv Zheng <lv.zheng@intel.com> - 2016-07-07 09:20 +0200
      [PATCH v2 1/4] ACPI: Add documentation describing ACPICA release automation Lv Zheng <lv.zheng@intel.com> - 2016-07-07 09:20 +0200
      [PATCH v2 4/4] ACPI / button: Add document for ACPI control method lid device restrictions Lv Zheng <lv.zheng@intel.com> - 2016-07-07 09:20 +0200
        Re: [PATCH v2 4/4] ACPI / button: Add document for ACPI control  method lid device restrictions Benjamin Tissoires <benjamin.tissoires@gmail.com> - 2016-07-08 11:20 +0200
          Re: [PATCH v2 4/4] ACPI / button: Add document for ACPI control  method lid device restrictions Dmitry Torokhov <dmitry.torokhov@gmail.com> - 2016-07-08 20:00 +0200
      [PATCH v2 2/4] ACPI / debugger: Add AML debugger documentation Lv Zheng <lv.zheng@intel.com> - 2016-07-07 09:20 +0200

#1436934 — [PATCH 0/5] ACPI: ACPI documentations and trivial fixes

FromLv Zheng <lv.zheng@intel.com>
Date2016-07-05 13:20 +0200
Subject[PATCH 0/5] ACPI: ACPI documentations and trivial fixes
Message-ID<rRwyt-24B-5@gated-at.bofh.it>
This patch adds ACPI documentations related to:
1. AML debugger
2. Control method LID device
3. ACPICA release process
This patch also contains several trivial fixes detected during the
documentation work.

Lv Zheng (5):
  ACPI: Add documentation describing ACPICA release automation
  ACPI / debugger: Fix regressions that AML debugger stops working
  ACPI / debugger: Add AML debugger documentation
  ACPI / button: Add SW_ACPI_LID for new usage model
  ACPI: Add configuration item to configure ACPICA error logs out

 Documentation/acpi/acpi-lid.txt         |   42 ++++++
 Documentation/acpi/aml-debugger.txt     |   56 +++++++
 Documentation/acpi/linuxized-acpica.txt |  251 +++++++++++++++++++++++++++++++
 drivers/acpi/Kconfig                    |    7 +
 drivers/acpi/acpi_dbg.c                 |    6 +-
 drivers/acpi/button.c                   |   20 ++-
 include/acpi/platform/aclinux.h         |    4 +
 include/linux/mod_devicetable.h         |    2 +-
 include/uapi/linux/input-event-codes.h  |    3 +-
 9 files changed, 381 insertions(+), 10 deletions(-)
 create mode 100644 Documentation/acpi/acpi-lid.txt
 create mode 100644 Documentation/acpi/aml-debugger.txt
 create mode 100644 Documentation/acpi/linuxized-acpica.txt

-- 
1.7.10

[toc] | [next] | [standalone]


#1438210 — [PATCH v2 3/4] ACPI / button: Add SW_ACPI_LID for new usage model

FromLv Zheng <lv.zheng@intel.com>
Date2016-07-07 09:20 +0200
Subject[PATCH v2 3/4] ACPI / button: Add SW_ACPI_LID for new usage model
Message-ID<rSbLj-3Kd-3@gated-at.bofh.it>
In reply to#1436934
There are many AML tables reporting wrong initial lid state, and some of
them never reports lid state. As a proxy layer acting between, ACPI button
driver is not able to handle all such cases, but need to re-define the
usage model of the ACPI lid. That is:
1. It's initial state is not reliable;
2. There may not be open event;
3. Userspace should only take action against the close event which is
   reliable, always sent after a real lid close.
This patch adds a new input key event so that new userspace programs can
use it to handle this usage model correctly. And in the meanwhile, no old
programs will be broken by the userspace changes.

Link: https://lkml.org/2016/3/7/460
Link: https://github.com/systemd/systemd/issues/2087
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Cc: Bastien Nocera: <hadess@hadess.net>
Cc: Benjamin Tissoires <benjamin.tissoires@gmail.com>
Cc: linux-input@vger.kernel.org
---
 drivers/acpi/button.c                  |   20 ++++++++++++++------
 include/linux/mod_devicetable.h        |    2 +-
 include/uapi/linux/input-event-codes.h |    3 ++-
 3 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/drivers/acpi/button.c b/drivers/acpi/button.c
index 148f4e5..4ef94d2 100644
--- a/drivers/acpi/button.c
+++ b/drivers/acpi/button.c
@@ -130,7 +130,8 @@ static int acpi_lid_evaluate_state(struct acpi_device *device)
 	return lid_state ? 1 : 0;
 }
 
-static int acpi_lid_notify_state(struct acpi_device *device, int state)
+static int acpi_lid_notify_state(struct acpi_device *device,
+				 int state, bool notify_acpi)
 {
 	struct acpi_button *button = acpi_driver_data(device);
 	int ret;
@@ -138,6 +139,11 @@ static int acpi_lid_notify_state(struct acpi_device *device, int state)
 	/* input layer checks if event is redundant */
 	input_report_switch(button->input, SW_LID, !state);
 	input_sync(button->input);
+	if (notify_acpi) {
+		input_report_switch(button->input,
+				    SW_ACPI_LID, !state);
+		input_sync(button->input);
+	}
 
 	if (state)
 		pm_wakeup_event(&device->dev, 0);
@@ -279,7 +285,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 notify_acpi)
 {
 	int state;
 
@@ -287,17 +294,17 @@ static int acpi_lid_update_state(struct acpi_device *device)
 	if (state < 0)
 		return state;
 
-	return acpi_lid_notify_state(device, state);
+	return acpi_lid_notify_state(device, state, notify_acpi);
 }
 
 static void acpi_lid_initialize_state(struct acpi_device *device)
 {
 	switch (lid_init_state) {
 	case ACPI_BUTTON_LID_INIT_OPEN:
-		(void)acpi_lid_notify_state(device, 1);
+		(void)acpi_lid_notify_state(device, 1, false);
 		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:
@@ -317,7 +324,7 @@ static void acpi_button_notify(struct acpi_device *device, u32 event)
 	case ACPI_BUTTON_NOTIFY_STATUS:
 		input = button->input;
 		if (button->type == ACPI_BUTTON_TYPE_LID) {
-			acpi_lid_update_state(device);
+			acpi_lid_update_state(device, true);
 		} else {
 			int keycode;
 
@@ -436,6 +443,7 @@ static int acpi_button_add(struct acpi_device *device)
 
 	case ACPI_BUTTON_TYPE_LID:
 		input_set_capability(input, EV_SW, SW_LID);
+		input_set_capability(input, EV_SW, SW_ACPI_LID);
 		break;
 	}
 
diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
index 6e4c645..1014968 100644
--- a/include/linux/mod_devicetable.h
+++ b/include/linux/mod_devicetable.h
@@ -291,7 +291,7 @@ struct pcmcia_device_id {
 #define INPUT_DEVICE_ID_LED_MAX		0x0f
 #define INPUT_DEVICE_ID_SND_MAX		0x07
 #define INPUT_DEVICE_ID_FF_MAX		0x7f
-#define INPUT_DEVICE_ID_SW_MAX		0x0f
+#define INPUT_DEVICE_ID_SW_MAX		0x10
 
 #define INPUT_DEVICE_ID_MATCH_BUS	1
 #define INPUT_DEVICE_ID_MATCH_VENDOR	2
diff --git a/include/uapi/linux/input-event-codes.h b/include/uapi/linux/input-event-codes.h
index 737fa32..81c344c 100644
--- a/include/uapi/linux/input-event-codes.h
+++ b/include/uapi/linux/input-event-codes.h
@@ -780,7 +780,8 @@
 #define SW_ROTATE_LOCK		0x0c  /* set = rotate locked/disabled */
 #define SW_LINEIN_INSERT	0x0d  /* set = inserted */
 #define SW_MUTE_DEVICE		0x0e  /* set = device disabled */
-#define SW_MAX			0x0f
+#define SW_ACPI_LID		0x0f  /* set = lid shut */
+#define SW_MAX			0x10
 #define SW_CNT			(SW_MAX+1)
 
 /*
-- 
1.7.10

[toc] | [prev] | [next] | [standalone]


#1439211 — Re: [PATCH v2 3/4] ACPI / button: Add SW_ACPI_LID for new usage model

FromBenjamin Tissoires <benjamin.tissoires@gmail.com>
Date2016-07-08 11:30 +0200
SubjectRe: [PATCH v2 3/4] ACPI / button: Add SW_ACPI_LID for new usage model
Message-ID<rSAgG-2PC-9@gated-at.bofh.it>
In reply to#1438210
On Thu, Jul 7, 2016 at 9:10 AM, Lv Zheng <lv.zheng@intel.com> wrote:
> There are many AML tables reporting wrong initial lid state, and some of
> them never reports lid state. As a proxy layer acting between, ACPI button
> driver is not able to handle all such cases, but need to re-define the
> usage model of the ACPI lid. That is:
> 1. It's initial state is not reliable;
> 2. There may not be open event;
> 3. Userspace should only take action against the close event which is
>    reliable, always sent after a real lid close.
> This patch adds a new input key event so that new userspace programs can
> use it to handle this usage model correctly. And in the meanwhile, no old
> programs will be broken by the userspace changes.
>
> Link: https://lkml.org/2016/3/7/460
> Link: https://github.com/systemd/systemd/issues/2087
> Signed-off-by: Lv Zheng <lv.zheng@intel.com>
> Cc: Bastien Nocera: <hadess@hadess.net>
> Cc: Benjamin Tissoires <benjamin.tissoires@gmail.com>
> Cc: linux-input@vger.kernel.org
> ---
>  drivers/acpi/button.c                  |   20 ++++++++++++++------
>  include/linux/mod_devicetable.h        |    2 +-
>  include/uapi/linux/input-event-codes.h |    3 ++-
>  3 files changed, 17 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/acpi/button.c b/drivers/acpi/button.c
> index 148f4e5..4ef94d2 100644
> --- a/drivers/acpi/button.c
> +++ b/drivers/acpi/button.c
> @@ -130,7 +130,8 @@ static int acpi_lid_evaluate_state(struct acpi_device *device)
>         return lid_state ? 1 : 0;
>  }
>
> -static int acpi_lid_notify_state(struct acpi_device *device, int state)
> +static int acpi_lid_notify_state(struct acpi_device *device,
> +                                int state, bool notify_acpi)
>  {
>         struct acpi_button *button = acpi_driver_data(device);
>         int ret;
> @@ -138,6 +139,11 @@ static int acpi_lid_notify_state(struct acpi_device *device, int state)
>         /* input layer checks if event is redundant */
>         input_report_switch(button->input, SW_LID, !state);
>         input_sync(button->input);
> +       if (notify_acpi) {
> +               input_report_switch(button->input,
> +                                   SW_ACPI_LID, !state);
> +               input_sync(button->input);

If you use a switch, you'll never send subsequent open state if you
doesn't close it yourself.
See my comments in 5/5 and please use a KEY event instead.

> +       }
>
>         if (state)
>                 pm_wakeup_event(&device->dev, 0);
> @@ -279,7 +285,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 notify_acpi)
>  {
>         int state;
>
> @@ -287,17 +294,17 @@ static int acpi_lid_update_state(struct acpi_device *device)
>         if (state < 0)
>                 return state;
>
> -       return acpi_lid_notify_state(device, state);
> +       return acpi_lid_notify_state(device, state, notify_acpi);
>  }
>
>  static void acpi_lid_initialize_state(struct acpi_device *device)
>  {
>         switch (lid_init_state) {
>         case ACPI_BUTTON_LID_INIT_OPEN:
> -               (void)acpi_lid_notify_state(device, 1);
> +               (void)acpi_lid_notify_state(device, 1, false);
>                 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:
> @@ -317,7 +324,7 @@ static void acpi_button_notify(struct acpi_device *device, u32 event)
>         case ACPI_BUTTON_NOTIFY_STATUS:
>                 input = button->input;
>                 if (button->type == ACPI_BUTTON_TYPE_LID) {
> -                       acpi_lid_update_state(device);
> +                       acpi_lid_update_state(device, true);
>                 } else {
>                         int keycode;
>
> @@ -436,6 +443,7 @@ static int acpi_button_add(struct acpi_device *device)
>
>         case ACPI_BUTTON_TYPE_LID:
>                 input_set_capability(input, EV_SW, SW_LID);
> +               input_set_capability(input, EV_SW, SW_ACPI_LID);

Can't we export this new event only if the _LID function is not
reliable? This could check for the module parameter lid_init_state and
only enable it for ACPI_BUTTON_LID_INIT_OPEN.

I really hope we will be able to find a reliable way to determine
whether or not the platform support reliable LID state. If not, there
might be a need to have a db of reliable switch platforms. This can be
set in the kernel or with a hwdb entry in userspace.

Cheers,
Benjamin

>                 break;
>         }
>
> diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
> index 6e4c645..1014968 100644
> --- a/include/linux/mod_devicetable.h
> +++ b/include/linux/mod_devicetable.h
> @@ -291,7 +291,7 @@ struct pcmcia_device_id {
>  #define INPUT_DEVICE_ID_LED_MAX                0x0f
>  #define INPUT_DEVICE_ID_SND_MAX                0x07
>  #define INPUT_DEVICE_ID_FF_MAX         0x7f
> -#define INPUT_DEVICE_ID_SW_MAX         0x0f
> +#define INPUT_DEVICE_ID_SW_MAX         0x10
>
>  #define INPUT_DEVICE_ID_MATCH_BUS      1
>  #define INPUT_DEVICE_ID_MATCH_VENDOR   2
> diff --git a/include/uapi/linux/input-event-codes.h b/include/uapi/linux/input-event-codes.h
> index 737fa32..81c344c 100644
> --- a/include/uapi/linux/input-event-codes.h
> +++ b/include/uapi/linux/input-event-codes.h
> @@ -780,7 +780,8 @@
>  #define SW_ROTATE_LOCK         0x0c  /* set = rotate locked/disabled */
>  #define SW_LINEIN_INSERT       0x0d  /* set = inserted */
>  #define SW_MUTE_DEVICE         0x0e  /* set = device disabled */
> -#define SW_MAX                 0x0f
> +#define SW_ACPI_LID            0x0f  /* set = lid shut */
> +#define SW_MAX                 0x10
>  #define SW_CNT                 (SW_MAX+1)
>
>  /*
> --
> 1.7.10
>

[toc] | [prev] | [next] | [standalone]


#1439724 — Re: [PATCH v2 3/4] ACPI / button: Add SW_ACPI_LID for new usage model

FromDmitry Torokhov <dmitry.torokhov@gmail.com>
Date2016-07-08 20:00 +0200
SubjectRe: [PATCH v2 3/4] ACPI / button: Add SW_ACPI_LID for new usage model
Message-ID<rSIed-7ZA-1@gated-at.bofh.it>
In reply to#1439211
On Fri, Jul 08, 2016 at 11:27:23AM +0200, Benjamin Tissoires wrote:
> On Thu, Jul 7, 2016 at 9:10 AM, Lv Zheng <lv.zheng@intel.com> wrote:
> > There are many AML tables reporting wrong initial lid state, and some of
> > them never reports lid state. As a proxy layer acting between, ACPI button
> > driver is not able to handle all such cases, but need to re-define the
> > usage model of the ACPI lid. That is:
> > 1. It's initial state is not reliable;
> > 2. There may not be open event;
> > 3. Userspace should only take action against the close event which is
> >    reliable, always sent after a real lid close.
> > This patch adds a new input key event so that new userspace programs can
> > use it to handle this usage model correctly. And in the meanwhile, no old
> > programs will be broken by the userspace changes.
> >
> > Link: https://lkml.org/2016/3/7/460

Does not work for me.

> > Link: https://github.com/systemd/systemd/issues/2087

Gives me info about pull "Basic DNSSEC support, and unrelated fixes"

> > Signed-off-by: Lv Zheng <lv.zheng@intel.com>
> > Cc: Bastien Nocera: <hadess@hadess.net>
> > Cc: Benjamin Tissoires <benjamin.tissoires@gmail.com>
> > Cc: linux-input@vger.kernel.org
> > ---
> >  drivers/acpi/button.c                  |   20 ++++++++++++++------
> >  include/linux/mod_devicetable.h        |    2 +-
> >  include/uapi/linux/input-event-codes.h |    3 ++-
> >  3 files changed, 17 insertions(+), 8 deletions(-)
> >
> > diff --git a/drivers/acpi/button.c b/drivers/acpi/button.c
> > index 148f4e5..4ef94d2 100644
> > --- a/drivers/acpi/button.c
> > +++ b/drivers/acpi/button.c
> > @@ -130,7 +130,8 @@ static int acpi_lid_evaluate_state(struct acpi_device *device)
> >         return lid_state ? 1 : 0;
> >  }
> >
> > -static int acpi_lid_notify_state(struct acpi_device *device, int state)
> > +static int acpi_lid_notify_state(struct acpi_device *device,
> > +                                int state, bool notify_acpi)
> >  {
> >         struct acpi_button *button = acpi_driver_data(device);
> >         int ret;
> > @@ -138,6 +139,11 @@ static int acpi_lid_notify_state(struct acpi_device *device, int state)
> >         /* input layer checks if event is redundant */
> >         input_report_switch(button->input, SW_LID, !state);
> >         input_sync(button->input);
> > +       if (notify_acpi) {
> > +               input_report_switch(button->input,
> > +                                   SW_ACPI_LID, !state);
> > +               input_sync(button->input);
> 
> If you use a switch, you'll never send subsequent open state if you
> doesn't close it yourself.
> See my comments in 5/5 and please use a KEY event instead.
> 
> > +       }
> >
> >         if (state)
> >                 pm_wakeup_event(&device->dev, 0);
> > @@ -279,7 +285,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 notify_acpi)
> >  {
> >         int state;
> >
> > @@ -287,17 +294,17 @@ static int acpi_lid_update_state(struct acpi_device *device)
> >         if (state < 0)
> >                 return state;
> >
> > -       return acpi_lid_notify_state(device, state);
> > +       return acpi_lid_notify_state(device, state, notify_acpi);
> >  }
> >
> >  static void acpi_lid_initialize_state(struct acpi_device *device)
> >  {
> >         switch (lid_init_state) {
> >         case ACPI_BUTTON_LID_INIT_OPEN:
> > -               (void)acpi_lid_notify_state(device, 1);
> > +               (void)acpi_lid_notify_state(device, 1, false);
> >                 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:
> > @@ -317,7 +324,7 @@ static void acpi_button_notify(struct acpi_device *device, u32 event)
> >         case ACPI_BUTTON_NOTIFY_STATUS:
> >                 input = button->input;
> >                 if (button->type == ACPI_BUTTON_TYPE_LID) {
> > -                       acpi_lid_update_state(device);
> > +                       acpi_lid_update_state(device, true);
> >                 } else {
> >                         int keycode;
> >
> > @@ -436,6 +443,7 @@ static int acpi_button_add(struct acpi_device *device)
> >
> >         case ACPI_BUTTON_TYPE_LID:
> >                 input_set_capability(input, EV_SW, SW_LID);
> > +               input_set_capability(input, EV_SW, SW_ACPI_LID);
> 
> Can't we export this new event only if the _LID function is not
> reliable? This could check for the module parameter lid_init_state and
> only enable it for ACPI_BUTTON_LID_INIT_OPEN.
> 
> I really hope we will be able to find a reliable way to determine
> whether or not the platform support reliable LID state. If not, there
> might be a need to have a db of reliable switch platforms. This can be
> set in the kernel or with a hwdb entry in userspace.
> 
> Cheers,
> Benjamin
> 
> >                 break;
> >         }
> >
> > diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
> > index 6e4c645..1014968 100644
> > --- a/include/linux/mod_devicetable.h
> > +++ b/include/linux/mod_devicetable.h
> > @@ -291,7 +291,7 @@ struct pcmcia_device_id {
> >  #define INPUT_DEVICE_ID_LED_MAX                0x0f
> >  #define INPUT_DEVICE_ID_SND_MAX                0x07
> >  #define INPUT_DEVICE_ID_FF_MAX         0x7f
> > -#define INPUT_DEVICE_ID_SW_MAX         0x0f
> > +#define INPUT_DEVICE_ID_SW_MAX         0x10
> >
> >  #define INPUT_DEVICE_ID_MATCH_BUS      1
> >  #define INPUT_DEVICE_ID_MATCH_VENDOR   2
> > diff --git a/include/uapi/linux/input-event-codes.h b/include/uapi/linux/input-event-codes.h
> > index 737fa32..81c344c 100644
> > --- a/include/uapi/linux/input-event-codes.h
> > +++ b/include/uapi/linux/input-event-codes.h
> > @@ -780,7 +780,8 @@
> >  #define SW_ROTATE_LOCK         0x0c  /* set = rotate locked/disabled */
> >  #define SW_LINEIN_INSERT       0x0d  /* set = inserted */
> >  #define SW_MUTE_DEVICE         0x0e  /* set = device disabled */
> > -#define SW_MAX                 0x0f
> > +#define SW_ACPI_LID            0x0f  /* set = lid shut */

0x0f is busy already.

> > +#define SW_MAX                 0x10
> >  #define SW_CNT                 (SW_MAX+1)
> >
> >  /*
> > --
> > 1.7.10
> >

-- 
Dmitry

[toc] | [prev] | [next] | [standalone]


#1438211 — [PATCH v2 0/4] ACPI: ACPI documentation

FromLv Zheng <lv.zheng@intel.com>
Date2016-07-07 09:20 +0200
Subject[PATCH v2 0/4] ACPI: ACPI documentation
Message-ID<rSbLj-3Kd-1@gated-at.bofh.it>
In reply to#1436934
This patch adds new ACPI documents related to:
1. ACPICA release process
2. AML debugger
3. ACPI control method lid device
This patch also contains an update of the ACPI LID input event in order to
support the new usage model defined by the documentation change.

History:
1. Remove the upstreamed trivial fixes;
2. Split lid device code and documents;
3. Fix grammar issues in the documents.

Lv Zheng (4):
  ACPI: Add documentation describing ACPICA release automation
  ACPI / debugger: Add AML debugger documentation
  ACPI / button: Add SW_ACPI_LID for new usage model
  ACPI / button: Add document for ACPI control method lid device
    restrictions

 Documentation/acpi/acpi-lid.txt         |   62 ++++++++
 Documentation/acpi/aml-debugger.txt     |   56 +++++++
 Documentation/acpi/linuxized-acpica.txt |  253 +++++++++++++++++++++++++++++++
 drivers/acpi/button.c                   |   20 ++-
 include/linux/mod_devicetable.h         |    2 +-
 include/uapi/linux/input-event-codes.h  |    3 +-
 6 files changed, 388 insertions(+), 8 deletions(-)
 create mode 100644 Documentation/acpi/acpi-lid.txt
 create mode 100644 Documentation/acpi/aml-debugger.txt
 create mode 100644 Documentation/acpi/linuxized-acpica.txt

-- 
1.7.10

[toc] | [prev] | [next] | [standalone]


#1438216 — [PATCH v2 1/4] ACPI: Add documentation describing ACPICA release automation

FromLv Zheng <lv.zheng@intel.com>
Date2016-07-07 09:20 +0200
Subject[PATCH v2 1/4] ACPI: Add documentation describing ACPICA release automation
Message-ID<rSbLk-3Kd-15@gated-at.bofh.it>
In reply to#1438211
This patch adds documentation on ACPICA release automation into the kernel
Documentation/acpi folder.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
---
 Documentation/acpi/linuxized-acpica.txt |  253 +++++++++++++++++++++++++++++++
 1 file changed, 253 insertions(+)
 create mode 100644 Documentation/acpi/linuxized-acpica.txt

diff --git a/Documentation/acpi/linuxized-acpica.txt b/Documentation/acpi/linuxized-acpica.txt
new file mode 100644
index 0000000..74103c1
--- /dev/null
+++ b/Documentation/acpi/linuxized-acpica.txt
@@ -0,0 +1,253 @@
+Linuxized ACPICA - Introduction of ACPICA Release Automation
+
+Copyright (C) 2013-2016, Intel Corporation
+Author: Lv Zheng <lv.zheng@intel.com>
+
+
+Abstract:
+
+This document describes the ACPICA project and the relationship between
+ACPICA and Linux.  It also includes the descriptions on how ACPICA code is
+automatically released to the following Linux subdirectories:
+drivers/acpi/acpica, include/acpi and tools/power/acpi.
+
+
+1. ACPICA Project
+
+   The ACPI Component Architecture (ACPICA) project provides an operating
+   system (OS)-independent reference implementation of the Advanced
+   Configuration and Power Interface Specification (ACPI).  It has been
+   adapted by various host OSes.  By directly integrating ACPICA, Linux can
+   also benefit from the application experiences of ACPICA from other host
+   OSes.
+
+   The homepage of ACPICA project is: www.acpica.org, it is maintained and
+   supported by Intel Corporation.
+
+   The following figure dipicts the Linux ACPI subystem where the ACPICA
+   adaption is included:
+
+      +---------------------------------------------------------+
+      |                                                         |
+      |   +---------------------------------------------------+ |
+      |   | +------------------+                              | |
+      |   | | Table Management |                              | |
+      |   | +------------------+                              | |
+      |   | +----------------------+                          | |
+      |   | | Namespace Management |                          | |
+      |   | +----------------------+                          | |
+      |   | +------------------+       ACPICA Components      | |
+      |   | | Event Management |                              | |
+      |   | +------------------+                              | |
+      |   | +---------------------+                           | |
+      |   | | Resource Management |                           | |
+      |   | +---------------------+                           | |
+      |   | +---------------------+                           | |
+      |   | | Hardware Management |                           | |
+      |   | +---------------------+                           | |
+      | +---------------------------------------------------+ | |
+      | | |                            +------------------+ | | |
+      | | |                            | OS Service Layer | | | |
+      | | |                            +------------------+ | | |
+      | | +-------------------------------------------------|-+ |
+      | |   +--------------------+                          |   |
+      | |   | Device Enumeration |                          |   |
+      | |   +--------------------+                          |   |
+      | |   +------------------+                            |   |
+      | |   | Power Management |                            |   |
+      | |   +------------------+     Linux/ACPI Components  |   |
+      | |   +--------------------+                          |   |
+      | |   | Thermal Management |                          |   |
+      | |   +--------------------+                          |   |
+      | |   +--------------------------+                    |   |
+      | |   | Drivers for ACPI Devices |                    |   |
+      | |   +--------------------------+                    |   |
+      | |   +--------+                                      |   |
+      | |   | ...... |                                      |   |
+      | |   +--------+                                      |   |
+      | +---------------------------------------------------+   |
+      |                                                         |
+      +---------------------------------------------------------+
+
+                 Figure 1. Linux ACPI Software Components
+
+   NOTE:
+    A. OS Service Layer - Provided by Linux to offer OS dependent
+       implementation of the predefined ACPICA interfaces (acpi_os_*).
+         include/acpi/acpiosxf.h
+         drivers/acpi/osl.c
+         include/acpi/platform
+         include/asm/acenv.h
+    B. ACPICA Functionalities - Released from ACPICA code base to offer
+       OS independent implementation of the ACPICA interfaces (acpi_*).
+         drivers/acpi/acpica
+         include/acpi/ac*.h
+         tools/power/acpi
+    C. Linux/ACPI Functionalities - Providing Linux specific ACPI
+       functionalities to the other Linux kernel subsystems and the user
+       space programs.
+         drivers/acpi
+         include/linux/acpi.h
+         include/linux/acpi*.h
+         include/acpi
+         tools/power/acpi
+    D. Architecture Specific ACPICA/ACPI Functionalities - Provided by the
+       ACPI subsystem to offer architecture specific implementation of the
+       ACPI interfaces.  They are Linux specific components, and is out of
+       the scope of this document.
+         include/asm/acpi.h
+         include/asm/acpi*.h
+         arch/*/acpi
+
+2. ACPICA Release
+
+   ACPICA project maintains a code base at the following repository URL:
+   https://github.com/acpica/acpica.git.  It is released once a month.
+
+   As the coding style adopted by the ACPICA project is not acceptable by
+   Linux, there is a release process to convert the ACPICA GIT commits into
+   the Linux acceptable patches.  The patches generated by this process are
+   known as "Linuxized ACPICA Patches".  The release process is performed
+   against a local copy of the ACPICA git repository.  Each commit in the
+   monthly release is converted into the linuxized ACPICA patch.  They form
+   a montly ACPICA release patchset for Linux ACPI community.  The
+   following figure dipicts the Linux upstream process of the ACPICA
+   commits:
+
+    +-----------------------------+
+    | acpica / master (-) commits |
+    +-----------------------------+
+       /|\         |
+        |         \|/
+        |  /---------------------\    +----------------------+
+        | < Linuxize repo Utility >-->| old linuxized acpica |--+
+        |  \---------------------/    +----------------------+  |
+        |                                                       |
+     /---------\                                                |
+    < git reset >                                                \
+     \---------/                                                  \
+       /|\                                                        /+-+
+        |                                                        /   |
+    +-----------------------------+                             |    |
+    | acpica / master (+) commits |                             |    |
+    +-----------------------------+                             |    |
+                   |                                            |    |
+                  \|/                                           |    |
+         /-----------------------\    +----------------------+  |    |
+        < Linuxize repo Utilities >-->| new linuxized acpica |--+    |
+         \-----------------------/    +----------------------+       |
+                                                                    \|/
+    +--------------------------+                  /----------------------\
+    | Linuxized ACPICA Patches |<----------------< Linuxize patch Utility >
+    +--------------------------+                  \----------------------/
+                   |
+                  \|/
+     /---------------------------\
+    < Linux ACPI Community Review >
+     \---------------------------/
+                   |
+                  \|/
+    +-----------------------+   /------------------\    +----------------+
+    | linux-pm / linux-next |--< Linux Merge Window >-->| linux / master |
+    +-----------------------+   \------------------/    +----------------+
+
+                Figure 2. ACPICA -> Linux Upstream Process
+
+   NOTE:
+    A. Linuxize Utilities - Provided by the ACPICA repository, including a
+       utility located in source/tools/acpisrc folder and a bunch of
+       scripts located in generate/linux folder.
+    B. acpica / master - "master" branch of the git repository at
+       <https://github.com/acpica/acpica.git>.
+    C. linux-pm / linux-next - "linux-next" branch of the git repository at
+       <http://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git>.
+    D. linux / master - "master" branch of the git repository at
+       <http://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git>.
+    E. Linux ACPI Community - Reached at
+       <mailto:linux-acpi@vger.kernel.org>.
+
+   Before the linuxized ACPICA patches are sent to the Linux ACPI community
+   for review, there is a quality ensurance build test process performed to
+   reduce porting issues.  Currently this build process only cares about
+   the following kernel configurations:
+   CONFIG_ACPI/CONFIG_ACPI_DEBUG/CONFIG_ACPI_DEBUGGER
+
+3. ACPICA Divergence
+
+   It's ideal that if all of the ACPICA commits are upstreamed
+   automatically without modifications, the "linux / master" tree should
+   contain the ACPICA code that is exactly same as the ACPICA code
+   contained in "new linuxized acpica" tree and the release process thus
+   could be performed automatically.
+
+   But the facts are there are always source code differences between
+   Linux and ACPICA, such differences are known as "ACPICA Divergences".
+
+   The various sources of the ACPICA divergences include:
+   1. The existing divergences - Before the ACPICA release cycle is
+      fully running, there has already been divergences between Linux and
+      ACPICA. Over the past several years, the divergences are greatly
+      reduced, but there are still several ones and it takes time to figure
+      out the root cause of these old divergences.
+   2. Manual modifications - Any manual modification (ex., coding style
+      fixes) done directly in the Linux side obviously hurts the ACPICA
+      release automation.  Thus it is recommended to fix such issues in the
+      ACPICA upstream and generate the linuxized fix using the ACPICA
+      release utilities (please refer to the Chapter 4 for the details).
+   3. Linux specific features - Sometime, it's impossible to use the
+      current ACPICA APIs to implement the features required by the Linux
+      kernel, the Linux developers have to hack ACPICA code directly.  Such
+      hacks may not be acceptable from ACPICA's point of view, then they
+      are left as committed ACPICA divergences unless ACPICA side can
+      implement new mechanisms as replacements to clean these hacks up.
+   4. ACPICA release fixups - ACPICA only tests commits using a set of the
+      user space simulation utilies, thus the linuxized ACPICA patches may
+      break the Linux kernel, leaving us build/boot failures.  In order not
+      to break the Linux bisection process, fixes are done directly to the
+      linuxized ACPICA patches during the release process.  When the
+      release fixups are back ported to the ACPICA upstream, they must
+      follow the ACPICA upstream rules and thus risk further modifications.
+      These can all result in the new divergences.
+   5. Quick path of the ACPICA commits - Some ACPICA commits are good
+      stable materials, they are upstreamed prior than the ACPICA release
+      process.  If such commits are reverted or rebased in the ACPICA side
+      in order to offer better solutions, new ACPICA divergences are
+      generated.
+
+4. ACPICA Development
+
+   This paragraph guides the Linux developers to use the ACPICA upstream
+   release utilities to obtain the ACPICA upstream commits before they
+   are released by the ACPICA release process.
+
+   1. Cherry-pick an ACPICA commit:
+   First you need to git clone the ACPICA repository and the ACPICA changes
+   you want to cherry pick must be committed into the local repository.
+   Then the gen-patch.sh command can help to cherry-pick an ACPICA commit
+   from the ACPICA local repository.
+   # git clone https://github.com/acpica/acpica
+   # cd acpica
+   # generate/linux/gen-patch.sh -u [commit ID]
+   Here the commit ID is the ACPICA local repository commit ID you want to
+   cherry pick.  It can be omitted if the commit is "HEAD".
+
+   2. Cherry-pick the recent ACPICA commits:
+   Sometimes you need to rebase your code on top of the recent ACPICA
+   changes that haven't been upstreamed to Linux yet.  You can generate
+   the ACPICA release series on your own and rebase your code on top of
+   the generated ACPICA release patches.
+   # git clone https://github.com/acpica/acpica
+   # cd acpica
+   # generate/linux/make-patches.sh -u [commit ID]
+   The commit ID should be the last ACPICA commit accepted by Linux.
+   Normally it is a commit modifying ACPI_CA_VERSION.  The modification can
+   be achieved by executing "git blame source/include/acpixf.h" and
+   referencing line that contains "ACPI_CA_VERSION".
+
+   3. Confirm the current divergences:
+   If you have local copies of both Linux and ACPICA, you can generate a
+   diff file indicating the state of the current divergences:
+   # git clone https://github.com/acpica/acpica
+   # git clone http://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
+   # cd acpica
+   # generate/linux/divergences.sh -s ../linux
-- 
1.7.10

[toc] | [prev] | [next] | [standalone]


#1438218 — [PATCH v2 4/4] ACPI / button: Add document for ACPI control method lid device restrictions

FromLv Zheng <lv.zheng@intel.com>
Date2016-07-07 09:20 +0200
Subject[PATCH v2 4/4] ACPI / button: Add document for ACPI control method lid device restrictions
Message-ID<rSbLk-3Kd-21@gated-at.bofh.it>
In reply to#1438211
There are many AML tables reporting wrong initial lid state, and some of
them never reports lid state. As a proxy layer acting between, ACPI button
driver is not able to handle all such cases, but need to re-define the
usage model of the ACPI lid. That is:
1. It's initial state is not reliable;
2. There may not be open event;
3. Userspace should only take action against the close event which is
   reliable, always sent after a real lid close.
This patch adds documentation of the usage model.

Link: https://lkml.org/2016/3/7/460
Link: https://github.com/systemd/systemd/issues/2087
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Cc: Bastien Nocera: <hadess@hadess.net>
Cc: Benjamin Tissoires <benjamin.tissoires@gmail.com>
Cc: linux-input@vger.kernel.org
---
 Documentation/acpi/acpi-lid.txt |   62 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 62 insertions(+)
 create mode 100644 Documentation/acpi/acpi-lid.txt

diff --git a/Documentation/acpi/acpi-lid.txt b/Documentation/acpi/acpi-lid.txt
new file mode 100644
index 0000000..7e4f7ed
--- /dev/null
+++ b/Documentation/acpi/acpi-lid.txt
@@ -0,0 +1,62 @@
+Usage Model of the ACPI Control Method Lid Device
+
+Copyright (C) 2016, Intel Corporation
+Author: Lv Zheng <lv.zheng@intel.com>
+
+
+Abstract:
+
+Platforms containing lids convey lid state (open/close) to OSPMs using a
+control method lid device. To implement this, the AML tables issue
+Notify(lid_device, 0x80) to notify the OSPMs whenever the lid state has
+changed. The _LID control method for the lid device must be implemented to
+report the "current" state of the lid as either "opened" or "closed".
+
+This document describes the restrictions and the expections of the Linux
+ACPI lid device driver.
+
+
+1. Restrictions of the returning value of the _LID control method
+
+The _LID control method is described to return the "current" lid state.
+However the word of "current" has ambiguity, many AML tables return the lid
+state upon the last lid notification instead of returning the lid state
+upon the last _LID evaluation. There won't be difference when the _LID
+control method is evaluated during the runtime, the problem is its initial
+returning value. When the AML tables implement this control method with
+cached value, the initial returning value is likely not reliable. There are
+simply so many examples always retuning "closed" as initial lid state.
+
+2. Restrictions of the lid state change notifications
+
+There are many AML tables never notifying when the lid device state is
+changed to "opened". But it is ensured that the AML tables always notify
+"closed" when the lid state is changed to "closed". This is normally used
+to trigger some system power saving operations on Windows. Since it is
+fully tested, this notification is reliable for all AML tables.
+
+3. Expections for the userspace users of the ACPI lid device driver
+
+The userspace programs should stop relying on
+/proc/acpi/button/lid/LID0/state to obtain the lid state. This file is only
+used for the validation purpose.
+
+New userspace programs should rely on the lid "closed" notification to
+trigger some power saving operations and may stop taking actions according
+to the lid "opened" notification. A new input switch event - SW_ACPI_LID is
+prepared for the new userspace to implement this ACPI control method lid
+device specific logics.
+
+During the period the userspace hasn't been switched to use the new
+SW_ACPI_LID event, Linux users can use the following boot parameter to
+handle possible issues:
+  button.lid_init_state=method:
+   This is the default behavior of the Linux ACPI lid driver, Linux kernel
+   reports the initial lid state using the returning value of the _LID
+   control method.
+   This can be used to fix some platforms if the _LID control method's
+   returning value is reliable.
+  button.lid_init_state=open:
+   Linux kernel always reports the initial lid state as "opened".
+   This may fix some platforms if the returning value of the _LID control
+   method is not reliable.
-- 
1.7.10

[toc] | [prev] | [next] | [standalone]


#1439196 — Re: [PATCH v2 4/4] ACPI / button: Add document for ACPI control method lid device restrictions

FromBenjamin Tissoires <benjamin.tissoires@gmail.com>
Date2016-07-08 11:20 +0200
SubjectRe: [PATCH v2 4/4] ACPI / button: Add document for ACPI control method lid device restrictions
Message-ID<rSA70-2JT-1@gated-at.bofh.it>
In reply to#1438218
Hi,

On Thu, Jul 7, 2016 at 9:11 AM, Lv Zheng <lv.zheng@intel.com> wrote:
> There are many AML tables reporting wrong initial lid state, and some of
> them never reports lid state. As a proxy layer acting between, ACPI button
> driver is not able to handle all such cases, but need to re-define the
> usage model of the ACPI lid. That is:
> 1. It's initial state is not reliable;
> 2. There may not be open event;
> 3. Userspace should only take action against the close event which is
>    reliable, always sent after a real lid close.
> This patch adds documentation of the usage model.
>
> Link: https://lkml.org/2016/3/7/460
> Link: https://github.com/systemd/systemd/issues/2087
> Signed-off-by: Lv Zheng <lv.zheng@intel.com>
> Cc: Bastien Nocera: <hadess@hadess.net>
> Cc: Benjamin Tissoires <benjamin.tissoires@gmail.com>
> Cc: linux-input@vger.kernel.org
> ---
>  Documentation/acpi/acpi-lid.txt |   62 +++++++++++++++++++++++++++++++++++++++
>  1 file changed, 62 insertions(+)
>  create mode 100644 Documentation/acpi/acpi-lid.txt
>
> diff --git a/Documentation/acpi/acpi-lid.txt b/Documentation/acpi/acpi-lid.txt
> new file mode 100644
> index 0000000..7e4f7ed
> --- /dev/null
> +++ b/Documentation/acpi/acpi-lid.txt
> @@ -0,0 +1,62 @@
> +Usage Model of the ACPI Control Method Lid Device
> +
> +Copyright (C) 2016, Intel Corporation
> +Author: Lv Zheng <lv.zheng@intel.com>
> +
> +
> +Abstract:
> +
> +Platforms containing lids convey lid state (open/close) to OSPMs using a
> +control method lid device. To implement this, the AML tables issue
> +Notify(lid_device, 0x80) to notify the OSPMs whenever the lid state has
> +changed. The _LID control method for the lid device must be implemented to
> +report the "current" state of the lid as either "opened" or "closed".
> +
> +This document describes the restrictions and the expections of the Linux
> +ACPI lid device driver.
> +
> +
> +1. Restrictions of the returning value of the _LID control method
> +
> +The _LID control method is described to return the "current" lid state.
> +However the word of "current" has ambiguity, many AML tables return the lid
> +state upon the last lid notification instead of returning the lid state
> +upon the last _LID evaluation. There won't be difference when the _LID
> +control method is evaluated during the runtime, the problem is its initial
> +returning value. When the AML tables implement this control method with
> +cached value, the initial returning value is likely not reliable. There are
> +simply so many examples always retuning "closed" as initial lid state.
> +
> +2. Restrictions of the lid state change notifications
> +
> +There are many AML tables never notifying when the lid device state is
> +changed to "opened". But it is ensured that the AML tables always notify
> +"closed" when the lid state is changed to "closed". This is normally used
> +to trigger some system power saving operations on Windows. Since it is
> +fully tested, this notification is reliable for all AML tables.
> +
> +3. Expections for the userspace users of the ACPI lid device driver
> +
> +The userspace programs should stop relying on
> +/proc/acpi/button/lid/LID0/state to obtain the lid state. This file is only
> +used for the validation purpose.

I'd say: this file actually calls the _LID method described above. And
given the previous explanation, it is not reliable enough on some
platforms. So it is strongly advised for user-space program to not
solely rely on this file to determine the actual lid state.

> +
> +New userspace programs should rely on the lid "closed" notification to
> +trigger some power saving operations and may stop taking actions according
> +to the lid "opened" notification. A new input switch event - SW_ACPI_LID is
> +prepared for the new userspace to implement this ACPI control method lid
> +device specific logics.

That's not entirely what we discussed before (to prevent regressions):
- if the device doesn't have reliable LID switch state, then there
would be the new input event, and so userspace should only rely on
opened notifications.
- if the device has reliable switch information, the new input event
should not be exported and userspace knows that the current input
switch event is reliable.

Also, using a new "switch" event is a terrible idea. Switches have a
state (open/close) and you are using this to forward a single open
event. So using a switch just allows you to say to userspace you are
using the "new" LID meaning, but you'll still have to manually reset
the switch and you will have to document how this event is not a
switch.

Please use a simple KEY_LID_OPEN event you will send through
[input_key_event(KEY_LID_OPEN, 1), input_sync(),
input_key_event(KEY_LID_OPEN, 0), input_sync()], which userspace knows
how to handle.

> +
> +During the period the userspace hasn't been switched to use the new
> +SW_ACPI_LID event, Linux users can use the following boot parameter to
> +handle possible issues:
> +  button.lid_init_state=method:
> +   This is the default behavior of the Linux ACPI lid driver, Linux kernel
> +   reports the initial lid state using the returning value of the _LID
> +   control method.
> +   This can be used to fix some platforms if the _LID control method's
> +   returning value is reliable.
> +  button.lid_init_state=open:
> +   Linux kernel always reports the initial lid state as "opened".
> +   This may fix some platforms if the returning value of the _LID control
> +   method is not reliable.

This worries me as there is no plan after "During the period the
userspace hasn't been switched to use the new event".

I really hope you'll keep sending SW_LID for reliable LID platforms,
and not remove it entirely as you will break platforms.

Cheers,
Benjamin

> --
> 1.7.10
>

[toc] | [prev] | [next] | [standalone]


#1439725 — Re: [PATCH v2 4/4] ACPI / button: Add document for ACPI control method lid device restrictions

FromDmitry Torokhov <dmitry.torokhov@gmail.com>
Date2016-07-08 20:00 +0200
SubjectRe: [PATCH v2 4/4] ACPI / button: Add document for ACPI control method lid device restrictions
Message-ID<rSIed-7ZA-5@gated-at.bofh.it>
In reply to#1439196
On Fri, Jul 08, 2016 at 11:17:39AM +0200, Benjamin Tissoires wrote:
> Hi,
> 
> On Thu, Jul 7, 2016 at 9:11 AM, Lv Zheng <lv.zheng@intel.com> wrote:
> > There are many AML tables reporting wrong initial lid state, and some of
> > them never reports lid state. As a proxy layer acting between, ACPI button
> > driver is not able to handle all such cases, but need to re-define the
> > usage model of the ACPI lid. That is:
> > 1. It's initial state is not reliable;
> > 2. There may not be open event;
> > 3. Userspace should only take action against the close event which is
> >    reliable, always sent after a real lid close.
> > This patch adds documentation of the usage model.
> >
> > Link: https://lkml.org/2016/3/7/460
> > Link: https://github.com/systemd/systemd/issues/2087
> > Signed-off-by: Lv Zheng <lv.zheng@intel.com>
> > Cc: Bastien Nocera: <hadess@hadess.net>
> > Cc: Benjamin Tissoires <benjamin.tissoires@gmail.com>
> > Cc: linux-input@vger.kernel.org
> > ---
> >  Documentation/acpi/acpi-lid.txt |   62 +++++++++++++++++++++++++++++++++++++++
> >  1 file changed, 62 insertions(+)
> >  create mode 100644 Documentation/acpi/acpi-lid.txt
> >
> > diff --git a/Documentation/acpi/acpi-lid.txt b/Documentation/acpi/acpi-lid.txt
> > new file mode 100644
> > index 0000000..7e4f7ed
> > --- /dev/null
> > +++ b/Documentation/acpi/acpi-lid.txt
> > @@ -0,0 +1,62 @@
> > +Usage Model of the ACPI Control Method Lid Device
> > +
> > +Copyright (C) 2016, Intel Corporation
> > +Author: Lv Zheng <lv.zheng@intel.com>
> > +
> > +
> > +Abstract:
> > +
> > +Platforms containing lids convey lid state (open/close) to OSPMs using a
> > +control method lid device. To implement this, the AML tables issue
> > +Notify(lid_device, 0x80) to notify the OSPMs whenever the lid state has
> > +changed. The _LID control method for the lid device must be implemented to
> > +report the "current" state of the lid as either "opened" or "closed".
> > +
> > +This document describes the restrictions and the expections of the Linux
> > +ACPI lid device driver.
> > +
> > +
> > +1. Restrictions of the returning value of the _LID control method
> > +
> > +The _LID control method is described to return the "current" lid state.
> > +However the word of "current" has ambiguity, many AML tables return the lid
> > +state upon the last lid notification instead of returning the lid state
> > +upon the last _LID evaluation. There won't be difference when the _LID
> > +control method is evaluated during the runtime, the problem is its initial
> > +returning value. When the AML tables implement this control method with
> > +cached value, the initial returning value is likely not reliable. There are
> > +simply so many examples always retuning "closed" as initial lid state.
> > +
> > +2. Restrictions of the lid state change notifications
> > +
> > +There are many AML tables never notifying when the lid device state is
> > +changed to "opened". But it is ensured that the AML tables always notify
> > +"closed" when the lid state is changed to "closed". This is normally used
> > +to trigger some system power saving operations on Windows. Since it is
> > +fully tested, this notification is reliable for all AML tables.
> > +
> > +3. Expections for the userspace users of the ACPI lid device driver
> > +
> > +The userspace programs should stop relying on
> > +/proc/acpi/button/lid/LID0/state to obtain the lid state. This file is only
> > +used for the validation purpose.
> 
> I'd say: this file actually calls the _LID method described above. And
> given the previous explanation, it is not reliable enough on some
> platforms. So it is strongly advised for user-space program to not
> solely rely on this file to determine the actual lid state.
> 
> > +
> > +New userspace programs should rely on the lid "closed" notification to
> > +trigger some power saving operations and may stop taking actions according
> > +to the lid "opened" notification. A new input switch event - SW_ACPI_LID is
> > +prepared for the new userspace to implement this ACPI control method lid
> > +device specific logics.
> 
> That's not entirely what we discussed before (to prevent regressions):
> - if the device doesn't have reliable LID switch state, then there
> would be the new input event, and so userspace should only rely on
> opened notifications.
> - if the device has reliable switch information, the new input event
> should not be exported and userspace knows that the current input
> switch event is reliable.
> 
> Also, using a new "switch" event is a terrible idea. Switches have a
> state (open/close) and you are using this to forward a single open
> event. So using a switch just allows you to say to userspace you are
> using the "new" LID meaning, but you'll still have to manually reset
> the switch and you will have to document how this event is not a
> switch.
> 
> Please use a simple KEY_LID_OPEN event you will send through
> [input_key_event(KEY_LID_OPEN, 1), input_sync(),
> input_key_event(KEY_LID_OPEN, 0), input_sync()], which userspace knows
> how to handle.
> 
> > +
> > +During the period the userspace hasn't been switched to use the new
> > +SW_ACPI_LID event, Linux users can use the following boot parameter to
> > +handle possible issues:
> > +  button.lid_init_state=method:
> > +   This is the default behavior of the Linux ACPI lid driver, Linux kernel
> > +   reports the initial lid state using the returning value of the _LID
> > +   control method.
> > +   This can be used to fix some platforms if the _LID control method's
> > +   returning value is reliable.
> > +  button.lid_init_state=open:
> > +   Linux kernel always reports the initial lid state as "opened".
> > +   This may fix some platforms if the returning value of the _LID control
> > +   method is not reliable.
> 
> This worries me as there is no plan after "During the period the
> userspace hasn't been switched to use the new event".
> 
> I really hope you'll keep sending SW_LID for reliable LID platforms,
> and not remove it entirely as you will break platforms.

How about we leave the kernel alone and userspace (which would have to
cope with the new KEY_LID_OPEN anyway) would just have to know that if
switch's parent is PNP0C0D:00 (or phys is PNP0C0D/button/input0) then it
can't trust the events and it needs additional heuristics.

Thanks.

-- 
Dmitry

[toc] | [prev] | [next] | [standalone]


#1438219 — [PATCH v2 2/4] ACPI / debugger: Add AML debugger documentation

FromLv Zheng <lv.zheng@intel.com>
Date2016-07-07 09:20 +0200
Subject[PATCH v2 2/4] ACPI / debugger: Add AML debugger documentation
Message-ID<rSbLk-3Kd-13@gated-at.bofh.it>
In reply to#1438211
This patch adds AML debugger documentation.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
---
 Documentation/acpi/aml-debugger.txt |   56 +++++++++++++++++++++++++++++++++++
 1 file changed, 56 insertions(+)
 create mode 100644 Documentation/acpi/aml-debugger.txt

diff --git a/Documentation/acpi/aml-debugger.txt b/Documentation/acpi/aml-debugger.txt
new file mode 100644
index 0000000..2f1c184
--- /dev/null
+++ b/Documentation/acpi/aml-debugger.txt
@@ -0,0 +1,56 @@
+The AML Debugger
+
+Copyright (C) 2016, Intel Corporation
+Author: Lv Zheng <lv.zheng@intel.com>
+
+
+Abstract:
+
+This document describes the usage of the AML debugger embedded in the Linux
+kernel.
+
+1. Build the debugger
+
+   The following kernel configuration items are required to enable the AML
+   debugger interface from the Linux kernel:
+   CONFIG_ACPI_DEBUGGER=y
+   CONFIG_ACPI_DEBUGGER_USER=m
+   The userspace utlities can be built from the kernel source tree using
+   the following commands:
+   # cd tools
+   # make acpi
+   The built userspace tool can be found at:
+     tools/acpi/power/acpi/acpidbg/acpidbg
+   You can install it to the system directories using the following
+   command:
+   # make install
+
+2. Start the userspace debugger interface
+
+   After booting the kernel with the debugger built-in, developers can
+   start the debugger with the following commands:
+   # mount -t debugfs none /sys/kernel/debug
+   # modprobe acpi_dbg
+   # tools/acpi/power/acpi/acpidbg/acpidbg
+   Now you have entered the interactive AML debugger environment, where
+   you can execute the debugger functionalities by typing the debugger
+   commands.
+   You can start to use it from typing "help" command and can download
+   <ACPICA Overview and Programmer Reference> from the following site:
+     https://acpica.org/documentation
+   And find detailed command reference in "Chapter 12. ACPICA Debugger
+   Reference".
+
+3. Stop the userspace debugger interface
+
+   You can type the Ctrl+C, quit, exit to end the interactive debugger
+   interface. And unload the module with the following commands:
+   # rmmod acpi_dbg
+   The module unloading may fail if there is an acpidbg instance running.
+
+4. Run the debugger in a script
+
+   It will be very useful to have the ability to run the AML debugger in
+   a test script. "acpidbg" supports this in a special "batch" mode. For
+   example, the following command outputs the entire ACPI namespace:
+   # acpidbg -b "namespace"
-- 
1.7.10

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web