summaryrefslogtreecommitdiff
path: root/tests/ZZ_hangman
blob: 7afda570bcc8580b01f729fec244985700a5af5c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/bin/sh
#
# Testcase: Simulate gpu hang
#
# This check uses the stop_rings facility to exercise the gpu hang code.
# by reading /sys/kernel/debug/dri/0/i915_emon_status too quickly
#

if [ -d /debug/dri ] ; then
	debugfs_path=/debug_dri
fi

if [ -d /sys/kernel/debug/dri ] ; then
	debugfs_path=/sys/kernel/debug/dri
fi

cur_path=`pwd`
i915_path=x
for dir in `ls $debugfs_path` ; do
	if [ -f $debugfs_path/$dir/i915_error_state ] ; then
		i915_path=$debugfs_path/$dir
		break
	fi
done

if [ $i915_path = "x" ] ; then
	echo i915 debugfs path not found.
	exit 1
fi

cd $i915_path

if [ ! -f i915_ring_stop ] ; then
	echo "kernel doesn't support ring stopping"
	exit 77
fi

if cat i915_error_state | grep -v "no error state collected" > /dev/null ; then
	echo "gpu hang dectected"
	exit 1
fi

# stop rings
echo 0xf > i915_ring_stop

# need to run it twice, otherwise there are no waiters
$cur_path/gem_exec_nop > /dev/null 2>&1 &
$cur_path/gem_exec_nop > /dev/null 2>&1 &

sleep 10

if cat i915_error_state | grep -v "no error state collected" > /dev/null ; then
	echo "gpu hang correctly dectected"
else
	echo "gpu hang not dectected"
	exit 2
fi

# clear error state
echo 0 > i915_ring_stop

exit 0