Linux kernel and device drivers for NXP i.MX platforms
 help / color / mirror / Atom feed
From: Lucas Stach <l.stach@pengutronix.de>
To: Vitor Soares <ivitro@gmail.com>,
	Ulf Hansson <ulf.hansson@linaro.org>,
	 Shawn Guo <shawnguo@kernel.org>,
	Sascha Hauer <s.hauer@pengutronix.de>,
	Pengutronix Kernel Team <kernel@pengutronix.de>,
	Fabio Estevam <festevam@gmail.com>
Cc: Vitor Soares <vitor.soares@toradex.com>,
	linux-pm@vger.kernel.org,  imx@lists.linux.dev,
	linux-arm-kernel@lists.infradead.org,
	 linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH v1] pmdomain: imx8m-blk-ctrl: fix suspend/resume order
Date: Wed, 08 May 2024 19:46:01 +0200	[thread overview]
Message-ID: <a08ac1e225d29797cf8d375c5cf4c331f66c92a8.camel@pengutronix.de> (raw)
In-Reply-To: <20240418155151.355133-1-ivitro@gmail.com>

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);
>  	}


  parent reply	other threads:[~2024-05-08 17:46 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2024-05-10  9:34 ` Ulf Hansson
2024-06-25  7:32   ` Vitor Soares

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a08ac1e225d29797cf8d375c5cf4c331f66c92a8.camel@pengutronix.de \
    --to=l.stach@pengutronix.de \
    --cc=festevam@gmail.com \
    --cc=imx@lists.linux.dev \
    --cc=ivitro@gmail.com \
    --cc=kernel@pengutronix.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=s.hauer@pengutronix.de \
    --cc=shawnguo@kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=ulf.hansson@linaro.org \
    --cc=vitor.soares@toradex.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox