eeh-basic.sh 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #!/bin/sh
  2. # SPDX-License-Identifier: GPL-2.0-only
  3. . ./eeh-functions.sh
  4. eeh_test_prep # NB: may exit
  5. pre_lspci=`mktemp`
  6. lspci > $pre_lspci
  7. # record the devices that we break in here. Assuming everything
  8. # goes to plan we should get them back once the recover process
  9. # is finished.
  10. devices=""
  11. # Build up a list of candidate devices.
  12. for dev in `ls -1 /sys/bus/pci/devices/ | grep '\.0$'` ; do
  13. if ! eeh_can_break $dev ; then
  14. continue;
  15. fi
  16. # Skip VFs for now since we don't have a reliable way to break them.
  17. if [ -e "/sys/bus/pci/devices/$dev/physfn" ] ; then
  18. echo "$dev, Skipped: virtfn"
  19. continue;
  20. fi
  21. echo "$dev, Added"
  22. # Add to this list of device to check
  23. devices="$devices $dev"
  24. done
  25. dev_count="$(echo $devices | wc -w)"
  26. echo "Found ${dev_count} breakable devices..."
  27. failed=0
  28. for dev in $devices ; do
  29. echo "Breaking $dev..."
  30. if ! pe_ok $dev ; then
  31. echo "Skipping $dev, Initial PE state is not ok"
  32. failed="$((failed + 1))"
  33. continue;
  34. fi
  35. if ! eeh_one_dev $dev ; then
  36. failed="$((failed + 1))"
  37. fi
  38. done
  39. echo "$failed devices failed to recover ($dev_count tested)"
  40. lspci | diff -u $pre_lspci -
  41. rm -f $pre_lspci
  42. test "$failed" -eq 0
  43. exit $?