Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the automatically wake up on surface pro6 #525

Closed
yjzzjy4 opened this issue Jun 17, 2019 · 2 comments
Closed

Fix the automatically wake up on surface pro6 #525

yjzzjy4 opened this issue Jun 17, 2019 · 2 comments

Comments

@yjzzjy4
Copy link

yjzzjy4 commented Jun 17, 2019

After using the kernel, everything works like a charm on my surface pro6 except the hibernate or suspend, my device wakes up automatically for no reason. But after some googling(thanks to #396), I may have found the key to solve the issue. It turns out to be the problem of the keyboard, which is seen as a XHC device(I don't know what XHC device is, but it is exactly what caused the problem). Due to the particularity of the 2 in 1 device, it makes the kernel to misunderstand the structure of your device, something like this:

The kernel regards surface pro6 tablet as a PC with monitor,

then the keyboard is a XHC type of keyboard.

That means the kernel is not regarding your surface as a laptop-like device,

instead it's regarded as a PC with some kind of XHC keyboard.

And as long as they're connected, your device will automatically wake up from hibernate or suspend.

Why?

Because your system allows the XHC devices to do it,so...

Let's see what can wake your device up. Run the following command:

cat /proc/acpi/wakeup

Here's what I got from my surface pro6:

Device	S-state	  Status   Sysfs node
GLAN	  S4	*disabled
XHC	  S4	*enabled   pci:0000:00:14.0
XDCI	  S4	*disabled
HDAS	  S4	*disabled  pci:0000:00:1f.3
RP01	  S4	*disabled
PXSX	  S4	*disabled
RP02	  S4	*disabled
PXSX	  S4	*disabled
RP03	  S4	*disabled
PXSX	  S4	*disabled
RP04	  S4	*enabled   pci:0000:00:1c.0
PXSX	  S4	*disabled  pci:0000:01:00.0
RP05	  S4	*disabled
PXSX	  S4	*disabled
RP06	  S4	*disabled
PXSX	  S4	*disabled
RP07	  S4	*disabled
PXSX	  S4	*disabled
RP08	  S4	*disabled
PXSX	  S4	*disabled
RP09	  S4	*enabled   pci:0000:00:1d.0
PXSX	  S4	*disabled  pci:0000:02:00.0
RP10	  S4	*disabled
PXSX	  S4	*disabled
RP11	  S4	*disabled
PXSX	  S4	*disabled
RP12	  S4	*disabled
PXSX	  S4	*disabled
RP13	  S4	*disabled
PXSX	  S4	*disabled
RP14	  S4	*disabled
PXSX	  S4	*disabled
RP15	  S4	*disabled
PXSX	  S4	*disabled
RP16	  S4	*disabled
PXSX	  S4	*disabled
RP17	  S4	*disabled
PXSX	  S4	*disabled
RP18	  S4	*disabled
PXSX	  S4	*disabled
RP19	  S4	*disabled
PXSX	  S4	*disabled
RP20	  S4	*disabled
PXSX	  S4	*disabled
RP21	  S4	*disabled
PXSX	  S4	*disabled
RP22	  S4	*disabled
PXSX	  S4	*disabled
RP23	  S4	*disabled
PXSX	  S4	*disabled
RP24	  S4	*disabled
PXSX	  S4	*disabled

In the line 3,there is something like this, and that's what we gonna disable:

XHC	  S4	*enabled   pci:0000:00:14.0

To disable it permanently, We shall edit the /etc/rc.local file, create it if not exits:

sudoedit /etc/rc.local

Write something down like the followings:

#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution bits.
#
# By default this script does nothing.

# Disable the XHC device in wakeup list.
echo XHC | tee /proc/acpi/wakeup

exit 0

And set it's permissions to 775:

sudo chmod 775 /etc/rc.local

Then we create a custom service named rc-local:

sudo vim /etc/systemd/system/rc-local.service

Here's it's content:

[Unit]
Description=/etc/rc.local
ConditionPathExists=/etc/rc.local

[Service]
Type=forking
ExecStart=/etc/rc.local start
TimeoutSec=0
StandardOutput=tty
RemainAfterExit=yes
SysVStartPriority=99

[Install]
WantedBy=multi-user.target

Then we enable the service, so that it can start on boot:

sudo systemctl enable rc-local.service

We should then reboot to test the service:

reboot

After reboot we can check the status of our service:

systemctl status rc-local.service

And it is active! Which means it's working:

● rc-local.service - /etc/rc.local
   Loaded: loaded (/etc/systemd/system/rc-local.service; enabled; vendor preset
  Drop-In: /usr/lib/systemd/system/rc-local.service.d
           └─debian.conf
   Active: active (exited) since Mon 2019-06-17 19:34:23 CST; 2min 27s ago
  Process: 985 ExecStart=/etc/rc.local start (code=exited, status=0/SUCCESS)

6月 17 19:34:23 yjzzjy4-Surface-Pro-6 systemd[1]: Starting /etc/rc.local...
6月 17 19:34:23 yjzzjy4-Surface-Pro-6 rc.local[985]: XHC
6月 17 19:34:23 yjzzjy4-Surface-Pro-6 systemd[1]: Started /etc/rc.local.

Then we re-check the /proc/acpi/wakeup file to see the output:

cat /proc/acpi/wakeup

It's clear that the XHC device has been disabled:

Device	S-state	  Status   Sysfs node
GLAN	  S4	*disabled
XHC	  S4	*disabled  pci:0000:00:14.0
XDCI	  S4	*disabled
HDAS	  S4	*disabled  pci:0000:00:1f.3
RP01	  S4	*disabled
PXSX	  S4	*disabled
RP02	  S4	*disabled
PXSX	  S4	*disabled
RP03	  S4	*disabled
PXSX	  S4	*disabled
RP04	  S4	*enabled   pci:0000:00:1c.0
PXSX	  S4	*disabled  pci:0000:01:00.0
RP05	  S4	*disabled
PXSX	  S4	*disabled
RP06	  S4	*disabled
PXSX	  S4	*disabled
RP07	  S4	*disabled
PXSX	  S4	*disabled
RP08	  S4	*disabled
PXSX	  S4	*disabled
RP09	  S4	*enabled   pci:0000:00:1d.0
PXSX	  S4	*disabled  pci:0000:02:00.0
RP10	  S4	*disabled
PXSX	  S4	*disabled
RP11	  S4	*disabled
PXSX	  S4	*disabled
RP12	  S4	*disabled
PXSX	  S4	*disabled
RP13	  S4	*disabled
PXSX	  S4	*disabled
RP14	  S4	*disabled
PXSX	  S4	*disabled
RP15	  S4	*disabled
PXSX	  S4	*disabled
RP16	  S4	*disabled
PXSX	  S4	*disabled
RP17	  S4	*disabled
PXSX	  S4	*disabled
RP18	  S4	*disabled
PXSX	  S4	*disabled
RP19	  S4	*disabled
PXSX	  S4	*disabled
RP20	  S4	*disabled
PXSX	  S4	*disabled
RP21	  S4	*disabled
PXSX	  S4	*disabled
RP22	  S4	*disabled
PXSX	  S4	*disabled
RP23	  S4	*disabled
PXSX	  S4	*disabled
RP24	  S4	*disabled
PXSX	  S4	*disabled

Then we can test the suspend or hibernate, through any of the command:

systemctl suspend
systemctl hibernate

Theoretically, we can see that when suspend or hibernate, we're unable to wake up our device by any click through the keyboard, nor can the lid wakes our device up when suspend(as mentioned, the kernel doesn't regard our device as laptop, so there is no lid anyway). The only way you can wake your device up is through a single press of the power button.

And some may encounter the situation that after wake up(I did), our wifi and bluetooth are both out of function, we can solve it by simple running:

sudo systemctl restart 'NetworkManager*'

The solution above is tested on my surface por6, it may be a solution for all 2 in 1 devices.

Hoping it can help you guys!

@yjzzjy4
Copy link
Author

yjzzjy4 commented Jun 17, 2019

BTW, if you want hibernate to work properly, you need to set the swap file or swap partition big enough to handle this task(double size of your physical RAM is usually recommanded), and follow the instruction in the README.md file of this project to config your /etc/default/grub file, which is this.

@yjzzjy4
Copy link
Author

yjzzjy4 commented Jun 18, 2019

For the wifi and bluetooth problems, we can simply add

systemctl restart NetworkManager

to the /etc/rc.local file, so the file will be something like this:

#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution bits.
#
# By default this script does nothing.

# Disable the XHC device in the wakeup list.
echo XHC | tee /proc/acpi/wakeup

# Restart the NetworkManager service after each suspend or hibernate.
systemctl restart 'NetworkManager*'

exit 0

PS: Don't use the Gnome way to suspend your system, it might cause some problem due to delay(that's Gnome's fault).

the Gnome way means at the menu(when you click the right top of your top panel, it shows up) where you press Alt, so that the power icon becomes a suspend icon(see the picture below), don't use this way to suspend plz.

You can suspend your surface by using the

systemctl suspend

command, and if you want to hibernate, just through the

systemctl hibernate

command, or replace syspend with hibernate, but that's another story.

Whatever ways you choose, you can easily wake up your device by a single press of your power button, remember the keyboard can no longer wakes it up.

@yjzzjy4 yjzzjy4 closed this as completed Aug 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant