opp: Keep track of currently programmed OPP
authorViresh Kumar <viresh.kumar@linaro.org>
Wed, 20 Jan 2021 10:46:48 +0000 (16:16 +0530)
committerViresh Kumar <viresh.kumar@linaro.org>
Tue, 2 Feb 2021 04:57:52 +0000 (10:27 +0530)
commit81c4d8a3c41488e5491142c31cd7a821ff5d71ec
treee839375ee5c624fe857d457f82df492febad7ec8
parent1d3c42cabbd351e9c171e906603b5cc2ea513640
opp: Keep track of currently programmed OPP

The dev_pm_opp_set_rate() helper needs to know the currently programmed
OPP to make few decisions and currently we try to find it on every
invocation of this routine.

Lets start keeping track of the current_opp programmed for the devices
of the opp table, that will be quite useful going forward.

If we fail to find the current OPP, we pick the first one available in
the list, as the list is in ascending order of frequencies, level, or
bandwidth and that's the best guess we can make anyway.

Note that we used to do the frequency comparison a bit early in
dev_pm_opp_set_rate() previously, and now instead we check the target
opp, which shall be more accurate anyway.

We need to make sure that current_opp's memory doesn't get freed while
it is being used and so we keep a reference of it until the time it is
used.

Now that current_opp will always be set, we can drop some unnecessary
checks as well.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Tested-by: Dmitry Osipenko <digetx@gmail.com>
drivers/opp/core.c
drivers/opp/opp.h