Le mardi 24 novembre 2026 à 16:40 +0300, Sergei Khomenkov via B4 Relay a écrit : > The H1 and VEPU2 JPEG encoders are given their stream buffer limit in > bytes, but the register counts 64-bit words, so a stream that does not > fit the CAPTURE buffer is written past its end, up to eight times the > buffer size. A quality 100 frame of noise does not fit the default > sizeimage, and userspace can also set a smaller one. > > Patch 1 stops the encoder in the VEPU1 interrupt handler after a > buffer-full interrupt, which leaves it paused. Patch 2 programs the > limit in 64-bit words, rounded down to whole 64-byte bursts, on the H1 > and on the VEPU2. Patch 3 makes the smallest CAPTURE sizeimage of the > JPEG encoders the 624-byte header plus one burst, set in the variant > format data. > > Testing, on an RK3026 (its H1 is Rockchip's VEPU1) only: without the > series the encoder wrote 230 KB past a default-sized 640x480 buffer and > 1.6 MB past a 1920x1088 one. With it, 17 overflowing frames, four of > them queued back to back, stopped at the programmed limit without > writing past the plane and came back with the ERROR flag, one interrupt > each and no timeout; the jobs after them completed, and frames that fit > are byte for byte the same as before. A sizeimage of 1 or 600 now reads > back 688. v4l2-compliance 1.30.1 on the encoder node shows no new > failures. > > I cannot test the VEPU2 or the STM32MP25 VENC. The VEPU2 gets patches 2 > and 3, but its interrupt handler is unchanged; Nicolas offered to test > the VEPU2 part of patch 2. The STM32MP25 VENC runs the H1 code of patch > 2 and gets patch 3, but not the stop of patch 1. > > The bugs were found and the patches drafted with an LLM coding > assistant while porting mainline Linux to an RK3026 board. > > --- > Changes in v3: > - Move the LLM and test notes below the --- line and add an > Assisted-by: tag (Nicolas). I've just learned today that we just don't do tagging anymore for this. So **if** you have to make a new version later on, just remove them. commit 1e035297ffdadf2184c3c773b8c098e372324aaf Author: Sasha Levin Date: Tue Oct 13 08:15:01 2026 -0400 docs: remove Assisted-by references > - 1/3: add Nicolas's Reviewed-by. > - 2/3: program the VEPU2 JPEG encoder's limit in 64-bit words as well; > Nicolas offered to test it. Subject says "JPEG encoder", not "H1". Yep, thanks, I'll do. > - 3/3: move the header + 64 floor out of hantro_try_fmt() into a new > min_size field of struct hantro_fmt, set in the JPEG encoder formats > of the Rockchip and STM32MP25 variants (Nicolas). > - Rebase on media next aa0f4c41d487. > - Link to v2: https://lore.kernel.org/all/20261110-hantro-buflimit-v2-0-ff7790def9fc@gmail.com/ > > Changes in v2: > - Trim the commit messages and code comments (Nicolas). > - 1/3: clear only the enable bit of H1_REG_ENC_CTRL instead of writing > 0 to the register, and add a rate-limited warning per fault bit, as > hantro_g2_irq() does; add the H1_REG_INTERRUPT_* fault bits (Nicolas). > - 3/3: keep max(): it is a floor of header + one burst, the 64-byte > rounding is on the stream limit in 2/3 (Nicolas). > - Move the test numbers from the commit messages to this cover letter. > - Link to v1: https://lore.kernel.org/r/20261109-hantro-buflimit-v1-0-f0b86ce61e66@gmail.com > > --- > Sergei Khomenkov (3): > media: verisilicon: stop the VEPU1 JPEG encoder after an unfinished frame > media: verisilicon: program the JPEG encoder stream limit in 64-bit words > media: verisilicon: leave room for the JPEG header and one stream burst > > drivers/media/platform/verisilicon/hantro.h | 2 ++ > .../media/platform/verisilicon/hantro_h1_jpeg_enc.c | 4 +++- > drivers/media/platform/verisilicon/hantro_h1_regs.h | 4 ++++ > drivers/media/platform/verisilicon/hantro_v4l2.c | 3 +++ > .../platform/verisilicon/rockchip_vpu2_hw_jpeg_enc.c | 4 +++- > drivers/media/platform/verisilicon/rockchip_vpu_hw.c | 19 +++++++++++++++++++ > drivers/media/platform/verisilicon/stm32mp25_vpu_hw.c | 1 + > 7 files changed, 35 insertions(+), 2 deletions(-) > --- > base-commit: aa0f4c41d4870a18e65772a1817af16427200371 > change-id: 20261106-hantro-buflimit-055e8029be23 > > Best regards,