From: Sascha Hauer <s.hauer@pengutronix.de> To: Christian Eggers <ceggers@arri.de> Cc: Mark Brown <broonie@kernel.org>, Shawn Guo <shawnguo@kernel.org>, Pengutronix Kernel Team <kernel@pengutronix.de>, Fabio Estevam <festevam@gmail.com>, NXP Linux Team <linux-imx@nxp.com>, linux-spi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] spi: imx: Revert "spi: imx: enable runtime pm support" Date: Mon, 12 Oct 2020 16:07:53 +0200 [thread overview] Message-ID: <20201012140753.GF12463@pengutronix.de> (raw) In-Reply-To: <6367849.hfWVFoRi9M@n95hx1g2> On Fri, Oct 09, 2020 at 09:48:29AM +0200, Christian Eggers wrote: > Hi Sascha, > > On Friday, 9 October 2020, 09:39:44 CEST, Sascha Hauer wrote: > > On Fri, Oct 09, 2020 at 06:27:38AM +0200, Christian Eggers wrote: > > > This reverts commit 525c9e5a32bd7951eae3f06d9d077fea51718a6c. > > > > > > If CONFIG_PM is disabled, the system completely freezes on probe as > > > nothing enables the clock of the SPI peripheral. > > > > Instead of reverting it, why not just fix it? > I expect that 5.9 will be released soon. I think that in this late stage > reverting is more safe than fixing... > > > Normally the device should be brought to active state manually in probe > > before pm_runtime takes over, then CONFIG_PM disabled doesn't hurt. > > Using pm_runtime to put the device to active state initially has the > > problem you describe. > Thanks for the hint. I've no experience in runtime power management. If you > could provide a patch against the current version, I can make a quick test. I > can also try to fix it myself, but this will take until next week. Here we go. The patch basically works, but I am also not very confident with pm_runtime, so please have a close look ;) Sascha -------------------------------8<-------------------------------- From 6c584eb8a2fbff46bf8bbebae6c10609c169309b Mon Sep 17 00:00:00 2001 From: Sascha Hauer <s.hauer@pengutronix.de> Date: Mon, 12 Oct 2020 15:59:50 +0200 Subject: [PATCH] spi: imx: fix runtime pm support for !CONFIG_PM 525c9e5a32bd introduced pm_runtime support for the i.MX SPI driver. With this pm_runtime is used to bring up the clocks initially. When CONFIG_PM is disabled the clocks are no longer enabled and the driver doesn't work anymore. Fix this by enabling the clocks in the probe function and telling pm_runtime that the device is active using pm_runtime_set_active(). Fixes: 525c9e5a32bd spi: imx: enable runtime pm support Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> --- drivers/spi/spi-imx.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/drivers/spi/spi-imx.c b/drivers/spi/spi-imx.c index 38a5f1304cec..c796e937dc6a 100644 --- a/drivers/spi/spi-imx.c +++ b/drivers/spi/spi-imx.c @@ -1674,15 +1674,18 @@ static int spi_imx_probe(struct platform_device *pdev) goto out_master_put; } - pm_runtime_enable(spi_imx->dev); + ret = clk_prepare_enable(spi_imx->clk_per); + if (ret) + goto out_master_put; + + ret = clk_prepare_enable(spi_imx->clk_ipg); + if (ret) + goto out_put_per; + pm_runtime_set_autosuspend_delay(spi_imx->dev, MXC_RPM_TIMEOUT); pm_runtime_use_autosuspend(spi_imx->dev); - - ret = pm_runtime_get_sync(spi_imx->dev); - if (ret < 0) { - dev_err(spi_imx->dev, "failed to enable clock\n"); - goto out_runtime_pm_put; - } + pm_runtime_set_active(spi_imx->dev); + pm_runtime_enable(spi_imx->dev); spi_imx->spi_clk = clk_get_rate(spi_imx->clk_per); /* @@ -1719,8 +1722,12 @@ static int spi_imx_probe(struct platform_device *pdev) out_runtime_pm_put: pm_runtime_dont_use_autosuspend(spi_imx->dev); - pm_runtime_put_sync(spi_imx->dev); + pm_runtime_set_suspended(&pdev->dev); pm_runtime_disable(spi_imx->dev); + + clk_disable_unprepare(spi_imx->clk_ipg); +out_put_per: + clk_disable_unprepare(spi_imx->clk_per); out_master_put: spi_master_put(master); -- 2.28.0 -- Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
next prev parent reply other threads:[~2020-10-12 14:08 UTC|newest] Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-10-09 4:27 Christian Eggers 2020-10-09 7:39 ` Sascha Hauer 2020-10-09 7:48 ` Christian Eggers 2020-10-12 14:07 ` Sascha Hauer [this message] 2020-10-13 11:58 ` Christian Eggers 2020-10-14 12:15 ` Mark Brown 2020-10-12 10:59 ` Christian Eggers 2020-10-12 13:28 ` Sascha Hauer 2020-10-12 13:42 ` Mark Brown
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=20201012140753.GF12463@pengutronix.de \ --to=s.hauer@pengutronix.de \ --cc=broonie@kernel.org \ --cc=ceggers@arri.de \ --cc=festevam@gmail.com \ --cc=kernel@pengutronix.de \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-imx@nxp.com \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-spi@vger.kernel.org \ --cc=shawnguo@kernel.org \ --subject='Re: [PATCH] spi: imx: Revert "spi: imx: enable runtime pm support"' \ /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
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 NNTP newsgroup(s).