Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

PM: EM: Update Energy Model with new flag indicating power scale

Update description and meaning of a new flag, which indicates the type of
power scale used for a registered Energy Model (EM) device.

Reviewed-by: Quentin Perret <qperret@google.com>
Signed-off-by: Lukasz Luba <lukasz.luba@arm.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

authored by

Lukasz Luba and committed by
Rafael J. Wysocki
b56a352c f2c90b12

+12 -5
+12 -5
Documentation/power/energy-model.rst
··· 30 30 thus the real milli-Watts might be needed. An example of these requirements can 31 31 be found in the Intelligent Power Allocation in 32 32 Documentation/driver-api/thermal/power_allocator.rst. 33 + Kernel subsystems might implement automatic detection to check whether EM 34 + registered devices have inconsistent scale (based on EM internal flag). 33 35 Important thing to keep in mind is that when the power values are expressed in 34 36 an 'abstract scale' deriving real energy in milli-Joules would not be possible. 35 37 ··· 88 86 calling the following API:: 89 87 90 88 int em_dev_register_perf_domain(struct device *dev, unsigned int nr_states, 91 - struct em_data_callback *cb, cpumask_t *cpus); 89 + struct em_data_callback *cb, cpumask_t *cpus, bool milliwatts); 92 90 93 91 Drivers must provide a callback function returning <frequency, power> tuples 94 92 for each performance state. The callback function provided by the driver is free ··· 96 94 deemed necessary. Only for CPU devices, drivers must specify the CPUs of the 97 95 performance domains using cpumask. For other devices than CPUs the last 98 96 argument must be set to NULL. 97 + The last argument 'milliwatts' is important to set with correct value. Kernel 98 + subsystems which use EM might rely on this flag to check if all EM devices use 99 + the same scale. If there are different scales, these subsystems might decide 100 + to: return warning/error, stop working or panic. 99 101 See Section 3. for an example of driver implementing this 100 102 callback, and kernel/power/energy_model.c for further documentation on this 101 103 API. ··· 175 169 37 nr_opp = foo_get_nr_opp(policy); 176 170 38 177 171 39 /* And register the new performance domain */ 178 - 40 em_dev_register_perf_domain(cpu_dev, nr_opp, &em_cb, policy->cpus); 179 - 41 180 - 42 return 0; 181 - 43 } 172 + 40 em_dev_register_perf_domain(cpu_dev, nr_opp, &em_cb, policy->cpus, 173 + 41 true); 174 + 42 175 + 43 return 0; 176 + 44 }