1
0
mirror of https://github.com/ARM-software/workload-automation.git synced 2025-01-19 12:24:32 +00:00

framework/target: fix generic "frequency" runtime param

The generic "frequency" runtime parameter was only being set when there
are common frequences between avialable cores. It should always be set,
even if there are no frequencies in common, as it still valid to use it
with special values "min" and "max", in which case it should resolve
correctly to the appropriate frequencies.
This commit is contained in:
Sergei Trofimov 2017-10-11 17:10:50 +01:00
parent ccaeb5a142
commit 4826f8f2f2

View File

@ -1,5 +1,6 @@
import logging import logging
from collections import defaultdict, OrderedDict from collections import defaultdict, OrderedDict
from copy import copy
from wa.framework.exception import ConfigError from wa.framework.exception import ConfigError
from wa.framework.plugin import Plugin, Parameter from wa.framework.plugin import Plugin, Parameter
@ -255,10 +256,8 @@ class FreqValue(object):
return value return value
elif isinstance(value, basestring): elif isinstance(value, basestring):
value = caseless_string(value) value = caseless_string(value)
if value == 'max': if value in ['min', 'max']:
return self.values[-1] return value
elif value == 'min':
return self.values[0]
msg = 'Invalid frequency value: {}; Must be in {}' msg = 'Invalid frequency value: {}; Must be in {}'
raise ValueError(msg.format(value, self.values)) raise ValueError(msg.format(value, self.values))
@ -266,6 +265,7 @@ class FreqValue(object):
def __str__(self): def __str__(self):
return 'valid frequency value: {}'.format(self.values) return 'valid frequency value: {}'.format(self.values)
class CpufreqRuntimeConfig(RuntimeConfig): class CpufreqRuntimeConfig(RuntimeConfig):
name = 'rt-cpufreq' name = 'rt-cpufreq'
@ -311,11 +311,10 @@ class CpufreqRuntimeConfig(RuntimeConfig):
return return
self._retrive_cpufreq_info() self._retrive_cpufreq_info()
common_freqs, common_gov = self._get_common_values() all_freqs, common_freqs, common_gov = self._get_common_values()
# Add common parameters if available. # Add common parameters if available.
if common_freqs: freq_val = FreqValue(all_freqs)
freq_val = FreqValue(common_freqs)
param_name = 'frequency' param_name = 'frequency'
self._runtime_params[param_name] = \ self._runtime_params[param_name] = \
RuntimeParameter(param_name, kind=freq_val, RuntimeParameter(param_name, kind=freq_val,
@ -351,6 +350,7 @@ class CpufreqRuntimeConfig(RuntimeConfig):
description=""" description="""
The governor to be set for all cores The governor to be set for all cores
""") """)
param_name = 'governor_tunables' param_name = 'governor_tunables'
self._runtime_params[param_name] = \ self._runtime_params[param_name] = \
RuntimeParameter(param_name, kind=dict, RuntimeParameter(param_name, kind=dict,
@ -544,8 +544,14 @@ class CpufreqRuntimeConfig(RuntimeConfig):
self.configure_governor(cpu, self.configure_governor(cpu,
config.get('governor'), config.get('governor'),
config.get('governor_tunables')) config.get('governor_tunables'))
frequency = config.get('frequency')
if frequency == 'min':
frequency = self.target.cpufreq.get_min_frequency(cpu)
elif frequency == 'max':
frequency = self.target.cpufreq.get_max_frequency(cpu)
self.configure_frequency(cpu, self.configure_frequency(cpu,
config.get('frequency'), frequency,
config.get('min_frequency'), config.get('min_frequency'),
config.get('max_frequency'), config.get('max_frequency'),
config.get('governor')) config.get('governor'))
@ -647,21 +653,20 @@ class CpufreqRuntimeConfig(RuntimeConfig):
''' Find common values for frequency and governors across all cores''' ''' Find common values for frequency and governors across all cores'''
common_freqs = None common_freqs = None
common_gov = None common_gov = None
all_freqs = None
initialized = False initialized = False
for cpu in resolve_unique_domain_cpus('all', self.target): for cpu in resolve_unique_domain_cpus('all', self.target):
if not initialized: if not initialized:
initialized = True initialized = True
if self.supported_cpu_freqs.get(cpu): common_freqs = set(self.supported_cpu_freqs.get(cpu) or [])
common_freqs = set(self.supported_cpu_freqs.get(cpu)) all_freqs = copy(common_freqs)
if self.supported_cpu_governors.get(cpu): common_gov = set(self.supported_cpu_governors.get(cpu) or [])
common_gov = set(self.supported_cpu_governors.get(cpu))
else: else:
if self.supported_cpu_freqs.get(cpu): common_freqs = common_freqs.intersection(self.supported_cpu_freqs.get(cpu) or set())
common_freqs = common_freqs.intersection(self.supported_cpu_freqs.get(cpu)) all_freqs = all_freqs.union(self.supported_cpu_freqs.get(cpu) or set())
if self.supported_cpu_governors.get(cpu):
common_gov = common_gov.intersection(self.supported_cpu_governors.get(cpu)) common_gov = common_gov.intersection(self.supported_cpu_governors.get(cpu))
return common_freqs, common_gov return all_freqs, common_freqs, common_gov
class IdleStateValue(object): class IdleStateValue(object):