From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 55B82C5DF81 for ; Mon, 24 Aug 2026 10:19:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:In-Reply-To:From:References:Cc:To:Subject:MIME-Version:Date: Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=EDaqviIjZuxlDEo1LAssKWLXNSktY9rLgZN6ZXeVI1w=; b=cXogEdowrdtZDKF/kkoqppKfkX jEuUN0jhIhGC9PqLmiSW0h+/rsYMDivifUDE372KmNT2uswv5/1mP0JgRoje6bY3gAtjFwEvpn3eb K5YkFjtP2Xha/7oSqvvN1pEm4S4wkaQJS6aznBVxV9cbbAfXUsyoEAkkVtlBFpOp+4P3xOFm3KlXs lS30WDSXJZo0g+gPIMgm9YXSQYVOXjuDi7VNNKVbdeL0vn3pSdd3mPyyn22k/EwtCBDLhMoILZLEc 1iZfrOEXTAS1zyNbDtEDBITJDuup8Gc9cS5lVgW3xWlrAWlReqPp6/+1bA+lm1WRshqoC0jEGGQ5b Y9h4tADA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1wyRm2-0000000GNk6-3KOc; Mon, 24 Aug 2026 10:19:26 +0000 Received: from sender6-op-o11.zoho.com ([165.173.180.11]) by bombadil.infradead.org with esmtps (Exim 4.99.1 #2 (Red Hat Linux)) id 1wyRm0-0000000GNjY-0nH2; Mon, 24 Aug 2026 10:19:25 +0000 ARC-Seal: i=1; a=rsa-sha256; t=1787566757; cv=none; d=zohomail.com; s=zohoarc; b=NjkPGi2z90N/qcNSj4UVefeV77WR0yv0SVaqGlT2liozH2pFcoflpzgC4eZlsSnwetPsvZfxjlE9LPVYoZcDBuVDvvjXvakrOOOT5Gr+xHsub1Ss4zWug7FZ1T2DHOf50VMpMGd3WN3NFsVu4UV1PYBPVofVM1TZIy7pyGTf4pQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1787566757; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:Subject:Subject:To:To:Message-Id:Reply-To; bh=EDaqviIjZuxlDEo1LAssKWLXNSktY9rLgZN6ZXeVI1w=; b=WVbe/PAa2IUSNI89XeSdGdH4KFQozxlc1Y0Do5kU880Oc5g40MLCB/32mTp3sHqRMzRbgET1uGS5pdTYfoeib0dP5qQVHRCxNelENTx0xmapjFQkMLVdNO30f1C43AJ+FzTvfCOwBqHhz++zdjXGlSXzVabSfTZCk53xvDPhcvQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=collabora.com; spf=pass smtp.mailfrom=benjamin.gaignard@collabora.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1787566757; s=zohomail; d=collabora.com; i=benjamin.gaignard@collabora.com; h=Message-ID:Date:Date:MIME-Version:Subject:Subject:To:To:Cc:Cc:From:From:In-Reply-To:Content-Type:Content-Transfer-Encoding:Message-Id:Reply-To; bh=EDaqviIjZuxlDEo1LAssKWLXNSktY9rLgZN6ZXeVI1w=; b=VQWKNZIzXORzcUOUp75yxFwQlROELLB11epx4N3ll/oQagvx1T1n+dGLRoHx4Q+T dlOfA6PMuZpRqgV6c6d/DAl3HTPa1BOD4omzh+gfasefQeEDuk2dx3Drf+/WNdrM1EX BbntqT8c5J+akvYBJbAn5oH4woltNCxiTksVRW7I= Received: by mx.zohomail.com with SMTPS id 1787566756102122.65970812260821; Mon, 24 Aug 2026 03:19:16 -0700 (PDT) Message-ID: Date: Mon, 24 Aug 2026 12:19:12 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 2/3] media: verisilicon: Complete the request on the ->run() error paths To: Sascha Hauer , Nicolas Dufresne , Philipp Zabel , Mauro Carvalho Chehab , Heiko Stuebner , Ezequiel Garcia , Hans Verkuil , Chen-Yu Tsai Cc: Mauro Carvalho Chehab , linux-media@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org References: <20260824-rk3588-jpegdec-v1-0-180a30a2852d@pengutronix.de> <20260824-rk3588-jpegdec-v1-2-180a30a2852d@pengutronix.de> Content-Language: en-US From: Benjamin Gaignard In-Reply-To: <20260824-rk3588-jpegdec-v1-2-180a30a2852d@pengutronix.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20260824_031924_266727_72B692CA X-CRM114-Status: GOOD ( 21.87 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Le 24/08/2026 à 08:39, Sascha Hauer a écrit : > Several codec ->run() operations return early without completing the > request, even though hantro_start_prepare_run() has already run and set up > the controls of the request attached to the source buffer. > > The buffers are still returned to userspace, device_run() finishes the job > with VB2_BUF_STATE_ERROR, but nothing completes the control handler object > bound to the media request. vb2_buffer_done() only unbinds the request > object owned by videobuf2 itself, so num_incomplete_objects never drops to > zero and the request stays in MEDIA_REQUEST_STATE_QUEUED forever: poll() on > the request file descriptor never returns and MEDIA_REQUEST_IOC_REINIT > fails with -EBUSY. The request is only cleaned up when userspace closes it. > > The vb2 buf_request_complete() callback does not help here, it is only > called from __vb2_queue_cancel() for buffers that were never queued to the > driver. > > Call hantro_abort_prepare_run() on those paths, which completes the request > and leaves the watchdog alone. > > Fixes: 42cb2a8f27d2 ("media: hantro: change hantro_codec_ops run prototype to return errors") > Assisted-by: Claude:claude-opus-5 > Signed-off-by: Sascha Hauer Reviewed-by Benjamin Gaignard > --- > drivers/media/platform/verisilicon/hantro_g1_h264_dec.c | 4 +++- > drivers/media/platform/verisilicon/hantro_g1_vp8_dec.c | 4 +++- > drivers/media/platform/verisilicon/hantro_g2_hevc_dec.c | 9 +++++++-- > drivers/media/platform/verisilicon/rockchip_vpu2_hw_h264_dec.c | 4 +++- > drivers/media/platform/verisilicon/rockchip_vpu2_hw_jpeg_enc.c | 4 +++- > drivers/media/platform/verisilicon/rockchip_vpu2_hw_vp8_dec.c | 4 +++- > 6 files changed, 22 insertions(+), 7 deletions(-) > > diff --git a/drivers/media/platform/verisilicon/hantro_g1_h264_dec.c b/drivers/media/platform/verisilicon/hantro_g1_h264_dec.c > index ad5c1a6634f5c..14ebb25ea24be 100644 > --- a/drivers/media/platform/verisilicon/hantro_g1_h264_dec.c > +++ b/drivers/media/platform/verisilicon/hantro_g1_h264_dec.c > @@ -255,8 +255,10 @@ int hantro_g1_h264_dec_run(struct hantro_ctx *ctx) > > /* Prepare the H264 decoder context. */ > ret = hantro_h264_dec_prepare_run(ctx); > - if (ret) > + if (ret) { > + hantro_abort_prepare_run(ctx); > return ret; > + } > > /* Configure hardware registers. */ > src_buf = hantro_get_src_buf(ctx); > diff --git a/drivers/media/platform/verisilicon/hantro_g1_vp8_dec.c b/drivers/media/platform/verisilicon/hantro_g1_vp8_dec.c > index 851eb67f19f50..e866ff86019a0 100644 > --- a/drivers/media/platform/verisilicon/hantro_g1_vp8_dec.c > +++ b/drivers/media/platform/verisilicon/hantro_g1_vp8_dec.c > @@ -442,8 +442,10 @@ int hantro_g1_vp8_dec_run(struct hantro_ctx *ctx) > hantro_start_prepare_run(ctx); > > hdr = hantro_get_ctrl(ctx, V4L2_CID_STATELESS_VP8_FRAME); > - if (WARN_ON(!hdr)) > + if (WARN_ON(!hdr)) { > + hantro_abort_prepare_run(ctx); > return -EINVAL; > + } > > /* Reset segment_map buffer in keyframe */ > if (V4L2_VP8_FRAME_IS_KEY_FRAME(hdr) && ctx->vp8_dec.segment_map.cpu) > diff --git a/drivers/media/platform/verisilicon/hantro_g2_hevc_dec.c b/drivers/media/platform/verisilicon/hantro_g2_hevc_dec.c > index e8c2e83379def..5778813a9eb2f 100644 > --- a/drivers/media/platform/verisilicon/hantro_g2_hevc_dec.c > +++ b/drivers/media/platform/verisilicon/hantro_g2_hevc_dec.c > @@ -596,7 +596,7 @@ int hantro_g2_hevc_dec_run(struct hantro_ctx *ctx) > /* Prepare HEVC decoder context. */ > ret = hantro_hevc_dec_prepare_run(ctx); > if (ret) > - return ret; > + goto abort_prepare_run; > > /* Configure hardware registers. */ > set_params(ctx); > @@ -604,7 +604,7 @@ int hantro_g2_hevc_dec_run(struct hantro_ctx *ctx) > /* set reference pictures */ > ret = set_ref(ctx); > if (ret) > - return ret; > + goto abort_prepare_run; > > set_buffers(ctx); > prepare_tile_info_buffer(ctx); > @@ -634,4 +634,9 @@ int hantro_g2_hevc_dec_run(struct hantro_ctx *ctx) > vdpu_write(vpu, G2_REG_INTERRUPT_DEC_E, G2_REG_INTERRUPT); > > return 0; > + > +abort_prepare_run: > + hantro_abort_prepare_run(ctx); > + > + return ret; > } > diff --git a/drivers/media/platform/verisilicon/rockchip_vpu2_hw_h264_dec.c b/drivers/media/platform/verisilicon/rockchip_vpu2_hw_h264_dec.c > index 6da87f5184bcb..d412d5d661226 100644 > --- a/drivers/media/platform/verisilicon/rockchip_vpu2_hw_h264_dec.c > +++ b/drivers/media/platform/verisilicon/rockchip_vpu2_hw_h264_dec.c > @@ -473,8 +473,10 @@ int rockchip_vpu2_h264_dec_run(struct hantro_ctx *ctx) > > /* Prepare the H264 decoder context. */ > ret = hantro_h264_dec_prepare_run(ctx); > - if (ret) > + if (ret) { > + hantro_abort_prepare_run(ctx); > return ret; > + } > > src_buf = hantro_get_src_buf(ctx); > set_params(ctx, src_buf); > diff --git a/drivers/media/platform/verisilicon/rockchip_vpu2_hw_jpeg_enc.c b/drivers/media/platform/verisilicon/rockchip_vpu2_hw_jpeg_enc.c > index 61621b1be8a2f..0ba078b9d1875 100644 > --- a/drivers/media/platform/verisilicon/rockchip_vpu2_hw_jpeg_enc.c > +++ b/drivers/media/platform/verisilicon/rockchip_vpu2_hw_jpeg_enc.c > @@ -143,8 +143,10 @@ int rockchip_vpu2_jpeg_enc_run(struct hantro_ctx *ctx) > > memset(&jpeg_ctx, 0, sizeof(jpeg_ctx)); > jpeg_ctx.buffer = vb2_plane_vaddr(&dst_buf->vb2_buf, 0); > - if (!jpeg_ctx.buffer) > + if (!jpeg_ctx.buffer) { > + hantro_abort_prepare_run(ctx); > return -ENOMEM; > + } > > jpeg_ctx.width = ctx->dst_fmt.width; > jpeg_ctx.height = ctx->dst_fmt.height; > diff --git a/drivers/media/platform/verisilicon/rockchip_vpu2_hw_vp8_dec.c b/drivers/media/platform/verisilicon/rockchip_vpu2_hw_vp8_dec.c > index d079075448c96..15f4872dd2bdd 100644 > --- a/drivers/media/platform/verisilicon/rockchip_vpu2_hw_vp8_dec.c > +++ b/drivers/media/platform/verisilicon/rockchip_vpu2_hw_vp8_dec.c > @@ -519,8 +519,10 @@ int rockchip_vpu2_vp8_dec_run(struct hantro_ctx *ctx) > hantro_start_prepare_run(ctx); > > hdr = hantro_get_ctrl(ctx, V4L2_CID_STATELESS_VP8_FRAME); > - if (WARN_ON(!hdr)) > + if (WARN_ON(!hdr)) { > + hantro_abort_prepare_run(ctx); > return -EINVAL; > + } > > /* Reset segment_map buffer in keyframe */ > if (V4L2_VP8_FRAME_IS_KEY_FRAME(hdr) && ctx->vp8_dec.segment_map.cpu) >