aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/opp/of.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/of.c
parentopp: Attach genpds to devices from within OPP core (diff)
downloadlinux-dev-c0ab9e0812da8e2134dd63d030c8a8abd2112a5a.tar.xz
linux-dev-c0ab9e0812da8e2134dd63d030c8a8abd2112a5a.zip
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/of.c')
-rw-r--r--drivers/opp/of.c30
1 files changed, 2 insertions, 28 deletions
diff --git a/drivers/opp/of.c b/drivers/opp/of.c
index c10c782d15aa..a637f30552a3 100644
--- a/drivers/opp/of.c
+++ b/drivers/opp/of.c
@@ -141,7 +141,6 @@ err:
static void _opp_table_free_required_tables(struct opp_table *opp_table)
{
struct opp_table **required_opp_tables = opp_table->required_opp_tables;
- struct device **genpd_virt_devs = opp_table->genpd_virt_devs;
int i;
if (!required_opp_tables)
@@ -155,10 +154,8 @@ static void _opp_table_free_required_tables(struct opp_table *opp_table)
}
kfree(required_opp_tables);
- kfree(genpd_virt_devs);
opp_table->required_opp_count = 0;
- opp_table->genpd_virt_devs = NULL;
opp_table->required_opp_tables = NULL;
}
@@ -171,9 +168,8 @@ static void _opp_table_alloc_required_tables(struct opp_table *opp_table,
struct device_node *opp_np)
{
struct opp_table **required_opp_tables;
- struct device **genpd_virt_devs = NULL;
struct device_node *required_np, *np;
- int count, count_pd, i;
+ int count, i;
/* Traversing the first OPP node is all we need */
np = of_get_next_available_child(opp_np, NULL);
@@ -186,33 +182,11 @@ static void _opp_table_alloc_required_tables(struct opp_table *opp_table,
if (!count)
goto put_np;
- /*
- * Check the number of power-domains to know if we need to deal
- * with virtual devices. In some cases we have devices with multiple
- * power domains but with only one of them being scalable, hence
- * 'count' could be 1, but we still have to deal with multiple genpds
- * and virtual devices.
- */
- count_pd = of_count_phandle_with_args(dev->of_node, "power-domains",
- "#power-domain-cells");
- if (!count_pd)
- goto put_np;
-
- if (count_pd > 1) {
- genpd_virt_devs = kcalloc(count, sizeof(*genpd_virt_devs),
- GFP_KERNEL);
- if (!genpd_virt_devs)
- goto put_np;
- }
-
required_opp_tables = kcalloc(count, sizeof(*required_opp_tables),
GFP_KERNEL);
- if (!required_opp_tables) {
- kfree(genpd_virt_devs);
+ if (!required_opp_tables)
goto put_np;
- }
- opp_table->genpd_virt_devs = genpd_virt_devs;
opp_table->required_opp_tables = required_opp_tables;
opp_table->required_opp_count = count;