summaryrefslogtreecommitdiffstats
path: root/meta-raptor
diff options
context:
space:
mode:
authorTimothy Pearson <tpearson@raptorengineering.com>2017-08-28 21:59:49 -0500
committerTimothy Pearson <tpearson@raptorengineering.com>2017-08-28 21:59:49 -0500
commitb2d60b2f32b3a8636c7db65b780ce59a211116f8 (patch)
treef293233e5df967af5e3c9298f590fcb139d77e9e /meta-raptor
parentd3836296b82ce422140f88a481ad16f22a30bf39 (diff)
downloadast2050-yocto-openbmc-b2d60b2f32b3a8636c7db65b780ce59a211116f8.zip
ast2050-yocto-openbmc-b2d60b2f32b3a8636c7db65b780ce59a211116f8.tar.gz
Add workaround to prevent BMC timer lockup and reboot
This is a bit of a nasty hack but it works...
Diffstat (limited to 'meta-raptor')
-rwxr-xr-xmeta-raptor/meta-asus/recipes-core/fan-ctrl/fan-ctrl/ast2050-timer-workaround.sh45
-rwxr-xr-x[-rw-r--r--]meta-raptor/meta-asus/recipes-core/fan-ctrl/fan-ctrl/setup-fan.sh4
-rw-r--r--meta-raptor/meta-asus/recipes-core/fan-ctrl/fan-ctrl_0.1.bbappend2
3 files changed, 51 insertions, 0 deletions
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
index 2b2e902..1016715 100644..100755
--- 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 "
OpenPOWER on IntegriCloud