Hi Jie,
Thanks for fixing! It is shame that my single patch caused issues both in driver's probe and remove - I have to admit that I don't understand runtime PM's state machine.
TBC, this patch only fixes probe. The driver's remove is fixed in: https://lore.kernel.org/linux-arm-kernel/20260710-fix-clock-refcount-unbalan...
The series above and this patch should be picked up together so can have complete fix.
The probe wrapper then unconditionally calls pm_runtime_put() regardless of whether the inner probe succeeded, so on failure this also fires runtime_suspend() and disables the same clocks a first time.
pm_runtime_put() can be used for success case, but for the failure case, we should disable the runtime PM but not release reference: https://docs.kernel.org/power/runtime_pm.html#runtime-pm-initialization-devi...
@@ -632,11 +632,14 @@ static int catu_platform_probe(struct platform_device *pdev) pm_runtime_enable(&pdev->dev); ret = __catu_probe(&pdev->dev, res);
- pm_runtime_put(&pdev->dev);
- if (ret)
- if (ret) {
pm_runtime_disable(&pdev->dev);pm_runtime_put_noidle(&pdev->dev);
Nitpick: please reverse the sequence between pm_runtime_put_noidle() and pm_runtime_disable(). As we need to first disable runtime PM for the device, then release usage reference.
Since the driver core will reset device's active state, AI told me that calling pm_runtime_set_suspended() is redundant. It is still good to explicitly call it for bookkeeping. This can be aligned with the change in driver remove.
Thus, please update the flow:
pm_runtime_disable(&pdev->dev); pm_runtime_set_suspended(dev); pm_runtime_put_noidle(&pdev->dev);
With the update:
Reviewed-by: Leo Yan leo.yan@arm.com