All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] spi: meson-spifc: use devm_pm_runtime_set_active_enabled
@ 2026-08-01 17:51 ` Felix Gu
  0 siblings, 0 replies; 5+ messages in thread
From: Felix Gu @ 2026-08-01 17:51 UTC (permalink / raw)
  To: Mark Brown, Neil Armstrong, Kevin Hilman, Jerome Brunet,
	Martin Blumenstingl
  Cc: linux-spi, linux-arm-kernel, linux-amlogic, linux-kernel,
	Felix Gu

Use devm_pm_runtime_set_active_enabled to replace
pm_runtime_set_active() + pm_runtime_enable() and drop the out_pm
error label.

Signed-off-by: Felix Gu <ustc.gu@gmail.com>
---
Changes in v2:
- Fix Mark's comment.
- Link to v1: https://patch.msgid.link/20260722-spifc-v1-1-e4462a4c6a06@gmail.com

To: Mark Brown <broonie@kernel.org>
To: Neil Armstrong <neil.armstrong@linaro.org>
To: Kevin Hilman <khilman@baylibre.com>
To: Jerome Brunet <jbrunet@baylibre.com>
To: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Cc: linux-spi@vger.kernel.org
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-amlogic@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
---
 drivers/spi/spi-meson-spifc.c | 16 +++++-----------
 1 file changed, 5 insertions(+), 11 deletions(-)

diff --git a/drivers/spi/spi-meson-spifc.c b/drivers/spi/spi-meson-spifc.c
index e36aa94bbdae..82c1c3c0c84b 100644
--- a/drivers/spi/spi-meson-spifc.c
+++ b/drivers/spi/spi-meson-spifc.c
@@ -325,26 +325,20 @@ static int meson_spifc_probe(struct platform_device *pdev)
 
 	meson_spifc_hw_init(spifc);
 
-	pm_runtime_set_active(spifc->dev);
-	pm_runtime_enable(spifc->dev);
+	ret =  devm_pm_runtime_set_active_enabled(spifc->dev);
+	if (ret)
+		return dev_err_probe(spifc->dev, ret, "failed to set runtime PM\n");
 
 	ret = devm_spi_register_controller(spifc->dev, host);
-	if (ret) {
-		dev_err(spifc->dev, "failed to register spi host\n");
-		goto out_pm;
-	}
+	if (ret)
+		return dev_err_probe(spifc->dev, ret, "failed to register spi host\n");
 
 	return 0;
-out_pm:
-	pm_runtime_disable(spifc->dev);
-
-	return ret;
 }
 
 static void meson_spifc_remove(struct platform_device *pdev)
 {
 	pm_runtime_get_sync(&pdev->dev);
-	pm_runtime_disable(&pdev->dev);
 	pm_runtime_put_noidle(&pdev->dev);
 }
 

---
base-commit: 3fe08b9796f36ef437ab9328e7dd1e5ff2d66603
change-id: 20260722-spifc-336fbde9511b

Best regards,
--  
Felix Gu <ustc.gu@gmail.com>



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

* [PATCH v2] spi: meson-spifc: use devm_pm_runtime_set_active_enabled
@ 2026-08-01 17:51 ` Felix Gu
  0 siblings, 0 replies; 5+ messages in thread
From: Felix Gu @ 2026-08-01 17:51 UTC (permalink / raw)
  To: Mark Brown, Neil Armstrong, Kevin Hilman, Jerome Brunet,
	Martin Blumenstingl
  Cc: linux-spi, linux-arm-kernel, linux-amlogic, linux-kernel,
	Felix Gu

Use devm_pm_runtime_set_active_enabled to replace
pm_runtime_set_active() + pm_runtime_enable() and drop the out_pm
error label.

Signed-off-by: Felix Gu <ustc.gu@gmail.com>
---
Changes in v2:
- Fix Mark's comment.
- Link to v1: https://patch.msgid.link/20260722-spifc-v1-1-e4462a4c6a06@gmail.com

To: Mark Brown <broonie@kernel.org>
To: Neil Armstrong <neil.armstrong@linaro.org>
To: Kevin Hilman <khilman@baylibre.com>
To: Jerome Brunet <jbrunet@baylibre.com>
To: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Cc: linux-spi@vger.kernel.org
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-amlogic@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
---
 drivers/spi/spi-meson-spifc.c | 16 +++++-----------
 1 file changed, 5 insertions(+), 11 deletions(-)

diff --git a/drivers/spi/spi-meson-spifc.c b/drivers/spi/spi-meson-spifc.c
index e36aa94bbdae..82c1c3c0c84b 100644
--- a/drivers/spi/spi-meson-spifc.c
+++ b/drivers/spi/spi-meson-spifc.c
@@ -325,26 +325,20 @@ static int meson_spifc_probe(struct platform_device *pdev)
 
 	meson_spifc_hw_init(spifc);
 
-	pm_runtime_set_active(spifc->dev);
-	pm_runtime_enable(spifc->dev);
+	ret =  devm_pm_runtime_set_active_enabled(spifc->dev);
+	if (ret)
+		return dev_err_probe(spifc->dev, ret, "failed to set runtime PM\n");
 
 	ret = devm_spi_register_controller(spifc->dev, host);
-	if (ret) {
-		dev_err(spifc->dev, "failed to register spi host\n");
-		goto out_pm;
-	}
+	if (ret)
+		return dev_err_probe(spifc->dev, ret, "failed to register spi host\n");
 
 	return 0;
-out_pm:
-	pm_runtime_disable(spifc->dev);
-
-	return ret;
 }
 
 static void meson_spifc_remove(struct platform_device *pdev)
 {
 	pm_runtime_get_sync(&pdev->dev);
-	pm_runtime_disable(&pdev->dev);
 	pm_runtime_put_noidle(&pdev->dev);
 }
 

---
base-commit: 3fe08b9796f36ef437ab9328e7dd1e5ff2d66603
change-id: 20260722-spifc-336fbde9511b

Best regards,
--  
Felix Gu <ustc.gu@gmail.com>


_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

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

* Re: [PATCH v2] spi: meson-spifc: use devm_pm_runtime_set_active_enabled
  2026-08-01 17:51 ` Felix Gu
  (?)
@ 2026-08-01 18:08 ` sashiko-bot
  -1 siblings, 0 replies; 5+ messages in thread
From: sashiko-bot @ 2026-08-01 18:08 UTC (permalink / raw)
  To: Felix Gu; +Cc: neil.armstrong, linux-amlogic

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Removing `pm_runtime_disable()` from `meson_spifc_remove()` introduces a race condition during device removal that can cause a clock usage underflow.
--

--- Patch [1]: [PATCH v2] spi: meson-spifc: use devm_pm_runtime_set_active_enabled ---
commit b45e95aa00b1b02a9f6c29275b73bb003b297870
Author: Felix Gu <ustc.gu@gmail.com>

spi: meson-spifc: use devm_pm_runtime_set_active_enabled

This commit converts the driver to use devm_pm_runtime_set_active_enabled(),
dropping explicit pm_runtime_enable and pm_runtime_disable calls along with
their associated error paths.

Link: https://patch.msgid.link/20260722-spifc-v1-1-e4462a4c6a06@gmail.com

> diff --git a/drivers/spi/spi-meson-spifc.c b/drivers/spi/spi-meson-spifc.c
> index e36aa94bbdae3..82c1c3c0c84b5 100644
> --- a/drivers/spi/spi-meson-spifc.c
> +++ b/drivers/spi/spi-meson-spifc.c
> @@ -325,26 +325,20 @@ static int meson_spifc_probe(struct platform_device *pdev)
>  
>  	meson_spifc_hw_init(spifc);
>  
> -	pm_runtime_set_active(spifc->dev);
> -	pm_runtime_enable(spifc->dev);
> +	ret =  devm_pm_runtime_set_active_enabled(spifc->dev);

[ ... ]

>  static void meson_spifc_remove(struct platform_device *pdev)
>  {
>  	pm_runtime_get_sync(&pdev->dev);
> -	pm_runtime_disable(&pdev->dev);
>  	pm_runtime_put_noidle(&pdev->dev);

[Severity: High]
Does removing pm_runtime_disable() here create a race condition that can
lead to a clock usage underflow?

When pm_runtime_put_noidle() drops the usage count to 0, PM runtime remains
enabled until the devres teardown phase.

Next, devres teardown runs devm_spi_unregister_controller(), which
unregisters child SPI devices.

If a child device (like an SPI flash) performs a final transfer during its
own removal, the SPI core will temporarily wake this parent controller and
then call pm_runtime_put_autosuspend() when the transfer completes.

Because the base usage count is now 0, this queues an asynchronous suspend.
When meson_spifc_runtime_suspend() runs, it calls clk_disable_unprepare(),
dropping the clock count to 0.

Later in the devres teardown sequence, the cleanup for devm_clk_get_enabled()
executes and unconditionally calls clk_disable_unprepare() again, causing
the clock count to underflow.

>  }
>

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260802-spifc-v2-1-46e9d06a3217@gmail.com?part=1

_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

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

* Re: [PATCH v2] spi: meson-spifc: use devm_pm_runtime_set_active_enabled
  2026-08-01 17:51 ` Felix Gu
@ 2026-08-11 14:05   ` Mark Brown
  -1 siblings, 0 replies; 5+ messages in thread
From: Mark Brown @ 2026-08-11 14:05 UTC (permalink / raw)
  To: Neil Armstrong, Kevin Hilman, Jerome Brunet, Martin Blumenstingl,
	Felix Gu
  Cc: linux-spi, linux-arm-kernel, linux-amlogic, linux-kernel

On Sun, 02 Aug 2026 01:51:24 +0800, Felix Gu wrote:
> spi: meson-spifc: use devm_pm_runtime_set_active_enabled

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-7.3

Thanks!

[1/1] spi: meson-spifc: use devm_pm_runtime_set_active_enabled
      https://git.kernel.org/broonie/spi/c/c10b7f5e0cb1

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark


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

* Re: [PATCH v2] spi: meson-spifc: use devm_pm_runtime_set_active_enabled
@ 2026-08-11 14:05   ` Mark Brown
  0 siblings, 0 replies; 5+ messages in thread
From: Mark Brown @ 2026-08-11 14:05 UTC (permalink / raw)
  To: Neil Armstrong, Kevin Hilman, Jerome Brunet, Martin Blumenstingl,
	Felix Gu
  Cc: linux-spi, linux-arm-kernel, linux-amlogic, linux-kernel

On Sun, 02 Aug 2026 01:51:24 +0800, Felix Gu wrote:
> spi: meson-spifc: use devm_pm_runtime_set_active_enabled

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-7.3

Thanks!

[1/1] spi: meson-spifc: use devm_pm_runtime_set_active_enabled
      https://git.kernel.org/broonie/spi/c/c10b7f5e0cb1

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark


_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

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

end of thread, other threads:[~2026-08-11 16:47 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-01 17:51 [PATCH v2] spi: meson-spifc: use devm_pm_runtime_set_active_enabled Felix Gu
2026-08-01 17:51 ` Felix Gu
2026-08-01 18:08 ` sashiko-bot
2026-08-11 14:05 ` Mark Brown
2026-08-11 14:05   ` Mark Brown

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.