Hello,

I have been testing GNU/Hurd on real hardware and found that my
ThinkPad T400 does not power off at the end of halt. The machine stays
on after this message and I have to hold the power button:

  hwsleep-0079 hw_legacy_sleep : Entering sleep state [S5]

In QEMU the same image powers off correctly.

Setup:
- ThinkPad T400, stock Lenovo BIOS, Intel GM45 chipset
- Guix System, Hurd 64-bit (x86_64-gnu)
- hurd 0.9.git20261127 (30202dc)
- libacpica 20220331 (0c3593e). The same acpi_enter_sleep() code is
still in salsa master (fd28640).

What I tried:
Looking at acpi_init.c (created by
debian/patches/acpi-init-files.diff), acpi_enter_sleep() calls
acpi_hw_legacy_sleep() directly and does not call
acpi_enter_sleep_state_prep() first. As far as I understand, prep is
what reads the SLP_TYP values from \_S5, so I tried this change:

--- a/acpi_init.c
+++ b/acpi_init.c
 void
 acpi_enter_sleep(int sleep_state)
 {
-  acpi_hw_legacy_sleep (sleep_state);
+  acpi_status err;
+
+  err = acpi_enter_sleep_state_prep (sleep_state);
+  if (ACPI_FAILURE (err))
+    acpi_os_printf ("acpi_enter_sleep_state_prep failed: 0x%x, trying
anyway\n", err);
+  acpi_enter_sleep_state (sleep_state);
 }

Result:
With this change the T400 powers off cleanly on halt, and the next
boot is clean.

One thing I noticed: on this ThinkPad, _PTS fails because it tries to
access the Embedded Controller and there is no handler for it, so prep
returns an error. That is why the change continues even when prep
fails. With an early return on error the machine did not power off.
This is the console output:

  Enter evaluation : _S5 (Package)
  Exit evaluation  : _S5
  Enter evaluation : _S0 (Package)
  Exit evaluation  : _S0
  Enter evaluation : _PTS (Method)
  Nested method call : _SB.PCI0.LPC.EC.HKEY.MHKE
  ACPI Error: No handler for Region [ECOR] (0x2000000258a0)
[EmbeddedControl] (20220331/evregion-129)
  ACPI Error: Region EmbeddedControl (ID=3) has no handler
(20220331/exfldio-260)
  ACPI Error: Aborting method \_PTS due to previous error
(AE_NOT_EXIST) (20220331/psparse-528)
  acpi_enter_sleep_state_prep failed: 0x6

I am not familiar with ACPICA, so I am not sure this is the right way
to fix it. I am happy to test other patches on the T400.

Thanks,
Tristan

Reply via email to