162306a36Sopenharmony_ci#!/bin/sh 262306a36Sopenharmony_ci# SPDX-License-Identifier: GPL-2.0-only 362306a36Sopenharmony_ci 462306a36Sopenharmony_ci. ./eeh-functions.sh 562306a36Sopenharmony_ci 662306a36Sopenharmony_cieeh_test_prep # NB: may exit 762306a36Sopenharmony_ci 862306a36Sopenharmony_civf_list="$(eeh_enable_vfs)"; 962306a36Sopenharmony_ciif $? != 0 ; then 1062306a36Sopenharmony_ci log "No usable VFs found. Skipping EEH unaware VF test" 1162306a36Sopenharmony_ci exit $KSELFTESTS_SKIP; 1262306a36Sopenharmony_cifi 1362306a36Sopenharmony_ci 1462306a36Sopenharmony_cilog "Enabled VFs: $vf_list" 1562306a36Sopenharmony_ci 1662306a36Sopenharmony_cifailed=0 1762306a36Sopenharmony_cifor vf in $vf_list ; do 1862306a36Sopenharmony_ci log "Testing $vf" 1962306a36Sopenharmony_ci 2062306a36Sopenharmony_ci if eeh_can_recover $vf ; then 2162306a36Sopenharmony_ci log "Driver for $vf supports error recovery. Unbinding..." 2262306a36Sopenharmony_ci echo "$vf" > /sys/bus/pci/devices/$vf/driver/unbind 2362306a36Sopenharmony_ci fi 2462306a36Sopenharmony_ci 2562306a36Sopenharmony_ci log "Breaking $vf..." 2662306a36Sopenharmony_ci if ! eeh_one_dev $vf ; then 2762306a36Sopenharmony_ci log "$vf failed to recover" 2862306a36Sopenharmony_ci failed="$((failed + 1))" 2962306a36Sopenharmony_ci fi 3062306a36Sopenharmony_cidone 3162306a36Sopenharmony_ci 3262306a36Sopenharmony_cieeh_disable_vfs 3362306a36Sopenharmony_ci 3462306a36Sopenharmony_citest "$failed" != 0 3562306a36Sopenharmony_ciexit $?; 36