Re: [PATCH 2/7] cpufreq: dt: Register an Energy Model

From: Viresh Kumar
Date: Wed Jan 30 2019 - 05:17:23 EST


On 30-01-19, 09:12, Quentin Perret wrote:
> What I had in mind is something as simple as:
>
> void of_dev_pm_opp_register_em(struct cpumask *cpus)
> {
> /* Bail out if an EM is there */
> if (em_cpu_get(cpumask_first(cpus)))
> return;
>
> /* Check prerequisites: dpc coeff in DT, ... */
> ...
>
> em_register_perf_domain(...);
> }
>
> IIUC, Matthias' point was that if the EM is already registered, there is
> no good reason to call em_register_perf_domain() again. Now, that should
> in fact be harmless because em_register_perf_domain() already does that
> check. It's just cleaner and easier to understand from a conceptual
> standpoint to not call that function several times for no reason I
> assume.

If there is no good reason to call em_register_perf_domain() several
times, then the same applies to of_dev_pm_opp_register_em() as well,
isn't it ?

This is init code anyway isn't going to run a lot, so I wouldn't
suggest adding any such (duplicate) checks in
of_dev_pm_opp_register_em().

--
viresh