1
0
mirror of https://github.com/ARM-software/devlib.git synced 2025-01-31 02:00:45 +00:00

cpufreq: switch to usage of shutils functions

This patch convert some functions to the usage of shutils provided calls.
This approach is more portable and allows to use these calls also on
an Android target.

Signed-off-by: Patrick Bellasi <patrick.bellasi@arm.com>
This commit is contained in:
Patrick Bellasi 2015-11-27 16:38:30 +00:00
parent f2eac51c69
commit cf761317bd
2 changed files with 50 additions and 19 deletions

View File

@ -7,12 +7,46 @@ BUSYBOX=${BUSYBOX:-__DEVLIB_BUSYBOX__}
GREP=${GREP:-$BUSYBOX grep} GREP=${GREP:-$BUSYBOX grep}
SED=${SED:-$BUSYBOX sed} SED=${SED:-$BUSYBOX sed}
################################################################################
# CPUFrequency Utility Functions
################################################################################
cpufreq_set_all_frequencies() {
FREQ=$1
for CPU in /sys/devices/system/cpu/cpu[0-9]*; do
echo $FREQ > $CPU/cpufreq/scaling_cur_freq
done
}
cpufreq_set_all_governors() {
GOV=$1
for CPU in /sys/devices/system/cpu/cpu[0-9]*; do
echo $GOV > $CPU/cpufreq/scaling_governor
done
}
cpufreq_trace_all_frequencies() {
FREQS=$(cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_cur_freq)
CPU=0; for F in $FREQS; do
echo "cpu_frequency: state=$F cpu_id=$CPU" > /sys/kernel/debug/tracing/trace_marker
CPU=$((CPU + 1))
done
}
################################################################################ ################################################################################
# Main Function Dispatcher # Main Function Dispatcher
################################################################################ ################################################################################
case $CMD in case $CMD in
cpufreq_set_all_frequencies)
cpufreq_set_all_frequencies $*
;;
cpufreq_set_all_governors)
cpufreq_set_all_governors $*
;;
cpufreq_trace_all_frequencies)
cpufreq_trace_all_frequencies $*
;;
*) *)
echo "Command [$CMD] not supported" echo "Command [$CMD] not supported"
exit -1 exit -1

View File

@ -349,30 +349,27 @@ class CpufreqModule(Module):
for cpu in online_cpus: for cpu in online_cpus:
self.set_frequency(cpu, freq, exact) self.set_frequency(cpu, freq, exact)
def set_all_frequencies(self, freq, exact=False): def set_all_frequencies(self, freq):
self.target.execute( """
"for CPU in /sys/devices/system/cpu/cpu[0-9]*; do "\ Set the specified (minimum) frequency for all the (online) CPUs
"echo {} > $CPU/cpufreq/scaling_cur_freq; "\ """
"done"\ return self.target._execute_util(
.format(freq), as_root=True) 'cpufreq_set_all_frequencies {}'.format(freq),
as_root=True)
def set_all_governors(self, governor): def set_all_governors(self, governor):
self.target.execute( """
"for CPU in /sys/devices/system/cpu/cpu[0-9]*; do "\ Set the specified governor for all the (online) CPUs
"echo {} > $CPU/cpufreq/scaling_governor; "\ """
"done"\ return self.target._execute_util(
.format(governor), as_root=True) 'cpufreq_set_all_governors {}'.format(governor),
as_root=True)
def trace_frequencies(self): def trace_frequencies(self):
""" """
Report current frequencies on trace file Report current frequencies on trace file
""" """
self.target.execute( return self.target._execute_util('cpufreq_trace_all_frequencies', as_root=True)
'FREQS=$(cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_cur_freq); '
'CPU=0; for F in $FREQS; do '
' echo "cpu_frequency: state=$F cpu_id=$CPU" > /sys/kernel/debug/tracing/trace_marker; '
' let CPU++; '
'done',
as_root=True
)