Commit 1bc138c6 authored by Lukasz Luba's avatar Lukasz Luba Committed by Rafael J. Wysocki

PM / EM: add support for other devices than CPUs in Energy Model

Add support for other devices than CPUs. The registration function
does not require a valid cpumask pointer and is ready to handle new
devices. Some of the internal structures has been reorganized in order to
keep consistent view (like removing per_cpu pd pointers).
Signed-off-by: default avatarLukasz Luba <lukasz.luba@arm.com>
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent d0351cc3
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#define _DEVICE_H_ #define _DEVICE_H_
#include <linux/dev_printk.h> #include <linux/dev_printk.h>
#include <linux/energy_model.h>
#include <linux/ioport.h> #include <linux/ioport.h>
#include <linux/kobject.h> #include <linux/kobject.h>
#include <linux/klist.h> #include <linux/klist.h>
...@@ -559,6 +560,10 @@ struct device { ...@@ -559,6 +560,10 @@ struct device {
struct dev_pm_info power; struct dev_pm_info power;
struct dev_pm_domain *pm_domain; struct dev_pm_domain *pm_domain;
#ifdef CONFIG_ENERGY_MODEL
struct em_perf_domain *em_pd;
#endif
#ifdef CONFIG_GENERIC_MSI_IRQ_DOMAIN #ifdef CONFIG_GENERIC_MSI_IRQ_DOMAIN
struct irq_domain *msi_domain; struct irq_domain *msi_domain;
#endif #endif
......
...@@ -12,8 +12,10 @@ ...@@ -12,8 +12,10 @@
/** /**
* em_perf_state - Performance state of a performance domain * em_perf_state - Performance state of a performance domain
* @frequency: The CPU frequency in KHz, for consistency with CPUFreq * @frequency: The frequency in KHz, for consistency with CPUFreq
* @power: The power consumed by 1 CPU at this level, in milli-watts * @power: The power consumed at this level, in milli-watts (by 1 CPU or
by a registered device). It can be a total power: static and
dynamic.
* @cost: The cost coefficient associated with this level, used during * @cost: The cost coefficient associated with this level, used during
* energy calculation. Equal to: power * max_frequency / frequency * energy calculation. Equal to: power * max_frequency / frequency
*/ */
...@@ -27,12 +29,16 @@ struct em_perf_state { ...@@ -27,12 +29,16 @@ struct em_perf_state {
* em_perf_domain - Performance domain * em_perf_domain - Performance domain
* @table: List of performance states, in ascending order * @table: List of performance states, in ascending order
* @nr_perf_states: Number of performance states * @nr_perf_states: Number of performance states
* @cpus: Cpumask covering the CPUs of the domain * @cpus: Cpumask covering the CPUs of the domain. It's here
* * for performance reasons to avoid potential cache
* A "performance domain" represents a group of CPUs whose performance is * misses during energy calculations in the scheduler
* scaled together. All CPUs of a performance domain must have the same * and simplifies allocating/freeing that memory region.
* micro-architecture. Performance domains often have a 1-to-1 mapping with *
* CPUFreq policies. * In case of CPU device, a "performance domain" represents a group of CPUs
* whose performance is scaled together. All CPUs of a performance domain
* must have the same micro-architecture. Performance domains often have
* a 1-to-1 mapping with CPUFreq policies. In case of other devices the @cpus
* field is unused.
*/ */
struct em_perf_domain { struct em_perf_domain {
struct em_perf_state *table; struct em_perf_state *table;
...@@ -71,10 +77,12 @@ struct em_data_callback { ...@@ -71,10 +77,12 @@ struct em_data_callback {
#define EM_DATA_CB(_active_power_cb) { .active_power = &_active_power_cb } #define EM_DATA_CB(_active_power_cb) { .active_power = &_active_power_cb }
struct em_perf_domain *em_cpu_get(int cpu); struct em_perf_domain *em_cpu_get(int cpu);
struct em_perf_domain *em_pd_get(struct device *dev);
int em_register_perf_domain(cpumask_t *span, unsigned int nr_states, int em_register_perf_domain(cpumask_t *span, unsigned int nr_states,
struct em_data_callback *cb); struct em_data_callback *cb);
int em_dev_register_perf_domain(struct device *dev, unsigned int nr_states, int em_dev_register_perf_domain(struct device *dev, unsigned int nr_states,
struct em_data_callback *cb, cpumask_t *span); struct em_data_callback *cb, cpumask_t *span);
void em_dev_unregister_perf_domain(struct device *dev);
/** /**
* em_pd_energy() - Estimates the energy consumed by the CPUs of a perf. domain * em_pd_energy() - Estimates the energy consumed by the CPUs of a perf. domain
...@@ -184,10 +192,17 @@ int em_dev_register_perf_domain(struct device *dev, unsigned int nr_states, ...@@ -184,10 +192,17 @@ int em_dev_register_perf_domain(struct device *dev, unsigned int nr_states,
{ {
return -EINVAL; return -EINVAL;
} }
static inline void em_dev_unregister_perf_domain(struct device *dev)
{
}
static inline struct em_perf_domain *em_cpu_get(int cpu) static inline struct em_perf_domain *em_cpu_get(int cpu)
{ {
return NULL; return NULL;
} }
static inline struct em_perf_domain *em_pd_get(struct device *dev)
{
return NULL;
}
static inline unsigned long em_pd_energy(struct em_perf_domain *pd, static inline unsigned long em_pd_energy(struct em_perf_domain *pd,
unsigned long max_util, unsigned long sum_util) unsigned long max_util, unsigned long sum_util)
{ {
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment