]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blob - src/initscripts/packages/cpufreq
beee532b5009981faf03f7e75339e7096c731a31
[people/pmueller/ipfire-2.x.git] / src / initscripts / packages / cpufreq
1 #!/bin/sh
2 ###############################################################################
3 # #
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2007-2022 IPFire Team <info@ipfire.org> #
6 # #
7 # This program is free software: you can redistribute it and/or modify #
8 # it under the terms of the GNU General Public License as published by #
9 # the Free Software Foundation, either version 3 of the License, or #
10 # (at your option) any later version. #
11 # #
12 # This program is distributed in the hope that it will be useful, #
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15 # GNU General Public License for more details. #
16 # #
17 # You should have received a copy of the GNU General Public License #
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
19 # #
20 ###############################################################################
21
22 . /etc/sysconfig/rc
23 . ${rc_functions}
24
25 case "${1}" in
26 start)
27 boot_mesg -n "Starting cpufreq... "
28
29 # try cpufreq hardware depend modules
30 for i in $(find /lib/modules/$(uname -r)/kernel/drivers/cpufreq \
31 ! -name speedstep-lib.ko.xz ! -name p4-clockmod.ko.xz ! -name "cpufreq_*" ! -name mperf.ko.xz | sort -d -r); do
32 module=$(basename $i | cut -d. -f1);
33 modprobe $module > /dev/null 2>&1;
34 if [ ${?} = 0 ]; then
35 boot_mesg -n "$SUCCESS$module$NORMAL "
36 fi
37 done
38 boot_mesg ""
39
40 # load cqufreq governors
41 modprobe cpufreq_conservative
42 modprobe cpufreq_ondemand
43 modprobe cpufreq_powersave
44 modprobe cpufreq_userspace
45
46 driver=`cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_driver 2>/dev/null`
47
48 case "$driver" in
49 intel_pstate)
50 # pstate use internal gov so skip this setting
51 echo_ok;
52 ;;
53 *)
54 CPUCOUNT=`ls /sys/devices/system/cpu/cpu*/cpufreq/affected_cpus 2> /dev/null | wc -l `;
55 let CPUCOUNT-=1
56 # Set the governor to ondemand to test if it works
57 cpufreq-set -g ondemand
58 if [ ${?} = 0 ]; then
59 # Set the governor to ondemand for all cpus
60 for i in `seq 0 $CPUCOUNT`;
61 do
62 cpufreq-set -c $i -g ondemand
63 done
64 echo_ok;
65 else
66 echo_failure;
67 fi
68 ;;
69 esac
70 exit 0;
71 ;;
72 *)
73 echo "Usage: ${0} {start}"
74 exit 1
75 ;;
76 esac