From b598b38f125cf84a501f9c1ec58938b29a36f7a9 Mon Sep 17 00:00:00 2001 From: Patrick Bellasi Date: Thu, 17 Sep 2015 17:39:32 +0100 Subject: [PATCH] cpufreq: add methods to configure all CPUs at once Sometimes it could be required to change governor or frequency for a all the online CPUs of a target. This patch provides an utility method to easily do that using a single method call. Signed-off-by: Patrick Bellasi --- devlib/module/cpufreq.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/devlib/module/cpufreq.py b/devlib/module/cpufreq.py index 37c49dc..f4386ad 100644 --- a/devlib/module/cpufreq.py +++ b/devlib/module/cpufreq.py @@ -349,3 +349,17 @@ class CpufreqModule(Module): for cpu in online_cpus: self.set_frequency(cpu, freq, exact) + def set_all_frequencies(self, freq, exact=False): + self.target.execute( + "for CPU in /sys/devices/system/cpu/cpu[0-9]*; do "\ + "echo {} > $CPU/cpufreq/scaling_cur_freq; "\ + "done"\ + .format(freq), as_root=True) + + def set_all_governors(self, governor): + self.target.execute( + "for CPU in /sys/devices/system/cpu/cpu[0-9]*; do "\ + "echo {} > $CPU/cpufreq/scaling_governor; "\ + "done"\ + .format(governor), as_root=True) +