diff options
author | Xo Wang <xow@google.com> | 2017-01-27 15:00:25 -0800 |
---|---|---|
committer | Patrick Williams <patrick@stwcx.xyz> | 2017-02-01 19:40:57 +0000 |
commit | 952ce27ea28a4bf47c3deffbb7525b634b964892 (patch) | |
tree | 5c5b68c427b0be535e2d38808519d6bb73c5b224 /meta-openbmc-machines/meta-openpower | |
parent | 395cd552a3dda0bcebcd1cda87ca4c84d4770c6d (diff) | |
download | talos-openbmc-952ce27ea28a4bf47c3deffbb7525b634b964892.tar.gz talos-openbmc-952ce27ea28a4bf47c3deffbb7525b634b964892.zip |
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 <xow@google.com>
Change-Id: Ia9eee013001c47ffc9706984b110f312ccdbc175
Diffstat (limited to 'meta-openbmc-machines/meta-openpower')
-rwxr-xr-x | meta-openbmc-machines/meta-openpower/meta-ingrasys/meta-zaius/recipes-phosphor/chassis/vcs-control/zaius_vcs.sh | 36 |
1 files changed, 24 insertions, 12 deletions
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 |