* [PATCH 0/2] i2c: qcom-cci: Recover after a target powers down under a running controller
@ 2026-10-20 19:39 Birk Skyum
2026-10-20 19:39 ` [PATCH 1/2] i2c: qcom-cci: Reset the controller when it resumes Birk Skyum
2026-10-20 19:39 ` [PATCH 2/2] i2c: qcom-cci: Suspend the controller 50 ms after the last transfer Birk Skyum
0 siblings, 2 replies; 7+ messages in thread
From: Birk Skyum @ 2026-10-20 19:39 UTC (permalink / raw)
To: Loic Poulain, Robert Foss, Andi Shyti
Cc: Bryan O'Donoghue, Vladimir Zapolskiy, Jishnu Prakash,
Saikiran, Mark Brown, linux-i2c, linux-arm-msm, linux-media,
linux-kernel
On the Lenovo Yoga Slim 7x (X1E80100) the OV02C10 front camera on CCI1
master 1 fails to start whenever it is opened again within about a
second of being closed. The first register write times out ("master 1
queue 0 timeout") and the stream does not start. Two attempts so far
treated this as a sensor power-up problem. One gave the ov02c10 driver a
longer settle time, the other a minimum off time for the camera rails
through regulator-off-on-delay-us [1]. Neither is needed.
The sensor holds SCL and SDA low while it is powered down. If the CCI
controller stays clocked from then until its next transfer, the master
no longer starts transfers. The queue stays on its first command, no
interrupt arrives, and only the reset in cci_run_queue()'s timeout path
brings it back. A runtime suspend clears the state too, but only when
the power domain collapses, because cci_resume_runtime() does not reset
the controller. With the 1 s autosuspend delay, any power cycle of a
target that is shorter than a second runs into it.
Patch 1 resets the controller on every runtime resume. Patch 2 suspends
it 50 ms after its last transfer.
Tested on the Yoga with the driver from i2c/i2c-next, built as a module
for a 7.2.8-based kernel whose device tree has no off-on delay for the
camera rails. The CCI clock runs at 37.5 MHz there. Starting the camera
with v4l2-ctl after a pause:
pause 0.05 s 0.1 s 0.2 s 0.5 s 1 s
failed before 19/20 19/20 19/20 19/20 16/20
failed after 0/20 0/20 0/20 0/20 0/20
With the series, 150 libcamera starts back to back all started, so the
sensor itself starts fine after a 50 ms pause. The same two changes on
7.2.8's driver, with the CCI clock at 19.2 MHz, gave the same result.
[1] https://lore.kernel.org/all/20261001-regulator-off-on-delay-v4-0-258ba9612da8@oss.qualcomm.com/
Birk Skyum (2):
i2c: qcom-cci: Reset the controller when it resumes
i2c: qcom-cci: Suspend the controller 50 ms after the last transfer
drivers/i2c/busses/i2c-qcom-cci.c | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
base-commit: bd4a545e4f5dbd5e4dd0064777429813516b8784
--
2.53.0
^ permalink raw reply [flat|nested] 7+ messages in thread* [PATCH 1/2] i2c: qcom-cci: Reset the controller when it resumes
2026-10-20 19:39 [PATCH 0/2] i2c: qcom-cci: Recover after a target powers down under a running controller Birk Skyum
@ 2026-10-20 19:39 ` Birk Skyum
2026-10-21 7:20 ` Loic Poulain
2026-10-20 19:39 ` [PATCH 2/2] i2c: qcom-cci: Suspend the controller 50 ms after the last transfer Birk Skyum
1 sibling, 1 reply; 7+ messages in thread
From: Birk Skyum @ 2026-10-20 19:39 UTC (permalink / raw)
To: Loic Poulain, Robert Foss, Andi Shyti
Cc: Bryan O'Donoghue, Vladimir Zapolskiy, Jishnu Prakash,
Saikiran, Mark Brown, linux-i2c, linux-arm-msm, linux-media,
linux-kernel
A CCI master can stop starting transfers after a target on its bus was
powered down and up again while the controller kept its clocks running.
The next transfer's queue then stays on its first command, neither
CCI_IRQ_STATUS_0 nor the queue's report status changes, and
cci_run_queue() times out after 100 ms ("master 1 queue 0 timeout").
Only the controller reset in that error path, or the controller's power
domain collapsing while it is runtime suspended, brings it back.
On the Lenovo Yoga Slim 7x (X1E80100) the OV02C10 front camera is
powered down whenever it stops streaming, and the unpowered sensor
holds SCL and SDA low: both read low at the TLMM pins with the internal
pull-ups enabled. The queue registers at the timeout show the stuck
first command (CUR_CMD 0x08010339, a write of 03 01 08) with the bus
timing registers intact and no error or halt interrupt before it.
cci_resume_runtime() only programs the interrupt mask and the bus timing
again, so a controller that was runtime suspended without its power
domain collapsing keeps the stuck state. With the camera's TITAN_TOP
GDSC held on and the controller suspended between camera starts, 3 of
40 starts failed this way; with a reset on resume, 0 of 40.
Reset the controller on every runtime resume, as the timeout path does.
Signed-off-by: Birk Skyum <birk.skyum@pm.me>
---
drivers/i2c/busses/i2c-qcom-cci.c | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/drivers/i2c/busses/i2c-qcom-cci.c b/drivers/i2c/busses/i2c-qcom-cci.c
index 76a5ded..51ce174 100644
--- a/drivers/i2c/busses/i2c-qcom-cci.c
+++ b/drivers/i2c/busses/i2c-qcom-cci.c
@@ -651,7 +651,20 @@ static int __maybe_unused cci_resume_runtime(struct device *dev)
if (ret)
return ret;
- return cci_init(cci);
+ /*
+ * A master can stop starting transfers after a target was powered
+ * down and up again while the controller ran, and keeps that state
+ * over a runtime suspend unless the power domain collapsed. Reset
+ * the controller, with the interrupt mask set first so that the
+ * reset-done interrupt also arrives after a power collapse.
+ */
+ ret = cci_init(cci);
+ if (!ret)
+ ret = cci_reset(cci);
+ if (ret)
+ cci_disable_clocks(cci);
+
+ return ret;
}
static const struct dev_pm_ops qcom_cci_pm = {
--
2.53.0
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH 1/2] i2c: qcom-cci: Reset the controller when it resumes
2026-10-20 19:39 ` [PATCH 1/2] i2c: qcom-cci: Reset the controller when it resumes Birk Skyum
@ 2026-10-21 7:20 ` Loic Poulain
2026-10-21 19:37 ` Birk Skyum
0 siblings, 1 reply; 7+ messages in thread
From: Loic Poulain @ 2026-10-21 7:20 UTC (permalink / raw)
To: Birk Skyum
Cc: Robert Foss, Andi Shyti, Bryan O'Donoghue,
Vladimir Zapolskiy, Jishnu Prakash, Saikiran, Mark Brown,
linux-i2c, linux-arm-msm, linux-media, linux-kernel
On Tue, Oct 20, 2026 at 9:40 PM Birk Skyum <birk.skyum@pm.me> wrote:
>
> A CCI master can stop starting transfers after a target on its bus was
> powered down and up again while the controller kept its clocks running.
> The next transfer's queue then stays on its first command, neither
> CCI_IRQ_STATUS_0 nor the queue's report status changes, and
> cci_run_queue() times out after 100 ms ("master 1 queue 0 timeout").
> Only the controller reset in that error path, or the controller's power
> domain collapsing while it is runtime suspended, brings it back.
>
> On the Lenovo Yoga Slim 7x (X1E80100) the OV02C10 front camera is
> powered down whenever it stops streaming, and the unpowered sensor
> holds SCL and SDA low: both read low at the TLMM pins with the internal
> pull-ups enabled. The queue registers at the timeout show the stuck
> first command (CUR_CMD 0x08010339, a write of 03 01 08) with the bus
> timing registers intact and no error or halt interrupt before it.
>
> cci_resume_runtime() only programs the interrupt mask and the bus timing
> again, so a controller that was runtime suspended without its power
> domain collapsing keeps the stuck state. With the camera's TITAN_TOP
> GDSC held on and the controller suspended between camera starts, 3 of
> 40 starts failed this way; with a reset on resume, 0 of 40.
>
> Reset the controller on every runtime resume, as the timeout path does.
>
> Signed-off-by: Birk Skyum <birk.skyum@pm.me>
> ---
> drivers/i2c/busses/i2c-qcom-cci.c | 15 ++++++++++++++-
> 1 file changed, 14 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/i2c/busses/i2c-qcom-cci.c b/drivers/i2c/busses/i2c-qcom-cci.c
> index 76a5ded..51ce174 100644
> --- a/drivers/i2c/busses/i2c-qcom-cci.c
> +++ b/drivers/i2c/busses/i2c-qcom-cci.c
> @@ -651,7 +651,20 @@ static int __maybe_unused cci_resume_runtime(struct device *dev)
> if (ret)
> return ret;
>
> - return cci_init(cci);
> + /*
> + * A master can stop starting transfers after a target was powered
> + * down and up again while the controller ran, and keeps that state
> + * over a runtime suspend unless the power domain collapsed. Reset
> + * the controller, with the interrupt mask set first so that the
> + * reset-done interrupt also arrives after a power collapse.
> + */
> + ret = cci_init(cci);
> + if (!ret)
> + ret = cci_reset(cci);
If we don't know the state, it's probably better to just
unconditionally cci_reset().
> + if (ret)
> + cci_disable_clocks(cci);
> +
> + return ret;
> }
>
> static const struct dev_pm_ops qcom_cci_pm = {
> --
> 2.53.0
>
>
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH 1/2] i2c: qcom-cci: Reset the controller when it resumes
2026-10-21 7:20 ` Loic Poulain
@ 2026-10-21 19:37 ` Birk Skyum
0 siblings, 0 replies; 7+ messages in thread
From: Birk Skyum @ 2026-10-21 19:37 UTC (permalink / raw)
To: Loic Poulain
Cc: Robert Foss, Andi Shyti, Bryan O'Donoghue,
Vladimir Zapolskiy, Jishnu Prakash, Saikiran, Mark Brown,
linux-i2c, linux-arm-msm, linux-media, linux-kernel
On Wed, Oct 21, 2026 at 9:20 AM Loic Poulain <loic.poulain@oss.qualcomm.com> wrote:
> > + ret = cci_init(cci);
> > + if (!ret)
> > + ret = cci_reset(cci);
>
> If we don't know the state, it's probably better to just
> unconditionally cci_reset().
Right. I kept cci_init() first so the reset-done interrupt is unmasked
after a power collapse, but cci_reset() alone works there too. On 7.3
with only cci_reset() on resume, all 30 camera restarts after 2 s
pauses started, with the controller suspended in between and no reset
timeout. v2 calls just cci_reset() on resume.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 2/2] i2c: qcom-cci: Suspend the controller 50 ms after the last transfer
2026-10-20 19:39 [PATCH 0/2] i2c: qcom-cci: Recover after a target powers down under a running controller Birk Skyum
2026-10-20 19:39 ` [PATCH 1/2] i2c: qcom-cci: Reset the controller when it resumes Birk Skyum
@ 2026-10-20 19:39 ` Birk Skyum
2026-10-21 7:44 ` Loic Poulain
1 sibling, 1 reply; 7+ messages in thread
From: Birk Skyum @ 2026-10-20 19:39 UTC (permalink / raw)
To: Loic Poulain, Robert Foss, Andi Shyti
Cc: Bryan O'Donoghue, Vladimir Zapolskiy, Jishnu Prakash,
Saikiran, Mark Brown, linux-i2c, linux-arm-msm, linux-media,
linux-kernel
With a 1 s autosuspend delay the controller stays clocked across any
power cycle of a target that is shorter than a second, so the reset on
resume never runs in between and the first transfer after the target
comes back stalls until the 100 ms timeout. Camera sensors are powered
down when they stop streaming and up again when they start, so closing
and reopening a camera quickly hits this.
On the Lenovo Yoga Slim 7x (X1E80100), restarting the OV02C10 with
v4l2-ctl after pauses of 0.05, 0.1, 0.2 and 0.5 s failed in 19 of 20
cycles each, and in 16 of 20 after 1 s pauses. With this change and the
reset on resume, all 100 cycles started, and so did 150 of 150
libcamera starts back to back.
Transfers come in bursts (a sensor mode alone is a few hundred register
writes), so suspending 50 ms after the last one costs one reset per
burst.
Signed-off-by: Birk Skyum <birk.skyum@pm.me>
---
drivers/i2c/busses/i2c-qcom-cci.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/i2c/busses/i2c-qcom-cci.c b/drivers/i2c/busses/i2c-qcom-cci.c
index 51ce174..62b0fcb 100644
--- a/drivers/i2c/busses/i2c-qcom-cci.c
+++ b/drivers/i2c/busses/i2c-qcom-cci.c
@@ -794,7 +794,7 @@ static int cci_probe(struct platform_device *pdev)
if (ret < 0)
goto disable_clocks;
- pm_runtime_set_autosuspend_delay(dev, MSEC_PER_SEC);
+ pm_runtime_set_autosuspend_delay(dev, 50);
ret = devm_pm_runtime_set_active_enabled(dev);
if (ret)
goto disable_clocks;
--
2.53.0
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 2/2] i2c: qcom-cci: Suspend the controller 50 ms after the last transfer
2026-10-20 19:39 ` [PATCH 2/2] i2c: qcom-cci: Suspend the controller 50 ms after the last transfer Birk Skyum
@ 2026-10-21 7:44 ` Loic Poulain
2026-10-21 19:37 ` Birk Skyum
0 siblings, 1 reply; 7+ messages in thread
From: Loic Poulain @ 2026-10-21 7:44 UTC (permalink / raw)
To: Birk Skyum
Cc: Robert Foss, Andi Shyti, Bryan O'Donoghue,
Vladimir Zapolskiy, Jishnu Prakash, Saikiran, Mark Brown,
linux-i2c, linux-arm-msm, linux-media, linux-kernel
Hi Birk,
On Tue, Oct 20, 2026 at 9:40 PM Birk Skyum <birk.skyum@pm.me> wrote:
>
> With a 1 s autosuspend delay the controller stays clocked across any
> power cycle of a target that is shorter than a second, so the reset on
> resume never runs in between and the first transfer after the target
> comes back stalls until the 100 ms timeout. Camera sensors are powered
> down when they stop streaming and up again when they start, so closing
> and reopening a camera quickly hits this.
>
> On the Lenovo Yoga Slim 7x (X1E80100), restarting the OV02C10 with
> v4l2-ctl after pauses of 0.05, 0.1, 0.2 and 0.5 s failed in 19 of 20
> cycles each, and in 16 of 20 after 1 s pauses. With this change and the
> reset on resume, all 100 cycles started, and so did 150 of 150
> libcamera starts back to back.
>
> Transfers come in bursts (a sensor mode alone is a few hundred register
> writes), so suspending 50 ms after the last one costs one reset per
> burst.
So, no, we should not rely on runtime suspend/resume timing as a
workaround for this. That approach is inherently bad and fragile.
Have you been able to probe the CCI I2C bus during resume? It would be
useful to see whether there is any activity on SCL/SDA and, in
particular, whether either line is being held low.
I wonder if enabling SCL stretching support could help here. One
possibility is that the sensor (or another I2C slave) is not yet ready
when the transfer is initiated and therefore holds SCL low. If that's
the case, have you tried the change below?
https://lore.kernel.org/all/20261007050147.274096-1-hitesh@ebytelogic.com/#t
Regards,
Loic
>
> Signed-off-by: Birk Skyum <birk.skyum@pm.me>
> ---
> drivers/i2c/busses/i2c-qcom-cci.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/i2c/busses/i2c-qcom-cci.c b/drivers/i2c/busses/i2c-qcom-cci.c
> index 51ce174..62b0fcb 100644
> --- a/drivers/i2c/busses/i2c-qcom-cci.c
> +++ b/drivers/i2c/busses/i2c-qcom-cci.c
> @@ -794,7 +794,7 @@ static int cci_probe(struct platform_device *pdev)
> if (ret < 0)
> goto disable_clocks;
>
> - pm_runtime_set_autosuspend_delay(dev, MSEC_PER_SEC);
> + pm_runtime_set_autosuspend_delay(dev, 50);
> ret = devm_pm_runtime_set_active_enabled(dev);
> if (ret)
> goto disable_clocks;
> --
> 2.53.0
>
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 2/2] i2c: qcom-cci: Suspend the controller 50 ms after the last transfer
2026-10-21 7:44 ` Loic Poulain
@ 2026-10-21 19:37 ` Birk Skyum
0 siblings, 0 replies; 7+ messages in thread
From: Birk Skyum @ 2026-10-21 19:37 UTC (permalink / raw)
To: Loic Poulain
Cc: Robert Foss, Andi Shyti, Bryan O'Donoghue,
Vladimir Zapolskiy, Jishnu Prakash, Saikiran, Mark Brown,
linux-i2c, linux-arm-msm, linux-media, linux-kernel
On Wed, Oct 21, 2026 at 9:44 AM Loic Poulain <loic.poulain@oss.qualcomm.com> wrote:
> So, no, we should not rely on runtime suspend/resume timing as a
> workaround for this. That approach is inherently bad and fragile.
Agreed, I'll drop this patch.
> Have you been able to probe the CCI I2C bus during resume? It would be
> useful to see whether there is any activity on SCL/SDA and, in
> particular, whether either line is being held low.
I don't have a scope on these pins, so I read the pad levels from the
TLMM (gpio235/236, aon_cci) in the driver, on 7.3 without this series
and with SCL stretching on (MISC_CTL 0x133):
- When the controller suspends after the sensor powered off, both
lines read low (13 of 13). The unpowered OV02C10 clamps them.
- At the first transfer after the sensor powered on again, both read
high (114 of 114).
- At the 100 ms queue timeout both still read high (86 of 86), with the
queue on its first command (CUR_CMD 0x08010339, CUR_WORD_CNT 1,
EXEC_WORD_CNT 3, REPORT_STATUS 0) and IRQ_STATUS_0 at 0.
- After cci_reset() the next transfers go through.
So nothing holds SCL or SDA low when the transfer should start. The
master doesn't start until it is reset.
> I wonder if enabling SCL stretching support could help here.
It doesn't change it. Restarting the camera after pauses of 0.05, 0.1,
0.2 and 0.5 s failed in 19 of 20 cycles each with 7.3 as released, and
the same with Hitesh's change applied. After 1 s pauses it was 13 of 20
without it and 15 of 20 with it.
What works without depending on the autosuspend delay is retrying a
message once when it times out, since cci_run_queue() has reset the
controller by then. With that retry in cci_xfer(), the reset on resume
and the 1 s autosuspend unchanged, all 120 camera restarts started
(pauses of 0.05 to 2 s, 20 each). 91 of them hit the stall, and every
retry went through. The cost is the 100 ms timeout, so a restart took
about 500 ms instead of about 400 ms with this patch.
Unless you'd rather see it handled elsewhere, v2 replaces this patch
with that retry.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2026-10-21 19:37 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-20 19:39 [PATCH 0/2] i2c: qcom-cci: Recover after a target powers down under a running controller Birk Skyum
2026-10-20 19:39 ` [PATCH 1/2] i2c: qcom-cci: Reset the controller when it resumes Birk Skyum
2026-10-21 7:20 ` Loic Poulain
2026-10-21 19:37 ` Birk Skyum
2026-10-20 19:39 ` [PATCH 2/2] i2c: qcom-cci: Suspend the controller 50 ms after the last transfer Birk Skyum
2026-10-21 7:44 ` Loic Poulain
2026-10-21 19:37 ` Birk Skyum
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®