Skip to content

Commit ee1a198

Browse files
lukaszluba-armrafaeljw
authored andcommitted
PM: EM: Add em_perf_state_from_pd() to get performance states table
Introduce a wrapper to get the performance states table of the performance domain. The function should be called within the RCU read critical section. 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 977230d commit ee1a198

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

include/linux/energy_model.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,23 @@ static inline int em_pd_nr_perf_states(struct em_perf_domain *pd)
338338
return pd->nr_perf_states;
339339
}
340340

341+
/**
342+
* em_perf_state_from_pd() - Get the performance states table of perf.
343+
* domain
344+
* @pd : performance domain for which this must be done
345+
*
346+
* To use this function the rcu_read_lock() should be hold. After the usage
347+
* of the performance states table is finished, the rcu_read_unlock() should
348+
* be called.
349+
*
350+
* Return: the pointer to performance states table of the performance domain
351+
*/
352+
static inline
353+
struct em_perf_state *em_perf_state_from_pd(struct em_perf_domain *pd)
354+
{
355+
return rcu_dereference(pd->em_table)->state;
356+
}
357+
341358
#else
342359
struct em_data_callback {};
343360
#define EM_ADV_DATA_CB(_active_power_cb, _cost_cb) { }
@@ -384,6 +401,11 @@ int em_dev_update_perf_domain(struct device *dev,
384401
{
385402
return -EINVAL;
386403
}
404+
static inline
405+
struct em_perf_state *em_perf_state_from_pd(struct em_perf_domain *pd)
406+
{
407+
return NULL;
408+
}
387409
#endif
388410

389411
#endif

0 commit comments

Comments
 (0)