From b2d60b2f32b3a8636c7db65b780ce59a211116f8 Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Mon, 28 Aug 2017 21:59:49 -0500 Subject: Add workaround to prevent BMC timer lockup and reboot This is a bit of a nasty hack but it works... --- .../fan-ctrl/fan-ctrl/ast2050-timer-workaround.sh | 45 ++++++++++++++++++++++ .../recipes-core/fan-ctrl/fan-ctrl/setup-fan.sh | 4 ++ .../recipes-core/fan-ctrl/fan-ctrl_0.1.bbappend | 2 + 3 files changed, 51 insertions(+) create mode 100755 meta-raptor/meta-asus/recipes-core/fan-ctrl/fan-ctrl/ast2050-timer-workaround.sh mode change 100644 => 100755 meta-raptor/meta-asus/recipes-core/fan-ctrl/fan-ctrl/setup-fan.sh (limited to 'meta-raptor') diff --git a/meta-raptor/meta-asus/recipes-core/fan-ctrl/fan-ctrl/ast2050-timer-workaround.sh b/meta-raptor/meta-asus/recipes-core/fan-ctrl/fan-ctrl/ast2050-timer-workaround.sh new file mode 100755 index 0000000..d8631dd --- /dev/null +++ b/meta-raptor/meta-asus/recipes-core/fan-ctrl/fan-ctrl/ast2050-timer-workaround.sh @@ -0,0 +1,45 @@ +#/bin/bash +# +# Copyright 2017 Raptor Engineering, LLC +# +# Work around glitchy timer0 on the AST2050 +# For an unknown reason, sometimes when timer0 +# expires it does not fire an IRQ. This in turn +# causes Linux to hang waiting for the timer to +# expire, causing all nanosleep calls to stall +# indefinitely. On a stock OpenBMC system, this +# manifests as a spontanous reboot every few hours +# of uptime as the watchdog timer kicks in. +# +# This script works around the problem by watching +# timer0 and seeing if it is stuck at 0. If so, it +# gives the afflicted timer a good kick in the rear +# to get it going again, which in turn un-stalls all +# of the queued nanosleep calls. +# +# Note that due to what this does and how it operates, +# using sleep in this script is a VERY BAD IDEA! + +function daemon_process { + while [[ 1 == 1 ]]; do + TIMER_COUNT=$(devmem 0x1e782000 32) + if [[ "$TIMER_COUNT" == "0x00000000" ]]; then + TIMER_COUNT=$(devmem 0x1e782000 32) + if [[ "$TIMER_COUNT" == "0x00000000" ]]; then + echo "Kicking timer back into operation!" + devmem 0x1e782004 32 0x00000001 + fi + fi + + # Busy wait at highest niceness + COUNTER=1000 + until [[ $COUNTER -lt 1 ]]; do + let COUNTER-=1 + done + done +} + +renice -n 19 $$ + +daemon_process < /dev/null & +disown diff --git a/meta-raptor/meta-asus/recipes-core/fan-ctrl/fan-ctrl/setup-fan.sh b/meta-raptor/meta-asus/recipes-core/fan-ctrl/fan-ctrl/setup-fan.sh old mode 100644 new mode 100755 index 2b2e902..1016715 --- a/meta-raptor/meta-asus/recipes-core/fan-ctrl/fan-ctrl/setup-fan.sh +++ b/meta-raptor/meta-asus/recipes-core/fan-ctrl/fan-ctrl/setup-fan.sh @@ -28,6 +28,10 @@ # Short-Description: Set fan speed ### END INIT INFO +echo -n "Start AST2050 timer workaround..." +/usr/local/bin/ast2050-timer-workaround.sh > /dev/null +echo "done". + echo -n "Setup fan speed... " rmmod w83795 || true /usr/local/bin/platform_sensor_init diff --git a/meta-raptor/meta-asus/recipes-core/fan-ctrl/fan-ctrl_0.1.bbappend b/meta-raptor/meta-asus/recipes-core/fan-ctrl/fan-ctrl_0.1.bbappend index b6f0ae1..ae0508a 100644 --- a/meta-raptor/meta-asus/recipes-core/fan-ctrl/fan-ctrl_0.1.bbappend +++ b/meta-raptor/meta-asus/recipes-core/fan-ctrl/fan-ctrl_0.1.bbappend @@ -22,6 +22,7 @@ SRC_URI += "file://get_fan_speed.sh \ file://set_fan_speed.sh \ file://init_pwm.sh \ file://setup-fan.sh \ + file://ast2050-timer-workaround.sh \ " S = "${WORKDIR}" @@ -32,6 +33,7 @@ binfiles = " \ init_pwm.sh \ fand \ platform_sensor_init \ + ast2050-timer-workaround.sh \ " CXXFLAGS_prepend = "-DCONFIG_ASUS " -- cgit v1.1