Code Monkey home page Code Monkey logo

surface-gpe's Introduction

Linux kernel driver for GPE/Lid of Microsoft Surface Devices

Surface GPE/Lid driver to enable wakeup from suspend via the lid.

Conventionally, wake-up events for a specific device, e.g. the lid device, are managed via the ACPI _PRW field. While this does not seem strictly necessary based on ACPI spec, since commit 941d3e41da7f86bdb9dcc1977c2bcc6b89bfe47 (ACPI: EC / PM: Disable non-wakeup GPEs for suspend-to-idle) the kernel disables GPE wakeups to avoid non-wakeup interrupts preventing suspend by default and only enables GPEs associated via the _PRW field with a wake-up capable device.

As there is no _PRW field on the lid device of MS Surface devices, we have to enable those GPEs ourselves as a workaround.

Testing and Installing

Note: You normally do not need to manually install these module if you are already using a kernel from https://github.com/linux-surface/linux-surface.

Build/Test the module

You can build the module by running make inside the module/ directory. After that, you can load the module by running insmod surface_gpe.ko and remove it by running rmmod surface_gpe.

Permanently install the module

If you want to permanently install the module (or ensure it is loaded during boot), you can run make dkms-install. To uninstall it, run make dkms-uninstall. In case you've installed a patched kernel already contiaining the in-kernel version of this module, dkms should detect this and override the in-kernel module with the externally built one. This should get reverted by uninstalling the module via the command above.

surface-gpe's People

Contributors

pcsabi avatar qzed avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Forkers

pcsabi

surface-gpe's Issues

Surface Pro 9 Business: Suspend/wake up with lid does not work properly

Hi,

I'm using a Surface Pro 9 Business with freshly installed Arch Linux and the linux-surface Kernel set up according to the instructions. So far everything works perfectly, except for the problem that the device only goes into suspend mode once after a reboot when I close the lid. It never wakes up from suspend mode when I open the lid. After it goes into suspend mode once by closing the lid, it doesn't work again.

I also tried messing around with the logind.conf under /etc/systemd/logind.conf by commenting out

HandleLidSwitch=suspend
HandleLidSwitchExternalPower=suspend

which had no effect.

When I investigated the dmesg output, I found the following problem, which led me here:

[    3.868851] surface_gpe: no compatible Microsoft Surface device found, exiting
[    3.990270] surface_serial_hub serial0-0: SAM firmware version: 6.101.139
[   24.600041] surface_serial_hub serial0-0: event: unhandled event (rqid: 0x02, tc: 0x02, tid: 0x01, cid: 0x1a, iid: 0x01)
[   27.542263] surface_serial_hub serial0-0: event: unhandled event (rqid: 0x02, tc: 0x02, tid: 0x01, cid: 0x1a, iid: 0x01)
[  102.812272] surface_serial_hub serial0-0: rx: parser: invalid start of frame, skipping

Then i looked in the surface_gpe.c file and found one entry for the normal Surface Pro 9 which searches for the following SKU number:
DMI_EXACT_MATCH(DMI_PRODUCT_SKU, "Surface_Pro_9_2038")

My sudo dmidecode -t system output is:

# dmidecode 3.5
Getting SMBIOS data from sysfs.
SMBIOS 3.3.0 present.

Handle 0x000A, DMI type 1, 27 bytes
System Information
	Manufacturer: Microsoft Corporation
	Product Name: Surface Pro 9
	Version: 124I:00093T:000M:0000000D:0B:11F:1C:04P:01Y:1U:00
	Serial Number: xxxxxxxxxxx
	UUID: ef3657c2-ef21-a3b9-a1a6-467f93525e80
	Wake-up Type: Power Switch
	SKU Number: Surface_Pro_9_for_Business_2038
	Family: Surface

Does the problem occur because of a missing entry for the Business model of the Surface Pro 9 in surface_gpe.c?

Expected behaviour
Surface goes to suspend and wakes up from suspend when closing/opening the lid.

System information
Machine: Microsoft Surface Pro 9 Business
Kernel: 6.6.6-arch1-1-surface
OS: Arch Linux

Surface Pro 5 wakes up on lid closing (but not opening)

Issue
Whenever I turn my Surface into suspend mode, it will wake up on lid (aka Typecover) closing, but not on lid opening.

This way unfortunately I can never put my Surface into Suspend and then close the lid. Therefore currently, I am running Suspend with a 5 seconds delay, so the lid can be closed before Suspend is executed. When the lid is closed before Suspend is initiated, the Surface remains in Suspend afterwards.

However, the Suspend mode is not interrupted on lid opening either, even though the Typecover (aka lid) starts illuminating the keys after a few seconds delay. No key will wake the device, only the Power Button will do this.

My current workaround is to deactivate the Surface GPE: "sudo modprobe -r surface_gpe" ... after which I can close and open the lid without affecting the Suspend mode of device.

Expected behaviour
Surface does not wakeup at all on closing the lid/Typecover.

System information
Machine: Surface Pro 5 (2017)
Kernel: 5.19.13-surface
OS: Ubuntu / LXQt / 20.04

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.