pmdomain: imx8m-blk-ctrl: fix suspend/resume order
PATCH 1/1 pmdomain: imx8m-blk-ctrl: fix suspend/resume order
From: Vitor Soares <[email protected]>
During the probe, the genpd power_dev is added to the dpm_list after blk_ctrl due to its parent/child relationship. Making the blk_ctrl suspend after and resume before the genpd power_dev.
As a consequence, the system hangs when resuming the VPU due to the power domain dependency.
To ensure the proper suspend/resume order, add a device link betweem blk_ctrl and genpd power_dev. It guarantees genpd power_dev is suspended after and resumed before blk-ctrl.
---
This is a new patch, but is a follow-up of:
https://lore.kernel.org/all/[email protected]/
As suggested by Lucas, we are addressing this PM issue in the imx8m-blk-ctrl driver instead of in the imx8mm.dtsi.
drivers/pmdomain/imx/imx8m-blk-ctrl.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
drivers/pmdomain/imx/imx8m-blk-ctrl.c +16 -0
@@ -283,6 +283,20 @@ static int imx8m_blk_ctrl_probe(struct platform_device *pdev) goto cleanup_pds; } +/* +* Enforce suspend/resume ordering by making genpd power_dev a +* provider of blk-ctrl. Genpd power_dev is suspended after and +* resumed before blk-ctrl. +*/ +if (!device_link_add (dev, domain->power_dev,DL_FLAG_STATELESS )) { + ret = -EINVAL ; +dev_err_probe (dev, ret, +"failed to link to %s\n" , data->name); +pm_genpd_remove (&domain->genpd); +dev_pm_domain_detach (domain->power_dev, true); + goto cleanup_pds; + } +/* * We use runtime PM to trigger power on/off of the upstream GPC * domain, as a strict hierarchical parent/child power domain
@@ -324,6 +338,7 @@ static int imx8m_blk_ctrl_probe(struct platform_device *pdev)of_genpd_del_provider (dev->of_node); cleanup_pds:for (i--; i >=0 ; i--) { +device_link_remove (dev, bc->domains[i].power_dev);pm_genpd_remove (&bc->domains[i].genpd);dev_pm_domain_detach (bc->domains[i].power_dev, true); }
@@ -343,6 +358,7 @@ static void imx8m_blk_ctrl_remove(struct platform_device *pdev)for (i =0 ; bc->onecell_data.num_domains; i++) {struct imx8m_blk_ctrl_domain *domain = &bc->domains[i]; +device_link_remove (&pdev->dev, domain->power_dev);pm_genpd_remove (&domain->genpd);dev_pm_domain_detach (domain->power_dev, true); }
Signature · 1 line
2.34.1
Quoted 2 lines
…, add a device link betweem
blk_ctrland genpdpower_dev. …
I hope that a typo will be avoided in this change description for the final commit.
Regards,
Markus
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Hi Markus,
Quoted 5 lines · Markus Elfring
Quoted 2 lines
…, add a device link betweem
blk_ctrland genpdpower_dev. …I hope that a typo will be avoided in this change description for the final commit.
Thanks for you feedback.
I will fix it next version.
Best regards,
Vitor Soares
Quoted 2 lines
Regards,
Markus
Quoted 6 lines · Vitor Soares
From: Vitor Soares <[email protected]>
During the probe, the genpd
power_devis added to thedpm_listafterblk_ctrldue to its parent/child relationship. Making theblk_ctrlsuspend after and resume before the genpdpower_dev.
Quoted 7 lines
As a consequence, the system hangs when resuming the VPU due to the power domain dependency.
To ensure the proper suspend/resume order, add a device link betweem
blk_ctrland genpdpower_dev. It guarantees genpdpower_devis suspended after and resumed before blk-ctrl.
Francesco
Quoted 11 lines · Francesco Dolcini
Quoted 9 lines · Vitor Soares
From: Vitor Soares <[email protected]>
During the probe, the genpd
power_devis added to thedpm_listafterblk_ctrldue to its parent/child relationship. Making theblk_ctrlsuspend after and resume before the genpdpower_dev.As a consequence, the system hangs when resuming the VPU due to the power domain dependency.
Quoted 6 lines
Quoted 4 lines
To ensure the proper suspend/resume order, add a device link betweem
blk_ctrland genpdpower_dev. It guarantees genpdpower_devis suspended after and resumed before blk-ctrl.Cc Adam Ford
Thanks! This is what I was thinking from the other thread. I just didn't see this one.
adam
Quoted 3 lines
Francesco
Am Donnerstag, dem 18.04.2024 um 16:51 +0100 schrieb Vitor Soares:
Quoted 13 lines
From: Vitor Soares <[email protected]>
During the probe, the genpd
power_devis added to thedpm_listafterblk_ctrldue to its parent/child relationship. Making theblk_ctrlsuspend after and resume before the genpdpower_dev.As a consequence, the system hangs when resuming the VPU due to the power domain dependency.
To ensure the proper suspend/resume order, add a device link betweem
blk_ctrland genpdpower_dev. It guarantees genpdpower_devis suspended after and resumed before blk-ctrl.
Quoted 6 lines
Cc <[email protected]>Fixes 2684ac05a8c4 ("soc: imx: add i.MX8M blk-ctrl driver")Suggested-by Lucas Stach <[email protected]>Signed-off-by Vitor Soares <[email protected]>
Quoted 52 lines
---
This is a new patch, but is a follow-up of:
https://lore.kernel.org/all/[email protected]/As suggested by Lucas, we are addressing this PM issue in the imx8m-blk-ctrl driver instead of in the
imx8mm.dtsi.drivers/pmdomain/imx/imx8m-blk-ctrl.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)drivers/pmdomain/imx/imx8m-blk-ctrl.c +16
-0@@ -283,6 +283,20 @@ static int imx8m_blk_ctrl_probe(struct platform_device *pdev) goto cleanup_pds; } +/* +* Enforce suspend/resume ordering by making genpd power_dev a +* provider of blk-ctrl. Genpd power_dev is suspended after and +* resumed before blk-ctrl. +*/ +if (!device_link_add (dev, domain->power_dev,DL_FLAG_STATELESS )) { + ret = -EINVAL ; +dev_err_probe (dev, ret, +"failed to link to %s\n" , data->name); +pm_genpd_remove (&domain->genpd); +dev_pm_domain_detach (domain->power_dev, true); + goto cleanup_pds; + } +/* * We use runtime PM to trigger power on/off of the upstream GPC * domain, as a strict hierarchical parent/child power domain @@ -324,6 +338,7 @@ static int imx8m_blk_ctrl_probe(struct platform_device *pdev)of_genpd_del_provider (dev->of_node); cleanup_pds:for (i--; i >=0 ; i--) { +device_link_remove (dev, bc->domains[i].power_dev);pm_genpd_remove (&bc->domains[i].genpd);dev_pm_domain_detach (bc->domains[i].power_dev, true); }@@ -343,6 +358,7 @@ static void imx8m_blk_ctrl_remove(struct platform_device *pdev)for (i =0 ; bc->onecell_data.num_domains; i++) {struct imx8m_blk_ctrl_domain *domain = &bc->domains[i]; +device_link_remove (&pdev->dev, domain->power_dev);pm_genpd_remove (&domain->genpd);dev_pm_domain_detach (domain->power_dev, true); }
Quoted 7 lines · Vitor Soares
From: Vitor Soares <[email protected]>
During the probe, the genpd
power_devis added to thedpm_listafterblk_ctrldue to its parent/child relationship. Making theblk_ctrlsuspend after and resume before the genpdpower_dev.
Quoted 6 lines
As a consequence, the system hangs when resuming the VPU due to the power domain dependency.
To ensure the proper suspend/resume order, add a device link betweem
blk_ctrland genpdpower_dev. It guarantees genpdpower_devis suspended after and resumed before blk-ctrl.
Before discussing $subject patch, would you mind explaining to me why imx8m-blk-ctrl needs to use the ->suspend() callback at all?
Looking closer at that code (imx8m_blk_ctrl_suspend()), it calls pm_runtime_get_sync() for devices to power on "everything". Why isn't that managed by the consumer drivers (on a case by case basis) that are managing the devices that are attached to the genpds instead?
Kind regards
Uffe
Quoted 62 lines
Cc <[email protected]>Fixes 2684ac05a8c4 ("soc: imx: add i.MX8M blk-ctrl driver")Suggested-by Lucas Stach <[email protected]>Signed-off-by Vitor Soares <[email protected]>---
This is a new patch, but is a follow-up of:
https://lore.kernel.org/all/[email protected]/As suggested by Lucas, we are addressing this PM issue in the imx8m-blk-ctrl driver instead of in the
imx8mm.dtsi.drivers/pmdomain/imx/imx8m-blk-ctrl.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)drivers/pmdomain/imx/imx8m-blk-ctrl.c +16
-1@@ -283,6 +283,20 @@ static int imx8m_blk_ctrl_probe(struct platform_device *pdev) goto cleanup_pds; } +/* +* Enforce suspend/resume ordering by making genpd power_dev a +* provider of blk-ctrl. Genpd power_dev is suspended after and +* resumed before blk-ctrl. +*/ +if (!device_link_add (dev, domain->power_dev,DL_FLAG_STATELESS )) { + ret = -EINVAL ; +dev_err_probe (dev, ret, +"failed to link to %s\n" , data->name); +pm_genpd_remove (&domain->genpd); +dev_pm_domain_detach (domain->power_dev, true); + goto cleanup_pds; + } +/* * We use runtime PM to trigger power on/off of the upstream GPC * domain, as a strict hierarchical parent/child power domain @@ -324,6 +338,7 @@ static int imx8m_blk_ctrl_probe(struct platform_device *pdev)of_genpd_del_provider (dev->of_node); cleanup_pds:for (i--; i >=0 ; i--) { +device_link_remove (dev, bc->domains[i].power_dev);pm_genpd_remove (&bc->domains[i].genpd);dev_pm_domain_detach (bc->domains[i].power_dev, true); }@@ -343,6 +358,7 @@ static void imx8m_blk_ctrl_remove(struct platform_device *pdev)for (i =0 ; bc->onecell_data.num_domains; i++) {struct imx8m_blk_ctrl_domain *domain = &bc->domains[i]; +device_link_remove (&pdev->dev, domain->power_dev);pm_genpd_remove (&domain->genpd);dev_pm_domain_detach (domain->power_dev, true); } --2.34.1
Quoted 18 lines · Ulf Hansson
Quoted 7 lines · Vitor Soares
From: Vitor Soares <[email protected]>
During the probe, the genpd
power_devis added to thedpm_listafterblk_ctrldue to its parent/child relationship. Making theblk_ctrlsuspend after and resume before the genpdpower_dev.Quoted 6 lines
As a consequence, the system hangs when resuming the VPU due to the power domain dependency.
To ensure the proper suspend/resume order, add a device link betweem
blk_ctrland genpdpower_dev. It guarantees genpdpower_devis suspended after and resumed before blk-ctrl.Before discussing $subject patch, would you mind explaining to me why imx8m-blk-ctrl needs to use the ->suspend() callback at all?
Quoted 8 lines
Looking closer at that code (
imx8m_blk_ctrl_suspend()), it callspm_runtime_get_sync()for devices to power on "everything". Why isn't that managed by the consumer drivers (on a case by case basis) that are managing the devices that are attached to the genpds instead?Kind regards
Uffe
Hi Lucas, you know the driver architecture better than I do. Would you mind addressing Ulf concerns?
In addition to that, I would say that given that this is a bug fix, it would be nice to have it merged. Having a buggy driver in the kernel is not solving this kind of architectural question.
Best regards,
Vitor Soares
Quoted 72 lines
Quoted 72 lines
Cc: <[email protected]>
Closes:
https://lore.kernel.org/all/[email protected]/Fixes 2684ac05a8c4 ("soc: imx: add i.MX8M blk-ctrl driver")Suggested-by Lucas Stach <[email protected]>Signed-off-by Vitor Soares <[email protected]>---
This is a new patch, but is a follow-up of:
https://lore.kernel.org/all/[email protected]/As suggested by Lucas, we are addressing this PM issue in the imx8m-blk-ctrl driver instead of in the
imx8mm.dtsi.drivers/pmdomain/imx/imx8m-blk-ctrl.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)drivers/pmdomain/imx/imx8m-blk-ctrl.c +2
-0@@ -283,6 +283,20 @@ static int imx8m_blk_ctrl_probe(struct platform_device *pdev) goto cleanup_pds; } + /* +* Enforce suspend/resume ordering by making genpd power_dev a
+ * provider of blk-ctrl. Genpdpower_devis suspended after and
+ * resumed before blk-ctrl.
+ */
+ if (!device_link_add(dev,domain->power_dev,DL_FLAG_STATELESS)) {
+ ret =-EINVAL;
+ dev_err_probe(dev, ret,
+ "failed to link to %s\n",data->name); +pm_genpd_remove(&domain->genpd);
+dev_pm_domain_detach(domain->power_dev, true); + gotocleanup_pds;
+ }
+
/*
* We use runtime PM to trigger power on/off of the upstream GPC
* domain, as a strict hierarchical parent/child power domaindrivers/pmdomain/imx/imx8m-blk-ctrl.c +0
-0@@ -324,6 +338,7 @@ static int imx8m_blk_ctrl_probe(struct platform_device *pdev) of_genpd_del_provider(dev->of_node);cleanup_pds:
for (i--; i >= 0; i--) {
+device_link_remove(dev, bc->domains[i].power_dev);pm_genpd_remove(&bc->domains[i].genpd);dev_pm_domain_detach(bc->domains[i].power_dev, true); }drivers/pmdomain/imx/imx8m-blk-ctrl.c +1
-0@@ -343,6 +358,7 @@ static void imx8m_blk_ctrl_remove(struct platform_device *pdev) for (i = 0; bc->onecell_data.num_domains; i++) { struct imx8m_blk_ctrl_domain *domain = &bc->domains[i]; + device_link_remove(&pdev->dev, domain->power_dev); pm_genpd_remove(&domain->genpd); dev_pm_domain_detach(domain->power_dev, true);}
--
2.34.1