mirror of
https://github.com/ARM-software/devlib.git
synced 2025-01-31 02:00:45 +00:00
module/cpufreq: Warn when cpuinfo doesn't reflect the cpufreq request
The cpufreq/scaling_* files reflect the policy configuration from a kernel point of view. The actual frequency at which the CPU is running can be found in cpuinfo_cur_freq. Warn when the requested frequency does not match the actual one. As the kernel does not provide any guarantee that the requested frequency will be actually used (due to other part of the system such as thermal or the firmware), printing a warning instead of raising an error seems more suitable here.
This commit is contained in:
parent
d14df074ee
commit
bbc891341c
@ -301,7 +301,7 @@ class CpufreqModule(Module):
|
||||
except ValueError:
|
||||
raise ValueError('Frequency must be an integer; got: "{}"'.format(frequency))
|
||||
|
||||
def get_frequency(self, cpu):
|
||||
def get_frequency(self, cpu, cpuinfo=False):
|
||||
"""
|
||||
Returns the current frequency currently set for the specified CPU.
|
||||
|
||||
@ -309,12 +309,18 @@ class CpufreqModule(Module):
|
||||
try to read the current frequency and the following exception will be
|
||||
raised ::
|
||||
|
||||
:param cpuinfo: Read the value in the cpuinfo interface that reflects
|
||||
the actual running frequency.
|
||||
|
||||
:raises: TargetStableError if for some reason the frequency could not be read.
|
||||
|
||||
"""
|
||||
if isinstance(cpu, int):
|
||||
cpu = 'cpu{}'.format(cpu)
|
||||
sysfile = '/sys/devices/system/cpu/{}/cpufreq/scaling_cur_freq'.format(cpu)
|
||||
|
||||
sysfile = '/sys/devices/system/cpu/{}/cpufreq/{}'.format(
|
||||
cpu,
|
||||
'cpuinfo_cur_freq' if cpuinfo else 'scaling_cur_freq')
|
||||
return self.target.read_int(sysfile)
|
||||
|
||||
def set_frequency(self, cpu, frequency, exact=True):
|
||||
@ -350,6 +356,10 @@ class CpufreqModule(Module):
|
||||
raise TargetStableError('Can\'t set {} frequency; governor must be "userspace"'.format(cpu))
|
||||
sysfile = '/sys/devices/system/cpu/{}/cpufreq/scaling_setspeed'.format(cpu)
|
||||
self.target.write_value(sysfile, value, verify=False)
|
||||
cpuinfo = self.get_frequency(cpu, cpuinfo=True)
|
||||
if cpuinfo != value:
|
||||
self.logger.warning(
|
||||
'The cpufreq value has not been applied properly cpuinfo={} request={}'.format(cpuinfo, value))
|
||||
except ValueError:
|
||||
raise ValueError('Frequency must be an integer; got: "{}"'.format(frequency))
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user