mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] media: i2c: ov5670: fix double runtime-suspend on remove
@ 2026-09-28 14:10 Cong Nguyen
  2026-09-28 18:23 ` Laurent Pinchart
  0 siblings, 1 reply; 2+ messages in thread
From: Cong Nguyen @ 2026-09-28 14:10 UTC (permalink / raw)
  To: Sakari Ailus
  Cc: Mauro Carvalho Chehab, Laurent Pinchart, Jacopo Mondi,
	linux-media, linux-kernel

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>
---
 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);
 }
-- 
2.25.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-09-28 18:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-28 14:10 [PATCH] media: i2c: ov5670: fix double runtime-suspend on remove Cong Nguyen
2026-09-28 18:23 ` Laurent Pinchart

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®