Bug 15168 - ACPI Lid state is incorrect - Toshiba Satellite A205-S4607
Summary: ACPI Lid state is incorrect - Toshiba Satellite A205-S4607
Status: CLOSED UNREPRODUCIBLE
Alias: None
Product: ACPI
Classification: Unclassified
Component: BIOS (show other bugs)
Hardware: All Linux
: P1 normal
Assignee: acpi_bios
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-01-29 01:16 UTC by Robin
Modified: 2012-06-05 04:04 UTC (History)
2 users (show)

See Also:
Kernel Version: 2.6.26-2-686 (Debian 5.0)
Subsystem:
Regression: No
Bisected commit-id:


Attachments
acpidump output from the laptop (133.32 KB, text/plain)
2010-01-29 01:16 UTC, Robin
Details
custom _LID method (90 bytes, application/octet-stream)
2010-01-29 01:43 UTC, Zhang Rui
Details
_LID method with debug info (118 bytes, application/octet-stream)
2010-02-26 01:53 UTC, Zhang Rui
Details
_Q10 method with debug info (183 bytes, application/octet-stream)
2010-02-26 01:54 UTC, Zhang Rui
Details
_Q14 method with debug info (203 bytes, application/octet-stream)
2010-02-26 01:54 UTC, Zhang Rui
Details
dmesg output (36.56 KB, text/plain)
2011-02-19 00:59 UTC, Robin
Details

Description Robin 2010-01-29 01:16:37 UTC
Created attachment 24774 [details]
acpidump output from the laptop

**I apologize in advance if I selected the wrong component.  This is as close I could get to my issue.**

The lid/suspend event works on my Toshiba Satellite A205-S4607 50% of
the time.  I think it is possible it is an ACPI driver clitch.

After doing a little research I found out that the current lid state
is stored at:
/proc/acpi/button/lid/*/state.

So I ran some simple tests:

1)  After a fresh boot:
cat /proc/acpi/button/lid/*/state gives me:
State: open

2) Close (successful suspend) and Reopen the lid:
cat /proc/acpi/button/lid/*/state gives me:
State: closed

3) Close the lid (failure to suspend the laptop) and reopen
cat /proc/acpi/button/lid/*/state gives me:
State: open

4) Close (successful suspend) and Reopen the lid:
cat /proc/acpi/button/lid/*/state gives me:
State: closed

I repeated this several times to make sure the pattern is consistent.
Comment 1 Robin 2010-01-29 01:22:52 UTC
I made a mistake with the kernel version.
Comment 2 Zhang Rui 2010-01-29 01:43:40 UTC
Created attachment 24779 [details]
custom _LID method

please try the custom _LID method attached.
Note that the test must be done in 2.6.33-rc kernel.
Please read Documentation/acpi/method-customizing.txt to see how to override an ACPI control method.
Comment 3 Zhang Rui 2010-01-29 01:44:33 UTC
it would be good if you can cat the content of /proc/acpi/button/lid/*/state when the lid is closed.
Comment 4 Robin 2010-01-29 02:37:16 UTC
Any suggestion on how to get this information for you?  Especially if the laptop is suspended.
Comment 5 Zhang Rui 2010-01-29 02:56:39 UTC
please run "lsof /proc/acpi/event" as root user and kill the process that opens this file. The laptop should not go to suspend when you close the lid. so you can get the lid state using something like remote login/external keyboard, etc.

BTW, I think you should do the test in comment #2 first to see if the problem still exists.
Comment 6 Len Brown 2010-02-02 02:41:14 UTC
Since Rui suspects an AML bug, it would be great if you can investigate
how the LID works with Windows to make sure the bug is common
to all operating systems.
Comment 7 Robin 2010-02-02 11:35:59 UTC
Alright, after spending 4 days fixing issues with Debian and re-configure/re-building I got 2.6.33-rc5 compiled and running on my laptop. 

I did the following from as per Documentation/acpi/method-customizing.txt:
1) mount -t debugfs none /sys/kernel/debug
2) cat asl.aml > /sys/kernel/debug/acpi/custom_method


I than ran the same test pattern I initially performed with the following results:

1)  After a fresh boot AND loading the AML custom method:
cat /proc/acpi/button/lid/*/state gives me:
State: open

2) Close (successful suspend) and Reopen the lid:
cat /proc/acpi/button/lid/*/state gives me:
State: open

3) Close the lid (successful suspend) and Reopen the lid
cat /proc/acpi/button/lid/*/state gives me:
State: open

4) Close (successful suspend) and Reopen the lid:
cat /proc/acpi/button/lid/*/state gives me:
State: open

I know it is working at this point, so my first question is:  was this related to the new kernel driver OR was it the AML that I loaded?  If so, will this AML have to be loaded every time OR is there a way to "unload" it and test again. (I should have done this first, but I was too anxious to try this out)

Robin
Comment 8 Robin 2010-02-02 11:38:41 UTC
(In reply to comment #6)
> Since Rui suspects an AML bug, it would be great if you can investigate
> how the LID works with Windows to make sure the bug is common
> to all operating systems.

That is an odd request, could you elaborate.  Under Windows XP (my laptop dual-boots) the suspend function works perfectly.  Although, at the same time after a month or two without a full restarts it eventually fails to come out of the suspend state properly.

Robin
Comment 9 Robin 2010-02-06 13:27:21 UTC
When should I expect this fix to be integrated?  I can currently loading the aml script on-boot so the lid open/close functionality works correctly.

Thanks!
Comment 10 Zhang Rui 2010-02-25 03:17:47 UTC
well, I think this is a AML code bug and my fix works for you.
But windows works well on this laptop, which means Linux should work as well, without any firmware code changes.
Here is the original _LID method,
            Method (_LID, 0, NotSerialized)
            {
                If (LDWK)
                {
                    Store (Zero, LDWK)
                    Return (One)
                }
                Else
                {
                    Return (LIDF)
                }
            }
So the LID state should be stored in LIDF.
comment #0 shows that LDWK is 0 every other time, when the Lid is opened.
                    Method (_Q10, 0, NotSerialized)
                    {
                        Store (LIDS, Local0)
                        If (LEqual (Local0, One))
                        {
                            Store (Zero, LIDF)
                        }
                        Else
                        {
                            Store (One, LIDF)
                        }

                        If (LDWK)
                        {
                            Store (0x10, PO80)
                            Store (One, LIDF)
                            Store (Zero, LDWK)
                        }

                        Notify (LID, 0x80)
                    }


So I change it to:
    Method (\_SB.LID._LID, 0, NotSerialized)
    {
        Store (\_SB.PCI0.LPCB.EC0.LIDS, Local0)
        If (LEqual (Local0, One))
        {
            Return (Zero)
        }
        Else
        {
            Return (One)
        }
    }
because IMO, \_SB.PCI0.LPCB.EC0.LIDS should always report the correct Lid state.

But the problem is that this doesn't seems like an AML issue because windows works well on this machine.
Comment 11 Robin 2010-02-25 21:39:38 UTC
Is there a long term solution?
Comment 12 Zhang Rui 2010-02-26 01:52:42 UTC
well, in order to make clear how the AML code works in Linux, please
1. rebuild your kernel with CONFIG_ACPI_DEBUG set
2. reboot with boot option acpi.debug_layer=0x80 acpi.debug_level=0x02.
3. apply the three custom ACPI methods I attached below, and then attach the dmesg output after the same test in comment #7.
Comment 13 Zhang Rui 2010-02-26 01:53:54 UTC
Created attachment 25230 [details]
_LID method with debug info
Comment 14 Zhang Rui 2010-02-26 01:54:22 UTC
Created attachment 25231 [details]
_Q10 method with debug info
Comment 15 Zhang Rui 2010-02-26 01:54:53 UTC
Created attachment 25232 [details]
_Q14 method with debug info
Comment 16 Zhang Rui 2010-02-26 01:56:05 UTC
Note that please follow the documentation to load the three custom methods one by one.
Comment 17 Zhang Rui 2010-03-02 08:24:11 UTC
ping ....
Comment 18 Robin 2011-02-18 23:55:17 UTC
I apologize for the delay.

After setting the requested boot options from comment #12 than rebooting and loading the custom methods in the order they are attached I get the following results:

1)  After a fresh boot AND loading the AML custom method:
cat /proc/acpi/button/lid/*/state gives me:
State: open

2) Close (successful suspend) and Reopen the lid:
cat /proc/acpi/button/lid/*/state gives me:
State: closed

I will attach my the complete output of dmesg.
Comment 19 Robin 2011-02-19 00:59:53 UTC
Created attachment 48372 [details]
dmesg output

This is the output requested from dmesg after repeating the relevant tests (previous comment) with the listed custom methods applied.
Comment 20 Robin 2011-02-19 01:01:32 UTC
Please let me know if you need more testing done or need more details.

Thanks
Comment 21 Zhang Rui 2012-01-18 01:57:34 UTC
It's great that kernel bugzilla is back.

can you please verify if the problem still exists in the latest upstream
kernel?
Comment 22 Robin 2012-01-18 08:52:52 UTC
Unfortunately this laptop has died on me so I have no way to test this.  Thanks for your effort!

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