Skip to content

Commit 22ea028

Browse files
lukaszluba-armrafaeljw
authored andcommitted
PM: EM: Add em_dev_compute_costs()
The device drivers can modify EM at runtime by providing a new EM table. The EM is used by the EAS and the em_perf_state::cost stores pre-calculated value to avoid overhead. This patch provides the API for device drivers to calculate the cost values properly (and not duplicate the same code). Reviewed-by: Dietmar Eggemann <dietmar.eggemann@arm.com> Tested-by: Dietmar Eggemann <dietmar.eggemann@arm.com> Signed-off-by: Lukasz Luba <lukasz.luba@arm.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent 24e9fb6 commit 22ea028

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

include/linux/energy_model.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,8 @@ int em_dev_register_perf_domain(struct device *dev, unsigned int nr_states,
170170
void em_dev_unregister_perf_domain(struct device *dev);
171171
struct em_perf_table __rcu *em_table_alloc(struct em_perf_domain *pd);
172172
void em_table_free(struct em_perf_table __rcu *table);
173+
int em_dev_compute_costs(struct device *dev, struct em_perf_state *table,
174+
int nr_states);
173175

174176
/**
175177
* em_pd_get_efficient_state() - Get an efficient performance state from the EM
@@ -379,6 +381,12 @@ struct em_perf_state *em_perf_state_from_pd(struct em_perf_domain *pd)
379381
{
380382
return NULL;
381383
}
384+
static inline
385+
int em_dev_compute_costs(struct device *dev, struct em_perf_state *table,
386+
int nr_states)
387+
{
388+
return -EINVAL;
389+
}
382390
#endif
383391

384392
#endif

kernel/power/energy_model.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,24 @@ static int em_compute_costs(struct device *dev, struct em_perf_state *table,
276276
return 0;
277277
}
278278

279+
/**
280+
* em_dev_compute_costs() - Calculate cost values for new runtime EM table
281+
* @dev : Device for which the EM table is to be updated
282+
* @table : The new EM table that is going to get the costs calculated
283+
*
284+
* Calculate the em_perf_state::cost values for new runtime EM table. The
285+
* values are used for EAS during task placement. It also calculates and sets
286+
* the efficiency flag for each performance state. When the function finish
287+
* successfully the EM table is ready to be updated and used by EAS.
288+
*
289+
* Return 0 on success or a proper error in case of failure.
290+
*/
291+
int em_dev_compute_costs(struct device *dev, struct em_perf_state *table,
292+
int nr_states)
293+
{
294+
return em_compute_costs(dev, table, NULL, nr_states, 0);
295+
}
296+
279297
/**
280298
* em_dev_update_perf_domain() - Update runtime EM table for a device
281299
* @dev : Device for which the EM is to be updated

0 commit comments

Comments
 (0)