Skip to content

media: i2c: imx415: handle failed standby writes on stream-off - #648

Open
XPiPiT wants to merge 1 commit into
radxa:linux-6.1-stan-rkr4.1from
XPiPiT:fix/imx415-standby-retry
Open

XPiPiT wants to merge 1 commit into
radxa:linux-6.1-stan-rkr4.1from
XPiPiT:fix/imx415-standby-retry

Conversation

@XPiPiT

@XPiPiT XPiPiT commented Nov 30, 2026

Copy link
Copy Markdown

Problem

The rk2410 IMX415 driver drops the result of the standby register write
in s_stream(0). A separate runtime PM reference can keep the sensor
powered after the stream reference is released. A later start can then
program the mode while the sensor may still be streaming.

Change

Return the standby error from the sensor callback and remember that the
standby state is unconfirmed. Before programming a new mode, retry the
standby write and abort the start if it fails again. An explicit stop
retry takes its own runtime PM reference. A partially completed start
also leaves standby pending.

Testing

  • On a ROCK 5B+ running the rk2410 BSP with two IMX415 sensors, kept one
    camera streaming while the other opened, captured eight frames and
    closed. All 100 cycles passed in each direction. The cycled sensor
    returned to runtime usage 0 and the suspended state after every cycle.
  • A diagnostic kernel injected a single -EIO on CAM1 after the
    physical standby write succeeded. The sensor callback returned
    -EIO and released its stream reference. The video-node
    VIDIOC_STREAMOFF returned 0. On the next start, the standby retry
    succeeded and CAM1 delivered frames with sequence numbers 0 through 7.
  • An isolated test using the actual driver callbacks also exercised a
    standby write that did not reach the simulated sensor, both with and
    without another runtime PM reference. Repeated standby failure,
    failed PM resume, reopen and repeated stop all passed.
  • The submitted driver file matches the hardware-tested source byte for
    byte. git diff --check passed. The target branch's checkpatch.pl
    reported 0 errors and 0 warnings.

imx415_s_stream() ignores the return value of __imx415_stop_stream().
If the I2C write fails, the callback reports success and clears the
streaming flag. Another runtime PM reference can keep the sensor
powered, so a subsequent start may program the mode registers while
the sensor is still streaming.

Return the standby error and remember that standby is unconfirmed.
Drop the stream's runtime PM reference even on failure. Retry standby
before programming the mode on the next start. Abort the start if the
retry fails. Take a temporary PM reference if the caller retries
stream-off instead. Also mark a partially completed start for recovery.

On a ROCK 5B+ with two IMX415s, a one-shot injected -EIO after a
successful standby write made the sensor callback return the error.
The next start retried standby and delivered frames with sequences 0-7.

Fixes: c7d0063 ("media: i2c: add imx415 sensor driver")
Signed-off-by: xiongzt <xiongzt2003@163.com>
@XPiPiT XPiPiT closed this Nov 30, 2026
@XPiPiT XPiPiT reopened this Dec 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant