mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: Xiangwu Lai <laixiangwu@cmss.chinamobile.com>
Cc: jic23@kernel.org, linux-iio@vger.kernel.org,
	linux-kernel@vger.kernel.org, andy@kernel.org,
	dlechner@baylibre.com, nuno.sa@analog.com
Subject: Re: [PATCH v4 2/2] iio: gyro: mpu3050: Fix runtime PM refcount leak in trigger enable path
Date: Wed, 4 Nov 2026 13:58:26 +0200	[thread overview]
Message-ID: <ausd4u09AfIcviHI@ashevche-desk.local> (raw)
In-Reply-To: <20261104040008.1458-3-laixiangwu@cmss.chinamobile.com>

On Wed, Nov 04, 2026 at 12:00:07PM +0800, Xiangwu Lai wrote:

> mpu3050_drdy_trigger_enable() calls pm_runtime_get_sync() when
> enabling the data ready trigger, but all five error returns in the
> enable path return directly without the matching
> pm_runtime_put_autosuspend(). The disable path, in contrast, drops
> the reference correctly.
> 
> As a result, a failed trigger enable leaves the runtime PM usage
> counter incremented and the sensor can never runtime suspend. It also
> leaves hw_irq_trigger set to true, claiming the hardware IRQ is in
> use when it is not.
> 
> Use pm_runtime_resume_and_get(), which does not leave the usage
> counter incremented when resume fails, and add an error label that
> drops the runtime PM reference and clears hw_irq_trigger so that a
> failed enable returns with the device in the same state as before
> the attempt.
> 
> Also propagate the error from the IRQ status read that clears the
> data ready flag instead of only printing it, so that a failure
> anywhere in the enable path consistently rolls the trigger state
> back.

...

> static int mpu3050_drdy_trigger_enable(struct mpu3050 *mpu3050)

>  	unsigned int val;
>  	int ret;
>  
> -	pm_runtime_get_sync(mpu3050->dev);
> +	ret = pm_runtime_resume_and_get(mpu3050->dev);
> +	if (ret)
> +		return ret;

Why not PM_RUNTIME_ACQUIRE*()?
Yes, to make the

	mpu3050->hw_irq_trigger = false;

this needs to be wrapped (two functions, outer one uses PM_RUNTIME_ACQUIRE(),
and handles the flag).

>  	mpu3050->hw_irq_trigger = true;

-- 
With Best Regards,
Andy Shevchenko



  reply	other threads:[~2026-11-04 11:58 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-04  4:00 [PATCH v4 0/2] " Xiangwu Lai
2026-11-04  4:00 ` [PATCH v4 1/2] iio: gyro: mpu3050: Split data ready trigger enable/disable into helpers Xiangwu Lai
2026-11-05 15:31   ` Joshua Crofts
2026-11-06  2:06     ` Xiangwu Lai
2026-11-04  4:00 ` [PATCH v4 2/2] iio: gyro: mpu3050: Fix runtime PM refcount leak in trigger enable path Xiangwu Lai
2026-11-04 11:58   ` Andy Shevchenko [this message]
2026-11-05  8:18     ` Xiangwu Lai

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=ausd4u09AfIcviHI@ashevche-desk.local \
    --to=andriy.shevchenko@intel.com \
    --cc=andy@kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=jic23@kernel.org \
    --cc=laixiangwu@cmss.chinamobile.com \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --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

all inboxes | Powered by JetHome®