Linux-PM Archive mirror
 help / color / mirror / Atom feed
* [PATCH v1] pmdomain: imx8m-blk-ctrl: fix suspend/resume order
@ 2024-04-18 15:51 Vitor Soares
  2024-04-18 16:24 ` [PATCH] " Markus Elfring
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Vitor Soares @ 2024-04-18 15:51 UTC (permalink / raw
  To: Ulf Hansson, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team,
	Fabio Estevam
  Cc: Vitor Soares, linux-pm, imx, linux-arm-kernel, linux-kernel,
	ivitro, stable, Lucas Stach

From: Vitor Soares <vitor.soares@toradex.com>

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.

Cc: <stable@vger.kernel.org>
Closes: https://lore.kernel.org/all/fccbb040330a706a4f7b34875db1d896a0bf81c8.camel@gmail.com/
Link: https://lore.kernel.org/all/20240409085802.290439-1-ivitro@gmail.com/
Fixes: 2684ac05a8c4 ("soc: imx: add i.MX8M blk-ctrl driver")
Suggested-by: Lucas Stach <l.stach@pengutronix.de>
Signed-off-by: Vitor Soares <vitor.soares@toradex.com>
---

This is a new patch, but is a follow-up of:
https://lore.kernel.org/all/20240409085802.290439-1-ivitro@gmail.com/

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(+)

diff --git a/drivers/pmdomain/imx/imx8m-blk-ctrl.c b/drivers/pmdomain/imx/imx8m-blk-ctrl.c
index ca942d7929c2..cd0d2296080d 100644
--- a/drivers/pmdomain/imx/imx8m-blk-ctrl.c
+++ b/drivers/pmdomain/imx/imx8m-blk-ctrl.c
@@ -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


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] pmdomain: imx8m-blk-ctrl: fix suspend/resume order
  2024-04-18 15:51 [PATCH v1] pmdomain: imx8m-blk-ctrl: fix suspend/resume order Vitor Soares
@ 2024-04-18 16:24 ` Markus Elfring
  2024-04-18 16:50   ` Vitor Soares
  2024-05-08 17:40 ` [PATCH v1] " Francesco Dolcini
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 7+ messages in thread
From: Markus Elfring @ 2024-04-18 16:24 UTC (permalink / raw
  To: Vitor Soares, linux-pm, imx, linux-arm-kernel, kernel-janitors,
	kernel, Fabio Estevam, Sascha Hauer, Shawn Guo, Ulf Hansson
  Cc: Vitor Soares, Lucas Stach, LKML, stable

>                                         …, add a device link betweem
> blk_ctrl and genpd power_dev. …

I hope that a typo will be avoided in this change description for the final commit.

Regards,
Markus

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] pmdomain: imx8m-blk-ctrl: fix suspend/resume order
  2024-04-18 16:24 ` [PATCH] " Markus Elfring
@ 2024-04-18 16:50   ` Vitor Soares
  0 siblings, 0 replies; 7+ messages in thread
From: Vitor Soares @ 2024-04-18 16:50 UTC (permalink / raw
  To: Markus Elfring, Vitor Soares, linux-pm, imx, linux-arm-kernel,
	kernel-janitors, kernel, Fabio Estevam, Sascha Hauer, Shawn Guo,
	Ulf Hansson
  Cc: Lucas Stach, LKML, stable

Hi Markus,


On Thu, 2024-04-18 at 18:24 +0200, Markus Elfring wrote:
> >                                         …, add a device link betweem
> > blk_ctrl and genpd power_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

> Regards,
> Markus


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v1] pmdomain: imx8m-blk-ctrl: fix suspend/resume order
  2024-04-18 15:51 [PATCH v1] pmdomain: imx8m-blk-ctrl: fix suspend/resume order Vitor Soares
  2024-04-18 16:24 ` [PATCH] " Markus Elfring
@ 2024-05-08 17:40 ` Francesco Dolcini
  2024-05-08 17:43   ` Adam Ford
  2024-05-08 17:46 ` Lucas Stach
  2024-05-10  9:34 ` Ulf Hansson
  3 siblings, 1 reply; 7+ messages in thread
From: Francesco Dolcini @ 2024-05-08 17:40 UTC (permalink / raw
  To: Vitor Soares, Adam Ford
  Cc: Ulf Hansson, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team,
	Fabio Estevam, Vitor Soares, linux-pm, imx, linux-arm-kernel,
	linux-kernel, stable, Lucas Stach

On Thu, Apr 18, 2024 at 04:51:51PM +0100, Vitor Soares wrote:
> From: Vitor Soares <vitor.soares@toradex.com>
> 
> 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.
> 

Cc: Adam Ford

Francesco


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v1] pmdomain: imx8m-blk-ctrl: fix suspend/resume order
  2024-05-08 17:40 ` [PATCH v1] " Francesco Dolcini
