Re: [PATCH] spi: meson-spifc: use devm_pm_runtime_set_active_enabled

[email protected] Wed, 22 Jul 2026 12:23:01 +0000
Newsgroups org.infradead.lists.linux-amlogic
Message-ID <[email protected]>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Removing `meson_spifc_remove()` introduces a clock enable count underflow (double-disable) when the device is unbound.
--

--- Patch [1]: [PATCH] spi: meson-spifc: use devm_pm_runtime_set_active_enabled ---
commit 8bdf0818e31891c7533aa22fdb8392acb6154567
Author: Felix Gu <[email protected]>

spi: meson-spifc: use devm_pm_runtime_set_active_enabled

This commit replaces pm_runtime_set_active() and pm_runtime_enable() with
devm_pm_runtime_set_active_enabled(). It also drops the out_pm error path
and entirely removes the meson_spifc_remove() function.

> diff --git a/drivers/spi/spi-meson-spifc.c b/drivers/spi/spi-meson-spifc.c
> --- a/drivers/spi/spi-meson-spifc.c
> +++ b/drivers/spi/spi-meson-spifc.c
[ ... ]
> -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: Medium]
Does removing this function introduce a clock enable count underflow during
driver unbind?

When the driver is unbound, the driver core calls pm_runtime_put_sync() in
__device_release_driver(). Since the driver does not use autosuspend, this
synchronously suspends the device by invoking meson_spifc_runtime_suspend(),
which disables the clock.

Subsequently, the devres cleanup for devm_clk_get_enabled() executes and
calls clk_disable_unprepare() a second time on the already disabled clock.

The removed meson_spifc_remove() function prevented this by calling
pm_runtime_get_sync() to wake the device and keep the clock active until
the devres teardown runs.

-- 
Sashiko AI review ยท https://sashiko.dev/#/patchset/[email protected]?part=1

_______________________________________________
linux-amlogic mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-amlogic