[PATCH 0/6] media: rockchip: rkcif: recover from a lost MIPI line

From: Daniel Golle

Date: Tue Nov 03 2026 - 06:32:17 EST


The VICAP MIPI DMA ends a frame after the configured number of lines
and the sensor frame start does not reset that count. A line dropped on
the CSI-2 link therefore leaves every later buffer composed of the tail
of one frame and the head of the next, with the Bayer phase flipped
when the offset is odd, until the capture is restarted. This was seen
on an RV1126 (same VICAP MIPI block as the RK3568) with an IMX415 after
a night of streaming, and it can be provoked at will by shortening the
D-PHY settle time for a second.

The series makes the capture notice the slip and recover, and makes
the two blocks involved report what they see:

- patch 1 masks the MIPI interrupt sources that come out of reset
enabled, which otherwise keep the line asserted until the kernel
disables the interrupt;
- patch 2 replaces the subdev state mutex taken on the stop path, which
the interrupt handler calls, with a spinlock around the shared
interrupt registers;
- patch 3 enables and counts the VICAP error interrupts in debugfs;
- patch 4 reads the line counter at every frame start and restarts the
stream through the existing stop and start paths once two frames in
a row show an offset, as the runtime suspend in between is what
resets the counter;
- patch 5 programs the DMA write priority the vendor driver uses;
- patch 6 lets the Synopsys CSI-2 receiver request its err1 and err2
interrupts and count the error classes in debugfs.

Tested on an RV1126 board (vendor DT, rkcif and dw-mipi-csi2rx with
local RV1126 compatibles) with the fault injection described in patch
4; the RK3568 and RK3588 register layouts for the error bits and the
line counter come from the vendor kernel and are untested here.

Daniel Golle (6):
media: rockchip: rkcif: mask MIPI interrupts when powered
media: rockchip: rkcif: fix the MIPI stop path locking
media: rockchip: rkcif: count the MIPI capture errors
media: rockchip: rkcif: restart the MIPI DMA when it slips
media: rockchip: rkcif: raise the MIPI DMA write priority
media: synopsys: csi2rx: handle the error interrupts

.../rockchip/rkcif/rkcif-capture-mipi.c | 210 ++++++++++++++++--
.../rockchip/rkcif/rkcif-capture-mipi.h | 2 +
.../platform/rockchip/rkcif/rkcif-common.h | 23 ++
.../media/platform/rockchip/rkcif/rkcif-dev.c | 8 +
.../platform/rockchip/rkcif/rkcif-regs.h | 2 +
.../platform/rockchip/rkcif/rkcif-stream.c | 64 ++++++
.../platform/rockchip/rkcif/rkcif-stream.h | 2 +
.../media/platform/synopsys/dw-mipi-csi2rx.c | 125 ++++++++++-
8 files changed, 409 insertions(+), 27 deletions(-)


base-commit: 24a19b953e2a3d0ea5a8c4951a0ab8f32720c907
--
2.56.0