diff --git a/tlp-mitigate-slowshutdown.patch b/tlp-mitigate-slowshutdown.patch new file mode 100644 index 0000000..6ac490d --- /dev/null +++ b/tlp-mitigate-slowshutdown.patch @@ -0,0 +1,100 @@ +commit dabd0e900f6e10c358436c584c51dd1f55c320d2 +Author: Thomas Koch +Date: Sun Mar 12 20:53:32 2017 +0100 + + Issue #242: mitigate slow shutdown + + Rationale: 'systemctl stop tlp' invokes 'nmcli radio on ' in systemd + context. This causes nmcli to hang for ~20 sec after switching the device. + The cause is unknown – when invoking nmcli directly it doesn't hang. + + Workaround: + * Execute radio switching last in 'tlp init [start|stop]' + * Add TimeoutStopSec=3 to tlp.service so systemd will kill the hanging + stop task after 3 secs. + + Caveat: does not cover all cases yet. When two radios (e.g. wifi and + wwan) are to be switched, the second switch never happens. + +diff --git a/tlp.in b/tlp.in +index bc2f852..fd0486c 100644 +--- a/tlp.in ++++ b/tlp.in +@@ -96,23 +96,21 @@ case "$mode" in + # do init business ... + case $mode2 in + start) +- # apply radio states +- set_radio_device_states start +- +- # apply power save settings -- but only if not previously run +- # (by the udev rule) for the same power state +- if compare_and_save_power_state $pwrmode; then +- echo -n "Applying power save settings..." +- apply_common_settings $pwrmode +- [ "$pwrmode" = "1" ] && poweroff_drivebay 0 +- [ "$X_TLP_USB_MODE" = "1" ] && set_usb_suspend 0 auto +- echo "done." +- fi ++ # apply power save settings ++ compare_and_save_power_state $pwrmode ++ echo -n "Applying power save settings..." ++ apply_common_settings $pwrmode ++ poweroff_drivebay $pwrmode 0 ++ [ "$X_TLP_USB_MODE" = "1" ] && set_usb_suspend 0 auto ++ echo "done." + + # apply battery settings + echo -n "Setting battery charge thresholds..." + set_charge_thresholds + echo "done." ++ ++ # apply radio states ++ set_radio_device_states start + ;; + + restart|force-reload) +@@ -131,14 +129,6 @@ case "$mode" in + ;; + + stop) +- set_radio_device_states stop +- +- if [ "$USB_AUTOSUSPEND_DISABLE_ON_SHUTDOWN" = "1" ]; then +- echo -n "Disabling usb autosuspend..." +- set_usb_suspend 0 on +- echo "done." +- fi +- + # remove usb startup flag + [ -f $USB_DONE ] && rm $USB_DONE + +@@ -149,6 +139,16 @@ case "$mode" in + echo -n "Applying power save settings..." + apply_common_settings 0 + echo "done." ++ ++ # disable usb autosuspend if configured ++ if [ "$USB_AUTOSUSPEND_DISABLE_ON_SHUTDOWN" = "1" ]; then ++ echo -n "Disabling usb autosuspend..." ++ set_usb_suspend 0 on ++ echo "done." ++ fi ++ ++ # apply radio states ++ set_radio_device_states stop + ;; + + *) +diff --git a/tlp.service.in b/tlp.service.in +index 7dc4b2c..67c131c 100644 +--- a/tlp.service.in ++++ b/tlp.service.in +@@ -15,6 +15,7 @@ Type=oneshot + RemainAfterExit=yes + ExecStart=@TLP_SBIN@/tlp init start + ExecStop=@TLP_SBIN@/tlp init stop ++TimeoutStopSec=3 + + [Install] + WantedBy=multi-user.target diff --git a/tlp-stat-fix.patch b/tlp-stat-fix.patch new file mode 100644 index 0000000..3c49a9e --- /dev/null +++ b/tlp-stat-fix.patch @@ -0,0 +1,83 @@ +commit 9498a85d1cedb78a38b54f243c9c4a3daad5bcc6 +Author: Thomas Koch +Date: Tue Feb 28 20:33:44 2017 +0100 + + tlp-stat: intercept non-existing or invalid charge values + + Reference: + * Issue #256: https://github.com/linrunner/TLP/issues/256 + +diff --git a/tlp-stat.in b/tlp-stat.in +index ca08527..8aeb6a6 100644 +--- a/tlp-stat.in ++++ b/tlp-stat.in +@@ -58,6 +58,15 @@ no_runtimepm=0 + + # --- Functions + ++catparm () { # echo contents of sysfile or default if non-existent or unreadable ++ # $1: sysfile, $2: default value ++ local val="$(cat $1 2> /dev/null)" ++ [ -n "$val" ] || val="$2" # sysfile nonexistent or read failed ++ ++ printf "%s" $val ++ return 0 ++} ++ + printparm () { # formatted output of sysfile - general + # $1: format, $2: sysfile, $3: namsg, $4: cutoff + local format="$1" +@@ -257,7 +266,7 @@ check_ata_errors () { # check kernel log for ata errors + # count matching error lines + echo $( dmesg | egrep -c "${RE_ATA_ERROR}" 2> /dev/null ) + else +- # no values in question configured ++ # no values in question configured + echo "0" + fi + +@@ -1115,9 +1124,9 @@ if [ "$show_bat" = "1" ] || [ "$show_all" = "1" ]; then + echo + + # store values for charge / capacity calculation below +- ed=$(cat $batd/design_capacity) +- ef=$(cat $batd/last_full_capacity) +- en=$(cat $batd/remaining_capacity) ++ ed=$(catparm $batd/design_capacity 0) ++ ef=$(catparm $batd/last_full_capacity 0) ++ en=$(catparm $batd/remaining_capacity 0) + + # show charge + capacity + lcnt=0 +@@ -1184,9 +1193,9 @@ if [ "$show_bat" = "1" ] || [ "$show_all" = "1" ]; then + printparm "%-59s = ##%6d## [mW]" $batd/power_now "" 000 + + # store values for charge / capacity calculation below +- ed=$(cat $batd/energy_full_design) +- ef=$(cat $batd/energy_full) +- en=$(cat $batd/energy_now) ++ ed=$(catparm $batd/energy_full_design 0) ++ ef=$(catparm $batd/energy_full 0) ++ en=$(catparm $batd/energy_now 0) + + elif [ -f $batd/charge_full ]; then + printparm "%-59s = ##%6d## [mAh]" $batd/charge_full_design "" 000 +@@ -1195,9 +1204,15 @@ if [ "$show_bat" = "1" ] || [ "$show_all" = "1" ]; then + printparm "%-59s = ##%6d## [mA]" $batd/current_now "" 000 + + # store values for charge / capacity calculation below +- ed=$(cat $batd/charge_full_design) +- ef=$(cat $batd/charge_full) +- en=$(cat $batd/charge_now) ++ ed=$(catparm $batd/charge_full_design 0) ++ ef=$(catparm $batd/charge_full 0) ++ en=$(catparm $batd/charge_now 0) ++ ++ else ++ ed=0 ++ ef=0 ++ en=0 ++ + fi + if [ $tpbat -eq 1 ]; then + print_tp_batstate $batd/status diff --git a/tlp.spec b/tlp.spec index 20a6f95..d16b008 100644 --- a/tlp.spec +++ b/tlp.spec @@ -1,6 +1,6 @@ Name: tlp Version: 0.9 -Release: 2%{?dist} +Release: 5%{?dist} Summary: Advanced power management tool for Linux License: GPLv2+ URL: http://linrunner.de/tlp @@ -8,6 +8,12 @@ Source0: https://github.com/linrunner/TLP/archive/%{version}.tar.gz #Provided by Andreas Roederer : Source1: 50-tlp.preset +#Cherry-pick upstream fixes to tlp-stat: +#https://github.com/linrunner/TLP/commit/9498a85d1cedb78a38b54f243c9c4a3daad5bcc6 +Patch0: tlp-stat-fix.patch +#https://github.com/linrunner/TLP/commit/dabd0e900f6e10c358436c584c51dd1f55c320d2 +Patch1: tlp-mitigate-slowshutdown.patch + BuildRequires: perl-generators BuildRequires: systemd @@ -91,12 +97,23 @@ systemctl mask systemd-rfkill.service %postun %systemd_postun_with_restart tlp.service %systemd_postun_with_restart tlp-sleep.service -systemctl unmask systemd-rfkill.service +if [ $1 -eq 0 ] ; then + systemctl unmask systemd-rfkill.service +fi %post rdw /bin/systemctl enable NetworkManager-dispatcher.service >/dev/null 2>&1 || : %changelog +* Mon Mar 20 2017 Jeremy Newton - 0.9-5 +- Cherry-pick upstream fix for mitigate slow shutdown + +* Thu Mar 02 2017 Jeremy Newton - 0.9-4 +- Cherry-pick upstream fix for tlp-stat + +* Sat Feb 11 2017 Fedora Release Engineering - 0.9-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild + * Sun Jan 15 2017 Jeremy Newton - 0.9-2 - Fix rfkill service masking