Message ID | 20240723144610.564273-2-ulf.hansson@linaro.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | OPP: Re-work code to drop _opp_attach|detach_genpd() | expand |
On Tue, Jul 23, 2024 at 04:46:07PM GMT, Ulf Hansson wrote: > Rather than hooking up the PM domains through devm_pm_opp_attach_genpd() > and manage the device-link, let's avoid the boilerplate-code by converting > into dev_pm_domain_attach|detach_list. > > Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org> > --- > drivers/gpu/drm/tegra/gr3d.c | 46 ++++++++++-------------------------- > 1 file changed, 13 insertions(+), 33 deletions(-) Applied to drm-misc-next, thanks. Thierry
On Wed, 28 Aug 2024 at 17:06, Thierry Reding <thierry.reding@gmail.com> wrote: > > On Tue, Jul 23, 2024 at 04:46:07PM GMT, Ulf Hansson wrote: > > Rather than hooking up the PM domains through devm_pm_opp_attach_genpd() > > and manage the device-link, let's avoid the boilerplate-code by converting > > into dev_pm_domain_attach|detach_list. > > > > Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org> > > --- > > drivers/gpu/drm/tegra/gr3d.c | 46 ++++++++++-------------------------- > > 1 file changed, 13 insertions(+), 33 deletions(-) > > Applied to drm-misc-next, thanks. Please drop this from your tree. I already have a patch [1] that you have acked, which is a newer version of $subject patch. Sorry if this was unclear. Kind regards Uffe [1] https://lore.kernel.org/all/CAPDyKFqZ9XXi5_-essaGbdWBDLX8uR5nO9vDJCExBGV+10KqZA@mail.gmail.com/
On Wed, Aug 28, 2024 at 05:26:40PM GMT, Ulf Hansson wrote: > On Wed, 28 Aug 2024 at 17:06, Thierry Reding <thierry.reding@gmail.com> wrote: > > > > On Tue, Jul 23, 2024 at 04:46:07PM GMT, Ulf Hansson wrote: > > > Rather than hooking up the PM domains through devm_pm_opp_attach_genpd() > > > and manage the device-link, let's avoid the boilerplate-code by converting > > > into dev_pm_domain_attach|detach_list. > > > > > > Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org> > > > --- > > > drivers/gpu/drm/tegra/gr3d.c | 46 ++++++++++-------------------------- > > > 1 file changed, 13 insertions(+), 33 deletions(-) > > > > Applied to drm-misc-next, thanks. > > Please drop this from your tree. I already have a patch [1] that you > have acked, which is a newer version of $subject patch. > > Sorry if this was unclear. Ugh... indeed. Sorry, I was confusing these. Unfortunately I had pushed to drm-misc-next already, so I can't drop, but I can revert. Thierry
diff --git a/drivers/gpu/drm/tegra/gr3d.c b/drivers/gpu/drm/tegra/gr3d.c index 00c8564520e7..4de1ea0fc7c0 100644 --- a/drivers/gpu/drm/tegra/gr3d.c +++ b/drivers/gpu/drm/tegra/gr3d.c @@ -46,6 +46,7 @@ struct gr3d { unsigned int nclocks; struct reset_control_bulk_data resets[RST_GR3D_MAX]; unsigned int nresets; + struct dev_pm_domain_list *pd_list; DECLARE_BITMAP(addr_regs, GR3D_NUM_REGS); }; @@ -369,18 +370,12 @@ static int gr3d_power_up_legacy_domain(struct device *dev, const char *name, 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 const char * const opp_genpd_names[] = { "3d0", "3d1", NULL }; - const u32 link_flags = DL_FLAG_STATELESS | DL_FLAG_PM_RUNTIME; - struct device **opp_virt_devs, *pd_dev; - struct device_link *link; - unsigned int i; + struct dev_pm_domain_attach_data pd_data = { + .pd_names = (const char *[]) { "3d0", "3d1" }, + .num_pd_names = 2, + }; int err; err = of_count_phandle_with_args(dev->of_node, "power-domains", @@ -414,29 +409,10 @@ static int gr3d_init_power(struct device *dev, struct gr3d *gr3d) if (dev->pm_domain) return 0; - err = devm_pm_opp_attach_genpd(dev, opp_genpd_names, &opp_virt_devs); - if (err) + err = dev_pm_domain_attach_list(dev, &pd_data, &gr3d->pd_list); + if (err < 0) 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; } @@ -527,13 +503,13 @@ static int gr3d_probe(struct platform_device *pdev) err = devm_tegra_core_dev_init_opp_table_common(&pdev->dev); if (err) - return err; + goto err; err = host1x_client_register(&gr3d->client.base); if (err < 0) { dev_err(&pdev->dev, "failed to register host1x client: %d\n", err); - return err; + goto err; } /* initialize address register map */ @@ -541,6 +517,9 @@ static int gr3d_probe(struct platform_device *pdev) set_bit(gr3d_addr_regs[i], gr3d->addr_regs); return 0; +err: + dev_pm_domain_detach_list(gr3d->pd_list); + return err; } static void gr3d_remove(struct platform_device *pdev) @@ -549,6 +528,7 @@ static void gr3d_remove(struct platform_device *pdev) pm_runtime_disable(&pdev->dev); host1x_client_unregister(&gr3d->client.base); + dev_pm_domain_detach_list(gr3d->pd_list); } static int __maybe_unused gr3d_runtime_suspend(struct device *dev)
Rather than hooking up the PM domains through devm_pm_opp_attach_genpd() and manage the device-link, let's avoid the boilerplate-code by converting into dev_pm_domain_attach|detach_list. Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org> --- drivers/gpu/drm/tegra/gr3d.c | 46 ++++++++++-------------------------- 1 file changed, 13 insertions(+), 33 deletions(-)