Le mardi 10 novembre 2026 à 15:41 +0300, Sergei Khomenkov via B4 Relay a écrit : > From: Sergei Khomenkov > > hantro_try_fmt() keeps any non-zero CAPTURE sizeimage of the JPEG > encoder, however small. The CPU writes the 624-byte header into the > plane, and on the RK3026 VEPU1 the encoder then writes at least one > 64-byte burst even with a stream limit of 0, so a smaller plane is > written past its end. A plane smaller than the header also makes the > WARN_ON() in hantro_h1_jpeg_enc_set_buffers() fire on every job. > > Raise a smaller request to header_size + 64. > > Found with an LLM coding assistant while porting mainline Linux to a > Rockchip RK3026 board; the assistant also drafted this change. Tested > on that board: a sizeimage of 1 or 600 now reads back 688, and frames > that do not fit a 688-byte plane stop exactly at its end. Not tested on > other SoCs. Move after --, and add Assisted-by: tag. > > Fixes: 775fec69008d ("media: add Rockchip VPU JPEG encoder driver") > Cc: stable@vger.kernel.org > Signed-off-by: Sergei Khomenkov > --- > drivers/media/platform/verisilicon/hantro_v4l2.c | 9 +++++++++ > 1 file changed, 9 insertions(+) > > diff --git a/drivers/media/platform/verisilicon/hantro_v4l2.c b/drivers/media/platform/verisilicon/hantro_v4l2.c > index 83af9fa1ce94..6a6d27443a5e 100644 > --- a/drivers/media/platform/verisilicon/hantro_v4l2.c > +++ b/drivers/media/platform/verisilicon/hantro_v4l2.c > @@ -394,6 +394,15 @@ static int hantro_try_fmt(const struct hantro_ctx *ctx, > */ > pix_mp->plane_fmt[0].sizeimage = fmt->header_size + > pix_mp->width * pix_mp->height * fmt->max_depth; > + } else if (fmt->codec_mode == HANTRO_MODE_JPEG_ENC) { > + /* > + * Room for the header and one stream burst (64 bytes on the > + * RK3026 VEPU1), which the encoder writes even with a stream > + * limit of 0. > + */ > + pix_mp->plane_fmt[0].sizeimage = > + max_t(u32, pix_mp->plane_fmt[0].sizeimage, > + fmt->header_size + 64); hantro_v4l2 is generic, place the magic numbers in the variants. > } > > return 0;