Laptop doesn't any reaction on lid close

Please run this to prove it:

sudo libinput debug-events

udo libinput debug-events  :heavy_check_mark:  
-event3 DEVICE_ADDED Video Bus seat0 default group1 cap:k
-event1 DEVICE_ADDED Lid Switch seat0 default group2 cap:S
-event0 DEVICE_ADDED Power Button seat0 default group3 cap:k
-event7 DEVICE_ADDED XiaoMi USB 2.0 Webcam: XiaoMi U seat0 default group4 cap:k
-event8 DEVICE_ADDED GXT7863:00 27C6:01E0 Mouse seat0 default group5 cap:p left scroll-nat scroll-button
-event9 DEVICE_ADDED GXT7863:00 27C6:01E0 Touchpad seat0 default group5 cap:pg size 128x83mm tap(dl off) left scroll-nat scroll-2fg-edge click-buttonareas-clickfinger dwt-on
-event2 DEVICE_ADDED AT Translated Set 2 keyboard seat0 default group6 cap:k
-event9 GESTURE_HOLD_BEGIN +0.040s 1
event9 POINTER_MOTION +0.112s 0.93/ -0.36 ( +3.00/ -1.15)
event9 POINTER_MOTION +0.120s 3.24/ -0.75 ( +5.00/ -1.15)
event9 GESTURE_HOLD_END +0.120s 1 cancelled
event9 POINTER_MOTION +0.126s 4.21/ -2.43 ( +6.00/ -3.46)
event9 POINTER_MOTION +0.133s 4.91/ -1.62 ( +7.00/ -2.31)
event9 POINTER_MOTION +0.140s 4.91/ -2.43 ( +7.00/ -3.46)
event9 POINTER_MOTION +0.147s 4.91/ -2.43 ( +7.00/ -3.46)

output never ends

sudo libinput list-devices

Example (choose another device if needed):

sudo libinput debug-events /dev/input/event0

Look for “lid switch” or “SWITCH_TOGGLE” :wink:

If it is not there. then it is a problem with firmware/UEFI.

there is
sudo libinput debug-events /dev/input/event1  TSTP ✘  8s   
-event1 DEVICE_ADDED Lid Switch seat0 default group1 cap:S

and when lid close\up nothing logged

and what a problem can be in the UEFI/Firmware if its work well on WIN :slight_smile: )

To put it simple: There are drivers/modules which use firmware to call the hardware. If the firmware (here the so called UEFI), have special rules/functions, which are not common (not following the specifications) and are made with windows in mind, then linux cannot call them, but windows can because of the windows drivers.

Only solution I can think of is: Switching Kernels or updating the UEFI.

Well, yes, the pre-installed is win system. but I would never have thought that the laptop close sensor could be a problem for Linux. Let’s refer to the fact that the laptop is too fresh. It’s a pity that this can not be solved by changing the settings. although I’m not an expert,but I installed linux on a bunch of laptops, but this is the first time when I have problem with this critical functionality, an unsuccessful purchase for me :roll_eyes:

https://bbs.archlinux.org/viewtopic.php?id=272473
https://askubuntu.com/questions/1238246/laptop-still-on-when-lid-closed

UEFI is up to date with latest firmware from vendor. Ok will wait for the future kernel relises. Thanks

there is not a suspend or hibernate problem it doesn’t even lock the system and switch off built in monitor

System can with any problem to systemctl suspend

Its simple no reaction on hardware trigger

although I may be wrong something is happening, maybe this will help?

and with systemd-inhibit --what=handle-lid-switch sleep 1m

Please post it as text in a code block. No pictures of text please.

  1. The text is not searchable.
  2. Don’t expect that someone will write everything by hand of a picture because the poster is too lazy to use the Copy&Paste function. :clown_face:

there is text version, sorry

