Skip to contentSkip to conversation

ACPI: button: Add an info message when we're sending a LID closed event

PATCH Superseded Hans de Goede 3 participants 7 messages Nov 15, 2017 – Nov 22, 2017 ACPI

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 ACPI: button: Add an info message when we're sending a LID closed event

I've been debugging some spurious suspend issues on various devices, at least on some devices these spurious suspends are caused by surious LID closed events being send to userspace.

Running e.g. evemu-record after noticing a spurious suspend is too late to detect that a LID closed event it the (probable) cause of this. This commit adds a pr_info("ACPI LID closed\n") call to help debugging.

---
 drivers/acpi/button.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/acpi/button.c +3 -0
index ef1856b15488..07da60fe9cae 100644
@@ -210,6 +210,9 @@ static int acpi_lid_notify_state(struct acpi_device *device, int state)
 	}
 	/* Send the platform triggered reliable event */
 	if (do_update) {
+		if (!state)
+			pr_info("ACPI LID closed\n");
+
 		input_report_switch(button->input, SW_LID, !state);
 		input_sync(button->input);
 		button->last_state = !!state;
Signature · 1 line
2.14.3
#1 lore raw

PATCH 2/2 ACPI: button: Add a LID switch blacklist and add 1 model to it

The GP-electronic T701 tablet does not have a LID switch, but it does define a LID device in its DSDT. The _LID method points to the "\\_SB.GPO2" pin 0x18 GPIO with a pull setting of "PullDefault", which leaves the pin floating.

This causes the ACPI button driver to cause spurious LID closed events, causing the device to suspend while the user is using it. There is nothing the ACPI button driver (or the gpio code) can do to fix this, so the only solution is to add a DMI based blacklist and ignore the LID device on these tablets.

---
 drivers/acpi/button.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
drivers/acpi/button.c +20 -0
index 07da60fe9cae..885382363c6e 100644
@@ -30,6 +30,7 @@
 #include <linux/input.h>
 #include <linux/slab.h>
 #include <linux/acpi.h>
+#include <linux/dmi.h>
 #include <acpi/button.h>
 
 #define PREFIX "ACPI: "
@@ -76,6 +77,22 @@ static const struct acpi_device_id button_device_ids[] = {
 };
 MODULE_DEVICE_TABLE(acpi, button_device_ids);
 
+/*
+ * Some devices which don't even have a lid in anyway have a broken _LID
+ * method (e.g. pointing to a floating gpio pin) causing spurious LID events.
+ */
+static const struct dmi_system_id lid_blacklst[] = {
+	{
+		/* GP-electronic T701 */
+		.matches = {
+			DMI_MATCH(DMI_SYS_VENDOR, "Insyde"),
+			DMI_MATCH(DMI_PRODUCT_NAME, "T701"),
+			DMI_MATCH(DMI_BIOS_VERSION, "BYT70A.YNCHENG.WIN.007"),
+		},
+	},
+	{}
+};
+
 static int acpi_button_add(struct acpi_device *device);
 static int acpi_button_remove(struct acpi_device *device);
 static void acpi_button_notify(struct acpi_device *device, u32 event);
@@ -459,6 +476,9 @@ static int acpi_button_add(struct acpi_device *device)
 	char *name, *class;
 	int error;
 
+	if (!strcmp(hid, ACPI_BUTTON_HID_LID) && dmi_check_system(lid_blacklst))
+		return -ENODEV;
+
 	button = kzalloc(sizeof(struct acpi_button), GFP_KERNEL);
 	if (!button)
 		return -ENOMEM;
Signature · 1 line
2.14.3
#2 lore raw
In reply to Hans de Goede
Quoted 18 lines · Hans de Goede

I've been debugging some spurious suspend issues on various devices, at least on some devices these spurious suspends are caused by surious LID closed events being send to userspace.

Running e.g. evemu-record after noticing a spurious suspend is too late to detect that a LID closed event it the (probable) cause of this. This commit adds a pr_info("ACPI LID closed\n") call to help debugging.

---
 drivers/acpi/button.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/acpi/button.c +0 -0
index ef1856b15488..07da60fe9cae 100644

drivers/acpi/button.c static int acpi_lid_notify_state(struct acpi_device *device, int state) · line 214

Quoted 5 lines
drivers/acpi/button.c +2 -0
@@ -210,6 +210,9 @@ static int acpi_lid_notify_state(struct acpi_device *device, int state)
        }
        /* Send the platform triggered reliable event */
        if (do_update) {
+               if (!state)
+                       pr_info("ACPI LID closed\n");

Why pr_info()?

Quoted 8 lines
drivers/acpi/button.c +1 -1
+
                input_report_switch(button->input, SW_LID, !state);
                input_sync(button->input);
                button->last_state = !!state;
--

2.14.3

--

#3 lore raw

Hi,

Quoted 14 lines · Rafael J. Wysocki
Quoted 13 lines · Hans de Goede

I've been debugging some spurious suspend issues on various devices, at least on some devices these spurious suspends are caused by surious LID closed events being send to userspace.

Running e.g. evemu-record after noticing a spurious suspend is too late to detect that a LID closed event it the (probable) cause of this. This commit adds a pr_info("ACPI LID closed\n") call to help debugging.

---
  drivers/acpi/button.c | 3 +++
  1 file changed, 3 insertions(+)
Quoted 12 lines

drivers/acpi/button.c static int acpi_lid_notify_state(struct acpi_device *device, int state) · line 214

Quoted 10 lines
drivers/acpi/button.c +2 -0
index ef1856b15488..07da60fe9cae 100644
@@ -210,6 +210,9 @@ static int acpi_lid_notify_state(struct acpi_device *device, int state)
         }
         /* Send the platform triggered reliable event */
         if (do_update) {
+               if (!state)
+                       pr_info("ACPI LID closed\n");

Why pr_info()?

The purpose of the patch is to help debug spurious suspends seen on some devices (typically Intel based tablets or 2in1s) so the goal is to look at the logs after the fact and figure things out, so we want something which shows up by default (typically a lid close leads to a suspend which already causes some logging anyways), but this is not an error or a warning, so I ended up with pr_info.

Regards,

Hans

#4 lore raw
Quoted 30 lines · CET Hans de Goede

Hi,

Quoted 14 lines · Rafael J. Wysocki
Quoted 13 lines · Hans de Goede

I've been debugging some spurious suspend issues on various devices, at least on some devices these spurious suspends are caused by surious LID closed events being send to userspace.

Running e.g. evemu-record after noticing a spurious suspend is too late to detect that a LID closed event it the (probable) cause of this. This commit adds a pr_info("ACPI LID closed\n") call to help debugging.

---
  drivers/acpi/button.c | 3 +++
  1 file changed, 3 insertions(+)
Quoted 12 lines

drivers/acpi/button.c static int acpi_lid_notify_state(struct acpi_device *device, int state) · line 214

Quoted 10 lines
drivers/acpi/button.c +2 -0
index ef1856b15488..07da60fe9cae 100644
@@ -210,6 +210,9 @@ static int acpi_lid_notify_state(struct acpi_device *device, int state)
         }
         /* Send the platform triggered reliable event */
         if (do_update) {
+               if (!state)
+                       pr_info("ACPI LID closed\n");

Why pr_info()?

Quoted 6 lines

The purpose of the patch is to help debug spurious suspends seen on some devices (typically Intel based tablets or 2in1s) so the goal is to look at the logs after the fact and figure things out, so we want something which shows up by default (typically a lid close leads to a suspend which already causes some logging anyways), but this is not an error or a warning, so I ended up with pr_info.

This prints a useless message avery time the lid closes on *many* systems that don't have this problem which is a bit overly excessive IMO.

And you can always ask bug reporters to collect logs with dynamic debug enabled if need be, can't you?

Thanks,
Rafael

#5 lore raw

Hi,

Quoted 38 lines · Rafael J. Wysocki
Quoted 30 lines · CET Hans de Goede

Hi,

Quoted 14 lines · Rafael J. Wysocki
Quoted 13 lines · Hans de Goede

I've been debugging some spurious suspend issues on various devices, at least on some devices these spurious suspends are caused by surious LID closed events being send to userspace.

Running e.g. evemu-record after noticing a spurious suspend is too late to detect that a LID closed event it the (probable) cause of this. This commit adds a pr_info("ACPI LID closed\n") call to help debugging.

---
   drivers/acpi/button.c | 3 +++
   1 file changed, 3 insertions(+)
Quoted 12 lines

drivers/acpi/button.c static int acpi_lid_notify_state(struct acpi_device *device, int state) · line 214

Quoted 10 lines
drivers/acpi/button.c +2 -0
index ef1856b15488..07da60fe9cae 100644
@@ -210,6 +210,9 @@ static int acpi_lid_notify_state(struct acpi_device *device, int state)
          }
          /* Send the platform triggered reliable event */
          if (do_update) {
+               if (!state)
+                       pr_info("ACPI LID closed\n");

Why pr_info()?

Quoted 6 lines

The purpose of the patch is to help debug spurious suspends seen on some devices (typically Intel based tablets or 2in1s) so the goal is to look at the logs after the fact and figure things out, so we want something which shows up by default (typically a lid close leads to a suspend which already causes some logging anyways), but this is not an error or a warning, so I ended up with pr_info.

Quoted 5 lines

This prints a useless message avery time the lid closes on *many* systems that don't have this problem which is a bit overly excessive IMO.

And you can always ask bug reporters to collect logs with dynamic debug enabled if need be, can't you?

Ok, I will send a v2 using pr_debug instead.

Regards,

Hans

#6 lore raw
Quoted 57 lines · Hans de Goede

Hi,

Quoted 53 lines · Rafael J. Wysocki
Quoted 37 lines · CET Hans de Goede

Hi,

Quoted 17 lines · Rafael J. Wysocki
Quoted 14 lines · Hans de Goede

I've been debugging some spurious suspend issues on various devices, at least on some devices these spurious suspends are caused by surious LID closed events being send to userspace.

Running e.g. evemu-record after noticing a spurious suspend is too late to detect that a LID closed event it the (probable) cause of this. This commit adds a pr_info("ACPI LID closed\n") call to help debugging.

---
   drivers/acpi/button.c | 3 +++
   1 file changed, 3 insertions(+)
Quoted 14 lines

drivers/acpi/button.c static int acpi_lid_notify_state(struct acpi_device · line 215

Quoted 11 lines
drivers/acpi/button.c +2 -0
index ef1856b15488..07da60fe9cae 100644
@@ -210,6 +210,9 @@ static int acpi_lid_notify_state(struct acpi_device
 *device, int state)
          }
          /* Send the platform triggered reliable event */
          if (do_update) {
+               if (!state)
+                       pr_info("ACPI LID closed\n");

Why pr_info()?

Quoted 8 lines

The purpose of the patch is to help debug spurious suspends seen on some devices (typically Intel based tablets or 2in1s) so the goal is to look at the logs after the fact and figure things out, so we want something
which shows up by default (typically a lid close leads to a suspend which already causes some logging anyways), but this is not an error or a warning,
so I ended up with pr_info.

This prints a useless message avery time the lid closes on *many* systems that
don't have this problem which is a bit overly excessive IMO.

Quoted 6 lines
Quoted 3 lines

And you can always ask bug reporters to collect logs with dynamic debug enabled
if need be, can't you?

Ok, I will send a v2 using pr_debug instead.

acpi_handle_debug() might be better, because it would allow you to identify the device too.

Thanks,
Rafael