Commit 22e6abaa authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'pmdomain-v6.12-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/linux-pm

Pull pmdomain fixes from Ulf Hansson:
 "pmdomain core:
   - Fix alloc/free in dev_pm_domain_attach|detach_list()

  pmdomain providers:
   - qcom: Fix the return of uninitialized variable

  pmdomain consumers:
   - drm/tegra/gr3d: Revert conversion to dev_pm_domain_attach|detach_list()

  OPP core:
   - Fix error code in dev_pm_opp_set_config()"

* tag 'pmdomain-v6.12-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/linux-pm:
  PM: domains: Fix alloc/free in dev_pm_domain_attach|detach_list()
  Revert "drm/tegra: gr3d: Convert into dev_pm_domain_attach|detach_list()"
  pmdomain: qcom-cpr: Fix the return of uninitialized variable
  OPP: fix error code in dev_pm_opp_set_config()
parents 7351a879 77385688
...@@ -195,6 +195,7 @@ int dev_pm_domain_attach_list(struct device *dev, ...@@ -195,6 +195,7 @@ int dev_pm_domain_attach_list(struct device *dev,
struct device *pd_dev = NULL; struct device *pd_dev = NULL;
int ret, i, num_pds = 0; int ret, i, num_pds = 0;
bool by_id = true; bool by_id = true;
size_t size;
u32 pd_flags = data ? data->pd_flags : 0; u32 pd_flags = data ? data->pd_flags : 0;
u32 link_flags = pd_flags & PD_FLAG_NO_DEV_LINK ? 0 : u32 link_flags = pd_flags & PD_FLAG_NO_DEV_LINK ? 0 :
DL_FLAG_STATELESS | DL_FLAG_PM_RUNTIME; DL_FLAG_STATELESS | DL_FLAG_PM_RUNTIME;
...@@ -217,19 +218,17 @@ int dev_pm_domain_attach_list(struct device *dev, ...@@ -217,19 +218,17 @@ int dev_pm_domain_attach_list(struct device *dev,
if (num_pds <= 0) if (num_pds <= 0)
return 0; return 0;
pds = devm_kzalloc(dev, sizeof(*pds), GFP_KERNEL); pds = kzalloc(sizeof(*pds), GFP_KERNEL);
if (!pds) if (!pds)
return -ENOMEM; return -ENOMEM;
pds->pd_devs = devm_kcalloc(dev, num_pds, sizeof(*pds->pd_devs), size = sizeof(*pds->pd_devs) + sizeof(*pds->pd_links);
GFP_KERNEL); pds->pd_devs = kcalloc(num_pds, size, GFP_KERNEL);
if (!pds->pd_devs) if (!pds->pd_devs) {
return -ENOMEM; ret = -ENOMEM;
goto free_pds;
pds->pd_links = devm_kcalloc(dev, num_pds, sizeof(*pds->pd_links), }
GFP_KERNEL); pds->pd_links = (void *)(pds->pd_devs + num_pds);
if (!pds->pd_links)
return -ENOMEM;
if (link_flags && pd_flags & PD_FLAG_DEV_LINK_ON) if (link_flags && pd_flags & PD_FLAG_DEV_LINK_ON)
link_flags |= DL_FLAG_RPM_ACTIVE; link_flags |= DL_FLAG_RPM_ACTIVE;
...@@ -272,6 +271,9 @@ int dev_pm_domain_attach_list(struct device *dev, ...@@ -272,6 +271,9 @@ int dev_pm_domain_attach_list(struct device *dev,
device_link_del(pds->pd_links[i]); device_link_del(pds->pd_links[i]);
dev_pm_domain_detach(pds->pd_devs[i], true); dev_pm_domain_detach(pds->pd_devs[i], true);
} }
kfree(pds->pd_devs);
free_pds:
kfree(pds);
return ret; return ret;
} }
EXPORT_SYMBOL_GPL(dev_pm_domain_attach_list); EXPORT_SYMBOL_GPL(dev_pm_domain_attach_list);
...@@ -363,6 +365,9 @@ void dev_pm_domain_detach_list(struct dev_pm_domain_list *list) ...@@ -363,6 +365,9 @@ void dev_pm_domain_detach_list(struct dev_pm_domain_list *list)
device_link_del(list->pd_links[i]); device_link_del(list->pd_links[i]);
dev_pm_domain_detach(list->pd_devs[i], true); dev_pm_domain_detach(list->pd_devs[i], true);
} }
kfree(list->pd_devs);
kfree(list);
} }
EXPORT_SYMBOL_GPL(dev_pm_domain_detach_list); EXPORT_SYMBOL_GPL(dev_pm_domain_detach_list);
......
...@@ -46,7 +46,6 @@ struct gr3d { ...@@ -46,7 +46,6 @@ struct gr3d {
unsigned int nclocks; unsigned int nclocks;
struct reset_control_bulk_data resets[RST_GR3D_MAX]; struct reset_control_bulk_data resets[RST_GR3D_MAX];
unsigned int nresets; unsigned int nresets;
struct dev_pm_domain_list *pd_list;
DECLARE_BITMAP(addr_regs, GR3D_NUM_REGS); DECLARE_BITMAP(addr_regs, GR3D_NUM_REGS);
}; };
...@@ -370,12 +369,18 @@ static int gr3d_power_up_legacy_domain(struct device *dev, const char *name, ...@@ -370,12 +369,18 @@ static int gr3d_power_up_legacy_domain(struct device *dev, const char *name,
return 0; return 0;
} }
static void gr3d_del_link(void *link)
{
device_link_del(link);
}
static int gr3d_init_power(struct device *dev, struct gr3d *gr3d) static int gr3d_init_power(struct device *dev, struct gr3d *gr3d)
{ {
struct dev_pm_domain_attach_data pd_data = { static const char * const opp_genpd_names[] = { "3d0", "3d1", NULL };
.pd_names = (const char *[]) { "3d0", "3d1" }, const u32 link_flags = DL_FLAG_STATELESS | DL_FLAG_PM_RUNTIME;
.num_pd_names = 2, struct device **opp_virt_devs, *pd_dev;
}; struct device_link *link;
unsigned int i;
int err; int err;
err = of_count_phandle_with_args(dev->of_node, "power-domains", err = of_count_phandle_with_args(dev->of_node, "power-domains",
...@@ -409,10 +414,29 @@ static int gr3d_init_power(struct device *dev, struct gr3d *gr3d) ...@@ -409,10 +414,29 @@ static int gr3d_init_power(struct device *dev, struct gr3d *gr3d)
if (dev->pm_domain) if (dev->pm_domain)
return 0; return 0;
err = dev_pm_domain_attach_list(dev, &pd_data, &gr3d->pd_list); err = devm_pm_opp_attach_genpd(dev, opp_genpd_names, &opp_virt_devs);
if (err < 0) if (err)
return err; return err;
for (i = 0; opp_genpd_names[i]; i++) {
pd_dev = opp_virt_devs[i];
if (!pd_dev) {
dev_err(dev, "failed to get %s power domain\n",
opp_genpd_names[i]);
return -EINVAL;
}
link = device_link_add(dev, pd_dev, link_flags);
if (!link) {
dev_err(dev, "failed to link to %s\n", dev_name(pd_dev));
return -EINVAL;
}
err = devm_add_action_or_reset(dev, gr3d_del_link, link);
if (err)
return err;
}
return 0; return 0;
} }
...@@ -503,13 +527,13 @@ static int gr3d_probe(struct platform_device *pdev) ...@@ -503,13 +527,13 @@ static int gr3d_probe(struct platform_device *pdev)
err = devm_tegra_core_dev_init_opp_table_common(&pdev->dev); err = devm_tegra_core_dev_init_opp_table_common(&pdev->dev);
if (err) if (err)
goto err; return err;
err = host1x_client_register(&gr3d->client.base); err = host1x_client_register(&gr3d->client.base);
if (err < 0) { if (err < 0) {
dev_err(&pdev->dev, "failed to register host1x client: %d\n", dev_err(&pdev->dev, "failed to register host1x client: %d\n",
err); err);
goto err; return err;
} }
/* initialize address register map */ /* initialize address register map */
...@@ -517,9 +541,6 @@ static int gr3d_probe(struct platform_device *pdev) ...@@ -517,9 +541,6 @@ static int gr3d_probe(struct platform_device *pdev)
set_bit(gr3d_addr_regs[i], gr3d->addr_regs); set_bit(gr3d_addr_regs[i], gr3d->addr_regs);
return 0; return 0;
err:
dev_pm_domain_detach_list(gr3d->pd_list);
return err;
} }
static void gr3d_remove(struct platform_device *pdev) static void gr3d_remove(struct platform_device *pdev)
...@@ -528,7 +549,6 @@ static void gr3d_remove(struct platform_device *pdev) ...@@ -528,7 +549,6 @@ static void gr3d_remove(struct platform_device *pdev)
pm_runtime_disable(&pdev->dev); pm_runtime_disable(&pdev->dev);
host1x_client_unregister(&gr3d->client.base); host1x_client_unregister(&gr3d->client.base);
dev_pm_domain_detach_list(gr3d->pd_list);
} }
static int __maybe_unused gr3d_runtime_suspend(struct device *dev) static int __maybe_unused gr3d_runtime_suspend(struct device *dev)
......
...@@ -2630,8 +2630,10 @@ int dev_pm_opp_set_config(struct device *dev, struct dev_pm_opp_config *config) ...@@ -2630,8 +2630,10 @@ int dev_pm_opp_set_config(struct device *dev, struct dev_pm_opp_config *config)
/* Attach genpds */ /* Attach genpds */
if (config->genpd_names) { if (config->genpd_names) {
if (config->required_devs) if (config->required_devs) {
ret = -EINVAL;
goto err; goto err;
}
ret = _opp_attach_genpd(opp_table, dev, config->genpd_names, ret = _opp_attach_genpd(opp_table, dev, config->genpd_names,
config->virt_devs); config->virt_devs);
......
...@@ -1052,7 +1052,7 @@ static unsigned long cpr_get_opp_hz_for_req(struct dev_pm_opp *ref, ...@@ -1052,7 +1052,7 @@ static unsigned long cpr_get_opp_hz_for_req(struct dev_pm_opp *ref,
of_parse_phandle(child_np, "required-opps", 0); of_parse_phandle(child_np, "required-opps", 0);
if (child_req_np == ref_np) { if (child_req_np == ref_np) {
u64 rate; u64 rate = 0;
of_property_read_u64(child_np, "opp-hz", &rate); of_property_read_u64(child_np, "opp-hz", &rate);
return (unsigned long) rate; return (unsigned long) rate;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment