| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 |
|
| 7 |
|
| 8 | |
| 9 | if [ -x ./getscom ] && [ -x ./putscom ]; then
|
| 10 | GETSCOM=./getscom
|
| 11 | PUTSCOM=./putscom
|
| 12 | elif which getscom > /dev/null; then
|
| 13 | GETSCOM=$(which getscom)
|
| 14 | PUTSCOM=$(which putscom)
|
| 15 | else
|
| 16 | cat <<EOF
|
| 17 | Can't find getscom/putscom in . or \$PATH.
|
| 18 | See https://github.com/open-power/skiboot.
|
| 19 | The tool is in external/xscom-utils
|
| 20 | EOF
|
| 21 | exit 1
|
| 22 | fi
|
| 23 |
|
| 24 | |
| 25 | |
| 26 | expected_hmis=8
|
| 27 | COUNT_HMIS() {
|
| 28 | dmesg | grep -c 'Harmless Hypervisor Maintenance interrupt'
|
| 29 | }
|
| 30 |
|
| 31 | |
| 32 | ppc64_cpu --smt-snooze-delay=1000000000
|
| 33 |
|
| 34 | |
| 35 | trap "ppc64_cpu --smt-snooze-delay=100" 0 1
|
| 36 |
|
| 37 | |
| 38 | |
| 39 | grep -E -o 'OCC: Chip [0-9a-f]+ Core [0-9a-f]' < /sys/firmware/opal/msglog |
|
| 40 | while read chipcore; do
|
| 41 | chip=$(echo "$chipcore"|awk '{print $3}')
|
| 42 | core=$(echo "$chipcore"|awk '{print $5}')
|
| 43 | fir="0x1${core}013100"
|
| 44 |
|
| 45 | |
| 46 | if [ "$($GETSCOM -c 0x${chip} $fir)" != 0 ]; then
|
| 47 | echo "FIR was not zero before injection for chip $chip, core $core. Aborting!"
|
| 48 | echo "Result of $GETSCOM -c 0x${chip} $fir:"
|
| 49 | $GETSCOM -c 0x${chip} $fir
|
| 50 | echo "If you get a -5 error, the core may be in idle state. Try stress-ng."
|
| 51 | echo "Otherwise, try $PUTSCOM -c 0x${chip} $fir 0"
|
| 52 | exit 1
|
| 53 | fi
|
| 54 |
|
| 55 | |
| 56 | old_hmis=$(COUNT_HMIS)
|
| 57 |
|
| 58 | |
| 59 | echo "Injecting HMI on core $core, chip $chip" | tee /dev/kmsg
|
| 60 | |
| 61 | if ! $PUTSCOM -c 0x${chip} $fir 2000000000000000 > /dev/null; then
|
| 62 | echo "Error injecting. Aborting!"
|
| 63 | exit 1
|
| 64 | fi
|
| 65 |
|
| 66 | |
| 67 | |
| 68 | i=0;
|
| 69 | new_hmis=$(COUNT_HMIS)
|
| 70 | while [ $new_hmis -lt $((old_hmis + expected_hmis)) ] && [ $i -lt 12 ]; do
|
| 71 | echo "Seen $((new_hmis - old_hmis)) HMI(s) out of $expected_hmis expected, sleeping"
|
| 72 | sleep 5;
|
| 73 | i=$((i + 1))
|
| 74 | new_hmis=$(COUNT_HMIS)
|
| 75 | done
|
| 76 | if [ $i = 12 ]; then
|
| 77 | echo "Haven't seen expected $expected_hmis recoveries after 1 min. Aborting."
|
| 78 | exit 1
|
| 79 | fi
|
| 80 | echo "Processed $expected_hmis events; presumed success. Check dmesg."
|
| 81 | echo ""
|
| 82 | done
|