Bug 17081 - Lid switch correct every other time; suspend every other lid close; Samsung N150-11 netbook
Summary: Lid switch correct every other time; suspend every other lid close; Samsung ...
Status: CLOSED DOCUMENTED
Alias: None
Product: ACPI
Classification: Unclassified
Component: EC (show other bugs)
Hardware: All Linux
: P1 normal
Assignee: Lan Tianyu
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-08-25 21:25 UTC by Doug Currie
Modified: 2013-04-17 08:41 UTC (History)
8 users (show)

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


Attachments
The requested acpidump results (122.22 KB, text/plain)
2010-09-14 03:28 UTC, Doug Currie
Details
DSDT for Samsung NC10 Plus (194.47 KB, application/octet-stream)
2011-01-08 16:22 UTC, Soenke
Details
custom _LID method (179 bytes, application/octet-stream)
2011-03-21 06:47 UTC, Zhang Rui
Details
Lid states with _LID.aml custom method. (590 bytes, text/plain)
2011-04-02 13:01 UTC, Soenke
Details
Syslog tail after boot (627 bytes, text/plain)
2011-04-02 13:02 UTC, Soenke
Details
Syslog after loading _LID.aml (627 bytes, text/plain)
2011-04-02 13:02 UTC, Soenke
Details
Syslog 02 as described in lid states file (4.23 KB, text/plain)
2011-04-02 13:03 UTC, Soenke
Details
Syslog 03 as described in lid states file (4.27 KB, text/plain)
2011-04-02 13:04 UTC, Soenke
Details
Syslog 04 as described in lid states file (4.33 KB, text/plain)
2011-04-02 13:04 UTC, Soenke
Details
Syslog 05 as described in lid states file (4.43 KB, text/plain)
2011-04-02 13:05 UTC, Soenke
Details
Syslog 06 as described in lid states file (4.43 KB, text/plain)
2011-04-02 13:06 UTC, Soenke
Details
custom _LID method (78 bytes, application/octet-stream)
2011-04-06 02:31 UTC, Zhang Rui
Details
syslog entries relating to comment #22 (747.50 KB, text/plain)
2012-05-13 15:07 UTC, andrzej
Details
DSDT.hex (200.52 KB, text/plain)
2013-04-12 03:31 UTC, Lan Tianyu
Details

Description Doug Currie 2010-08-25 21:25:05 UTC
Samsung N150-11 netbook. Each lid close&open toggles the lid switch state 
so when the lid is open, half the time it reports closed:

e@eSammy:~$ cat /proc/acpi/button/lid/LID0/state
state:      open

# close & open lid

e@eSammy:~$ cat /proc/acpi/button/lid/LID0/state
state:      closed

So, the netbook only suspends every other time the lid is closed.
This could be dangerous with the netbook stowed in running mode
draining battery and getting hot.

This seems to be related to https://bugzilla.kernel.org/show_bug.cgi?id=5809

Also see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=594149
Comment 1 Len Brown 2010-09-14 02:11:02 UTC
bug 5809 required a DSDT AML fix to make lid state work.
That is bad news.  Assuming Windows suspends on Lid close,
it means that Windows is not checking _LID state to decide if
it should suspend or not.

(eg. perhaps Windows is just getting the lid event and assuming
that since they are awake that they should suspend...)

If Linux depends on a BIOS feature to work that Windows never tests,
then Linux will always be less reliable -- for the system was
tested and shipped with Windows...

It may-be that in general, _LID is unreliable, and Linux user-space
needs to stop depending on it...

In the mean time, please supply the output from acpidump for this
box and perhaps we can prove this theory.
Comment 2 Doug Currie 2010-09-14 03:28:46 UTC
Created attachment 29862 [details]
The requested acpidump results

The requested acpidump results from Samsung N150 Plus.
Comment 3 Soenke 2011-01-08 16:22:40 UTC
Created attachment 42872 [details]
DSDT for Samsung NC10 Plus

Hi there,

same problem here with a Samsnung NC10 Plus which, I gather, is very similar to the N150 Plus. Disassembled DSDT of the machine is attached
Please let me know if I can help with anything else.

Regards,

