Bug 196249 - Resumed GPE State - Lid state remains "closed" when resuming from suspend by lifting lid - HP Pavilion dv5120us
Summary: Resumed GPE State - Lid state remains "closed" when resuming from suspend by ...
Status: RESOLVED CODE_FIX
Alias: None
Product: ACPI
Classification: Unclassified
Component: Config-Interrupts (show other bugs)
Hardware: All Linux
: P1 normal
Assignee: Lv Zheng
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-07-02 23:02 UTC by Eric Bakula-Davis
Modified: 2018-08-17 08:25 UTC (History)
4 users (show)

See Also:
Kernel Version: 4.11.8
Subsystem:
Regression: No
Bisected commit-id:


Attachments
acpidump (149.71 KB, text/plain)
2017-07-02 23:02 UTC, Eric Bakula-Davis
Details
[PATCH] ACPICA: Events: Stop unconditionally clearing ACPI IRQs' status (2.77 KB, patch)
2017-07-04 06:23 UTC, Lv Zheng
Details | Diff

Description Eric Bakula-Davis 2017-07-02 23:02:42 UTC
Created attachment 257297 [details]
acpidump

OS: 
Lubuntu 16.04

Hardware:
HP Pavilion dv5120us

Other Kernels Tried:
4.4.0-79 (Ubuntu version)
4.4.0-81 (Ubuntu version)

Overview: 
When the system is not configured to sleep on lid close, the lid state (/proc/acpi/button/lid/LID/state) is always accurate. However, when the system is configured to sleep on lid close, here is what happens:

The lid is closed and the system sleeps
The lid is opened and the system wakes but the lid state is "closed"
The lid is closed and nothing happens (state remains "closed")
The lid is opened and the state changes to "open"
The cycle can then repeat

Sleep/wake without using the lid does not affect the lid state.

This bug does not occur on other hardware with the same OS and kernels

Research:
The same behavior has been reported in these places: https://bugs.launchpad.net/ubuntu/+source/linux/+bug/34389
https://blog.twcloud.tech/2013/04/29/fixing-incorrect-lid-state/

