From: Frank Li <Frank.li@nxp.com>
To: Laurentiu Palcu <laurentiu.palcu@oss.nxp.com>
Cc: Abel Vesa <abelvesa@kernel.org>, Peng Fan <peng.fan@nxp.com>,
Michael Turquette <mturquette@baylibre.com>,
Stephen Boyd <sboyd@kernel.org>, Shawn Guo <shawnguo@kernel.org>,
Sascha Hauer <s.hauer@pengutronix.de>,
Pengutronix Kernel Team <kernel@pengutronix.de>,
Fabio Estevam <festevam@gmail.com>,
linux-clk@vger.kernel.org, imx@lists.linux.dev,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 2/2] clk: imx95-blk-ctl: Save/restore registers when RPM routines are called
Date: Tue, 5 Aug 2025 16:25:13 -0400 [thread overview]
Message-ID: <aJJoqZN4OOFS8hNT@lizhi-Precision-Tower-5810> (raw)
In-Reply-To: <20250804131450.3918846-3-laurentiu.palcu@oss.nxp.com>
On Mon, Aug 04, 2025 at 04:14:50PM +0300, Laurentiu Palcu wrote:
> When runtime PM is used for clock providers that are part of a power
> domain, the power domain supply is cut off during runtime suspend. This
> causes all BLK CTL registers belonging to that power domain to reset. To
> prevent this, save the state of the registers before entering suspend
> and restore them on resume. Additionally, disable the APB clock during
> suspend to minimize power consumption.
>
> Signed-off-by: Laurentiu Palcu <laurentiu.palcu@oss.nxp.com>
Reviewed-by: Frank Li <Frank.Li@nxp.com>
> ---
> drivers/clk/imx/clk-imx95-blk-ctl.c | 33 ++++++++++++++++++-----------
> 1 file changed, 21 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/clk/imx/clk-imx95-blk-ctl.c b/drivers/clk/imx/clk-imx95-blk-ctl.c
> index c72debaf3a60b..56bed44719954 100644
> --- a/drivers/clk/imx/clk-imx95-blk-ctl.c
> +++ b/drivers/clk/imx/clk-imx95-blk-ctl.c
> @@ -453,15 +453,24 @@ static int imx95_bc_runtime_suspend(struct device *dev)
> {
> struct imx95_blk_ctl *bc = dev_get_drvdata(dev);
>
> + bc->clk_reg_restore = readl(bc->base + bc->pdata->clk_reg_offset);
> clk_disable_unprepare(bc->clk_apb);
> +
> return 0;
> }
>
> static int imx95_bc_runtime_resume(struct device *dev)
> {
> struct imx95_blk_ctl *bc = dev_get_drvdata(dev);
> + int ret;
>
> - return clk_prepare_enable(bc->clk_apb);
> + ret = clk_prepare_enable(bc->clk_apb);
> + if (ret)
> + return ret;
> +
> + writel(bc->clk_reg_restore, bc->base + bc->pdata->clk_reg_offset);
> +
> + return 0;
> }
> #endif
>
> @@ -469,17 +478,12 @@ static int imx95_bc_runtime_resume(struct device *dev)
> static int imx95_bc_suspend(struct device *dev)
> {
> struct imx95_blk_ctl *bc = dev_get_drvdata(dev);
> - int ret;
>
> - if (bc->pdata->rpm_enabled) {
> - ret = pm_runtime_get_sync(bc->dev);
> - if (ret < 0) {
> - pm_runtime_put_noidle(bc->dev);
> - return ret;
> - }
> - }
> + if (pm_runtime_suspended(dev))
> + return 0;
>
> bc->clk_reg_restore = readl(bc->base + bc->pdata->clk_reg_offset);
> + clk_disable_unprepare(bc->clk_apb);
>
> return 0;
> }
> @@ -487,11 +491,16 @@ static int imx95_bc_suspend(struct device *dev)
> static int imx95_bc_resume(struct device *dev)
> {
> struct imx95_blk_ctl *bc = dev_get_drvdata(dev);
> + int ret;
>
> - writel(bc->clk_reg_restore, bc->base + bc->pdata->clk_reg_offset);
> + if (pm_runtime_suspended(dev))
> + return 0;
>
> - if (bc->pdata->rpm_enabled)
> - pm_runtime_put(bc->dev);
> + ret = clk_prepare_enable(bc->clk_apb);
> + if (ret)
> + return ret;
> +
> + writel(bc->clk_reg_restore, bc->base + bc->pdata->clk_reg_offset);
>
> return 0;
> }
> --
> 2.49.0
>
next prev parent reply other threads:[~2025-08-05 20:28 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-04 13:14 [PATCH v2 0/2] clk: imx95-blk-ctl: Fix runtime PM issues Laurentiu Palcu
2025-08-04 13:14 ` [PATCH v2 1/2] clk: imx95-blk-ctl: Save platform data in imx95_blk_ctl structure Laurentiu Palcu
2025-08-04 13:14 ` [PATCH v2 2/2] clk: imx95-blk-ctl: Save/restore registers when RPM routines are called Laurentiu Palcu
2025-08-05 20:25 ` Frank Li [this message]
2025-09-12 14:35 ` [PATCH v2 0/2] clk: imx95-blk-ctl: Fix runtime PM issues Abel Vesa
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=aJJoqZN4OOFS8hNT@lizhi-Precision-Tower-5810 \
--to=frank.li@nxp.com \
--cc=abelvesa@kernel.org \
--cc=festevam@gmail.com \
--cc=imx@lists.linux.dev \
--cc=kernel@pengutronix.de \
--cc=laurentiu.palcu@oss.nxp.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mturquette@baylibre.com \
--cc=peng.fan@nxp.com \
--cc=s.hauer@pengutronix.de \
--cc=sboyd@kernel.org \
--cc=shawnguo@kernel.org \
/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