Skip to content

Commit 659dbb3

Browse files
oohalgregkh
authored andcommitted
selftests/powerpc: Squash spurious errors due to device removal
[ Upstream commit 5f8cf64 ] For drivers that don't have the error handling callbacks we implement recovery by removing the device and re-probing it. This causes the sysfs directory for the PCI device to be removed which causes the following spurious error to be printed when checking the PE state: Breaking 0005:03:00.0... ./eeh-basic.sh: line 13: can't open /sys/bus/pci/devices/0005:03:00.0/eeh_pe_state: no such file 0005:03:00.0, waited 0/60 0005:03:00.0, waited 1/60 0005:03:00.0, waited 2/60 0005:03:00.0, waited 3/60 0005:03:00.0, waited 4/60 0005:03:00.0, waited 5/60 0005:03:00.0, waited 6/60 0005:03:00.0, waited 7/60 0005:03:00.0, Recovered after 8 seconds We currently try to avoid this by checking if the PE state file exists before reading from it. This is however inherently racy so re-work the state checking so that we only read from the file once, and we squash any errors that occur while reading. Fixes: 85d86c8 ("selftests/powerpc: Add basic EEH selftest") Signed-off-by: Oliver O'Halloran <oohall@gmail.com> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Link: https://lore.kernel.org/r/20200727010127.23698-1-oohall@gmail.com Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent cd1385c commit 659dbb3

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

‎tools/testing/selftests/powerpc/eeh/eeh-functions.sh‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,17 @@ pe_ok() {
55
local dev="$1"
66
local path="/sys/bus/pci/devices/$dev/eeh_pe_state"
77

8-
if ! [ -e "$path" ] ; then
8+
# if a driver doesn't support the error handling callbacks then the
9+
# device is recovered by removing and re-probing it. This causes the
10+
# sysfs directory to disappear so read the PE state once and squash
11+
# any potential error messages
12+
local eeh_state="$(cat $path 2>/dev/null)"
13+
if [ -z "$eeh_state" ]; then
914
return 1;
1015
fi
1116

12-
local fw_state="$(cut -d' ' -f1 < $path)"
13-
local sw_state="$(cut -d' ' -f2 < $path)"
17+
local fw_state="$(echo $eeh_state | cut -d' ' -f1)"
18+
local sw_state="$(echo $eeh_state | cut -d' ' -f2)"
1419

1520
# If EEH_PE_ISOLATED or EEH_PE_RECOVERING are set then the PE is in an
1621
# error state or being recovered. Either way, not ok.

0 commit comments

Comments
 (0)