[  210.510881] ACPI Error: Needed [Buffer/String/Package], found [Integer] 000000000b855835 (20211217/exresop-557)
[  210.510891] ACPI Error: AE_AML_OPERAND_TYPE, While resolving operands for [Index] (20211217/dswexec-431)
[  210.510897] ACPI Error: Aborting method \_SB.ALIB due to previous error (AE_AML_OPERAND_TYPE) (20211217/psparse-529)
[  210.510902] ACPI Error: Aborting method \_SB.PCI0.LPC0.EC0._Q80 due to previous error (AE_AML_OPERAND_TYPE) (20211217/psparse-529)
[  210.907624] ACPI Error: Needed [Buffer/String/Package], found [Integer] 00000000846aa96b (20211217/exresop-557)
[  210.907634] ACPI Error: AE_AML_OPERAND_TYPE, While resolving operands for [Index] (20211217/dswexec-431)
[  210.907640] ACPI Error: Aborting method \_SB.ALIB due to previous error (AE_AML_OPERAND_TYPE) (20211217/psparse-529)
[  210.907645] ACPI Error: Aborting method \_SB.PCI0.LPC0.EC0._Q80 due to previous error (AE_AML_OPERAND_TYPE) (20211217/psparse-529)
[  212.241085] ACPI: button: The lid device is not compliant to SW_LID.
[  215.740497] ACPI Error: Needed [Buffer/String/Package], found [Integer] 00000000c6f2e8bb (20211217/exresop-557)
[  215.740508] ACPI Error: AE_AML_OPERAND_TYPE, While resolving operands for [Index] (20211217/dswexec-431)
[  215.740514] ACPI Error: Aborting method \_SB.ALIB due to previous error (AE_AML_OPERAND_TYPE) (20211217/psparse-529)
[  215.740518] ACPI Error: Aborting method \_SB.PCI0.LPC0.EC0._Q80 due to previous error (AE_AML_OPERAND_TYPE) (20211217/psparse-529)
[  216.137230] ACPI Error: Needed [Buffer/String/Package], found [Integer] 000000009e94f261 (20211217/exresop-557)
[  216.137240] ACPI Error: AE_AML_OPERAND_TYPE, While resolving operands for [Index] (20211217/dswexec-431)
[  216.137246] ACPI Error: Aborting method \_SB.ALIB due to previous error (AE_AML_OPERAND_TYPE) (20211217/psparse-529)
[  216.137251] ACPI Error: Aborting method \_SB.PCI0.LPC0.EC0._Q80 due to previous error (AE_AML_OPERAND_TYPE) (20211217/psparse-529)
[  220.683600] ACPI Error: Needed [Buffer/String/Package], found [Integer] 000000008a2e475b (20211217/exresop-557)
[  220.683612] ACPI Error: AE_AML_OPERAND_TYPE, While resolving operands for [Index] (20211217/dswexec-431)
[  220.683619] ACPI Error: Aborting method \_SB.ALIB due to previous error (AE_AML_OPERAND_TYPE) (20211217/psparse-529)
[  220.683625] ACPI Error: Aborting method \_SB.PCI0.LPC0.EC0._Q80 due to previous error (AE_AML_OPERAND_TYPE) (20211217/psparse-529)
[  221.084324] ACPI Error: Needed [Buffer/String/Package], found [Integer] 000000005413f315 (20211217/exresop-557)
[  221.084335] ACPI Error: AE_AML_OPERAND_TYPE, While resolving operands for [Index] (20211217/dswexec-431)
[  221.084341] ACPI Error: Aborting method \_SB.ALIB due to previous error (AE_AML_OPERAND_TYPE) (20211217/psparse-529)
[  221.084346] ACPI Error: Aborting method \_SB.PCI0.LPC0.EC0._Q80 due to previous error (AE_AML_OPERAND_TYPE) (20211217/psparse-529)
[  223.863280] audit: type=1131 audit(1652574495.951:137): pid=1 uid=0 auid=4294967295 ses=4294967295 subj==unconfined msg='unit=systemd-timedated comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'
[  223.887941] audit: type=1334 audit(1652574495.974:138): prog-id=0 op=UNLOAD
[  223.887954] audit: type=1334 audit(1652574495.974:139): prog-id=0 op=UNLOAD
[  223.887957] audit: type=1334 audit(1652574495.974:140): prog-id=0 op=UNLOAD
[  224.977443] ACPI Error: Needed [Buffer/String/Package], found [Integer] 000000008c04a091 (20211217/exresop-557)
[  224.977454] ACPI Error: AE_AML_OPERAND_TYPE, While resolving operands for [Index] (20211217/dswexec-431)
[  224.977460] ACPI Error: Aborting method \_SB.ALIB due to previous error (AE_AML_OPERAND_TYPE) (20211217/psparse-529)
[  224.977465] ACPI Error: Aborting method \_SB.PCI0.LPC0.EC0._Q80 due to previous error (AE_AML_OPERAND_TYPE) (20211217/psparse-529)
[  225.373168] ACPI Error: Needed [Buffer/String/Package], found [Integer] 000000005563a027 (20211217/exresop-557)
[  225.373178] ACPI Error: AE_AML_OPERAND_TYPE, While resolving operands for [Index] (20211217/dswexec-431)
[  225.373183] ACPI Error: Aborting method \_SB.ALIB due to previous error (AE_AML_OPERAND_TYPE) (20211217/psparse-529)
[  225.373187] ACPI Error: Aborting method \_SB.PCI0.LPC0.EC0._Q80 due to previous error (AE_AML_OPERAND_TYPE) (20211217/psparse-529)

Possible that one of these calls are responsible to the lid switch. No idea… If you want to go down to rabbit hole:

pamac install acpica
mkdir /tmp/acpi
cd /tmp/acpi
sudo acpidump > acpidump.bin
acpixtract -a acpidump.bin
iasl -d *.dat

Now you can view the whole code of ACPI Tables of your hardware and search at the *.dsl files.

More here: ACPI Support — The Linux Kernel documentation

1 Like

Unfortunately I’m not very versed in all this :frowning_face:, and what should I do with these files now, but thanks

Read the comment here about this message:

So only way to fix this, is by updating the firmware. Maybe, if you are smart enough, you can fix it by editing the ACPIdump and overwrite it. But well, there no chance that a kernel update would fix a buggy UEFI. I guess Windows has a workaround for this behavior, but still the problem lies on the firmware, not Linux.

1 Like

Hello! Not sure if it still actual for you, but I have the same laptop and the same issue. I spent a lot of time trying to find the solution aaaaand looks like I found it! But, on Chinese forum… (unfortunately I can not post the link here).

If you still need help with it, then just ping me I’ll share the link and a bit late will try to post here translated guide.

1 Like

So, as I said above, this is translated instruction from Chinese forum.

The problem is really related with ACPI.

Firstly make sure, that you have the same error messages when you open or close your lid.

Run:

journalctl -b -f

After that close and open your lid and you will seen in the logs this lines:

ACPI Error: Needed [Buffer/String/Package], found [Integer] 00000000563bf479 (20210105/exresop-557)
ACPI Error: AE_AML_OPERAND_TYPE, While resolving operands for [Index] (20210105/dswexec-431)
ACPI Error: Aborting method \_SB.ALIB due to previous error (AE_AML_OPERAND_TYPE) (20210105/psparse-529)
ACPI Error: Aborting method \_SB.PCI0.LPC0.EC0._Q80 due to previous error (AE_AML_OPERAND_TYPE) (20210105/pspars>

(some numbers may differ, but the most important thing, that is \_SB.PCI0.LPC0.EC0._Q80. It must be in you log)


You need to decompile DSDT:

sudo acpidump > acpidata.dat
acpixtract -sSSDT acpidata.dat
acpixtract -sDSDT acpidata.dat
iasl -e ssdt*.dat -d dsdt.dat

The function _Q80 in dsdt.dsl looks like this:

Method (_Q80, 0, NotSerialized)  // _Qxx: EC Query, xx=0x00-0xFF
{
    If ((LSTE == Zero))
    {
        ALBH (0x06, 0x4E20)
        ALBH (0x07, 0x4E20)
        ALBH (0x05, 0x00051C98)
        ALIB (One, 0x05)
    }
    Else
    {
        STTC ()
    }

    LIDS = ECRD (RefOf (LSTE))
    Notify (LID0, 0x80) // Status Change
}

The problem appears to be the call to ALIB (One, 0x05). Found that the ALIB function is defined in ssdt2.dsl:

Method (ALIB, 2, NotSerialized)
{
    If ((Arg0 == 0x00))
    {
        。。。。。。
    }

    If ((Arg0 == 0x01))
    {
        Local0 = DerefOf (Arg1 [0x02])
        Return (A019 (Local0))
    }

It looks like Arg1 should be an array, not the integer 0x05. This also matches the error in the syslog.

So what should be changed? Searched this ALIB should be provided by AMD. Documentation: Link for AMD Documentation

Instructions for calling ALIB(1, _):

Report AC/DC State - Function 1.
The Platform BIOS should Report AC/DC State to report boot up power source as AC or DC.
This function could be performed from \_SB.PCI0._INI or from \_SB._INI, for example.

Input:
WORD Size
BYTE AC/DC State

Size
The size in bytes, 3.
AC/DC
State Indicate the current power source type.
0 - Current state is AC power.
1 - Current state is DC power.

Output: None.

The current power state should be passed in. I read this code full of four-letter abbreviations, and have no clue. Since the document says: “report boot up power source”, “This function could be performed from \_SB.PCI0._INI or from \_SB._INI”, it is better to assume that it does not need to be called in the closing event at all, delete it:

$ diff -u dsdt.dsl dsdt_patched.dsl
--- dsdt.dsl    2021-07-01 13:36:18.856593034 +0800
+++ dsdt_patched.dsl    2021-07-01 16:01:44.490812829 +0800
@@ -18,7 +18,7 @@
  *     Compiler ID      "ACPI"
  *     Compiler Version 0x00040000 (262144)
  */
-DefinitionBlock ("", "DSDT", 1, "XMCC  ", "XMCC2019", 0x00000002)
+DefinitionBlock ("", "DSDT", 1, "XMCC  ", "XMCC2019", 0x00000009)
 {
     External (_SB_.ALIB, MethodObj)    // 2 Arguments
     External (_SB_.APTS, MethodObj)    // 1 Arguments
@@ -4672,7 +4672,7 @@
                             ALBH (0x06, 0x4E20)
                             ALBH (0x07, 0x4E20)
                             ALBH (0x05, 0x00051C98)
-                            ALIB (One, 0x05)
+                            // ALIB (One, 0x05)
                         }
                         Else
                         {

Note that the version 0x00000002 of the file header needs to be increased, otherwise the original version cannot be overwritten.

According to the instructions of the arch wiki, overwrite the DSDT: (loaded at runtime, it will not overwrite the original version in the BIOS, rest assured):

patch < lid.patch
iasl dsdt.dsl
mkdir -p kernel/firmware/acpi
cp dsdt.aml kernel/firmware/acpi/
find kernel | cpio -H newc --create > acpi_override.img
sudo cp acpi_override.img /boot/

Then in the kernel command line of the bootloader, add initrd=acpi_override.img before initrd=initramfs-%v.img. example:

initrd=amd-ucode.img initrd=acpi_override.img initrd=initramfs-%v.img 

(I did this with adding GRUB_EARLY_INITRD_LINUX_CUSTOM="acpi_override.img" to /etc/default/grub)

After restarting, search for DSDT in the system log:

kernel: ACPI: DSDT ACPI table found in initrd [kernel/firmware/acpi/dsdt_patched.aml][0x6569]
...
kernel: ACPI: DSDT 0x00000000C843E000 006569 (v01 XMCC   XMCC2019 00000009 INTL 20210331)

Note that the version number changed from 02 to 09 which we changed.

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.