In both cases, the problem was fixed by patching the user's DSDT. However, I showed my DSDT to one of the people who fixed the problem, and their assessment was that the DSDT was not the problem. They suggested I file a bug report here and include an acpidump (attached). Apologies if I tagged the wrong product or component.
Comment 1 Lv Zheng 2017-07-03 06:28:43 UTC
Can you confirm your behavior about booting kernel with button.lid_init_state=ignore?
Comment 2 Eric Bakula-Davis 2017-07-03 13:53:48 UTC
(In reply to Lv Zheng from comment #1)
> Can you confirm your behavior about booting kernel with
> button.lid_init_state=ignore?

Hi Lv Zheng. The behavior is the same when booting with button.lid_init_state=ignore
Comment 3 Lv Zheng 2017-07-04 02:34:07 UTC
Are there any functional problem with this file returning wrong values?
also please paste "systemctl --version" output here.

Thanks
Lv
Comment 4 Lv Zheng 2017-07-04 02:43:34 UTC
Decoding the table, I got:

    Scope (_SB)
    {
        Device (PCI0)
        {
            Device (SMB)
            {
                OperationRegion (PMIO, SystemIO, 0x0CD6, 0x02)
                Field (PMIO, ByteAcc, NoLock, Preserve)
                {
                    INPM,   8,
                    DAPM,   8
                }

                IndexField (INPM, DAPM, ByteAcc, NoLock, Preserve)
                {
                    Offset (0x37),
                        ,   5,
                    LPOL,   1,
                }
            }
        }
        Device (LID)
        {
            Name (_HID, EisaId ("PNP0C0D"))
            Method (_LID, 0, NotSerialized)
            {
                If (\_SB.PCI0.SMB.LPOL)
                {
                    Return (0x00)
                }

                Return (0x01)
            }

            Name (_PRW, Package (0x02)
            {
                0x15,
                0x03
            })
        }

        Method (_L15, 0, NotSerialized)
        {
            \_SB.PCI0.SMB.LPOL = ~\_SB.PCI0.SMB.LPOL
            Notify (\_SB.LID, 0x80)
        }
    }

This seems to be a fixable known issue.
I guess GPE15 is errornously cleared after resume, causing this problem.
Comment 5 Eric Bakula-Davis 2017-07-04 02:52:45 UTC
Great - Can you recommend a fix? Do you still want a response to your previous comment?
Comment 6 Eric Bakula-Davis 2017-07-04 03:18:27 UTC
(In reply to Lv Zheng from comment #3)
> Are there any functional problem with this file returning wrong values?
> also please paste "systemctl --version" output here.
> 
> Thanks
> Lv

If you mean /proc/acpi/button/lid/LID/state, I'm not sure if there are functional problems with it. I can say that if the system is not configured to suspend when the lid is closed, the state file accurately reports the lid as "open" when it's open and "closed" when it's closed. 

systemctl --version returns:
systemd 229
+PAM +AUDIT +SELINUX +IMA +APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ -LZ4 +SECCOMP +BLKID +ELFUTILS +KMOD -IDN

The behavior also occurs when the lid triggers pm-suspend rather than systemctl suspend.
Comment 7 Lv Zheng 2017-07-04 04:48:49 UTC
> Great - Can you recommend a fix?

I'll give it a try.

> Do you still want a response to your previous comment?

Thanks for the information in comment 6.
Comment 8 Lv Zheng 2017-07-04 06:23:00 UTC
Created attachment 257343 [details]
[PATCH] ACPICA: Events: Stop unconditionally clearing ACPI IRQs' status

Please give this fix a try:

Apply this fix, recompile and boot the compiled kernel.
Comment 9 Eric Bakula-Davis 2017-07-04 18:28:56 UTC
Hi Lv

This is the first time I've compiled an upstream kernel. Below are the steps I took. I expect it will take over 5 hours to compile. If I did something wrong, please let me know so I can abort and retry.

I did this while running a pre-compiled 4.11.8 kernel from here: http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.11.8/

Steps:

$ cd ~
$ git clone git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git
$ cd linux-stable
$ git checkout 8afcfa55e6a7d8c58bdb4355bd544602e6f0c3ad
$ git describe --exact-match HEAD
v4.11.8
$ cp /boot/config-4.11.8* .config
$ make oldconfig
[saved raw unified patch as lv.patch]
$ patch -p1 < lv.patch
[manually confirmed that all changes were successfully made]
$ make clean
$ make deb-pkg LOCALVERSION=-custom
Comment 10 Eric Bakula-Davis 2017-07-05 06:23:41 UTC
Compile complete. Which of these packages should I install?

1. linux-firmware-image-4.11.8-custom_4.11.8-custom-1_amd64.deb
2. linux-headers-4.11.8-custom_4.11.8-custom-1_amd64.deb
3. linux-image-4.11.8-custom_4.11.8-custom-1_amd64.deb
4. linux-image-4.11.8-custom-dbg_4.11.8-custom-1_amd64.deb
5. linux-libc-dev_4.11.8-custom-1_amd64.deb

I also have...

linux-4.11.8-custom_4.11.8-custom-1_amd64.changes
linux-4.11.8-custom_4.11.8-custom-1.debian.tar.gz
linux-4.11.8-custom_4.11.8-custom-1.dsc
linux-4.11.8-custom_4.11.8-custom.orig.tar.gz
Comment 11 Chen Yu 2017-07-05 09:10:29 UTC
(In reply to Eric Bakula-Davis from comment #10)
> Compile complete. Which of these packages should I install?
> 
> 1. linux-firmware-image-4.11.8-custom_4.11.8-custom-1_amd64.deb
> 2. linux-headers-4.11.8-custom_4.11.8-custom-1_amd64.deb
> 3. linux-image-4.11.8-custom_4.11.8-custom-1_amd64.deb
> 4. linux-image-4.11.8-custom-dbg_4.11.8-custom-1_amd64.deb
> 5. linux-libc-dev_4.11.8-custom-1_amd64.deb
> 
> I also have...
> 
> linux-4.11.8-custom_4.11.8-custom-1_amd64.changes
> linux-4.11.8-custom_4.11.8-custom-1.debian.tar.gz
> linux-4.11.8-custom_4.11.8-custom-1.dsc
> linux-4.11.8-custom_4.11.8-custom.orig.tar.gz
Next time you can disabled CONFIG_DEBUG_INFO and the compiling time will be reduced a lot.
You can install the package via:
dpkg -i *.deb
Comment 12 Chen Yu 2017-07-05 09:11:48 UTC
(In reply to Chen Yu from comment #11)
> (In reply to Eric Bakula-Davis from comment #10)
> > Compile complete. Which of these packages should I install?
> > 
> > 1. linux-firmware-image-4.11.8-custom_4.11.8-custom-1_amd64.deb
> > 2. linux-headers-4.11.8-custom_4.11.8-custom-1_amd64.deb
> > 3. linux-image-4.11.8-custom_4.11.8-custom-1_amd64.deb
> > 4. linux-image-4.11.8-custom-dbg_4.11.8-custom-1_amd64.deb
> > 5. linux-libc-dev_4.11.8-custom-1_amd64.deb
> > 
> > I also have...
> > 
> > linux-4.11.8-custom_4.11.8-custom-1_amd64.changes
> > linux-4.11.8-custom_4.11.8-custom-1.debian.tar.gz
> > linux-4.11.8-custom_4.11.8-custom-1.dsc
> > linux-4.11.8-custom_4.11.8-custom.orig.tar.gz
> Next time you can disabled CONFIG_DEBUG_INFO and the compiling time will be
> reduced a lot.
> You can install the package via:
> dpkg -i *.deb
Also, you can speed up your compiling by make dpkg -jn (n is the cpu number of your platform)
Comment 13 Eric Bakula-Davis 2017-07-05 15:43:13 UTC
I installed all the .deb packages as Chen suggested, booted into the new kernel, and it worked! Now the lid state is always accurate and suspend works normally. Thank you both for your help. Special thanks to Lv for providing the patch.
Comment 14 Lv Zheng 2017-07-06 01:35:59 UTC
The LCD control method is special:
        Method (_L15, 0, NotSerialized)
        {
            \_SB.PCI0.SMB.LPOL = ~\_SB.PCI0.SMB.LPOL
            Notify (\_SB.LID, 0x80)
        }
The only condition for _L15 to work properly is no GPE loss.

However the fix may have side effect, I'll consider a better way to make it upstreamed.

Marking this bug as RESOVED, but will leave it unclosed until patch can land ACPICA upstream.

Thanks
Lv
Comment 15 Michal Suchanek 2018-08-17 08:25:45 UTC
Hello,

I hit a regression with this patch.

On my notebook I can no longer resume from suspend.

I use the power button to enter suspend. Without this patch system enters suspend after pressing power button and wakes up on power button or key press.

With patch first time I press power button system enters suspend and immediately resumes. Second time system enters suspend and does not respond neither to power button nor key press.

Note You need to log in before you can comment on or make changes to this bug.