Soenke
Comment 4 Soenke 2011-01-08 16:25:59 UTC
(In reply to comment #3)
> Created an attachment (id=42872) [details]
> DSDT for Samsung NC10 Plus
> 
> Hi there,
> 
> same problem here with a Samsnung NC10 Plus which, I gather, is very similar
> to
> the N150 Plus. Disassembled DSDT of the machine is attached
> Please let me know if I can help with anything else.
> 
> Regards,
> 
> Soenke

Sorry, I forgot:

Running kernel is 2.6.32 from Debian testing (linux-image-2.6.32-5-amd64, Debian version 2.6.32-29), but the problem is also present in 2.6.37 from Debian experimental.
Comment 5 Zhang Rui 2011-03-21 06:47:26 UTC
Created attachment 51442 [details]
custom _LID method

Please
1. download the _LID.aml attached
2. cat _LID.aml > /sys/kernel/debug/acpi/custom_method
3. echo 1 > /sys/module/acpi/parameters/aml_debug_output
then close&open the lid for several times, get the lid state and attach the test result like:
action(close/open), lid-state-shown, dmesg-output
Comment 6 Zhang Rui 2011-03-31 08:53:30 UTC
ping
Comment 7 Doug Currie 2011-04-01 14:05:53 UTC
My bios is now reconfigured with the workaround suggested by DarrellKavanagh on Voria:

http://www.voria.org/forum/viewtopic.php?f=3&t=523

> Disable "Wake on lid open" in the BIOS. the machine will then suspend every
> time the lid is closed, but raising the lid no longer resumes, - use the
> power switch to resume.

I will change the bios back, enabling "Wake on lid open," and then use the custom method to get the data you need... in the next week when I will have access to the N150-11 again.

Thank you.
Comment 8 Doug Currie 2011-04-02 00:39:05 UTC
I'm at a loss...


e@eSammy:~/Dropbox/eSammy$ cat _LID.aml > /sys/kernel/debug/acpi/custom_method
bash: /sys/kernel/debug/acpi/custom_method: No such file or directory
e@eSammy:~/Dropbox/eSammy$ cat _LID.aml 
_SB_.PCI0.LPC0.H_EC.LIDS[1p\/_SB_PCI0LPC0H_ECLIDS[1�\LIDSe@eSammy:~/Dropbox/eSammy$ 
e@eSammy:~/Dropbox/eSammy$ ls /sys/kernel/debug/
e@eSammy:~/Dropbox/eSammy$ mkdir /sys/kernel/debug/acpi/
mkdir: cannot create directory `/sys/kernel/debug/acpi/': No such file or directory
e@eSammy:~/Dropbox/eSammy$
Comment 9 Doug Currie 2011-04-02 00:43:28 UTC
e@eSammy:~/Dropbox/eSammy$ sudo mount -t debugfs none /sys/kernel/debug
e@eSammy:~/Dropbox/eSammy$ cat _LID.aml > /sys/kernel/debug/acpi/custom_method
bash: /sys/kernel/debug/acpi/custom_method: No such file or directory
e@eSammy:~/Dropbox/eSammy$ ls /sys/kernel/debug/
bdi  dri  ieee80211  kprobes  mce  sched_features  tracing  usb  x86
e@eSammy:~/Dropbox/eSammy$ ^C
Comment 10 Zhang Rui 2011-04-02 00:48:06 UTC
oh, you need to run this is a newer kernel. say 2.6.36/37/38.
Comment 11 Soenke 2011-04-02 13:01:13 UTC
Created attachment 53052 [details]
Lid states with _LID.aml custom method.

Lid states with _LID.aml custom method. Syslog files for the various tested states follow below.
Sorry I did not have time to test earlier. This is from a debian 2.6.38-2-amd64 kernel, custom method _LID.aml loaded as described here.
Comment 12 Soenke 2011-04-02 13:02:02 UTC
Created attachment 53062 [details]
Syslog tail after boot
Comment 13 Soenke 2011-04-02 13:02:59 UTC
Created attachment 53072 [details]
Syslog after loading _LID.aml

No difference to fresh boot
Comment 14 Soenke 2011-04-02 13:03:45 UTC
Created attachment 53082 [details]
Syslog 02 as described in lid states file
Comment 15 Soenke 2011-04-02 13:04:15 UTC
Created attachment 53092 [details]
Syslog 03 as described in lid states file
Comment 16 Soenke 2011-04-02 13:04:47 UTC
Created attachment 53102 [details]
Syslog 04 as described in lid states file
Comment 17 Soenke 2011-04-02 13:05:32 UTC
Created attachment 53112 [details]
Syslog 05 as described in lid states file
Comment 18 Soenke 2011-04-02 13:06:05 UTC
Created attachment 53122 [details]
Syslog 06 as described in lid states file
Comment 19 Zhang Rui 2011-04-06 02:31:23 UTC
Created attachment 53622 [details]
custom _LID method

really nice bug report! :)

please try the _LID.aml attached and see if the the lid state is always reported correctly.

IMO, the binary file attached should workaround the problem for you, but indeed this should be an EC driver problem.
So it would be great if you can try to build a 2.6.38 kernel, uncomment line30 "/* #define DEBUG */" in drivers/acpi/ec.c, and redo the test.
Comment 20 Soenke 2011-04-06 16:41:20 UTC
Hi Zhang,

thanks for the new custom method file. The work around seems to work fine here. Lid state is reported correctly, with and without suspend to ram.
I am not sure whether or when I will find the time to test again with a rebuilt kernel, sorry about that.

Regards,

Soenke
Comment 21 Zhang Rui 2011-04-07 01:45:33 UTC
okay.
Reject this bug for now, please feel free to re-open it if you can do the test in comment #19.
Comment 22 andrzej 2012-05-13 15:03:09 UTC
I have a Samsung N150 Plus that exhibits this bug.  I have done the
test in comment #19 with a recent mainline kernel:

$ cat /proc/version
Linux version 3.4.0-rc6-custom (root@andrzej-N150P) (gcc version 4.6.3
(Ubuntu/Linaro 4.6.3-1ubuntu5) ) #2 SMP Sat May 12 16:46:41 BST 2012

It seems that the bug manifests only if the laptop suspends to RAM
when the lid is closed.  With the custom method, the lid state is
reported correctly and the laptop can suspend/resume correctly every
time the lid is closed/opened.  I attach files containing the output
in /var/log/syslog upon doing an open/close action.  Please let me
know if there is anything else that is required.


Without custom method.  Not configured to suspend on lid close.
---------------------------------------------------------------

| action(close/open) | lid-state-shown | /var/log/syslog output |
|--------------------+-----------------+------------------------|
| initial state      | open            | -                      |
| close              | closed          | syslog.1               |
| open               | open            | syslog.2               |
| close              | closed          | syslog.3               |
| open               | open            | syslog.4               |
|--------------------+-----------------+------------------------|


Without custom method.  Suspend on lid close.
---------------------------------------------
(suspend happens every other time)

| action(close/open) | lid-state-shown | /var/log/syslog output |
|--------------------+-----------------+------------------------|
| initial state      | open            | -                      |
| close              | -               | -                      |
| open               | closed          | syslog.5               |
| close              | closed          | syslog.6               |
| open               | open            | syslog.7               |
| close              | -               | -                      |
| open               | closed          | syslog.8               |
|--------------------+-----------------+------------------------|


With custom method.  Not configured to suspend on lid close.
-------------------------------------------------------------

| action(close/open) | lid-state-shown | /var/log/syslog output |
|--------------------+-----------------+------------------------|
| initial state      | open            | -                      |
| close              | closed          | syslog.9               |
| open               | open            | syslog.10              |
| close              | closed          | syslog.11              |
| open               | open            | syslog.12              |
|--------------------+-----------------+------------------------|


With custom method.  Suspend on lid close.
------------------------------------------
(suspends every time lid closed)

| action(close/open) | lid-state-shown | /var/log/syslog output |
|--------------------+-----------------+------------------------|
| initial state      | open            | -                      |
| close              | -               | -                      |
| open               | open            | syslog.13              |
| close              | -               | -                      |
| open               | open            | syslog.14              |
| close              | -               | -                      |
| open               | open            | syslog.15              |
|--------------------+-----------------+------------------------|
Comment 23 andrzej 2012-05-13 15:07:15 UTC
Created attachment 73275 [details]
syslog entries relating to comment #22
Comment 24 Jonathan Nieder 2012-06-10 09:48:03 UTC
Reopening (Andrzej, watch closely if you want to see how to do this for next time).
Comment 25 Jonathan Nieder 2012-06-10 09:51:21 UTC
(Reassigning to Zhang Rui who was working on this before.  Sorry for the noise.)
Comment 26 Lan Tianyu 2013-04-12 03:25:14 UTC
Hi All:
        Found the root cause. There is two EC Query methods _Q5E and _Q5F which are associated with lid open and close event. They will read lid's state from the \_SB.PCI0.LPC0.H_EC.LIDS and then store the value to the \LIDS. When _LID method is invoked, it return the value stored in the \LIDS. For no suspend on lid close case, this can work. Because both _Q5E and _Q5F will be called when lid open and close. But in the suspend on lid close case, the close event will be processed during system running and suspend machine. So the value of \LIDS is close at this point. But when open lid, bios will detect the open event and resume system. For the open lid event, system don't get it and _Q5F will not be invoked. So \LIDS value is still close. So this is DSDT table problem. If _LID method read status directly from EC, there would be no problem(Rui's custom method already prove this.) So the problem can't be fixed by code in linux. Only solution is to override DSDT talbe. I will attach a table that should fix your problem. But you need compile the kernel by youself.


                Device (H_EC)
                {
                    ...

                    Method (_Q5E, 0, NotSerialized)
                    {
                        Store (LIDS, \LIDS)
                        Notify (\_SB.LID0, 0x80)
                    }

                    Method (_Q5F, 0, NotSerialized)
                    {
                        Store (LIDS, \LIDS)
                        Notify (\_SB.LID0, 0x80)
                    }
                    ...
               }
               
               Device (LID0)
               {
                        Name (_HID, EisaId ("PNP0C0D"))
                        Method (_LID, 0, NotSerialized)
                        {
                            Return (LIDS)
                        }
               }
Comment 27 Lan Tianyu 2013-04-12 03:31:11 UTC
Created attachment 98321 [details]
DSDT.hex

Please follow the link to override the DSDT. I have attached the DSDT table and you just need do step 5-7. 
https://lesswatts.org/projects/acpi/overridingDSDT.php

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