--- Begin Message ---
- To: Debian Bug Tracking System <submit@bugs.debian.org>
- Subject: powernowd: Powernowd should automatically load the right kernel modules
- From: Raphael Hertzog <hertzog@debian.org>
- Date: Sun, 14 May 2006 18:03:09 -0500
- Message-id: <20060514230309.31132.43950.reportbug@localhost>
Package: powernowd
Version: 0.97-1
Severity: wishlist
Tags: patch
Hi Bdale,
Ubuntu has some interesting changes to the powernowd package:
http://people.ubuntu.com/~scott/patches/powernowd/powernowd_0.96-2ubuntu2_packaging.patch
They add a script detecting the CPU type and automatically loading the
right cpufreq_ module. This is the kind of changes that make Ubuntu "just
work" that we should really integrate back. Please consider this.
Cheers,
-- System Information:
Debian Release: testing/unstable
APT prefers testing
APT policy: (990, 'testing'), (500, 'unstable')
Architecture: i386 (i686)
Shell: /bin/sh linked to /bin/bash
Kernel: Linux 2.6.15-1-686
Locale: LANG=fr_FR.UTF-8, LC_CTYPE=fr_FR.UTF-8 (charmap=UTF-8)
Versions of packages powernowd depends on:
ii libc6 2.3.6-7 GNU C Library: Shared libraries
powernowd recommends no packages.
-- no debconf information
diff -pruN powernowd_0.96-1/debian/control powernowd_0.96-2ubuntu2/debian/control
--- powernowd_0.96-1/debian/control 2005-12-06 13:32:44.000000000 +0000
+++ powernowd_0.96-2ubuntu2/debian/control 2006-02-24 14:29:09.000000000 +0000
@@ -7,8 +7,7 @@
Package: powernowd
Architecture: any
-Depends: ${shlibs:Depends}
-Conflicts: cpudyn, cpufreqd
+Depends: ${shlibs:Depends}, lsb-base (>= 1.3-9ubuntu2), module-init-tools (>=3.1-rel-2ubuntu2), laptop-detect
Description: control cpu speed and voltage using 2.6 kernel interface
This simple client controls CPU speed and voltage using the sysfs interface
to the CPUFreq driver in v2.6 Linux kernels. It does not depend on APM or
diff -pruN powernowd_0.96-1/debian/cpufreq-detect.sh powernowd_0.96-2ubuntu2/debian/cpufreq-detect.sh
--- powernowd_0.96-1/debian/cpufreq-detect.sh 1970-01-01 01:00:00.000000000 +0100
+++ powernowd_0.96-2ubuntu2/debian/cpufreq-detect.sh 2006-02-24 14:29:09.000000000 +0000
@@ -0,0 +1,94 @@
+#! /bin/bash
+
+if /usr/sbin/laptop-detect; then LAPTOP=1; fi
+CPUINFO=/proc/cpuinfo
+IOPORTS=/proc/ioports
+
+if [ ! -f $CPUINFO ] ; then
+ echo $CPUINFO not detected... >2
+ exit 1
+fi
+
+MODEL_NAME=`grep '^model name' "$CPUINFO" | head -1 | sed -e 's/^.*: //;'`
+CPU=`grep -E '^cpud[^:]+:' "$CPUINFO" | head -1 | sed -e 's/^.*: //;'`
+VENDOR_ID=`grep -E '^vendor_id[^:]+:' "$CPUINFO" | head -1 | sed -e 's/^.*: //;'`
+CPU_FAMILY=$(sed -e '/^cpu family/ {s/.*: //;p;Q};d' $CPUINFO)
+
+MODULE=none
+MODULE_FALLBACK=acpi-cpufreq
+
+# Two modules for PIII-M depending the chipset.
+# modprobe speedstep-ich$EXT || modprobe speestep-smi$EXT would be another way
+if [ -f $IOPORTS ] && grep -q 'Intel .*ICH' $IOPORTS ; then
+ PIII_MODULE=speedstep-ich
+else
+ PIII_MODULE=speedstep-smi
+fi
+
+case "$VENDOR_ID" in
+ GenuineIntel*)
+ # If the CPU has the est flag, it supports enhanced speedstep and should
+ # use the speedstep-centrino driver
+ if [ "`grep est $CPUINFO`" ]; then
+ MODULE=speedstep-centrino;
+ elif [ $CPU_FAMILY = 15 ]; then
+ # Right. Check if it's a P4 without est.
+ # Could be speedstep-ich, or could be p4-clockmod.
+ MODULE=speedstep-ich;
+ # Disabled for now - the latency tends to be bad enough to make it
+ # fairly pointless.
+ # echo "FREQDRIVER=p4-clockmod" >/etc/default/powernowd
+ # to override this
+# if [ $LAPTOP = "1" ]; then
+# MODULE_FALLBACK=p4-clockmod;
+# fi
+ else
+ # So it doesn't have Enhanced Speedstep, and it's not a P4. It could be
+ # a Speedstep PIII, or it may be unsupported. There's no terribly good
+ # programmatic way of telling.
+ case "$MODEL_NAME" in
+ Intel\(R\)\ Pentium\(R\)\ III\ Mobile\ CPU*)
+ MODULE=$PIII_MODULE ;;
+
+ # JD: says this works with cpufreq_userspace
+ Mobile\ Intel\(R\)\ Pentium\(R\)\ III\ CPU\ -\ M*)
+ MODULE=$PIII_MODULE ;;
+
+ # https://bugzilla.ubuntu.com/show_bug.cgi?id=4262
+ # UNCONFIRMED
+ Pentium\ III\ \(Coppermine\)*)
+ MODULE=$PIII_MODULE
+ ;;
+ esac
+ fi
+ ;;
+ AuthenticAMD*)
+ # Hurrah. This is nice and easy.
+ case $CPU_FAMILY in
+ 5)
+ # K6
+ MODULE=powernow-k6
+ ;;
+ 6)
+ # K7
+ MODULE=powernow-k7
+ ;;
+ 15)
+ # K8
+ MODULE=powernow-k8
+ ;;
+ esac
+ ;;
+ CentaurHauls*)
+ # VIA
+ if [ $CPU_FAMILY == 6 ]; then
+ MODULE=longhaul;
+ fi
+ ;;
+ GenuineTMx86*)
+ # Transmeta
+ if [ "`grep longrun $CPUINFO`" ]; then
+ MODULE=longrun
+ fi
+ ;;
+esac
diff -pruN powernowd_0.96-1/debian/dirs powernowd_0.96-2ubuntu2/debian/dirs
--- powernowd_0.96-1/debian/dirs 2005-12-06 13:32:44.000000000 +0000
+++ powernowd_0.96-2ubuntu2/debian/dirs 2006-02-24 14:29:09.000000000 +0000
@@ -1 +1,2 @@
usr/sbin
+usr/share/powernowd
diff -pruN powernowd_0.96-1/debian/init.d powernowd_0.96-2ubuntu2/debian/init.d
--- powernowd_0.96-1/debian/init.d 2005-12-06 13:32:44.000000000 +0000
+++ powernowd_0.96-2ubuntu2/debian/init.d 2006-02-24 14:29:09.000000000 +0000
@@ -13,36 +13,122 @@
OPTIONS="-q"
[ -f /etc/default/$NAME ] && . /etc/default/$NAME
+# Get lsb functions
+. /lib/lsb/init-functions
+. /etc/default/rcS
+
+if [ "x$VERBOSE" = "xno" ]; then
+ MODPROBE_OPTIONS="$MODPROBE_OPTIONS -Q"
+ export MODPROBE_OPTIONS
+fi
+
set -e
-case "$1" in
- start)
- echo -n "Starting $DESC: "
- if [ -f /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor ]
+load_modules() {
+ #stop the kernel printk'ing at all while we load.
+ PRINTK=`cat /proc/sys/kernel/printk`
+ [ "$VERBOSE" = no ] && echo "0 0 0 0" > /proc/sys/kernel/printk
+
+ #build a list of current modules so we don't load a module twice
+ LIST=`/sbin/lsmod|awk '!/Module/ {print $1}'`
+
+ #get list of available modules
+ LOC="/lib/modules/`uname -r`/kernel/drivers/cpufreq"
+ if [ -d $LOC ]; then
+ MODAVAIL=`( find $LOC -type f -name "*.o" -printf "basename %f .o\n"; \
+ find $LOC -type f -name "*.ko" -printf "basename %f .ko\n" ) | /bin/sh`
+ else
+ MODAVAIL=""
+ fi
+
+
+ #echo "Loading cpufreq modules:"
+ for mod in $MODAVAIL; do
+ # echo " $mod"
+ echo $LIST| grep -q -w "$mod" || modprobe $mod >/dev/null || /bin/true
+ done
+
+ #cpufreq is built in on powerpc; just return
+ if [ "`uname -m`" = "ppc" ]; then
+ return 0
+ fi
+
+
+ #new style detection system
+ if [ ! "$FREQDRIVER" = "" ]; then
+ modprobe "$FREQDRIVER"
+ else
+ . /usr/share/powernowd/cpufreq-detect.sh
+ [ ! -z "$MODULE" ] && (modprobe "$MODULE"||modprobe "$MODULE_FALLBACK")
+ fi
+
+ if [ "$USE_OLD_DETECT" = "fish" ]; then
+ # now lets load the driver
+ if [ ! $FREQDRIVER = "" ]; then
+ modprobe $FREQDRIVER||true
+ fi
+ if [ "`uname -m`" = "x86_64" ]; then
+ modprobe powernow-k8 >/dev/null 2>&1||true
+ fi
+
+ if [ ! -f /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor ]; then
+ modprobe acpi > /dev/null 2>&1|| true
+ fi
+ fi
+ echo "$PRINTK" > /proc/sys/kernel/printk
+}
+
+check_kernel() {
+ CPUFREQ=/sys/devices/system/cpu/cpu0/cpufreq
+
+ if [ -f "$CPUFREQ/scaling_governor" ] && \
+ [ -f "$CPUFREQ/scaling_available_governors" ] && \
+ grep -q userspace "$CPUFREQ/scaling_available_governors"
+ then
+ return 0
+ else
+ return 1
+ fi
+}
+
+start() {
+ log_begin_msg "Starting $DESC... "
+ if check_kernel
then
- start-stop-daemon --start --quiet --oknodo --exec $DAEMON -- $OPTIONS
+ # echo "Starting $DESC: "
+ start-stop-daemon --start --quiet --oknodo --exec $DAEMON -- $OPTIONS >/dev/null 2>&1 || {
+ status=$?
+ log_end_msg $status
+ return $status
+ }
else
- echo "required sysfs objects not found!"
- echo -e "\tRead /usr/share/doc/powernowd/README.Debian for more information."
- exit 0
+ log_success_msg "CPU frequency scaling not supported"
+ # echo "required sysfs objects not found!"
+ # echo -e "\tRead /usr/share/doc/powernowd/README.Debian for more information."
fi
- echo "$NAME."
+ log_end_msg 0
+ return 0
+}
+
+case "$1" in
+ start)
+ [ "x$DO_MODULES" = "xyes" -a -f /proc/modules ] && load_modules
+ [ "x$DO_MODULES" = "xyes" ] || start
;;
stop)
- echo -n "Stopping $DESC: "
+ log_begin_msg "Stopping $DESC: "
start-stop-daemon --stop --quiet --oknodo --exec $DAEMON
- echo "$NAME."
+ log_end_msg $?
;;
restart|force-reload)
- echo -n "Restarting $DESC: "
- start-stop-daemon --stop --quiet --oknodo --exec $DAEMON
+ $0 stop
sleep 1
- start-stop-daemon --start --quiet --oknodo --exec $DAEMON -- $OPTIONS
- echo "$NAME."
+ $0 start
+ #echo "$NAME."
;;
*)
N=/etc/init.d/$NAME
- echo "Usage: $N {start|stop|restart|force-reload}" >&2
+ log_success_msg "Usage: $N {start|stop|restart|force-reload}" >&2
exit 1
;;
esac
diff -pruN powernowd_0.96-1/debian/init.d.early powernowd_0.96-2ubuntu2/debian/init.d.early
--- powernowd_0.96-1/debian/init.d.early 1970-01-01 01:00:00.000000000 +0100
+++ powernowd_0.96-2ubuntu2/debian/init.d.early 2006-02-24 14:29:09.000000000 +0000
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+# Set DO_MODULES to yes which will trigger the module loading part of the
+# powernowd init script instead of the daemon part.
+
+DO_MODULES=yes
+. /etc/init.d/powernowd
diff -pruN powernowd_0.96-1/debian/postinst powernowd_0.96-2ubuntu2/debian/postinst
--- powernowd_0.96-1/debian/postinst 1970-01-01 01:00:00.000000000 +0100
+++ powernowd_0.96-2ubuntu2/debian/postinst 2006-02-24 14:29:09.000000000 +0000
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+if [ -x "/etc/init.d/powernowd.early" ]; then
+ update-rc.d powernowd.early start 10 2 . >/dev/null
+ if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then
+ invoke-rc.d powernowd.early start || exit 0
+ else
+ /etc/init.d/powernowd.early start || exit 0
+ fi
+fi
+
+##DEBHELPER##
diff -pruN powernowd_0.96-1/debian/postrm powernowd_0.96-2ubuntu2/debian/postrm
--- powernowd_0.96-1/debian/postrm 1970-01-01 01:00:00.000000000 +0100
+++ powernowd_0.96-2ubuntu2/debian/postrm 2006-02-24 14:29:09.000000000 +0000
@@ -0,0 +1,10 @@
+#!/bin/sh
+set -e
+
+if [ "$1" = "purge" ] ; then
+ update-rc.d powernowd.early remove >/dev/null || exit 0
+fi
+
+##DEBHELPER##
+
+
diff -pruN powernowd_0.96-1/debian/rules powernowd_0.96-2ubuntu2/debian/rules
--- powernowd_0.96-1/debian/rules 2005-12-06 13:32:44.000000000 +0000
+++ powernowd_0.96-2ubuntu2/debian/rules 2006-02-24 14:29:09.000000000 +0000
@@ -26,6 +26,12 @@
# Add here commands to install the package into debian/powernowd.
install -o root -g root -m 0755 powernowd \
debian/powernowd/usr/sbin/powernowd
+ install -o root -g root -m 0755 debian/cpufreq-detect.sh \
+ debian/powernowd/usr/share/powernowd/cpufreq-detect.sh
+
+ mkdir -p debian/powernowd/etc/init.d
+ install -o root -g root -m 0755 debian/init.d.early \
+ debian/powernowd/etc/init.d/powernowd.early
# Build architecture-independent files here.
binary-indep: build install
--- End Message ---