[1d97c1]: nouveau-pm / run-trace.sh Maximize Restore History

Download this file

run-trace.sh    120 lines (92 with data), 3.2 kB

  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
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#!/bin/bash
error() {
echo "ERROR - $1"
exit 1
}
if [ $UID -ne 0 ]; then
error "The script must be run as root"
fi
# Check if the mmio is the current tracer
TRACER=`cat /sys/kernel/debug/tracing/current_tracer`
if test "x$TRACER" != xmmiotrace; then
error "mmiotrace is not the current tracer"
fi
# Check for required programs
for i in "cat" "grep" "gawk" "sed" "perl" " lspci" "tar" "xz" "gzip" "git"
do
$i --version 1>/dev/null || error "$1 not found"
done
timeout --help 2>/dev/null
if [ $? -ne 1 ]; then
error "timeout not found"
fi
TMPDIR=`mktemp -d nouveau-pm.XXXXXXXXXX` || error "Cannot create temporary directory"
cat /sys/kernel/debug/tracing/trace_pipe > $TMPDIR/dump-downclock &
echo "Running glxgears" > /sys/kernel/debug/tracing/trace_marker
timeout 5s glxgears 2>/dev/null
echo "Stoping glxgears" > /sys/kernel/debug/tracing/trace_marker
echo "Running the monitor_downclocking"
./monitor_downclocking 2> /sys/kernel/debug/tracing/trace_marker
MONITOR_RETURN=$?
case "$MONITOR_RETURN" in
# [1])
# error ""
# ;;
[2])
error "The driver is not operating in Adaptive clock state"
;;
[3])
error "The PowerMizer mode is not Adaptive"
;;
[4])
error "Timeout while waiting for the driver to reach default 2D frequencies"
;;
esac
echo "Dumping done. Stopping tracer"
sleep 1
# XXX: check the following and print another ERROR message if does return an error
echo nop > /sys/kernel/debug/tracing/current_tracer
sleep 1
kill -12 %1
echo "Getting additional information"
cd $TMPDIR
if test -e /proc/driver/nvidia/version; then
cat /proc/driver/nvidia/version > ./driver-version
else
echo "unknown" > ./driver-version
fi
# Getting the bus the card is actually connected to
lspci | grep VGA | gawk '{print $1}' > ./CARD_BUS
# And some detailed information of the card itself form lspci
lspci -vvnn -d 10de: -s `cat ./CARD_BUS` > ./lspci
# get device/pci id
lspci -n -d 10de: -s `cat ./CARD_BUS` | gawk '{print $3}' > ./dev_pci_id
sed -nre 's/^10de:(.*)/\1/p' ./dev_pci_id |head -n 1 > ./pci_id
rm ./dev_pci_id
# The PBAR0
NV_PBAR0=0x`cat ./lspci | grep 'Region 0' | gawk '{print $5}'`
# Now lets get BOOT_0
grep $NV_PBAR0 ./dump-downclock | gawk '{ATTRB=$1; offset=strtonum($5); \
if ((ATTRB == "R") && (offset=='$NV_PBAR0')) \
print $6;}' | head -n 1 > ./BOOT
# Now to get the card generation/arch
perl -e '$_ = <>; chomp; $v = hex($_); if(($v & 0x0f000000) > 0) {printf("%x\n", ($v >> 20) & 0xff);} elsif(($v & 0xff00fff0) == 0x20004000) {print (($v & 0x00f00000) ? "05\n" : "04\n");} else {print "ff\n";}' ./BOOT > arch
# System info
uname -a > ./uname
nouveau_pm_name=nv`cat ./arch`-`cat ./BOOT`-`cat ./pci_id`-downclock
mv ./dump-downclock ./$nouveau_pm_name
echo "Compressing the dump"
xz -z -9 -v ./$nouveau_pm_name
cd ..
echo "Compressing the hole set of information"
mkdir ./$nouveau_pm_name
mv ./$TMPDIR/* ./$nouveau_pm_name/
tar -cpzf $nouveau_pm_name.tar.gz ./$nouveau_pm_name/
cd ..
echo "Unmounting debugfs"
# XXX: Another message to ignore if cannot me unmounted or send to /dev/null ?
umount /sys/kernel/debug
echo "Removing temporary directories"
rm -rf $TMPDIR
rm -rf $nouveau_pm_name
exit 0