Back to home page

OSCL-LXR

 
 

    


0001 #!/bin/sh
0002 # SPDX-License-Identifier: GPL-2.0-only
0003 
0004 . ./eeh-functions.sh
0005 
0006 eeh_test_prep # NB: may exit
0007 
0008 pre_lspci=`mktemp`
0009 lspci > $pre_lspci
0010 
0011 # record the devices that we break in here. Assuming everything
0012 # goes to plan we should get them back once the recover process
0013 # is finished.
0014 devices=""
0015 
0016 # Build up a list of candidate devices.
0017 for dev in `ls -1 /sys/bus/pci/devices/ | grep '\.0$'` ; do
0018         if ! eeh_can_break $dev ; then
0019                 continue;
0020         fi
0021 
0022         # Skip VFs for now since we don't have a reliable way to break them.
0023         if [ -e "/sys/bus/pci/devices/$dev/physfn" ] ; then
0024                 echo "$dev, Skipped: virtfn"
0025                 continue;
0026         fi
0027 
0028         echo "$dev, Added"
0029 
0030         # Add to this list of device to check
0031         devices="$devices $dev"
0032 done
0033 
0034 dev_count="$(echo $devices | wc -w)"
0035 echo "Found ${dev_count} breakable devices..."
0036 
0037 failed=0
0038 for dev in $devices ; do
0039         echo "Breaking $dev..."
0040 
0041         if ! pe_ok $dev ; then
0042                 echo "Skipping $dev, Initial PE state is not ok"
0043                 failed="$((failed + 1))"
0044                 continue;
0045         fi
0046 
0047         if ! eeh_one_dev $dev ; then
0048                 failed="$((failed + 1))"
0049         fi
0050 done
0051 
0052 echo "$failed devices failed to recover ($dev_count tested)"
0053 lspci | diff -u $pre_lspci -
0054 rm -f $pre_lspci
0055 
0056 test "$failed" -eq 0
0057 exit $?