Skip to content

Commit e07763b

Browse files
committed
systemd: Disable Intel RAPL PL4 on resume/boot
Fixes: linux-surface/linux-surface#706
1 parent a3852cd commit e07763b

File tree

6 files changed

+36
-0
lines changed

6 files changed

+36
-0
lines changed

pkg/bin/makebin

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,14 @@ package() {
6464
install -D -m644 "target/_surface" "$pkgdir/shell-completions/surface.zsh"
6565
install -D -m644 "target/surface.fish" "$pkgdir/shell-completions/surface.fish"
6666

67+
# copy service files
68+
install -D -m644 "systemd/surface-rapl.service" "$pkgdir/usr/lib/systemd/system/surface-rapl.service"
69+
install -D -m744 "systemd/surface-rapl.sh" "$pkgdir/usr/libexec/surface-rapl.sh"
70+
mkdir -p "$pkgdir/usr/lib/systemd/system/multi-user.target.wants"
71+
ln -sT "../surface-rapl.service" "$pkgdir/usr/lib/systemd/system/multi-user.target.wants/surface-rapl.service"
72+
mkdir -p "$pkgdir/usr/lib/systemd/system/suspend.target.wants"
73+
ln -sT "../surface-rapl.service" "$pkgdir/usr/lib/systemd/system/suspend.target.wants/surface-rapl.service"
74+
6775
# copy license
6876
install -D -m644 "LICENSE" "$pkgdir/LICENSE"
6977

pkg/deb/debian/rules

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,13 @@ override_dh_install:
2020
install -D -m644 "target/_surface" "${pkgdir}/usr/share/zsh/vendor-completions/_surface"
2121
install -D -m644 "target/surface.fish" "${pkgdir}/usr/share/fish/vendor_completions.d/surface.fish"
2222

23+
# service files
24+
install -D -m644 "systemd/surface-rapl.service" "${pkgdir}/usr/lib/systemd/system/surface-rapl.service"
25+
install -D -m744 "systemd/surface-rapl.sh" "${pkgdir}/usr/libexec/surface-rapl.sh"
26+
mkdir -p "${pkgdir}/usr/lib/systemd/system/multi-user.target.wants"
27+
ln -sT "../surface-rapl.service" "${pkgdir}/usr/lib/systemd/system/multi-user.target.wants/surface-rapl.service"
28+
mkdir -p "${pkgdir}/usr/lib/systemd/system/suspend.target.wants"
29+
ln -sT "../surface-rapl.service" "${pkgdir}/usr/lib/systemd/system/suspend.target.wants/surface-rapl.service"
30+
2331
%:
2432
dh $@
28.2 KB
Binary file not shown.

pkg/fedora/surface-control.spec

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ install -D -m755 "target/release/surface" "%{buildroot}/usr/bin/surface"
3131
install -D -m644 "target/surface.bash" "%{buildroot}/usr/share/bash-completion/completions/surface"
3232
install -D -m644 "target/_surface" "%{buildroot}/usr/share/zsh/site-functions/_surface"
3333
install -D -m644 "target/surface.fish" "%{buildroot}/usr/share/fish/vendor_completions.d/surface.fish"
34+
install -D -m644 "systemd/surface-rapl.service" "%{buildroot}/usr/lib/systemd/system/surface-rapl.service"
35+
install -D -m744 "systemd/surface-rapl.sh" "%{buildroot}/usr/libexec/surface-rapl.sh"
36+
mkdir -p "%{buildroot}/usr/lib/systemd/system/multi-user.target.wants"
37+
ln -sT "../surface-rapl.service" "%{buildroot}/usr/lib/systemd/system/multi-user.target.wants/surface-rapl.service"
38+
mkdir -p "%{buildroot}/usr/lib/systemd/system/suspend.target.wants"
39+
ln -sT "../surface-rapl.service" "%{buildroot}/usr/lib/systemd/system/suspend.target.wants/surface-rapl.service"
3440

3541
%files
3642
/usr/bin/surface

systemd/surface-rapl.service

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[Unit]
2+
Description=Undoes firmware throttling processor after low-battery boot/resume
3+
After=suspend.target
4+
5+
[Service]
6+
Type=oneshot
7+
ExecStart=/usr/libexec/surface-rapl.sh
8+
9+
[Install]
10+
WantedBy=multi-user.target
11+
WantedBy=suspend.target

systemd/surface-rapl.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/sh
2+
target=/sys/devices/virtual/powercap/intel-rapl/intel-rapl:0/constraint_2_power_limit_uw
3+
[ -f "$target" ] && echo 0 > "$target" || :

0 commit comments

Comments
 (0)