ia64/linux-2.6.18-xen.hg

annotate scripts/patch-kernel @ 798:b02a90bf5bbc

ACPI: Backport missing part for T-State MSR support

Part of below kernel commit was missed while packporting T-State
support.

commit f79f06ab9f86d7203006d2ec8992ac80df36a34e
Author: Zhao Yakui <yakui.zhao@intel.com>
Date: Thu Nov 15 17:06:36 2007 +0800

ACPI: Enable MSR (FixedHW) support for T-States

Add throttling control via MSR when T-states uses
the FixHW Control Status registers.

Signed-off-by: Zhao Yakui <yakui.zhao@intel.com>
Signed-off-by: Li Shaohua <shaohua.li@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>

Signed-off-by: Wei Gang <gang.wei@intel.com>
author Keir Fraser <keir.fraser@citrix.com>
date Mon Mar 02 10:53:59 2009 +0000 (2009-03-02)
parents 831230e53067
children
rev   line source
ian@0 1 #! /bin/sh
ian@0 2 # Script to apply kernel patches.
ian@0 3 # usage: patch-kernel [ sourcedir [ patchdir [ stopversion ] [ -acxx ] ] ]
ian@0 4 # The source directory defaults to /usr/src/linux, and the patch
ian@0 5 # directory defaults to the current directory.
ian@0 6 # e.g.
ian@0 7 # scripts/patch-kernel . ..
ian@0 8 # Update the kernel tree in the current directory using patches in the
ian@0 9 # directory above to the latest Linus kernel
ian@0 10 # scripts/patch-kernel . .. -ac
ian@0 11 # Get the latest Linux kernel and patch it with the latest ac patch
ian@0 12 # scripts/patch-kernel . .. 2.4.9
ian@0 13 # Gets standard kernel 2.4.9
ian@0 14 # scripts/patch-kernel . .. 2.4.9 -ac
ian@0 15 # Gets 2.4.9 with latest ac patches
ian@0 16 # scripts/patch-kernel . .. 2.4.9 -ac11
ian@0 17 # Gets 2.4.9 with ac patch ac11
ian@0 18 # Note: It uses the patches relative to the Linus kernels, not the
ian@0 19 # ac to ac relative patches
ian@0 20 #
ian@0 21 # It determines the current kernel version from the top-level Makefile.
ian@0 22 # It then looks for patches for the next sublevel in the patch directory.
ian@0 23 # This is applied using "patch -p1 -s" from within the kernel directory.
ian@0 24 # A check is then made for "*.rej" files to see if the patch was
ian@0 25 # successful. If it is, then all of the "*.orig" files are removed.
ian@0 26 #
ian@0 27 # Nick Holloway <Nick.Holloway@alfie.demon.co.uk>, 2nd January 1995.
ian@0 28 #
ian@0 29 # Added support for handling multiple types of compression. What includes
ian@0 30 # gzip, bzip, bzip2, zip, compress, and plaintext.
ian@0 31 #
ian@0 32 # Adam Sulmicki <adam@cfar.umd.edu>, 1st January 1997.
ian@0 33 #
ian@0 34 # Added ability to stop at a given version number
ian@0 35 # Put the full version number (i.e. 2.3.31) as the last parameter
ian@0 36 # Dave Gilbert <linux@treblig.org>, 11th December 1999.
ian@0 37
ian@0 38 # Fixed previous patch so that if we are already at the correct version
ian@0 39 # not to patch up.
ian@0 40 #
ian@0 41 # Added -ac option, use -ac or -ac9 (say) to stop at a particular version
ian@0 42 # Dave Gilbert <linux@treblig.org>, 29th September 2001.
ian@0 43 #
ian@0 44 # Add support for (use of) EXTRAVERSION (to support 2.6.8.x, e.g.);
ian@0 45 # update usage message;
ian@0 46 # fix some whitespace damage;
ian@0 47 # be smarter about stopping when current version is larger than requested;
ian@0 48 # Randy Dunlap <rdunlap@xenotime.net>, 2004-AUG-18.
ian@0 49 #
ian@0 50 # Add better support for (non-incremental) 2.6.x.y patches;
ian@0 51 # If an ending version number if not specified, the script automatically
ian@0 52 # increments the SUBLEVEL (x in 2.6.x.y) until no more patch files are found;
ian@0 53 # however, EXTRAVERSION (y in 2.6.x.y) is never automatically incremented
ian@0 54 # but must be specified fully.
ian@0 55 #
ian@0 56 # patch-kernel does not normally support reverse patching, but does so when
ian@0 57 # applying EXTRAVERSION (x.y) patches, so that moving from 2.6.11.y to 2.6.11.z
ian@0 58 # is easy and handled by the script (reverse 2.6.11.y and apply 2.6.11.z).
ian@0 59 # Randy Dunlap <rdunlap@xenotime.net>, 2005-APR-08.
ian@0 60
ian@0 61 PNAME=patch-kernel
ian@0 62
ian@0 63 # Set directories from arguments, or use defaults.
ian@0 64 sourcedir=${1-/usr/src/linux}
ian@0 65 patchdir=${2-.}
ian@0 66 stopvers=${3-default}
ian@0 67
ian@0 68 if [ "$1" == -h -o "$1" == --help -o ! -r "$sourcedir/Makefile" ]; then
ian@0 69 cat << USAGE
ian@0 70 usage: $PNAME [-h] [ sourcedir [ patchdir [ stopversion ] [ -acxx ] ] ]
ian@0 71 source directory defaults to /usr/src/linux,
ian@0 72 patch directory defaults to the current directory,
ian@0 73 stopversion defaults to <all in patchdir>.
ian@0 74 USAGE
ian@0 75 exit 1
ian@0 76 fi
ian@0 77
ian@0 78 # See if we have any -ac options
ian@0 79 for PARM in $*
ian@0 80 do
ian@0 81 case $PARM in
ian@0 82 -ac*)
ian@0 83 gotac=$PARM;
ian@0 84
ian@0 85 esac;
ian@0 86 done
ian@0 87
ian@0 88 # ---------------------------------------------------------------------------
ian@0 89 # arg1 is filename
ian@0 90 noFile () {
ian@0 91 echo "cannot find patch file: ${patch}"
ian@0 92 exit 1
ian@0 93 }
ian@0 94
ian@0 95 # ---------------------------------------------------------------------------
ian@0 96 backwards () {
ian@0 97 echo "$PNAME does not support reverse patching"
ian@0 98 exit 1
ian@0 99 }
ian@0 100
ian@0 101 # ---------------------------------------------------------------------------
ian@0 102 # Find a file, first parameter is basename of file
ian@0 103 # it tries many compression mechanisms and sets variables to say how to get it
ian@0 104 findFile () {
ian@0 105 filebase=$1;
ian@0 106
ian@0 107 if [ -r ${filebase}.gz ]; then
ian@0 108 ext=".gz"
ian@0 109 name="gzip"
ian@0 110 uncomp="gunzip -dc"
ian@0 111 elif [ -r ${filebase}.bz ]; then
ian@0 112 ext=".bz"
ian@0 113 name="bzip"
ian@0 114 uncomp="bunzip -dc"
ian@0 115 elif [ -r ${filebase}.bz2 ]; then
ian@0 116 ext=".bz2"
ian@0 117 name="bzip2"
ian@0 118 uncomp="bunzip2 -dc"
ian@0 119 elif [ -r ${filebase}.zip ]; then
ian@0 120 ext=".zip"
ian@0 121 name="zip"
ian@0 122 uncomp="unzip -d"
ian@0 123 elif [ -r ${filebase}.Z ]; then
ian@0 124 ext=".Z"
ian@0 125 name="uncompress"
ian@0 126 uncomp="uncompress -c"
ian@0 127 elif [ -r ${filebase} ]; then
ian@0 128 ext=""
ian@0 129 name="plaintext"
ian@0 130 uncomp="cat"
ian@0 131 else
ian@0 132 return 1;
ian@0 133 fi
ian@0 134
ian@0 135 return 0;
ian@0 136 }
ian@0 137
ian@0 138 # ---------------------------------------------------------------------------
ian@0 139 # Apply a patch and check it goes in cleanly
ian@0 140 # First param is patch name (e.g. patch-2.4.9-ac5) - without path or extension
ian@0 141
ian@0 142 applyPatch () {
ian@0 143 echo -n "Applying $1 (${name})... "
ian@0 144 if $uncomp ${patchdir}/$1${ext} | patch -p1 -s -N -E -d $sourcedir
ian@0 145 then
ian@0 146 echo "done."
ian@0 147 else
ian@0 148 echo "failed. Clean up yourself."
ian@0 149 return 1;
ian@0 150 fi
ian@0 151 if [ "`find $sourcedir/ '(' -name '*.rej' -o -name '.*.rej' ')' -print`" ]
ian@0 152 then
ian@0 153 echo "Aborting. Reject files found."
ian@0 154 return 1;
ian@0 155 fi
ian@0 156 # Remove backup files
ian@0 157 find $sourcedir/ '(' -name '*.orig' -o -name '.*.orig' ')' -exec rm -f {} \;
ian@0 158
ian@0 159 return 0;
ian@0 160 }
ian@0 161
ian@0 162 # ---------------------------------------------------------------------------
ian@0 163 # arg1 is patch filename
ian@0 164 reversePatch () {
ian@0 165 echo -n "Reversing $1 (${name}) ... "
ian@0 166 if $uncomp ${patchdir}/"$1"${ext} | patch -p1 -Rs -N -E -d $sourcedir
ian@0 167 then
ian@0 168 echo "done."
ian@0 169 else
ian@0 170 echo "failed. Clean it up."
ian@0 171 exit 1
ian@0 172 fi
ian@0 173 if [ "`find $sourcedir/ '(' -name '*.rej' -o -name '.*.rej' ')' -print`" ]
ian@0 174 then
ian@0 175 echo "Aborting. Reject files found."
ian@0 176 return 1
ian@0 177 fi
ian@0 178 # Remove backup files
ian@0 179 find $sourcedir/ '(' -name '*.orig' -o -name '.*.orig' ')' -exec rm -f {} \;
ian@0 180
ian@0 181 return 0
ian@0 182 }
ian@0 183
ian@0 184 # set current VERSION, PATCHLEVEL, SUBLEVEL, EXTRAVERSION
ian@0 185 TMPFILE=`mktemp .tmpver.XXXXXX` || { echo "cannot make temp file" ; exit 1; }
ian@0 186 grep -E "^(VERSION|PATCHLEVEL|SUBLEVEL|EXTRAVERSION)" $sourcedir/Makefile > $TMPFILE
ian@0 187 tr -d [:blank:] < $TMPFILE > $TMPFILE.1
ian@0 188 source $TMPFILE.1
ian@0 189 rm -f $TMPFILE*
ian@0 190 if [ -z "$VERSION" -o -z "$PATCHLEVEL" -o -z "$SUBLEVEL" ]
ian@0 191 then
ian@0 192 echo "unable to determine current kernel version" >&2
ian@0 193 exit 1
ian@0 194 fi
ian@0 195
ian@0 196 NAME=`grep ^NAME $sourcedir/Makefile`
ian@0 197 NAME=${NAME##*=}
ian@0 198
ian@0 199 echo "Current kernel version is $VERSION.$PATCHLEVEL.$SUBLEVEL${EXTRAVERSION} ($NAME)"
ian@0 200
ian@0 201 # strip EXTRAVERSION to just a number (drop leading '.' and trailing additions)
ian@0 202 EXTRAVER=
ian@0 203 if [ x$EXTRAVERSION != "x" ]
ian@0 204 then
ian@0 205 if [ ${EXTRAVERSION:0:1} == "." ]; then
ian@0 206 EXTRAVER=${EXTRAVERSION:1}
ian@0 207 else
ian@0 208 EXTRAVER=$EXTRAVERSION
ian@0 209 fi
ian@0 210 EXTRAVER=${EXTRAVER%%[[:punct:]]*}
ian@0 211 #echo "$PNAME: changing EXTRAVERSION from $EXTRAVERSION to $EXTRAVER"
ian@0 212 fi
ian@0 213
ian@0 214 #echo "stopvers=$stopvers"
ian@0 215 if [ $stopvers != "default" ]; then
ian@0 216 STOPSUBLEVEL=`echo $stopvers | cut -d. -f3`
ian@0 217 STOPEXTRA=`echo $stopvers | cut -d. -f4`
ian@0 218 #echo "#___STOPSUBLEVEL=/$STOPSUBLEVEL/, STOPEXTRA=/$STOPEXTRA/"
ian@0 219 else
ian@0 220 STOPSUBLEVEL=9999
ian@0 221 STOPEXTRA=9999
ian@0 222 fi
ian@0 223
ian@0 224 # This all assumes a 2.6.x[.y] kernel tree.
ian@0 225 # Don't allow backwards/reverse patching.
ian@0 226 if [ $STOPSUBLEVEL -lt $SUBLEVEL ]; then
ian@0 227 backwards
ian@0 228 fi
ian@0 229
ian@0 230 if [ x$EXTRAVER != "x" ]; then
ian@0 231 CURRENTFULLVERSION="$VERSION.$PATCHLEVEL.$SUBLEVEL.$EXTRAVER"
ian@0 232 else
ian@0 233 CURRENTFULLVERSION="$VERSION.$PATCHLEVEL.$SUBLEVEL"
ian@0 234 fi
ian@0 235
ian@0 236 if [ x$EXTRAVER != "x" ]; then
ian@0 237 echo "backing up to: $VERSION.$PATCHLEVEL.$SUBLEVEL"
ian@0 238 patch="patch-${CURRENTFULLVERSION}"
ian@0 239 findFile $patchdir/${patch} || noFile ${patch}
ian@0 240 reversePatch ${patch} || exit 1
ian@0 241 fi
ian@0 242
ian@0 243 # now current is 2.6.x, with no EXTRA applied,
ian@0 244 # so update to target SUBLEVEL (2.6.SUBLEVEL)
ian@0 245 # and then to target EXTRAVER (2.6.SUB.EXTRAVER) if requested.
ian@0 246 # If not ending sublevel is specified, it is incremented until
ian@0 247 # no further sublevels are found.
ian@0 248
ian@0 249 if [ $STOPSUBLEVEL -gt $SUBLEVEL ]; then
ian@0 250 while : # incrementing SUBLEVEL (s in v.p.s)
ian@0 251 do
ian@0 252 CURRENTFULLVERSION="$VERSION.$PATCHLEVEL.$SUBLEVEL"
ian@0 253 EXTRAVER=
ian@0 254 if [ $stopvers == $CURRENTFULLVERSION ]; then
ian@0 255 echo "Stopping at $CURRENTFULLVERSION base as requested."
ian@0 256 break
ian@0 257 fi
ian@0 258
ian@0 259 SUBLEVEL=$((SUBLEVEL + 1))
ian@0 260 FULLVERSION="$VERSION.$PATCHLEVEL.$SUBLEVEL"
ian@0 261 #echo "#___ trying $FULLVERSION ___"
ian@0 262
ian@0 263 if [ $((SUBLEVEL)) -gt $((STOPSUBLEVEL)) ]; then
ian@0 264 echo "Stopping since sublevel ($SUBLEVEL) is beyond stop-sublevel ($STOPSUBLEVEL)"
ian@0 265 exit 1
ian@0 266 fi
ian@0 267
ian@0 268 patch=patch-$FULLVERSION
ian@0 269 # See if the file exists and find extension
ian@0 270 findFile $patchdir/${patch} || noFile ${patch}
ian@0 271
ian@0 272 # Apply the patch and check all is OK
ian@0 273 applyPatch $patch || break
ian@0 274 done
ian@0 275 #echo "#___sublevel all done"
ian@0 276 fi
ian@0 277
ian@0 278 # There is no incremental searching for extraversion...
ian@0 279 if [ "$STOPEXTRA" != "" ]; then
ian@0 280 while : # just to allow break
ian@0 281 do
ian@0 282 # apply STOPEXTRA directly (not incrementally) (x in v.p.s.x)
ian@0 283 FULLVERSION="$VERSION.$PATCHLEVEL.$SUBLEVEL.$STOPEXTRA"
ian@0 284 #echo "#... trying $FULLVERSION ..."
ian@0 285 patch=patch-$FULLVERSION
ian@0 286
ian@0 287 # See if the file exists and find extension
ian@0 288 findFile $patchdir/${patch} || noFile ${patch}
ian@0 289
ian@0 290 # Apply the patch and check all is OK
ian@0 291 applyPatch $patch || break
ian@0 292 #echo "#___extraver all done"
ian@0 293 break
ian@0 294 done
ian@0 295 fi
ian@0 296
ian@0 297 if [ x$gotac != x ]; then
ian@0 298 # Out great user wants the -ac patches
ian@0 299 # They could have done -ac (get latest) or -acxx where xx=version they want
ian@0 300 if [ $gotac == "-ac" ]; then
ian@0 301 # They want the latest version
ian@0 302 HIGHESTPATCH=0
ian@0 303 for PATCHNAMES in $patchdir/patch-${CURRENTFULLVERSION}-ac*\.*
ian@0 304 do
ian@0 305 ACVALUE=`echo $PATCHNAMES | sed -e 's/^.*patch-[0-9.]*-ac\([0-9]*\).*/\1/'`
ian@0 306 # Check it is actually a recognised patch type
ian@0 307 findFile $patchdir/patch-${CURRENTFULLVERSION}-ac${ACVALUE} || break
ian@0 308
ian@0 309 if [ $ACVALUE -gt $HIGHESTPATCH ]; then
ian@0 310 HIGHESTPATCH=$ACVALUE
ian@0 311 fi
ian@0 312 done
ian@0 313
ian@0 314 if [ $HIGHESTPATCH -ne 0 ]; then
ian@0 315 findFile $patchdir/patch-${CURRENTFULLVERSION}-ac${HIGHESTPATCH} || break
ian@0 316 applyPatch patch-${CURRENTFULLVERSION}-ac${HIGHESTPATCH}
ian@0 317 else
ian@0 318 echo "No -ac patches found"
ian@0 319 fi
ian@0 320 else
ian@0 321 # They want an exact version
ian@0 322 findFile $patchdir/patch-${CURRENTFULLVERSION}${gotac} || {
ian@0 323 echo "Sorry, I couldn't find the $gotac patch for $CURRENTFULLVERSION. Hohum."
ian@0 324 exit 1
ian@0 325 }
ian@0 326 applyPatch patch-${CURRENTFULLVERSION}${gotac}
ian@0 327 fi
ian@0 328 fi