1#!/bin/sh
2
3if [ $(id -ru) -ne 0 ]; then
4    echo "$0 must be run as root"
5    exit 1
6fi
7
8get(){
9    if [ ! -e $tardir/${@:$#} ] ; then
10	mkdir -p $tardir/${@:$#}
11    fi
12    if [ -e $1 ] ; then
13	cp -a ${@:1:$#-1} $tardir/${@:$#} 2>/dev/null
14    fi
15}
16
17igtdir=`dirname $0`
18
19if [ -d /debug/dri ] ; then
20	debugfs_path=/debug_dri
21fi
22
23if [ -d /sys/kernel/debug/dri ] ; then
24	debugfs_path=/sys/kernel/debug/dri
25fi
26
27i915_debugfs=x
28for dir in `ls $debugfs_path` ; do
29	if [ -f $debugfs_path/$dir/i915_error_state ] ; then
30		i915_debugfs=$debugfs_path/$dir
31		break
32	fi
33done
34
35if [ $i915_debugfs = "x" ] ; then
36	echo i915 debugfs path not found.
37	exit 1
38fi
39
40tmpdir=`mktemp -d`
41tardir=$tmpdir/intel_gpu_abrt
42mkdir $tardir
43
44get $i915_debugfs/* debugfs
45
46get /sys/module/i915/parameters/* mod_opts
47
48mkdir $tardir/X
49xrandr --verbose > $tardir/X/xrandr
50get /var/log/Xorg.0.log X
51get /var/log/Xorg.0.log.old X
52get /etc/X11/xorg.conf X
53get /etc/X11/xorg.conf.d/ X
54
55dmesg > $tardir/dmesg
56lspci -nn > $tardir/lspci
57
58$igtdir/intel_reg dump > $tardir/intel_reg_dump.txt
59$igtdir/intel_bios_dumper $tardir/intel_bios_dump
60$igtdir/intel_stepping > $tardir/intel_stepping
61
62echo 1 > /sys/devices/pci0000:00/0000:00:02.0/rom
63cat /sys/devices/pci0000:00/0000:00:02.0/rom > $tardir/vbios.dump
64echo 0 > /sys/devices/pci0000:00/0000:00:02.0/rom
65
66(cd $tmpdir; tar -c intel_gpu_abrt ) > intel_gpu_abrt.tar
67
68rm $tmpdir -Rf
69
70if [ -f intel_gpu_abrt.tar ] ; then
71	cat <<EOF
72intel_gpu_abrt.tar has been created.
73
74Please attach it to https://bugs.freedesktop.org
75with a good bug description as suggested in this template:
76
77System environment:
78-- chipset:
79-- system architecture: `uname -m`
80-- xf86-video-intel:
81-- xserver: `grep "X.Org X Server" /var/log/Xorg.0.log | awk '{print $NF}'`
82-- mesa:
83-- libdrm: `pkg-config --modversion libdrm`
84-- kernel: `uname -r`
85-- Linux distribution:
86-- Machine or mobo model:
87-- Display connector:
88
89Reproducing steps:
90
91Additional info:
92
93EOF
94exit 0
95else
96cat <<EOF
97Error on tarball generation.
98For bug report, please follow manual instructions available at:
99https://01.org/linuxgraphics/documentation/how-report-bugs-0
100EOF
101exit 1
102fi
103