]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blame - src/initscripts/packages/cpufreq
cpufrequtils: fix initskript for amd-pstate
[people/pmueller/ipfire-2.x.git] / src / initscripts / packages / cpufreq
CommitLineData
d2c65e37 1#!/bin/sh
66c36198
PM
2###############################################################################
3# #
4# IPFire.org - A linux based firewall #
51fd73ea 5# Copyright (C) 2007-2024 IPFire Team <info@ipfire.org> #
66c36198
PM
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###############################################################################
d2c65e37
AF
21
22. /etc/sysconfig/rc
23. ${rc_functions}
24
51fd73ea
AF
25GOV="ondemand"
26
d2c65e37
AF
27case "${1}" in
28 start)
06391e6d 29 boot_mesg -n "Starting cpufreq... "
a041a28d 30
4f3651e6 31 # try cpufreq hardware depend modules
ceffe9bd 32 for i in $(find /lib/modules/$(uname -r)/kernel/drivers/cpufreq \
51fd73ea 33 ! -name speedstep-lib.ko.xz ! -name p4-clockmod.ko.xz ! -name amd-pstate* ! -name "cpufreq_*" ! -name mperf.ko.xz | sort -d -r); do
03755188
AF
34 module=$(basename $i | cut -d. -f1);
35 modprobe $module > /dev/null 2>&1;
36 if [ ${?} = 0 ]; then
37 boot_mesg -n "$SUCCESS$module$NORMAL "
38 fi
a041a28d
AF
39 done
40 boot_mesg ""
4f3651e6 41
d2c65e37
AF
42 # load cqufreq governors
43 modprobe cpufreq_conservative
44 modprobe cpufreq_ondemand
45 modprobe cpufreq_powersave
46 modprobe cpufreq_userspace
47
1f182999 48 driver=`cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_driver 2>/dev/null`
341a7082 49
1f182999 50 case "$driver" in
51fd73ea
AF
51 *pstate*)
52 # pstate not support ondemand so use powersave
53 GOV="powersave"
1f182999
AF
54 echo_ok;
55 ;;
51fd73ea
AF
56 esac
57 CPUCOUNT=`ls /sys/devices/system/cpu/cpu*/cpufreq/affected_cpus 2> /dev/null | wc -l `;
58 let CPUCOUNT-=1
59 # Set the governor to test if it works
60 cpufreq-set -g $GOV
61 if [ ${?} = 0 ]; then
62 # Set the governor to ondemand for all cpus
63 for i in `seq 0 $CPUCOUNT`;
64 do
65 cpufreq-set -c $i -g $GOV
66 done
67 echo_ok;
68 else
69 echo_failure;
70 fi
71 exit 0
d2c65e37
AF
72 ;;
73 *)
74 echo "Usage: ${0} {start}"
75 exit 1
76 ;;
77esac