mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Cong Nguyen <congnt264@gmail.com>
Cc: Sakari Ailus <sakari.ailus@linux.intel.com>,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	Jacopo Mondi <jacopo.mondi@ideasonboard.com>,
	linux-media@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] media: i2c: ov5670: fix double runtime-suspend on remove
Date: Mon, 28 Sep 2026 21:23:51 +0300	[thread overview]
Message-ID: <20260928182351.GD210522@killaraus.ideasonboard.com> (raw)
In-Reply-To: <20260928141045.2436838-1-congnt264@gmail.com>

On Mon, Sep 28, 2026 at 09:10:45PM +0700, Cong Nguyen wrote:
> ov5670_remove() calls ov5670_runtime_suspend() unconditionally, and
> that function has no internal "already off" guard -- it always
> asserts the reset/powerdown gpios, disables the regulators, and
> disables/unprepares the clock.
> 
> probe() ends with pm_runtime_idle(), which drives an immediate
> synchronous self-suspend (already calling ov5670_runtime_suspend()
> once) whenever nothing is streaming. That's the common case, so
> remove()'s unconditional second call clk_disable_unprepare()s an
> already-unprepared clock -- hitting the same underflow WARN() fixed
> elsewhere in this tree -- and disables already-disabled regulators,
> on every normal removal, not just an edge case.
> 
> Guard it with pm_runtime_status_suspended(), same as sibling
> imx412.c's remove().
> 
> Fixes: 62ab1e325978 ("media: i2c: ov5670: Add runtime_pm operations")
> Assisted-by: LLM
> Signed-off-by: Cong Nguyen <congnt264@gmail.com>

How have you tested this ?

> ---
>  drivers/media/i2c/ov5670.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/media/i2c/ov5670.c b/drivers/media/i2c/ov5670.c
> index 01fa892de079..a08bb4e9bfca 100644
> --- a/drivers/media/i2c/ov5670.c
> +++ b/drivers/media/i2c/ov5670.c
> @@ -2784,7 +2784,8 @@ static void ov5670_remove(struct i2c_client *client)
>  	mutex_destroy(&ov5670->mutex);
>  
>  	pm_runtime_disable(ov5670->dev);
> -	ov5670_runtime_suspend(ov5670->dev);
> +	if (!pm_runtime_status_suspended(ov5670->dev))
> +		ov5670_runtime_suspend(ov5670->dev);
>  
>  	v4l2_fwnode_endpoint_free(&ov5670->endpoint);
>  }

-- 
Regards,

Laurent Pinchart

      reply	other threads:[~2026-09-28 18:23 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-28 14:10 Cong Nguyen
2026-09-28 18:23 ` Laurent Pinchart [this message]

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=20260928182351.GD210522@killaraus.ideasonboard.com \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=congnt264@gmail.com \
    --cc=jacopo.mondi@ideasonboard.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=sakari.ailus@linux.intel.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®