The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: Linmao Li <lilinmao@kylinos.cn>
Cc: "Jonathan Cameron" <jic23@kernel.org>,
	"Chris Morgan" <macromorgan@hotmail.com>,
	"David Lechner" <dlechner@baylibre.com>,
	"Nuno Sá" <nuno.sa@analog.com>,
	"Andy Shevchenko" <andy@kernel.org>,
	linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH togreg 2/2] iio: imu: inv_icm42607: restore runtime PM on system resume errors
Date: Mon, 10 Aug 2026 22:38:29 +0300	[thread overview]
Message-ID: <anootUNH8xa_PRDe@ashevche-desk.local> (raw)
In-Reply-To: <20260805035451.487465-3-lilinmao@kylinos.cn>

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



  reply	other threads:[~2026-08-10 19:38 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-05  3:54 [PATCH togreg 0/2] iio: imu: inv_icm42607: fix PM error handling Linmao Li
2026-08-05  3:54 ` [PATCH togreg 1/2] iio: imu: inv_icm42607: propagate runtime suspend errors Linmao Li
2026-08-05  3:54 ` [PATCH togreg 2/2] iio: imu: inv_icm42607: restore runtime PM on system resume errors Linmao Li
2026-08-10 19:38   ` Andy Shevchenko [this message]
2026-08-11  2:03 ` [PATCH togreg v2 0/2] iio: imu: inv_icm42607: fix PM error handling Linmao Li
2026-08-11  2:03   ` [PATCH togreg v2 1/2] iio: imu: inv_icm42607: propagate runtime suspend errors Linmao Li
2026-08-11  2:03   ` [PATCH togreg v2 2/2] iio: imu: inv_icm42607: restore runtime PM on system resume errors Linmao Li
2026-08-11  8:54     ` Andy Shevchenko
2026-08-11 10:32       ` Linmao Li
2026-08-11  7:40   ` [PATCH togreg v2 0/2] iio: imu: inv_icm42607: fix PM error handling Andy Shevchenko
2026-08-11 10:32   ` [PATCH togreg v3 " Linmao Li
2026-08-11 10:33     ` [PATCH togreg v3 1/2] iio: imu: inv_icm42607: propagate runtime suspend errors Linmao Li
2026-08-11 10:33     ` [PATCH togreg v3 2/2] iio: imu: inv_icm42607: restore runtime PM on system resume errors Linmao Li

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=anootUNH8xa_PRDe@ashevche-desk.local \
    --to=andriy.shevchenko@intel.com \
    --cc=andy@kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=jic23@kernel.org \
    --cc=lilinmao@kylinos.cn \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=macromorgan@hotmail.com \
    --cc=nuno.sa@analog.com \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox