From 952ce27ea28a4bf47c3deffbb7525b634b964892 Mon Sep 17 00:00:00 2001 From: Xo Wang Date: Fri, 27 Jan 2017 15:00:25 -0800 Subject: meta-zaius: vcs-control: Add retries for power sequencer commands For reasons yet fully debugged, PMBus communication with the UCD90160 power sequencer is flaky, with the symptom that some i2c-{get,set} commands fail or the ucd9000 driver fails to probe. Add retries in the script that performs these commands as a workaround to their random failures. Though this script exits at first error and returns its code, the systemd services that use it have [Unit] Type=oneshot. So, systemd can not be configured to restart the script during failures. Signed-off-by: Xo Wang Change-Id: Ia9eee013001c47ffc9706984b110f312ccdbc175 --- .../chassis/vcs-control/zaius_vcs.sh | 36 ++++++++++++++-------- 1 file changed, 24 insertions(+), 12 deletions(-) (limited to 'meta-openbmc-machines/meta-openpower') diff --git a/meta-openbmc-machines/meta-openpower/meta-ingrasys/meta-zaius/recipes-phosphor/chassis/vcs-control/zaius_vcs.sh b/meta-openbmc-machines/meta-openpower/meta-ingrasys/meta-zaius/recipes-phosphor/chassis/vcs-control/zaius_vcs.sh index fc81f275e..fc5dc0861 100755 --- a/meta-openbmc-machines/meta-openpower/meta-ingrasys/meta-zaius/recipes-phosphor/chassis/vcs-control/zaius_vcs.sh +++ b/meta-openbmc-machines/meta-openpower/meta-ingrasys/meta-zaius/recipes-phosphor/chassis/vcs-control/zaius_vcs.sh @@ -7,24 +7,36 @@ ucd_bus="0" ucd_addr="0x64" ucd_path="/sys/bus/i2c/drivers/ucd9000" ucd_driver="${ucd_bus}-00${ucd_addr#0x}" +ucd_retries="5" + +retry() +{ + local i=0 + until [ $i -ge $ucd_retries ]; do + i=$((i+1)) + retry_output=`$@` && break + done + local ret=$? + if [ $i -eq $ucd_retries ]; then exit $ret; fi +} # Usage: ucd_get address # Result stored in $ucd_reg ucd_get() { - ucd_reg=`i2cget -y $ucd_bus $ucd_addr $1 b` + retry i2cget -y $ucd_bus $ucd_addr $1 b + ucd_reg=$retry_output } # Usage: ucd_get address value ucd_set() { - i2cset -y $ucd_bus $ucd_addr $1 $2 b + retry i2cset -y $ucd_bus $ucd_addr $1 $2 b } unbind_ucd() { - if [ -e $ucd_path/$ucd_driver ] - then + if [ -e $ucd_path/$ucd_driver ]; then echo -e "\tUnbinding UCD driver $ucd_driver" echo $ucd_driver > $ucd_path/unbind else @@ -34,10 +46,13 @@ unbind_ucd() rebind_ucd() { - if [ -e $ucd_path ] - then + if [ -e $ucd_path ]; then echo -e "\tBinding UCD driver $ucd_driver" - echo $ucd_driver > $ucd_path/bind + local i=0 + until [ -d $ucd_path/$ucd_driver ] || [ $i -ge $ucd_retries ]; do + i=$((i+1)) + echo $ucd_driver > $ucd_path/bind + done fi } @@ -71,13 +86,10 @@ vcs_get() } -if [ "$1" == "on" ] -then +if [ "$1" == "on" ]; then echo Turning on VCS vcs_set_gpios 0x7 - -elif [ "$1" == "off" ] -then +elif [ "$1" == "off" ]; then echo Turning off VCS vcs_set_gpios 0x3 else -- cgit v1.2.1