@ 2024-05-08 17:43   ` Adam Ford
  0 siblings, 0 replies; 7+ messages in thread
From: Adam Ford @ 2024-05-08 17:43 UTC (permalink / raw
  To: Francesco Dolcini
  Cc: Vitor Soares, Ulf Hansson, Shawn Guo, Sascha Hauer,
	Pengutronix Kernel Team, Fabio Estevam, Vitor Soares, linux-pm,
	imx, linux-arm-kernel, linux-kernel, stable, Lucas Stach

On Wed, May 8, 2024 at 12:40 PM Francesco Dolcini <francesco@dolcini.it> wrote:
>
> On Thu, Apr 18, 2024 at 04:51:51PM +0100, Vitor Soares wrote:
> > From: Vitor Soares <vitor.soares@toradex.com>
> >
> > 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.
> >
>
> Cc: Adam Ford

Thanks!  This is what I was thinking from the other thread.  I just
didn't see this one.


adam
>
> Francesco
>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v1] pmdomain: imx8m-blk-ctrl: fix suspend/resume order
  2024-04-18 15:51 [PATCH v1] pmdomain: imx8m-blk-ctrl: fix suspend/resume order Vitor Soares
  2024-04-18 16:24 ` [PATCH] " Markus Elfring
  2024-05-08 17:40 ` [PATCH v1] " Francesco Dolcini
@ 2024-05-08 17:46 ` Lucas Stach
  2024-05-10  9:34 ` Ulf Hansson
  3 siblings, 0 replies; 7+ messages in thread
From: Lucas Stach @ 2024-05-08 17:46 UTC (permalink / raw
  To: Vitor Soares, Ulf Hansson, Shawn Guo, Sascha Hauer,
	Pengutronix Kernel Team, Fabio Estevam
  Cc: Vitor Soares, linux-pm, imx, linux-arm-kernel, linux-kernel,
	stable

Am Donnerstag, dem 18.04.2024 um 16:51 +0100 schrieb Vitor Soares:
> From: Vitor Soares <vitor.soares@toradex.com>
> 
> 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.
> 
> Cc: <stable@vger.kernel.org>
> Closes: https://lore.kernel.org/all/fccbb040330a706a4f7b34875db1d896a0bf81c8.camel@gmail.com/
> Link: https://lore.kernel.org/all/20240409085802.290439-1-ivitro@gmail.com/
> Fixes: 2684ac05a8c4 ("soc: imx: add i.MX8M blk-ctrl driver")
> Suggested-by: Lucas Stach <l.stach@pengutronix.de>
> Signed-off-by: Vitor Soares <vitor.soares@toradex.com>

Reviewed-by: Lucas Stach <l.stach@pengutronix.de>

> ---
> 
> This is a new patch, but is a follow-up of:
> https://lore.kernel.org/all/20240409085802.290439-1-ivitro@gmail.com/
> 
> 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(+)
> 
> diff --git a/drivers/pmdomain/imx/imx8m-blk-ctrl.c b/drivers/pmdomain/imx/imx8m-blk-ctrl.c
> index ca942d7929c2..cd0d2296080d 100644
> --- a/drivers/pmdomain/imx/imx8m-blk-ctrl.c
> +++ b/drivers/pmdomain/imx/imx8m-blk-ctrl.c
> @@ -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);
>  	}


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v1] pmdomain: imx8m-blk-ctrl: fix suspend/resume order
  2024-04-18 15:51 [PATCH v1] pmdomain: imx8m-blk-ctrl: fix suspend/resume order Vitor Soares
                   ` (2 preceding siblings ...)
  2024-05-08 17:46 ` Lucas Stach
@ 2024-05-10  9:34 ` Ulf Hansson
  3 siblings, 0 replies; 7+ messages in thread
From: Ulf Hansson @ 2024-05-10  9:34 UTC (permalink / raw
  To: Vitor Soares, Lucas Stach
  Cc: Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
	Vitor Soares, linux-pm, imx, linux-arm-kernel, linux-kernel,
	stable

On Thu, 18 Apr 2024 at 17:52, Vitor Soares <ivitro@gmail.com> wrote:
>
> From: Vitor Soares <vitor.soares@toradex.com>
>
> 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.

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

>
> Cc: <stable@vger.kernel.org>
> Closes: https://lore.kernel.org/all/fccbb040330a706a4f7b34875db1d896a0bf81c8.camel@gmail.com/
> Link: https://lore.kernel.org/all/20240409085802.290439-1-ivitro@gmail.com/
> Fixes: 2684ac05a8c4 ("soc: imx: add i.MX8M blk-ctrl driver")
> Suggested-by: Lucas Stach <l.stach@pengutronix.de>
> Signed-off-by: Vitor Soares <vitor.soares@toradex.com>
> ---
>
> This is a new patch, but is a follow-up of:
> https://lore.kernel.org/all/20240409085802.290439-1-ivitro@gmail.com/
>
> 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(+)
>
> diff --git a/drivers/pmdomain/imx/imx8m-blk-ctrl.c b/drivers/pmdomain/imx/imx8m-blk-ctrl.c
> index ca942d7929c2..cd0d2296080d 100644
> --- a/drivers/pmdomain/imx/imx8m-blk-ctrl.c
> +++ b/drivers/pmdomain/imx/imx8m-blk-ctrl.c
> @@ -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
>

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2024-05-10  9:35 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-18 15:51 [PATCH v1] pmdomain: imx8m-blk-ctrl: fix suspend/resume order Vitor Soares
2024-04-18 16:24 ` [PATCH] " Markus Elfring
2024-04-18 16:50   ` Vitor Soares
2024-05-08 17:40 ` [PATCH v1] " Francesco Dolcini
2024-05-08 17:43   ` Adam Ford
2024-05-08 17:46 ` Lucas Stach
2024-05-10  9:34 ` Ulf Hansson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).