File tree Expand file tree Collapse file tree 1 file changed +78
-0
lines changed Expand file tree Collapse file tree 1 file changed +78
-0
lines changed Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+ # DRM PMU
3
+ # SPDX-License-Identifier: GPL-2.0
4
+
5
+ set -e
6
+
7
+ output=$( mktemp /tmp/perf.drm_pmu.XXXXXX.txt)
8
+
9
+ cleanup () {
10
+ rm -f " ${output} "
11
+
12
+ trap - EXIT TERM INT
13
+ }
14
+
15
+ trap_cleanup () {
16
+ echo " Unexpected signal in ${FUNCNAME[1]} "
17
+ cleanup
18
+ exit 1
19
+ }
20
+ trap trap_cleanup EXIT TERM INT
21
+
22
+ # Array to store file descriptors and device names
23
+ declare -A device_fds
24
+
25
+ # Open all devices and store file descriptors. Opening the device will create a
26
+ # /proc/$$/fdinfo file containing the DRM statistics.
27
+ fd_count=3 # Start with file descriptor 3
28
+ for device in /dev/dri/*
29
+ do
30
+ if [[ ! -c " $device " ]]
31
+ then
32
+ continue
33
+ fi
34
+ major=$( stat -c " %Hr" " $device " )
35
+ if [[ " $major " != 226 ]]
36
+ then
37
+ continue
38
+ fi
39
+ echo " Opening $device "
40
+ eval " exec $fd_count <\" $device \" "
41
+ echo " fdinfo for: $device (FD: $fd_count )"
42
+ cat " /proc/$$ /fdinfo/$fd_count "
43
+ echo
44
+ device_fds[" $device " ]=" $fd_count "
45
+ fd_count=$(( fd_count + 1 ))
46
+ done
47
+
48
+ if [[ ${# device_fds[@]} -eq 0 ]]
49
+ then
50
+ echo " No DRM devices found [Skip]"
51
+ cleanup
52
+ exit 2
53
+ fi
54
+
55
+ # For each DRM event
56
+ err=0
57
+ for p in $( perf list --raw-dump drm-)
58
+ do
59
+ echo -n " Testing perf stat of $p . "
60
+ perf stat -e " $p " --pid=$$ true > " $output " 2>&1
61
+ if ! grep -q " $p " " $output "
62
+ then
63
+ echo " Missing DRM event in: [Failed]"
64
+ cat " $output "
65
+ err=1
66
+ else
67
+ echo " [OK]"
68
+ fi
69
+ done
70
+
71
+ # Close all file descriptors
72
+ for fd in " ${device_fds[@]} " ; do
73
+ eval " exec $fd <&-"
74
+ done
75
+
76
+ # Finished
77
+ cleanup
78
+ exit $err
You can’t perform that action at this time.
0 commit comments