]> git.ipfire.org Git - ipfire-2.x.git/blob - src/initscripts/packages/cpufreq
motion: move initscript to src/initscripts/packages and use new macro
[ipfire-2.x.git] / src / initscripts / packages / cpufreq
1 #!/bin/sh
2 ########################################################################
3 # Begin $rc_base/init.d/cpufreq
4 #
5 # Description : Initalisize and startup cpufreq and set a governor
6 #
7 # Authors : Arne Fitzenreiter - arne_f@ipfire.org
8 #
9 # Version : 01.01
10 #
11 # Notes :
12 #
13 ########################################################################
14
15 . /etc/sysconfig/rc
16 . ${rc_functions}
17
18 case "${1}" in
19 start)
20 boot_mesg -n "Starting cpufreq... "
21
22 # try cpufreq hardware depend modules
23 for i in $(find /lib/modules/$(uname -r)/kernel/drivers/cpufreq \
24 ! -name speedstep-lib.ko ! -name p4-clockmod.ko ! -name "cpufreq_*" ! -name mperf.ko | sort -d -r); do
25 module=$(basename $i | cut -d. -f1);
26 modprobe $module > /dev/null 2>&1;
27 if [ ${?} = 0 ]; then
28 boot_mesg -n "$SUCCESS$module$NORMAL "
29 fi
30 done
31 boot_mesg ""
32
33 # load cqufreq governors
34 modprobe cpufreq_conservative
35 modprobe cpufreq_ondemand
36 modprobe cpufreq_powersave
37 modprobe cpufreq_userspace
38
39 driver=`cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_driver 2>/dev/null`
40
41 case "$driver" in
42 intel_pstate)
43 # pstate use internal gov so skip this setting
44 # activate cpufreq collectd module
45 sed -i -e "s|^#LoadPlugin cpufreq|LoadPlugin cpufreq|g" /etc/collectd.conf
46 echo_ok;
47 ;;
48 *)
49 CPUCOUNT=`ls /sys/devices/system/cpu/cpu*/cpufreq/affected_cpus 2> /dev/null | wc -l `;
50 let CPUCOUNT-=1
51 # Set the governor to ondemand to test if it works
52 cpufreq-set -g ondemand
53 if [ ${?} = 0 ]; then
54 # activate cpufreq collectd module
55 sed -i -e "s|^#LoadPlugin cpufreq|LoadPlugin cpufreq|g" /etc/collectd.conf
56
57 # Set the governor to ondemand for all cpus
58 for i in `seq 0 $CPUCOUNT`;
59 do
60 cpufreq-set -c $i -g ondemand
61 done
62 echo_ok;
63 else
64 echo_failure;
65 fi
66 ;;
67 esac
68 exit 0;
69 ;;
70 *)
71 echo "Usage: ${0} {start}"
72 exit 1
73 ;;
74 esac
75
76 # End $rc_base/init.d/cpufreq
77
78