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 8AE0EC982FF for ; Tue, 22 Sep 2026 09:15:49 +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-Type: Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date :Subject:CC:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=xLU1raGNRNkiRMZRkTcRsI52O6Ivn3m3LlM8helEoEo=; b=qevtgwC+Lh0SnYXzIMlVAjiCRB 6JPtnu+Xb5R0UGAmiW7h8614aA0lWW2mZZEvTR6rKc8Z+hWu0Rr0SNABcbwKP0H3dReLHz4EFv9OU vJaC0K/NRznT3FCVkxuKu0+1UknV6PRwsCamj5xo1wHJOLCuzxAtrdPMCoABZbbK7SygJcjokt9iJ duVDwgRE5kXyplrb28KvloMIy2xgsnhyEu2T7QYJp0OiPdyttSzUyaffZJ0iElhHTFdoSz9iNwAaA QfRdnTtkSYIwD3X+5Oa09pjH5RH2A+9oFUG1MkLsX7fgBjIbVOE75nletT5Tr7DH13XfwlqvRDHL5 7CTzs0zA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1x8wbL-00000004s5t-38dg; Tue, 22 Sep 2026 09:15:47 +0000 Received: from mailgw01.mediatek.com ([216.200.240.184]) by bombadil.infradead.org with esmtps (Exim 4.99.1 #2 (Red Hat Linux)) id 1x8wbK-00000004s3y-0PhE; Tue, 22 Sep 2026 09:15:47 +0000 X-UUID: 2db62302b66611f1afed4741b24580c9-20260922 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=xLU1raGNRNkiRMZRkTcRsI52O6Ivn3m3LlM8helEoEo=; b=Jce5IK6lkdFIvK3av8DKo+vp5N6Tuh6vKp9Wj1b7QknFriLF1WX73WQtT7t6j/Iq9P0ehr1BxD/riIZrpcfoosgk1SmAkSW/jBmYssJBAhW3UYV4r8SsYYGXj3qStaYrt1aeMG+izQeUukRfFLgUCY/qHLOQW1uCm+qB3jY6KLs=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.3.19,REQID:721abe94-2a1b-433a-9bab-6065aff79953,IP:0,U RL:0,TC:0,Content:0,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION: release,TS:0 X-CID-META: VersionHash:7db8b62,CLOUDID:f1e426e3-72a5-4ba1-af40-18bbd6ea8ffd,B ulkID:nil,BulkQuantity:0,SF:81|82|102|836|865|888|898,TC:-5,Content:0|15|5 0|99,EDM:-3,IP:nil,URL:0,File:130,RT:0,Bulk:nil,QS:nil,BEC:-1,COL:0,OSI:0, OSA:0,AV:0,LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0,ARC:0 X-CID-BVR: 2,SSN|SDN X-CID-BAS: 2,SSN|SDN,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-CID-RHF: D41D8CD98F00B204E9800998ECF8427E X-UUID: 2db62302b66611f1afed4741b24580c9-20260922 Received: from mtkmbs09n1.mediatek.inc [(172.21.101.35)] by mailgw01.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 638379290; Tue, 22 Sep 2026 02:15:39 -0700 Received: from mtkmbs13n2.mediatek.inc (172.21.101.108) by MTKMBS09N1.mediatek.inc (172.21.101.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.29; Tue, 22 Sep 2026 17:15:37 +0800 Received: from gcnsap21.gcn.mediatek.inc (10.17.81.22) by mtkmbs13n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.2562.29 via Frontend Transport; Tue, 22 Sep 2026 17:15:36 +0800 From: Kyrie Wu To: Mauro Carvalho Chehab , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Matthias Brugger , AngeloGioacchino Del Regno , Bin Liu , kyrie wu , Hans Verkuil , irui wang , Nicolas Dufresne , , , , , CC: Kyrie Wu Subject: [PATCH v17 04/12] media: mediatek: jpeg: Fix buffer completion on multi-core streaming stop Date: Tue, 22 Sep 2026 17:15:21 +0800 Message-ID: <20260922091530.241762-5-kyrie.wu@mediatek.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260922091530.241762-1-kyrie.wu@mediatek.com> References: <20260922091530.241762-1-kyrie.wu@mediatek.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20260922_021546_146846_0ECD4D95 X-CRM114-Status: GOOD ( 13.62 ) X-BeenThere: linux-mediatek@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-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org Enhances the Mediatek JPEG driver's stability and reliability by ensuring that all queued buffers are processed before stopping the streaming in multi-core environments. It introduces a call to `vb2_wait_for_all_buffers()` in the `mtk_jpeg_enc_stop_streaming()` and `mtk_jpeg_dec_stop_streaming()` functions when the `multi_core` variant is enabled. This change ensures that no buffers are left unprocessed, preventing potential data loss or corruption during multi-core flow. Fixes: 0fa49df4222f ("media: mtk-jpegdec: support jpegdec multi-hardware") Fixes: dedc21500334 ("media: mtk-jpegdec: add jpeg decode worker interface") Fixes: 934e8bccac95 ("mtk-jpegenc: support jpegenc multi-hardware") Fixes: 5fb1c2361e56 ("mtk-jpegenc: add jpeg encode worker interface") Signed-off-by: Kyrie Wu Reviewed-by: Nicolas Dufresne --- drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c b/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c index 7856a556c..d0fb68bc8 100644 --- a/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c +++ b/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c @@ -850,8 +850,12 @@ static struct vb2_v4l2_buffer *mtk_jpeg_buf_remove(struct mtk_jpeg_ctx *ctx, static void mtk_jpeg_enc_stop_streaming(struct vb2_queue *q) { struct mtk_jpeg_ctx *ctx = vb2_get_drv_priv(q); + struct mtk_jpeg_dev *jpeg = ctx->jpeg; struct vb2_v4l2_buffer *vb; + if (jpeg->variant->multi_core) + vb2_wait_for_all_buffers(q); + while ((vb = mtk_jpeg_buf_remove(ctx, q->type))) v4l2_m2m_buf_done(vb, VB2_BUF_STATE_ERROR); } @@ -859,6 +863,7 @@ static void mtk_jpeg_enc_stop_streaming(struct vb2_queue *q) static void mtk_jpeg_dec_stop_streaming(struct vb2_queue *q) { struct mtk_jpeg_ctx *ctx = vb2_get_drv_priv(q); + struct mtk_jpeg_dev *jpeg = ctx->jpeg; struct vb2_v4l2_buffer *vb; /* @@ -866,6 +871,9 @@ static void mtk_jpeg_dec_stop_streaming(struct vb2_queue *q) * Before STREAMOFF, we still have to return the old resolution and * subsampling. Update capture queue when the stream is off. */ + if (jpeg->variant->multi_core) + vb2_wait_for_all_buffers(q); + if (ctx->state == MTK_JPEG_SOURCE_CHANGE && V4L2_TYPE_IS_CAPTURE(q->type)) { struct mtk_jpeg_src_buf *src_buf; -- 2.51.0.windows.2