summaryrefslogtreecommitdiff
path: root/drivers/opp/core.c
diff options
context:
space:
mode:
authorViresh Kumar <viresh.kumar@linaro.org>2019-05-08 15:43:36 +0530
committerViresh Kumar <viresh.kumar@linaro.org>2019-05-20 12:04:45 +0530
commitc0ab9e0812da8e2134dd63d030c8a8abd2112a5a (patch)
treed5cc1b2ec0bb7a40f9498b06b1fa8639eadc6126 /drivers/opp/core.c
parent6319aee10e530315689db7609a7d4c444124ff22 (diff)
opp: Allocate genpd_virt_devs from dev_pm_opp_attach_genpd()
Currently the space for the array of virtual devices is allocated along with the OPP table, but that isn't going to work well from now onwards. For single power domain case, a driver can either use the original device structure for setting the performance state (if genpd attached with dev_pm_domain_attach()) or use the virtual device structure (if genpd attached with dev_pm_domain_attach_by_name(), which returns the virtual device) and so we can't know in advance if we are going to need genpd_virt_devs array or not. Lets delay the allocation a bit and do it along with dev_pm_opp_attach_genpd() rather. The deallocation is done from dev_pm_opp_detach_genpd(). Tested-by: Niklas Cassel <niklas.cassel@linaro.org> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Diffstat (limited to 'drivers/opp/core.c')
-rw-r--r--drivers/opp/core.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/drivers/opp/core.c b/drivers/opp/core.c
index 67d6b0caeab1..764e05a2fa66 100644
--- a/drivers/opp/core.c
+++ b/drivers/opp/core.c
@@ -1755,6 +1755,9 @@ static void _opp_detach_genpd(struct opp_table *opp_table)
dev_pm_domain_detach(opp_table->genpd_virt_devs[index], false);
opp_table->genpd_virt_devs[index] = NULL;
}
+
+ kfree(opp_table->genpd_virt_devs);
+ opp_table->genpd_virt_devs = NULL;
}
/**
@@ -1798,6 +1801,12 @@ struct opp_table *dev_pm_opp_attach_genpd(struct device *dev, const char **names
mutex_lock(&opp_table->genpd_virt_dev_lock);
+ opp_table->genpd_virt_devs = kcalloc(opp_table->required_opp_count,
+ sizeof(*opp_table->genpd_virt_devs),
+ GFP_KERNEL);
+ if (!opp_table->genpd_virt_devs)
+ goto unlock;
+
while (*name) {
index = of_property_match_string(dev->of_node,
"power-domain-names", *name);
@@ -1836,6 +1845,7 @@ struct opp_table *dev_pm_opp_attach_genpd(struct device *dev, const char **names
err:
_opp_detach_genpd(opp_table);
+unlock:
mutex_unlock(&opp_table->genpd_virt_dev_lock);
put_table: