Skip to content

Commit 22e6aba

Browse files
committed
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()
2 parents 7351a87 + 7738568 commit 22e6aba

File tree

4 files changed

+52
-25
lines changed

4 files changed

+52
-25
lines changed

drivers/base/power/common.c

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ int dev_pm_domain_attach_list(struct device *dev,
195195
struct device *pd_dev = NULL;
196196
int ret, i, num_pds = 0;
197197
bool by_id = true;
198+
size_t size;
198199
u32 pd_flags = data ? data->pd_flags : 0;
199200
u32 link_flags = pd_flags & PD_FLAG_NO_DEV_LINK ? 0 :
200201
DL_FLAG_STATELESS | DL_FLAG_PM_RUNTIME;
@@ -217,19 +218,17 @@ int dev_pm_domain_attach_list(struct device *dev,
217218
if (num_pds <= 0)
218219
return 0;
219220

220-
pds = devm_kzalloc(dev, sizeof(*pds), GFP_KERNEL);
221+
pds = kzalloc(sizeof(*pds), GFP_KERNEL);
221222
if (!pds)
222223
return -ENOMEM;
223224

224-
pds->pd_devs = devm_kcalloc(dev, num_pds, sizeof(*pds->pd_devs),
225-
GFP_KERNEL);
226-
if (!pds->pd_devs)
227-
return -ENOMEM;
228-
229-
pds->pd_links = devm_kcalloc(dev, num_pds, sizeof(*pds->pd_links),
230-
GFP_KERNEL);
231-
if (!pds->pd_links)
232-
return -ENOMEM;
225+
size = sizeof(*pds->pd_devs) + sizeof(*pds->pd_links);
226+
pds->pd_devs = kcalloc(num_pds, size, GFP_KERNEL);
227+
if (!pds->pd_devs) {
228+
ret = -ENOMEM;
229+
goto free_pds;
230+
}
231+
pds->pd_links = (void *)(pds->pd_devs + num_pds);
233232

234233
if (link_flags && pd_flags & PD_FLAG_DEV_LINK_ON)
235234
link_flags |= DL_FLAG_RPM_ACTIVE;
@@ -272,6 +271,9 @@ int dev_pm_domain_attach_list(struct device *dev,
272271
device_link_del(pds->pd_links[i]);
273272
dev_pm_domain_detach(pds->pd_devs[i], true);
274273
}
274+
kfree(pds->pd_devs);
275+
free_pds:
276+
kfree(pds);
275277
return ret;
276278
}
277279
EXPORT_SYMBOL_GPL(dev_pm_domain_attach_list);
@@ -363,6 +365,9 @@ void dev_pm_domain_detach_list(struct dev_pm_domain_list *list)
363365
device_link_del(list->pd_links[i]);
364366
dev_pm_domain_detach(list->pd_devs[i], true);
365367
}
368+
369+
kfree(list->pd_devs);
370+
kfree(list);
366371
}
367372
EXPORT_SYMBOL_GPL(dev_pm_domain_detach_list);
368373

drivers/gpu/drm/tegra/gr3d.c

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ struct gr3d {
4646
unsigned int nclocks;
4747
struct reset_control_bulk_data resets[RST_GR3D_MAX];
4848
unsigned int nresets;
49-
struct dev_pm_domain_list *pd_list;
5049

5150
DECLARE_BITMAP(addr_regs, GR3D_NUM_REGS);
5251
};
@@ -370,12 +369,18 @@ static int gr3d_power_up_legacy_domain(struct device *dev, const char *name,
370369
return 0;
371370
}
372371

372+
static void gr3d_del_link(void *link)
373+
{
374+
device_link_del(link);
375+
}
376+
373377
static int gr3d_init_power(struct device *dev, struct gr3d *gr3d)
374378
{
375-
struct dev_pm_domain_attach_data pd_data = {
376-
.pd_names = (const char *[]) { "3d0", "3d1" },
377-
.num_pd_names = 2,
378-
};
379+
static const char * const opp_genpd_names[] = { "3d0", "3d1", NULL };
380+
const u32 link_flags = DL_FLAG_STATELESS | DL_FLAG_PM_RUNTIME;
381+
struct device **opp_virt_devs, *pd_dev;
382+
struct device_link *link;
383+
unsigned int i;
379384
int err;
380385

381386
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)
409414
if (dev->pm_domain)
410415
return 0;
411416

412-
err = dev_pm_domain_attach_list(dev, &pd_data, &gr3d->pd_list);
413-
if (err < 0)
417+
err = devm_pm_opp_attach_genpd(dev, opp_genpd_names, &opp_virt_devs);
418+
if (err)
414419
return err;
415420

421+
for (i = 0; opp_genpd_names[i]; i++) {
422+
pd_dev = opp_virt_devs[i];
423+
if (!pd_dev) {
424+
dev_err(dev, "failed to get %s power domain\n",
425+
opp_genpd_names[i]);
426+
return -EINVAL;
427+
}
428+
429+
link = device_link_add(dev, pd_dev, link_flags);
430+
if (!link) {
431+
dev_err(dev, "failed to link to %s\n", dev_name(pd_dev));
432+
return -EINVAL;
433+
}
434+
435+
err = devm_add_action_or_reset(dev, gr3d_del_link, link);
436+
if (err)
437+
return err;
438+
}
439+
416440
return 0;
417441
}
418442

@@ -503,23 +527,20 @@ static int gr3d_probe(struct platform_device *pdev)
503527

504528
err = devm_tegra_core_dev_init_opp_table_common(&pdev->dev);
505529
if (err)
506-
goto err;
530+
return err;
507531

508532
err = host1x_client_register(&gr3d->client.base);
509533
if (err < 0) {
510534
dev_err(&pdev->dev, "failed to register host1x client: %d\n",
511535
err);
512-
goto err;
536+
return err;
513537
}
514538

515539
/* initialize address register map */
516540
for (i = 0; i < ARRAY_SIZE(gr3d_addr_regs); i++)
517541
set_bit(gr3d_addr_regs[i], gr3d->addr_regs);
518542

519543
return 0;
520-
err:
521-
dev_pm_domain_detach_list(gr3d->pd_list);
522-
return err;
523544
}
524545

525546
static void gr3d_remove(struct platform_device *pdev)
@@ -528,7 +549,6 @@ static void gr3d_remove(struct platform_device *pdev)
528549

529550
pm_runtime_disable(&pdev->dev);
530551
host1x_client_unregister(&gr3d->client.base);
531-
dev_pm_domain_detach_list(gr3d->pd_list);
532552
}
533553

534554
static int __maybe_unused gr3d_runtime_suspend(struct device *dev)

drivers/opp/core.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2630,8 +2630,10 @@ int dev_pm_opp_set_config(struct device *dev, struct dev_pm_opp_config *config)
26302630

26312631
/* Attach genpds */
26322632
if (config->genpd_names) {
2633-
if (config->required_devs)
2633+
if (config->required_devs) {
2634+
ret = -EINVAL;
26342635
goto err;
2636+
}
26352637

26362638
ret = _opp_attach_genpd(opp_table, dev, config->genpd_names,
26372639
config->virt_devs);

drivers/pmdomain/qcom/cpr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1052,7 +1052,7 @@ static unsigned long cpr_get_opp_hz_for_req(struct dev_pm_opp *ref,
10521052
of_parse_phandle(child_np, "required-opps", 0);
10531053

10541054
if (child_req_np == ref_np) {
1055-
u64 rate;
1055+
u64 rate = 0;
10561056

10571057
of_property_read_u64(child_np, "opp-hz", &rate);
10581058
return (unsigned long) rate;

0 commit comments

Comments
 (0)