Skip to content
This repository
Browse code

Added documentations of power management

  • Loading branch information...
commit d0c20471186c1eb37e58ca046ac032915bad39c0 1 parent 0e4fa54
Shinpei Kato authored
72 docs/nvclock-lookup.sh
... ... @@ -0,0 +1,72 @@
  1 +#!/bin/bash
  2 +
  3 +
  4 +
  5 +# nvclock-lookup.sh vbios.rom
  6 +
  7 +nvbios $1 > ${1}.dump
  8 +
  9 +if [ $? -eq 1 -o $# -eq 0 ]
  10 +then
  11 + echo -e "Please input vbios data!\nLike this: ./nvclock-lookup.sh [filename]"
  12 + rm -f ${1}.dump
  13 + exit 0
  14 +fi
  15 +
  16 +echo "$1"
  17 +
  18 +
  19 +SetCount=`grep Core ${1}.dump | wc -l`
  20 +
  21 +Memory=( 0 )
  22 +Core=( 0 )
  23 +i=1
  24 +
  25 +while [ ${SetCount} -ge ${i} ]
  26 +do
  27 + Memory[${i}]=`grep Core ${1}.dump | sed -n ${i}p | cut -f7 -d " "`
  28 + Core[${i}]=`grep Core ${1}.dump | sed -n ${i}p | cut -f5 -d " "`
  29 + i=`expr ${i} + 1 `
  30 +done
  31 +
  32 +
  33 +# ${${Conpornent}[${i}]}
  34 +
  35 +i=1
  36 +j=0
  37 +echo -n -e "You can select Memory frequency\t:\t"
  38 +while [ ${SetCount} -ge ${i} ]
  39 +do
  40 + if [ ${Memory[${i}]} != ${Memory[${j}]} ]
  41 + then
  42 + echo -n -e "${Memory[${i}]}\t"
  43 +
  44 +
  45 + fi
  46 +
  47 + i=`expr ${i} + 1 `
  48 + j=`expr ${j} + 1 `
  49 +
  50 +done
  51 +echo
  52 +
  53 +i=1
  54 +j=0
  55 +echo -n -e "You can select Core frequency\t:\t"
  56 +while [ ${SetCount} -ge ${i} ]
  57 +do
  58 + if [ ${Core[${i}]} != ${Core[${j}]} ]
  59 + then
  60 + echo -n -e "${Core[${i}]}\t"
  61 +
  62 +
  63 + fi
  64 +
  65 + i=`expr ${i} + 1 `
  66 + j=`expr ${j} + 1 `
  67 +
  68 +done
  69 +echo
  70 +
  71 +
  72 +
137 docs/nvclock-set.sh
... ... @@ -0,0 +1,137 @@
  1 +#!/bin/bash
  2 +# Please reboot, you want to clock level up or you want to use help (Option -h)
  3 +# nvclock-set.sh -c 700 -m 1848 vbios.rom
  4 +
  5 +nvbios $5 > ${5}.dump
  6 +modprobe -r nvidia
  7 +
  8 +if [ $? -eq 1 -o $# -ne 5 ]
  9 +then
  10 + echo -e "Please input vbios data and set frequency!\nLike this: ./nvclock-set.sh -c [Core frequency] -m Memory frequency] [filename]"
  11 + rm -f ${5}.dump
  12 + exit 0
  13 +fi
  14 +
  15 +
  16 +
  17 +SetCount=`grep Core ${5}.dump | wc -l`
  18 +
  19 +NumResister=0
  20 +SetLevel=0
  21 +
  22 +# check frequency
  23 +Memory=( 0 )
  24 +Core=( 0 )
  25 +i=1
  26 +
  27 +while [ ${SetCount} -ge ${i} ]
  28 +do
  29 + Memory[${i}]=`grep Core ${5}.dump | sed -n ${i}p | cut -f7 -d " "|cut -f1 -d "M"`
  30 + Core[${i}]=`grep Core ${5}.dump | sed -n ${i}p | cut -f5 -d " "|cut -f1 -d "M"`
  31 + i=`expr ${i} + 1 `
  32 +done
  33 +
  34 +
  35 +if [ $1 = -c -o $3 = -c ]
  36 +then
  37 + if [ $1 = -c ]
  38 + then
  39 + FreqCore=$2
  40 + else
  41 + FreqCore=$4
  42 + fi
  43 +
  44 +fi
  45 +
  46 +
  47 +if [ $1 = -m -o $3 = -m ]
  48 +then
  49 + if [ $1 = -m ]
  50 + then
  51 + FreqMem=$2
  52 + else
  53 + FreqMem=$4
  54 + fi
  55 +
  56 +fi
  57 +
  58 +i=${SetCount}
  59 +while [ $i -gt 0 ]
  60 +do
  61 + if [ ${FreqCore} = ${Core[${i}]} ]
  62 + then
  63 + break
  64 + fi
  65 + i=`expr $i - 1`
  66 + if [ $i -eq 0 ]
  67 + then
  68 + echo "Please input valid core frequency!"
  69 + fi
  70 +done
  71 +
  72 +j=${SetCount}
  73 +while [ $j -gt 0 ]
  74 +do
  75 + if [ ${FreqMem} -eq ${Memory[${j}]} ]
  76 + then
  77 + break
  78 + fi
  79 +
  80 + j=`expr $j - 1`
  81 + if [ $j -eq 0 ]
  82 + then
  83 + echo "Please input valid memory frequency!"
  84 + exit 0
  85 + fi
  86 +
  87 +
  88 +done
  89 +
  90 +# finsh check
  91 +
  92 +# set core frequency
  93 +while [ ${SetCount} -gt $i ]
  94 +do
  95 + SetLevel=`expr ${SetCount} \* 3 - 1 `
  96 + CoreNumResister=`grep -A 1 Core ${5}.dump | sed -n ${SetLevel}p |cut -f1 -d ":"`
  97 + SetCount=`expr ${SetCount} - 1 `
  98 + CoreOption=`echo "${CoreOption} -e ${CoreNumResister}:ff"`
  99 +done
  100 +
  101 +CoreOption=`echo "${CoreOption} -e ${CoreNumResister}:0${FreqCore0x}"`
  102 +
  103 +# set memory frequency
  104 +if [ ${FreqMem} -lt 1000 ]
  105 +then
  106 + FreqMemBin=`echo "obase=2; ibase=10; ${FreqMem} + 32768 " |bc`
  107 + FreqMemBin=`echo "obase=16; ibase=2; ${FreqMemBin} " |bc |tr A-Z a-z`
  108 +else
  109 + FreqMemBin=`echo "obase=2; ibase=10; ${FreqMem} + 16384 " |bc`
  110 + FreqMemBin=`echo "obase=16; ibase=2; ${FreqMemBin} " |bc |tr A-Z a-z`
  111 +fi
  112 +
  113 +FreqMem0x1=`echo ${FreqMemBin} |cut -c3-4`
  114 +FreqMem0x2=`echo ${FreqMemBin} |cut -c1-2`
  115 +
  116 +SetLevel=`expr ${SetCount} \* 9 - 1 `
  117 +MemNumResister=`grep -A 7 Core ${5}.dump | sed -n ${SetLevel}p |cut -f2 -d ":"`
  118 +
  119 +MemOption=`echo " -e ${MemNumResister}:${FreqMem0x1}"`
  120 +MemNumResister=`echo ${MemNumResister} |tr a-z A-Z`
  121 +MemNumResister=`echo "obase=16; ibase=16; ${MemNumResister} +1 " |bc |tr A-Z a-z`
  122 +
  123 +
  124 +MemOption=`echo -n "${MemOption} -e ${MemNumResister}:${FreqMem0x2}"`
  125 +echo "nvafakebios${CoreOption}${MemOption} ${5}"
  126 +nvafakebios ${CoreOption} ${MemOption} ${5}
  127 +modprobe nvidia
  128 +modprobe -r nvidia
  129 +nvagetbios > ${5}
  130 +nvbios ${5} > ${5}.dump
  131 +
  132 +echo "GPU run this frequency"
  133 +grep Core ${5}.dump | sed -n ${i}p | cut -f4-9 -d " "
  134 +rm -f ${5}.dump
  135 +modprobe nvidia
  136 +
  137 +
170 docs/nvidia-vfs.txt
... ... @@ -0,0 +1,170 @@
  1 +This document describes how to use frequency scaling in NVIDIA driver. It
  2 +conducts by modifying the GPU card's VBIOS. Using envytools can modify VBIOS.
  3 +
  4 +
  5 +1. Install envytools
  6 +
  7 +Envytools is a rich set of open-source tools to compile or decompile NVIDIA
  8 +GPU program code, firmware code, macro code, and so on. It is also used to
  9 +generate C header files with GPU command definitions.
  10 +
  11 +
  12 +cd $(TOPDIR)
  13 +git clone git://0x04.net/envytools.git
  14 +mkdir build
  15 +cd build
  16 +cmake .. # may require some packages on your distro
  17 +make
  18 +sudo make install # will install tools to /usr/local/{bin,lib}
  19 +
  20 +You'll need: cmake, libxml2, libxml2-dev, libpciaccess-dev, flex, bison
  21 +
  22 +
  23 +
  24 +2. Unload NVIDIA driver and extract the card's VBIOS
  25 +
  26 +nvagetbios extracts the card's VBIOS using the method given as parameter and
  27 +writes it to stdout.
  28 +
  29 +
  30 +cd ${TOPDIR}
  31 +sudo modprobe -r nvidia
  32 +sudo /usr/local/bin/nvagetbios > vbios.rom
  33 +
  34 +
  35 +
  36 +3. Decode the card's VBIOS
  37 +
  38 +nvbios decodes the card description structures found in NVIDIA VBIOS.
  39 +
  40 +
  41 +nvbios vbios.rom > vbios.rom.dump
  42 +
  43 +
  44 +
  45 +4. Modify the card's VBIOS
  46 +
  47 +Open vbios.rom.dump by a text editor. You will find the place setting
  48 +frequency like this.
  49 +# Contents of vbios.rom.dump depend on GPU cards.
  50 +
  51 +...
  52 +...
  53 +
  54 +-- ID 0xc Core 405MHz Memory 1848MHz Shader 810MHz ...
  55 +61c4: 0c 00 02 08 ...
  56 + 0:61d4: 2a 83 00 00
  57 + 1:61d8: 2a 83 00 00
  58 + 2:61dc: 95 01 00 00
  59 + 3:61e0: 2a 83 00 00
  60 + 4:61e4: 2a 83 00 00
  61 + 5:61e8: 38 47 00 00
  62 + 6:61ec: 95 01 00 00
  63 + ...
  64 +
  65 +-- ID 0xf Core 700MHz Memory 1848MHz Shader 1401MHz ...
  66 +6208: 0f 00 02 08 ...
  67 + 0:6218: 79 45 00 00
  68 + 1:621c: 79 45 00 00
  69 + 2:6220: 1c 02 00 00
  70 + 3:6224: 79 45 00 00
  71 + 4:6228: c0 45 00 00
  72 + 5:622c: 38 47 00 00
  73 + 6:6230: 1c 02 00 00
  74 + ...
  75 +
  76 +Configuration of [ID 0xf] is valid in default, because ID at the bottom is
  77 +active. Configuration of [ID 0xf] means GPU run by core frequency in 700MHz,
  78 +memory frequency in 135MHz, and shader frequency in 1401MHz. If you want to
  79 +use the configuration of [ID 0xc], you make configuration of [ID 0xf] invalid.
  80 +Changing [6208: 0f] under the [ID 0xf] to [6208: ff] by using nvafakebios, [ID
  81 +0xf] become invalid. Similarly, changing [61c4: 0c] to [61c4: ff] is invalid
  82 +[ID 0xc]. This is an example of how to disable the [ID 0xf].
  83 +
  84 +
  85 +sudo /usr/local/bin/nvafakebios -e 6208:ff vbios.rom
  86 +
  87 +
  88 +
  89 +5. Load NDIVIA driver
  90 +
  91 +If you load NVIDIA driver, setting frequency is valid.
  92 +
  93 +
  94 +sudo modprobe nvidia
  95 +
  96 +
  97 +
  98 +6. Extra frequency setting
  99 +
  100 +If you change only core frequency, or only memory frequency, you must analyze
  101 +file of vbios.rom.dump. For example,
  102 +
  103 + ...
  104 + ...
  105 +-- ID 0x7 Core 405MHz Memory 324MHz Shader 810MHz ...
  106 +6180: 07 00 00 08 ...
  107 + 0:6190: 2a 83 00 00
  108 + 1:6194: 2a 83 00 00
  109 + 2:6198: 95 01 00 00
  110 + 3:619c: 2a 83 00 00
  111 + 4:61a0: 2a 83 00 00
  112 + 5:61a4: 44 81 00 00
  113 + 6:61a8: 95 01 00 00
  114 + ...
  115 +
  116 +-- ID 0xc Core 405MHz Memory 1848MHz Shader 810MHz ...
  117 +61c4: 0c 00 02 08 ...
  118 + 0:61d4: 2a 83 00 00
  119 + 1:61d8: 2a 83 00 00
  120 + 2:61dc: 95 01 00 00
  121 + 3:61e0: 2a 83 00 00
  122 + 4:61e4: 2a 83 00 00
  123 + 5:61e8: 38 47 00 00
  124 + 6:61ec: 95 01 00 00
  125 + ...
  126 +
  127 +-- ID 0xf Core 700MHz Memory 1848MHz Shader 1401MHz ...
  128 +6208: 0f 00 02 08 ...
  129 + 0:6218: 79 45 00 00
  130 + 1:621c: 79 45 00 00
  131 + 2:6220: 1c 02 00 00
  132 + 3:6224: 79 45 00 00
  133 + 4:6228: c0 45 00 00
  134 + 5:622c: 38 47 00 00
  135 + 6:6230: 1c 02 00 00
  136 + ...
  137 +
  138 +[5:61a4 44 81], [5:61e8 38 47], and [5:622c 38 47] are estimated setting of
  139 +memory frequency. [44 81] of [5:61a4 44 81] means 0x144(324) by transposing
  140 +and ignoring first bit. [38 47] of [5:61e8 38 47] means 0x738(1848) by the
  141 +same token. Therefor, you change [5:622c 38 47] to [5:622c 44 81], GPU run by
  142 +core frequency in 700MHz, memory frequency in 324MHz and shader frequency in
  143 +1401MHz. This command change [5:622c 38 47] to [5:622c 44 81].
  144 +
  145 +
  146 +# use this command instead of Step 4
  147 +sudo /usr/local/bin/nvafakebios -e 622c:44 -e 622d:81 vbios.rom
  148 +
  149 +
  150 +
  151 +7. How to use script
  152 +You can use this script to check selectable frequency on your GPU card after
  153 +step 2.
  154 +
  155 +./nvclock-lockup.sh vbios.rom # You need to install bc
  156 +
  157 +
  158 +If you want to run GPU by core frequency in 405MHz, and memory frequency in
  159 +324MHz, you use this script like this after step 2.
  160 +
  161 +# use this script in a superuser
  162 +./nvclock-set.sh -c 405 -m 324 vbios.rom
  163 +
  164 +
  165 +We don't recommend using the lowest core frequency without using the lowest
  166 +memory frequency, because there are lack of stability. If you fail memory or
  167 +core clock up, please reboot your machine. We check the script working in
  168 +Geforce GTX 480, but we don't know this script work well in other GPU cards.
  169 +
  170 +

0 comments on commit d0c2047

Please sign in to comment.
Something went wrong with that request. Please try again.