Skip to content

Commit

Permalink
Add acpi wakeup
Browse files Browse the repository at this point in the history
  • Loading branch information
jouyouyun committed May 29, 2019
1 parent d5246a1 commit 59c103d
Show file tree
Hide file tree
Showing 11 changed files with 58 additions and 0 deletions.
39 changes: 39 additions & 0 deletions acpi-wakeup/README.org
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#+OPTIONS: toc:nil timestamp:nil
#+TITLE: 华为笔记本休眠失败修复方法

** 现象

华为笔记本在休眠后会被自动唤醒,查看日志并没有发现错误信息,于是猜测是某些设备产生的 =wakeup= 事件唤醒的。
便查看 =/proc/acpi/wakeup= 文件,发现只有 =XHC= 设备是 =enabled= 。
遂将其关闭(=echo XHC >> /proc/acpi/wakeup=), 然后测试休眠,则工作正常。

#+BEGIN_QUOTE
通过 =XHC= 的 =sysfs node= (=lspci -s <pci node>= 发现其是一个 =USB= 控制器,
在 =/sys/bus/pci/devices/<pci node>= 中发现其下有两个 =USB= 设备,通过设备下的 =uevent= 文件(里面的 =PRODUCT= 字段)和 =lsusb= 命令可查到此设备的名称。
#+END_QUOTE

** 处理方法

为了使上面的关闭方法持久化,这里决定使用 =systemd service= 来实现,并在加载 =multi-user.target= 时执行。

文件(=huawei_suspend_workaround.service=)如下:

#+BEGIN_SRC shell
[Unit]
Description=Huawei Suspend Workaround

[Service]
Type=oneshot
ExecStart=/bin/sh -c "echo XHC >> /proc/acpi/wakeup"

[Install]
WantedBy=multi-user.target
#+END_SRC

执行以下命令安装并启用:

#+BEGIN_SRC shell
sudo cp huawei_suspend_workaround.service /lib/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable huawei_suspend_workaround.service
#+END_SRC
10 changes: 10 additions & 0 deletions acpi-wakeup/acpi_wakeup_workaround.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

ENTRIES=`cat /proc/acpi/wakeup|grep enabled|awk '{print $1}'|xargs`
for i in ${ENTRIES}; do
echo "Entry: $i"
if [ $i != "PBTN" ]; then
echo "echo $i|tee /proc/acpi/wakeup"
echo $i|tee /proc/acpi/wakeup
fi
done
9 changes: 9 additions & 0 deletions acpi-wakeup/huawei_suspend_workaround.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[Unit]
Description=Huawei Suspend Workaround

[Service]
Type=oneshot
ExecStart=/bin/sh -c "echo XHC >> /proc/acpi/wakeup"

[Install]
WantedBy=multi-user.target
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 59c103d

Please sign in to comment.