Bug 106571 - Surface 3 Lid Switch Method parse/execution failed
Summary: Surface 3 Lid Switch Method parse/execution failed
Status: CLOSED CODE_FIX
Alias: None
Product: ACPI
Classification: Unclassified
Component: Config-Tables (show other bugs)
Hardware: x86-64 Linux
: P1 normal
Assignee: acpi_config-tables
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-10-24 19:51 UTC by Stephen Just
Modified: 2016-02-01 20:59 UTC (History)
4 users (show)

See Also:
Kernel Version: 4.3.0-rc6+acpi/bleeding-edge 6368074ac
Tree: Mainline
Regression: No


Attachments
dmesg until failure (227.44 KB, text/plain)
2015-10-24 19:51 UTC, Stephen Just
Details
acpidump (328.82 KB, application/octet-stream)
2015-10-24 19:53 UTC, Stephen Just
Details
Allow reuse of the event GPIO (887 bytes, patch)
2015-10-29 10:27 UTC, Mika Westerberg
Details | Diff

Description Stephen Just 2015-10-24 19:51:57 UTC
Created attachment 191021 [details]
dmesg until failure

On the Microsoft Surface 3, when you fold the type cover over the screen (or "close the lid"), the lid switch state does not change, and an ACPI error is thrown. The lid switch state always reports closed.

[root@localhost ~]# cat /proc/acpi/button/lid/LID/state 
state:      closed

[ 1130.459896] ACPI Exception: AE_ERROR, Returned by Handler for [GeneralPurposeIo] (20150930/evregion-297)
[ 1130.460061] ACPI Error: Method parse/execution failed [\_SB.GPO0._E4C] (Node ffff88013f4b4438), AE_ERROR (20150930/psparse-542)

From the DSDT, this is the GPIO event handler that toggles the lid switch state.
Comment 1 Stephen Just 2015-10-24 19:53:49 UTC
Created attachment 191031 [details]
acpidump
Comment 2 Aaron Lu 2015-10-27 06:25:50 UTC
[ 1130.459896] ACPI Exception: AE_ERROR, Returned by Handler for [GeneralPurposeIo] (20150930/evregion-297)
[ 1130.460061] ACPI Error: Method parse/execution failed [\_SB.GPO0._E4C] (Node ffff88013f4b4438), AE_ERROR (20150930/psparse-542)

            OperationRegion (GPOR, GeneralPurposeIo, Zero, One)
            Field (GPOR, ByteAcc, NoLock, Preserve)
            {
                Connection (
                    GpioIo (Shared, PullNone, 0x0000, 0x0000, IoRestrictionNone,
                        "\\_SB.GPO0", 0x00, ResourceConsumer, ,
                        )
                        {   // Pin list
                            0x004C
                        }
                ),
                HELD,   1
            }

            Method (_E4C, 0, Serialized)  // _Exx: Edge-Triggered GPE
            {
                If ((HELD == One))
                {
                    ^^LID.LIDB = One
                }
                Else
                {
                    ^^LID.LIDB = Zero
                    Notify (LID, 0x80) // Status Change
                }
                Notify (^^PCI0.SPI1.NTRG, One) // Device Check
            }

From the ASL code and the error message, it seems the GPIO handler to get the value of HELD failed. Mika, do you have any ideas?
Comment 3 Aaron Lu 2015-10-27 06:26:48 UTC
Hit the save button too quick, forgot to add Mika.

Mika,
Please take a look at comment #2, thanks.
Comment 4 Mika Westerberg 2015-10-29 09:40:45 UTC
Looks like both the _AEI returned event and OpRegion access use the same GPIO (0x4c). This is not supported yet.
Comment 5 Mika Westerberg 2015-10-29 10:27:57 UTC
Created attachment 191461 [details]
Allow reuse of the event GPIO
Comment 6 Mika Westerberg 2015-10-29 10:28:20 UTC
Stephen, can you try the attached patch?
Comment 7 Stephen Just 2015-10-29 14:46:48 UTC
The attached patch correctly allows the state of the lid switch to change by opening and closing the "lid". Thanks!

...now if only it didn't default to closed :)
(http://thread.gmane.org/gmane.linux.acpi.devel/77428)
Comment 8 Mika Westerberg 2015-10-30 10:02:54 UTC
Thanks for testing. I just sent that patch out.
Comment 9 Aaron Lu 2015-11-09 03:10:47 UTC
commit c103a10f690cc49054c52f493eeeff143d5f59e7
Author: Mika Westerberg <mika.westerberg@linux.intel.com>
Date:   Fri Oct 30 12:02:05 2015 +0200

    gpio / ACPI: Allow shared GPIO event to be read via operation region

for v4.4-rc1.
Comment 10 Bastien Nocera 2016-02-01 20:39:02 UTC
(In reply to Stephen Just from comment #7)
> The attached patch correctly allows the state of the lid switch to change by
> opening and closing the "lid". Thanks!
> 
> ...now if only it didn't default to closed :)

attachment 187171 [details] contains a full decompiled DSDT. Did you file a new bug about the initial state being wrong? Looking at GPO0 there, it seems that an edge-triggered event would make the NTRG device reprobe, and disable the touchscreen if the lid was closed.

> (http://thread.gmane.org/gmane.linux.acpi.devel/77428)

Is it possible that Microsoft stopped using the LID device on some machines (tablets with removable keyboards), checking for the availability of the touchscreen instead?

Stephen, did you file a new bug about this?
Comment 11 Bastien Nocera 2016-02-01 20:59:49 UTC
See also bug 89211 which contains a patch.

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