xref: /linux/tools/testing/selftests/powerpc/eeh/eeh-vf-aware.sh (revision d0034a7a4ac7fae708146ac0059b9c47a1543f0d)
1*38132cc0SOliver O'Halloran#!/bin/sh
2*38132cc0SOliver O'Halloran# SPDX-License-Identifier: GPL-2.0-only
3*38132cc0SOliver O'Halloran
4*38132cc0SOliver O'Halloran. ./eeh-functions.sh
5*38132cc0SOliver O'Halloran
6*38132cc0SOliver O'Halloraneeh_test_prep # NB: may exit
7*38132cc0SOliver O'Halloran
8*38132cc0SOliver O'Halloranvf_list="$(eeh_enable_vfs)";
9*38132cc0SOliver O'Halloranif $? != 0 ; then
10*38132cc0SOliver O'Halloran	log "No usable VFs found. Skipping EEH unaware VF test"
11*38132cc0SOliver O'Halloran	exit $KSELFTESTS_SKIP;
12*38132cc0SOliver O'Halloranfi
13*38132cc0SOliver O'Halloran
14*38132cc0SOliver O'Halloranlog "Enabled VFs: $vf_list"
15*38132cc0SOliver O'Halloran
16*38132cc0SOliver O'Hallorantested=0
17*38132cc0SOliver O'Halloranpassed=0
18*38132cc0SOliver O'Halloranfor vf in $vf_list ; do
19*38132cc0SOliver O'Halloran	log "Testing $vf"
20*38132cc0SOliver O'Halloran
21*38132cc0SOliver O'Halloran	if ! eeh_can_recover $vf ; then
22*38132cc0SOliver O'Halloran		log "Driver for $vf doesn't support error recovery, skipping"
23*38132cc0SOliver O'Halloran		continue;
24*38132cc0SOliver O'Halloran	fi
25*38132cc0SOliver O'Halloran
26*38132cc0SOliver O'Halloran	tested="$((tested + 1))"
27*38132cc0SOliver O'Halloran
28*38132cc0SOliver O'Halloran	log "Breaking $vf..."
29*38132cc0SOliver O'Halloran	if ! eeh_one_dev $vf ; then
30*38132cc0SOliver O'Halloran		log "$vf failed to recover"
31*38132cc0SOliver O'Halloran		continue;
32*38132cc0SOliver O'Halloran	fi
33*38132cc0SOliver O'Halloran
34*38132cc0SOliver O'Halloran	passed="$((passed + 1))"
35*38132cc0SOliver O'Hallorandone
36*38132cc0SOliver O'Halloran
37*38132cc0SOliver O'Halloraneeh_disable_vfs
38*38132cc0SOliver O'Halloran
39*38132cc0SOliver O'Halloranif [ "$tested" == 0 ] ; then
40*38132cc0SOliver O'Halloran	echo "No VFs with EEH aware drivers found, skipping"
41*38132cc0SOliver O'Halloran	exit $KSELFTESTS_SKIP
42*38132cc0SOliver O'Halloranfi
43*38132cc0SOliver O'Halloran
44*38132cc0SOliver O'Hallorantest "$failed" != 0
45*38132cc0SOliver O'Halloranexit $?;
46