Re: [PATCH togreg 2/2] iio: imu: inv_icm42607: restore runtime PM on system resume errors
Andy Shevchenko <[email protected]>
| Newsgroups | org.kernel.vger.linux-iio,org.kernel.vger.linux-kernel |
|---|---|
| Organization | Intel Finland Oy - BIC 0357606-4 - c/o Alberga Business Park, 6 krs, Bertel Jungin Aukio 5, 02600 Espoo |
| Message-ID | <[email protected]> |
On Wed, Aug 05, 2026 at 11:54:51AM +0800, Linmao Li wrote:
> pm_runtime_force_suspend() leaves runtime PM disabled after it succeeds and
> expects pm_runtime_force_resume() to restore runtime PM management during
> system resume.
>
> The resume callback returns early if enabling the vddio regulator or
> synchronizing the register cache fails, skipping the matching
> pm_runtime_force_resume() call. Runtime PM consequently remains disabled
> after the system has resumed, so runtime autosuspend can no longer turn off
> sensors enabled afterward.
>
> Call pm_runtime_force_resume() on both error paths. Keep the first error as
> the return value and report a runtime PM restore failure separately.
...
> static int inv_icm42607_resume(struct device *dev)
> {
> struct inv_icm42607_state *st = dev_get_drvdata(dev);
> + int resume_ret;
> int ret;
>
> ret = inv_icm42607_enable_vddio_reg(st);
> - if (ret)
> - return ret;
> + if (!ret) {
This usually hints that the function needs to be refactored by splitting out
the wrapper that does PM and the core (current function).
> + /* Sync the regcache again after regulator shutdown. */
> + regcache_mark_dirty(st->map);
> + ret = regcache_sync(st->map);
> + }
> +
> + resume_ret = pm_runtime_force_resume(dev);
> + if (ret) {
> + if (resume_ret)
> + dev_warn(dev, "Failed to restore runtime PM state: %d\n",
> + resume_ret);
>
> - /* Sync the regcache again after regulator shutdown. */
> - regcache_mark_dirty(st->map);
> - ret = regcache_sync(st->map);
> - if (ret)
> return ret;
> + }
>
> - return pm_runtime_force_resume(dev);
> + return resume_ret;
> }
--
With Best Regards,
Andy Shevchenko