diff mbox series

[4/5] platform/x86: x86-android-tablets: Workaround Lenovo Yoga Tablet 2 830/1050 poweroff hang

Message ID 20220223133153.730337-5-hdegoede@redhat.com
State New
Headers show
Series pinctrl/baytrail platform/x86: SUS6 mux / Lenovo Yoga Tablet 2 support | expand

Commit Message

Hans de Goede Feb. 23, 2022, 1:31 p.m. UTC
These tablets' DSDT does not set acpi_gbl_reduced_hardware, so
acpi_power_off gets used as pm_power_off handler. This causes "poweroff"
on these tablets to hang hard. Requiring pressing the powerbutton for
30 seconds *twice* followed by a normal 3 second press to recover.

Avoid this by overriding the global pm_power_off handler to do
an EFI poweroff instead.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/platform/x86/x86-android-tablets.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

Comments

Andy Shevchenko Feb. 23, 2022, 2:58 p.m. UTC | #1
On Wed, Feb 23, 2022 at 02:31:52PM +0100, Hans de Goede wrote:
> These tablets' DSDT does not set acpi_gbl_reduced_hardware, so
> acpi_power_off gets used as pm_power_off handler. This causes "poweroff"
> on these tablets to hang hard. Requiring pressing the powerbutton for
> 30 seconds *twice* followed by a normal 3 second press to recover.
> 
> Avoid this by overriding the global pm_power_off handler to do
> an EFI poweroff instead.

Oh, you eventually found the root cause (reduced HW bit)?
Perhaps we need to enforce it based on a quirk?
Hans de Goede Feb. 24, 2022, 4:57 p.m. UTC | #2
Hi,

On 2/23/22 15:58, Andy Shevchenko wrote:
> On Wed, Feb 23, 2022 at 02:31:52PM +0100, Hans de Goede wrote:
>> These tablets' DSDT does not set acpi_gbl_reduced_hardware, so
>> acpi_power_off gets used as pm_power_off handler. This causes "poweroff"
>> on these tablets to hang hard. Requiring pressing the powerbutton for
>> 30 seconds *twice* followed by a normal 3 second press to recover.
>>
>> Avoid this by overriding the global pm_power_off handler to do
>> an EFI poweroff instead.
> 
> Oh, you eventually found the root cause (reduced HW bit)?

I'm not sure, it is possible that not setting the reduced HW bit
is actually correct for this hw, but that does lead to using
acpi_power_off which seems broken on this system.

I've updated the commit message while merging this to reflect
that using acpi_power_off is the problem, rather then not setting
the reduced HW bit.

Also note that the issue of reboot being the same as poweroff once
the system has been rebooted at least once is still unresolved.

Regards,

Hans
Andy Shevchenko Feb. 25, 2022, 4:35 p.m. UTC | #3
On Thu, Feb 24, 2022 at 05:57:11PM +0100, Hans de Goede wrote:
> Hi,
> 
> On 2/23/22 15:58, Andy Shevchenko wrote:
> > On Wed, Feb 23, 2022 at 02:31:52PM +0100, Hans de Goede wrote:
> >> These tablets' DSDT does not set acpi_gbl_reduced_hardware, so
> >> acpi_power_off gets used as pm_power_off handler. This causes "poweroff"
> >> on these tablets to hang hard. Requiring pressing the powerbutton for
> >> 30 seconds *twice* followed by a normal 3 second press to recover.
> >>
> >> Avoid this by overriding the global pm_power_off handler to do
> >> an EFI poweroff instead.
> > 
> > Oh, you eventually found the root cause (reduced HW bit)?
> 
> I'm not sure, it is possible that not setting the reduced HW bit
> is actually correct for this hw, but that does lead to using
> acpi_power_off which seems broken on this system.
> 
> I've updated the commit message while merging this to reflect
> that using acpi_power_off is the problem, rather then not setting
> the reduced HW bit.

Understood. Thanks!

> Also note that the issue of reboot being the same as poweroff once
> the system has been rebooted at least once is still unresolved.
diff mbox series

Patch

diff --git a/drivers/platform/x86/x86-android-tablets.c b/drivers/platform/x86/x86-android-tablets.c
index 89972723f546..c3d2b30dbe26 100644
--- a/drivers/platform/x86/x86-android-tablets.c
+++ b/drivers/platform/x86/x86-android-tablets.c
@@ -12,6 +12,7 @@ 
 
 #include <linux/acpi.h>
 #include <linux/dmi.h>
+#include <linux/efi.h>
 #include <linux/gpio_keys.h>
 #include <linux/gpio/consumer.h>
 #include <linux/gpio/driver.h>
@@ -24,6 +25,7 @@ 
 #include <linux/mod_devicetable.h>
 #include <linux/platform_data/lp855x.h>
 #include <linux/platform_device.h>
+#include <linux/pm.h>
 #include <linux/power/bq24190_charger.h>
 #include <linux/rmi.h>
 #include <linux/serdev.h>
@@ -817,6 +819,7 @@  static struct x86_dev_info lenovo_yoga_tab2_830_1050_info __initdata = {
 	.modules = bq24190_modules,
 	.invalid_aei_gpiochip = "INT33FC:02",
 	.init = lenovo_yoga_tab2_830_1050_init,
+	.exit = lenovo_yoga_tab2_830_1050_exit,
 };
 
 /*
@@ -863,6 +866,18 @@  static int __init lenovo_yoga_tab2_830_1050_init_display(void)
 	return 0;
 }
 
+/*
+ * These tablet's DSDT does not set acpi_gbl_reduced_hardware, so acpi_power_off
+ * gets used as pm_power_off handler. This causes "poweroff" on these tablets
+ * to hang hard. Requiring pressing the powerbutton for 30 seconds *twice*
+ * followed by a normal 3 second press to recover. Avoid this by doing an EFI
+ * poweroff instead.
+ */
+static void lenovo_yoga_tab2_830_1050_power_off(void)
+{
+	efi.reset_system(EFI_RESET_SHUTDOWN, EFI_SUCCESS, 0, NULL);
+}
+
 static int __init lenovo_yoga_tab2_830_1050_init(void)
 {
 	int ret;
@@ -871,9 +886,15 @@  static int __init lenovo_yoga_tab2_830_1050_init(void)
 	if (ret)
 		return ret;
 
+	pm_power_off = lenovo_yoga_tab2_830_1050_power_off;
 	return 0;
 }
 
+static void lenovo_yoga_tab2_830_1050_exit(void)
+{
+	pm_power_off = NULL; /* Just turn poweroff into halt on module unload */
+}
+
 /* Nextbook Ares 8 tablets have an Android factory img with everything hardcoded */
 static const char * const nextbook_ares8_accel_mount_matrix[] = {
 	"0", "-1", "0",