From 4dcb4974e5cc1700bd1e410d85b85beff1ebe3dd Mon Sep 17 00:00:00 2001 From: Patrick Bellasi Date: Wed, 16 Sep 2015 18:03:04 +0100 Subject: [PATCH] cpufreq: add methods to set the governor for a specified set of CPUs Sometimes it could be required to change the governor for a set of different CPUs. This patch provides an utility method to easily and achieve that with a single method call. Signed-off-by: Patrick Bellasi --- devlib/module/cpufreq.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/devlib/module/cpufreq.py b/devlib/module/cpufreq.py index a41cff2..37c49dc 100644 --- a/devlib/module/cpufreq.py +++ b/devlib/module/cpufreq.py @@ -326,3 +326,26 @@ class CpufreqModule(Module): self.target.write_value(sysfile, value) except ValueError: raise ValueError('Frequency must be an integer; got: "{}"'.format(frequency)) + + def set_governor_for_cpus(self, cpus, governor, **kwargs): + """ + Set the governor for the specified list of CPUs. + See https://www.kernel.org/doc/Documentation/cpu-freq/governors.txt + + :param cpus: The list of CPU for which the governor is to be set. + """ + online_cpus = self.target.list_online_cpus() + for cpu in online_cpus: + self.set_governor(cpu, governor, kwargs) + + def set_frequency_for_cpus(self, cpus, freq, exact=False): + """ + Set the frequency for the specified list of CPUs. + See https://www.kernel.org/doc/Documentation/cpu-freq/governors.txt + + :param cpus: The list of CPU for which the frequency has to be set. + """ + online_cpus = self.target.list_online_cpus() + for cpu in online_cpus: + self.set_frequency(cpu, freq, exact) +