summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--modules.d/slx-watchdog/data/slx-nowayout.conf52
-rwxr-xr-xmodules.d/slx-watchdog/hooks/s3-watchdog.sh37
-rwxr-xr-xmodules.d/slx-watchdog/module-setup.sh16
3 files changed, 105 insertions, 0 deletions
diff --git a/modules.d/slx-watchdog/data/slx-nowayout.conf b/modules.d/slx-watchdog/data/slx-nowayout.conf
new file mode 100644
index 00000000..200c663c
--- /dev/null
+++ b/modules.d/slx-watchdog/data/slx-nowayout.conf
@@ -0,0 +1,52 @@
+options acquirewdt nowayout=1
+options advantechwdt nowayout=1
+options alim1535_wdt nowayout=1
+options alim7101_wdt nowayout=1
+options cadence_wdt nowayout=1
+options da9055_wdt nowayout=1
+options dw_wdt nowayout=1
+options ebc-c384_wdt nowayout=1
+options eurotechwdt nowayout=1
+options exar_wdt nowayout=1
+options f71808e_wdt nowayout=1
+options hpwdt nowayout=1
+options i6300esb nowayout=1
+options ib700wdt nowayout=1
+options ibmasr nowayout=1
+options ie6xx_wdt nowayout=1
+options it8712f_wdt nowayout=1
+options it87_wdt nowayout=1
+options iTCO_wdt nowayout=1
+options kempld_wdt nowayout=1
+options machzwd nowayout=1
+options max63xx_wdt nowayout=1
+options mena21_wdt nowayout=1
+options menf21bmc_wdt nowayout=1
+options menz69_wdt nowayout=1
+options ni903x_wdt nowayout=1
+options nic7018_wdt nowayout=1
+options nv_tco nowayout=1
+options pc87413_wdt nowayout=1
+options pcwd_pci nowayout=1
+options pcwd_usb nowayout=1
+options sbc60xxwdt nowayout=1
+options sbc_epx_c3 nowayout=1
+options sbc_fitpc2_wdt nowayout=1
+options sc1200wdt nowayout=1
+options sch311x_wdt nowayout=1
+options simatic-ipc-wdt nowayout=1
+options smsc37b787_wdt nowayout=1
+options softdog nowayout=1
+options sp5100_tco nowayout=1
+options twl4030_wdt nowayout=1
+options via_wdt nowayout=1
+options w83627hf_wdt nowayout=1
+options w83877f_wdt nowayout=1
+options w83977f_wdt nowayout=1
+options wafer5823wdt nowayout=1
+options wdat_wdt nowayout=1
+options wdt_pci nowayout=1
+options wm831x_wdt nowayout=1
+options wm8350_wdt nowayout=1
+options xen_wdt nowayout=1
+options ziirave_wdt nowayout=1
diff --git a/modules.d/slx-watchdog/hooks/s3-watchdog.sh b/modules.d/slx-watchdog/hooks/s3-watchdog.sh
new file mode 100755
index 00000000..ae0a0e0c
--- /dev/null
+++ b/modules.d/slx-watchdog/hooks/s3-watchdog.sh
@@ -0,0 +1,37 @@
+#!/bin/ash
+
+find_watchdog() {
+ dev=
+ for dir in /sys/class/watchdog/*; do
+ [ -f "$dir/identity" ] || continue
+ t=$( cat "$dir/identity" )
+ # iamt can go nuts after entering/leaving standby a couple times
+ # https://github.com/systemd/systemd/issues/35405
+ [ "$t" = "iamt_wdt" ] && continue
+ # Not properly enabled in some BIOSes, i.e. does nothing when it fires
+ # https://community.intel.com/t5/Processors/Using-linux-iTCO-wdt-driver-on-i3-7100/m-p/1126815
+ # https://archive.is/YuHcc
+ [ "$t" = "iTCO_wdt" ] && continue
+ # First one not known to suck is fine
+ dev="${dir##*/}"
+ break
+ done
+}
+
+find_watchdog
+if [ -z "$dev" ]; then
+ modprobe softdog
+ find_watchdog
+fi
+
+if [ -z "$dev" ]; then
+ echo "No suitable watchdog found, systemd will pick default"
+else
+ echo "Selected watchdog $dev, identity '$( cat "/sys/class/watchdog/$dev/identity" )'"
+ {
+ echo "[Manager]"
+ echo "WatchdogDevice=/dev/$dev"
+ } > "${NEWROOT}/etc/systemd/system.conf.d/10-watchdog-dev.conf"
+fi
+
+true
diff --git a/modules.d/slx-watchdog/module-setup.sh b/modules.d/slx-watchdog/module-setup.sh
new file mode 100755
index 00000000..80587b0c
--- /dev/null
+++ b/modules.d/slx-watchdog/module-setup.sh
@@ -0,0 +1,16 @@
+#!/bin/bash
+check() {
+ # Tell dracut that this module should only be included if it is required
+ # explicitly.
+ return 255
+}
+depends() {
+ :
+}
+install() {
+ slx_service "s3-watchdog" "Pick preferred watchdog device for systemd" \
+ --after "initrd-root-fs.target" \
+ --requires "initrd-root-fs.target"
+ # Try to enforce nowayout for all watchdogs
+ inst_simple "$moddir/data/slx-nowayout.conf" "/etc/modprobe.d/slx-nowayout.conf"
+}