From 789e044344f3d4c3146e9ae193780b29104913da Mon Sep 17 00:00:00 2001 From: Jordan Crouse Date: Tue, 7 Apr 2020 15:19:55 -0600 Subject: [PATCH] msm: kgsl: Don't populate the OPP table if it already exists If we query the OPP table when it doesn't exist we get an error. If we populate it again with the same operating points we get an error. So just skip the table create if it already exists and go with whatever we have. Change-Id: Ic0dedbad3d5bd24b35867a82873a6ece555d8314 Signed-off-by: Jordan Crouse --- drivers/gpu/msm/adreno.c | 47 ++++++---------------------------------- 1 file changed, 7 insertions(+), 40 deletions(-) diff --git a/drivers/gpu/msm/adreno.c b/drivers/gpu/msm/adreno.c index d1fb8d4772de..fd3a2c378442 100644 --- a/drivers/gpu/msm/adreno.c +++ b/drivers/gpu/msm/adreno.c @@ -779,51 +779,18 @@ static const struct of_device_id adreno_match_table[] = { /* Dynamically build the OPP table for the GPU device */ static void adreno_build_opp_table(struct device *dev, struct kgsl_pwrctrl *pwr) { - struct dev_pm_opp *opp; - unsigned long freq = 0; + struct opp_table *table; int i; - /* - * First an annoying step: Some targets have clock drivers that - * "helpfully" builds a OPP table for us but usually it is wrong. - * Go through and filter out unsupported frequencies - */ - - for (;;) { - opp = dev_pm_opp_find_freq_ceil(dev, &freq); - - if (IS_ERR(opp)) - break; - - dev_pm_opp_put(opp); - - for (i = 0; i < pwr->num_pwrlevels; i++) { - if (freq == pwr->pwrlevels[i].gpu_freq) - break; - } - - if (i == pwr->num_pwrlevels) - dev_pm_opp_remove(dev, freq); - - freq++; + table = dev_pm_opp_get_opp_table(dev); + if (table) { + dev_pm_opp_put_opp_table(table); + return; } - /* Now add all of our supported frequencies into the tree */ - for (i = 0; i < pwr->num_pwrlevels; i++) { - /* - * When we defer a probe the previous table will still be active - * don't add again to avoid duplicate OPP spam - */ - opp = dev_pm_opp_find_freq_exact(dev, - pwr->pwrlevels[i].gpu_freq, true); - - if (!IS_ERR(opp)) { - dev_pm_opp_put(opp); - continue; - } - + /* Add all the supported frequencies into the tree */ + for (i = 0; i < pwr->num_pwrlevels; i++) dev_pm_opp_add(dev, pwr->pwrlevels[i].gpu_freq, 0); - } } static int adreno_of_parse_pwrlevels(struct adreno_device *adreno_dev,