Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added documentations of power management

  • Loading branch information...
commit 9deadd44274145a62a1f4102529439dc3367591f 1 parent 5cbb706
Shinpei Kato authored
Showing with 379 additions and 0 deletions.
  1. +72 −0 docs/nvclock-lookup.sh
  2. +137 −0 docs/nvclock-set.sh
  3. +170 −0 docs/nvidia-vfs.txt
View
72 docs/nvclock-lookup.sh
@@ -0,0 +1,72 @@
+#!/bin/bash
+
+
+
+# nvclock-lookup.sh vbios.rom
+
+nvbios $1 > ${1}.dump
+
+if [ $? -eq 1 -o $# -eq 0 ]
+then
+ echo -e "Please input vbios data!\nLike this: ./nvclock-lookup.sh [filename]"
+ rm -f ${1}.dump
+ exit 0
+fi
+
+echo "$1"
+
+
+SetCount=`grep Core ${1}.dump | wc -l`
+
+Memory=( 0 )
+Core=( 0 )
+i=1
+
+while [ ${SetCount} -ge ${i} ]
+do
+ Memory[${i}]=`grep Core ${1}.dump | sed -n ${i}p | cut -f7 -d " "`
+ Core[${i}]=`grep Core ${1}.dump | sed -n ${i}p | cut -f5 -d " "`
+ i=`expr ${i} + 1 `
+done
+
+
+# ${${Conpornent}[${i}]}
+
+i=1
+j=0
+echo -n -e "You can select Memory frequency\t:\t"
+while [ ${SetCount} -ge ${i} ]
+do
+ if [ ${Memory[${i}]} != ${Memory[${j}]} ]
+ then
+ echo -n -e "${Memory[${i}]}\t"
+
+
+ fi
+
+ i=`expr ${i} + 1 `
+ j=`expr ${j} + 1 `
+
+done
+echo
+
+i=1
+j=0
+echo -n -e "You can select Core frequency\t:\t"
+while [ ${SetCount} -ge ${i} ]
+do
+ if [ ${Core[${i}]} != ${Core[${j}]} ]
+ then
+ echo -n -e "${Core[${i}]}\t"
+
+
+ fi
+
+ i=`expr ${i} + 1 `
+ j=`expr ${j} + 1 `
+
+done
+echo
+
+
+
View
137 docs/nvclock-set.sh
@@ -0,0 +1,137 @@
+#!/bin/bash
+# Please reboot, you want to clock level up or you want to use help (Option -h)
+# nvclock-set.sh -c 700 -m 1848 vbios.rom
+
+nvbios $5 > ${5}.dump
+modprobe -r nvidia
+
+if [ $? -eq 1 -o $# -ne 5 ]
+then
+ echo -e "Please input vbios data and set frequency!\nLike this: ./nvclock-set.sh -c [Core frequency] -m Memory frequency] [filename]"
+ rm -f ${5}.dump
+ exit 0
+fi
+
+
+
+SetCount=`grep Core ${5}.dump | wc -l`
+
+NumResister=0
+SetLevel=0
+
+# check frequency
+Memory=( 0 )
+Core=( 0 )
+i=1
+
+while [ ${SetCount} -ge ${i} ]
+do
+ Memory[${i}]=`grep Core ${5}.dump | sed -n ${i}p | cut -f7 -d " "|cut -f1 -d "M"`
+ Core[${i}]=`grep Core ${5}.dump | sed -n ${i}p | cut -f5 -d " "|cut -f1 -d "M"`
+ i=`expr ${i} + 1 `
+done
+
+
+if [ $1 = -c -o $3 = -c ]
+then
+ if [ $1 = -c ]
+ then
+ FreqCore=$2
+ else
+ FreqCore=$4
+ fi
+
+fi
+
+
+if [ $1 = -m -o $3 = -m ]
+then
+ if [ $1 = -m ]
+ then
+ FreqMem=$2
+ else
+ FreqMem=$4
+ fi
+
+fi
+
+i=${SetCount}
+while [ $i -gt 0 ]
+do
+ if [ ${FreqCore} = ${Core[${i}]} ]
+ then
+ break
+ fi
+ i=`expr $i - 1`
+ if [ $i -eq 0 ]
+ then
+ echo "Please input valid core frequency!"
+ fi
+done
+
+j=${SetCount}
+while [ $j -gt 0 ]
+do
+ if [ ${FreqMem} -eq ${Memory[${j}]} ]
+ then
+ break
+ fi
+
+ j=`expr $j - 1`
+ if [ $j -eq 0 ]
+ then
+ echo "Please input valid memory frequency!"
+ exit 0
+ fi
+
+
+done
+
+# finsh check
+
+# set core frequency
+while [ ${SetCount} -gt $i ]
+do
+ SetLevel=`expr ${SetCount} \* 3 - 1 `
+ CoreNumResister=`grep -A 1 Core ${5}.dump | sed -n ${SetLevel}p |cut -f1 -d ":"`
+ SetCount=`expr ${SetCount} - 1 `
+ CoreOption=`echo "${CoreOption} -e ${CoreNumResister}:ff"`
+done
+
+CoreOption=`echo "${CoreOption} -e ${CoreNumResister}:0${FreqCore0x}"`
+
+# set memory frequency
+if [ ${FreqMem} -lt 1000 ]
+then
+ FreqMemBin=`echo "obase=2; ibase=10; ${FreqMem} + 32768 " |bc`
+ FreqMemBin=`echo "obase=16; ibase=2; ${FreqMemBin} " |bc |tr A-Z a-z`
+else
+ FreqMemBin=`echo "obase=2; ibase=10; ${FreqMem} + 16384 " |bc`
+ FreqMemBin=`echo "obase=16; ibase=2; ${FreqMemBin} " |bc |tr A-Z a-z`
+fi
+
+FreqMem0x1=`echo ${FreqMemBin} |cut -c3-4`
+FreqMem0x2=`echo ${FreqMemBin} |cut -c1-2`
+
+SetLevel=`expr ${SetCount} \* 9 - 1 `
+MemNumResister=`grep -A 7 Core ${5}.dump | sed -n ${SetLevel}p |cut -f2 -d ":"`
+
+MemOption=`echo " -e ${MemNumResister}:${FreqMem0x1}"`
+MemNumResister=`echo ${MemNumResister} |tr a-z A-Z`
+MemNumResister=`echo "obase=16; ibase=16; ${MemNumResister} +1 " |bc |tr A-Z a-z`
+
+
+MemOption=`echo -n "${MemOption} -e ${MemNumResister}:${FreqMem0x2}"`
+echo "nvafakebios${CoreOption}${MemOption} ${5}"
+nvafakebios ${CoreOption} ${MemOption} ${5}
+modprobe nvidia
+modprobe -r nvidia
+nvagetbios > ${5}
+nvbios ${5} > ${5}.dump
+
+echo "GPU run this frequency"
+grep Core ${5}.dump | sed -n ${i}p | cut -f4-9 -d " "
+rm -f ${5}.dump
+modprobe nvidia
+
+
View
170 docs/nvidia-vfs.txt
@@ -0,0 +1,170 @@
+This document describes how to use frequency scaling in NVIDIA driver. It
+conducts by modifying the GPU card's VBIOS. Using envytools can modify VBIOS.
+
+
+1. Install envytools
+
+Envytools is a rich set of open-source tools to compile or decompile NVIDIA
+GPU program code, firmware code, macro code, and so on. It is also used to
+generate C header files with GPU command definitions.
+
+
+cd $(TOPDIR)
+git clone git://0x04.net/envytools.git
+mkdir build
+cd build
+cmake .. # may require some packages on your distro
+make
+sudo make install # will install tools to /usr/local/{bin,lib}
+
+You'll need: cmake, libxml2, libxml2-dev, libpciaccess-dev, flex, bison
+
+
+
+2. Unload NVIDIA driver and extract the card's VBIOS
+
+nvagetbios extracts the card's VBIOS using the method given as parameter and
+writes it to stdout.
+
+
+cd ${TOPDIR}
+sudo modprobe -r nvidia
+sudo /usr/local/bin/nvagetbios > vbios.rom
+
+
+
+3. Decode the card's VBIOS
+
+nvbios decodes the card description structures found in NVIDIA VBIOS.
+
+
+nvbios vbios.rom > vbios.rom.dump
+
+
+
+4. Modify the card's VBIOS
+
+Open vbios.rom.dump by a text editor. You will find the place setting
+frequency like this.
+# Contents of vbios.rom.dump depend on GPU cards.
+
+...
+...
+
+-- ID 0xc Core 405MHz Memory 1848MHz Shader 810MHz ...
+61c4: 0c 00 02 08 ...
+ 0:61d4: 2a 83 00 00
+ 1:61d8: 2a 83 00 00
+ 2:61dc: 95 01 00 00
+ 3:61e0: 2a 83 00 00
+ 4:61e4: 2a 83 00 00
+ 5:61e8: 38 47 00 00
+ 6:61ec: 95 01 00 00
+ ...
+
+-- ID 0xf Core 700MHz Memory 1848MHz Shader 1401MHz ...
+6208: 0f 00 02 08 ...
+ 0:6218: 79 45 00 00
+ 1:621c: 79 45 00 00
+ 2:6220: 1c 02 00 00
+ 3:6224: 79 45 00 00
+ 4:6228: c0 45 00 00
+ 5:622c: 38 47 00 00
+ 6:6230: 1c 02 00 00
+ ...
+
+Configuration of [ID 0xf] is valid in default, because ID at the bottom is
+active. Configuration of [ID 0xf] means GPU run by core frequency in 700MHz,
+memory frequency in 135MHz, and shader frequency in 1401MHz. If you want to
+use the configuration of [ID 0xc], you make configuration of [ID 0xf] invalid.
+Changing [6208: 0f] under the [ID 0xf] to [6208: ff] by using nvafakebios, [ID
+0xf] become invalid. Similarly, changing [61c4: 0c] to [61c4: ff] is invalid
+[ID 0xc]. This is an example of how to disable the [ID 0xf].
+
+
+sudo /usr/local/bin/nvafakebios -e 6208:ff vbios.rom
+
+
+
+5. Load NDIVIA driver
+
+If you load NVIDIA driver, setting frequency is valid.
+
+
+sudo modprobe nvidia
+
+
+
+6. Extra frequency setting
+
+If you change only core frequency, or only memory frequency, you must analyze
+file of vbios.rom.dump. For example,
+
+ ...
+ ...
+-- ID 0x7 Core 405MHz Memory 324MHz Shader 810MHz ...
+6180: 07 00 00 08 ...
+ 0:6190: 2a 83 00 00
+ 1:6194: 2a 83 00 00
+ 2:6198: 95 01 00 00
+ 3:619c: 2a 83 00 00
+ 4:61a0: 2a 83 00 00
+ 5:61a4: 44 81 00 00
+ 6:61a8: 95 01 00 00
+ ...
+
+-- ID 0xc Core 405MHz Memory 1848MHz Shader 810MHz ...
+61c4: 0c 00 02 08 ...
+ 0:61d4: 2a 83 00 00
+ 1:61d8: 2a 83 00 00
+ 2:61dc: 95 01 00 00
+ 3:61e0: 2a 83 00 00
+ 4:61e4: 2a 83 00 00
+ 5:61e8: 38 47 00 00
+ 6:61ec: 95 01 00 00
+ ...
+
+-- ID 0xf Core 700MHz Memory 1848MHz Shader 1401MHz ...
+6208: 0f 00 02 08 ...
+ 0:6218: 79 45 00 00
+ 1:621c: 79 45 00 00
+ 2:6220: 1c 02 00 00
+ 3:6224: 79 45 00 00
+ 4:6228: c0 45 00 00
+ 5:622c: 38 47 00 00
+ 6:6230: 1c 02 00 00
+ ...
+
+[5:61a4 44 81], [5:61e8 38 47], and [5:622c 38 47] are estimated setting of
+memory frequency. [44 81] of [5:61a4 44 81] means 0x144(324) by transposing
+and ignoring first bit. [38 47] of [5:61e8 38 47] means 0x738(1848) by the
+same token. Therefor, you change [5:622c 38 47] to [5:622c 44 81], GPU run by
+core frequency in 700MHz, memory frequency in 324MHz and shader frequency in
+1401MHz. This command change [5:622c 38 47] to [5:622c 44 81].
+
+
+# use this command instead of Step 4
+sudo /usr/local/bin/nvafakebios -e 622c:44 -e 622d:81 vbios.rom
+
+
+
+7. How to use script
+You can use this script to check selectable frequency on your GPU card after
+step 2.
+
+./nvclock-lockup.sh vbios.rom # You need to install bc
+
+
+If you want to run GPU by core frequency in 405MHz, and memory frequency in
+324MHz, you use this script like this after step 2.
+
+# use this script in a superuser
+./nvclock-set.sh -c 405 -m 324 vbios.rom
+
+
+We don't recommend using the lowest core frequency without using the lowest
+memory frequency, because there are lack of stability. If you fail memory or
+core clock up, please reboot your machine. We check the script working in
+Geforce GTX 480, but we don't know this script work well in other GPU cards.
+
+
Please sign in to comment.
Something went wrong with that request. Please try again.