Received: by 2002:ab2:2994:0:b0:1ef:ca3e:3cd5 with SMTP id n20csp28504lqb; Thu, 14 Mar 2024 04:45:43 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXsJZ6j0jg4ra775DwMvQm0TNbNsO1ZMS5ht5yWDfN5oX/dEj8z2eUGpkEJpVi+19bvH1x+S1YZ/crdtEYTDjPn6Y7bO0I/8vt2x3aoCw== X-Google-Smtp-Source: AGHT+IHdveFAKg2i7zMaCfxsVOm64oocXz7Z/9lSsz7Ox787cGAKCpfvUTrQ44NSvgRJCrJUIaYp X-Received: by 2002:a17:90a:b785:b0:29b:dc42:2b64 with SMTP id m5-20020a17090ab78500b0029bdc422b64mr7486461pjr.23.1710416743692; Thu, 14 Mar 2024 04:45:43 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710416743; cv=pass; d=google.com; s=arc-20160816; b=HZYRKbHWgt0vDlugDMuVyXR6RTNaKvegGMEp8B0Utq7Aubpw1WetnGE0/YRfyQZ4v5 lNyzMhGJRF03Fg2d0VUljD3ZOvItGM203BWSf6/y1YEfLm2952eb025pGmAOy4r+6989 e7KnFBzaKeZcB/G+kFivpLfwSf+ph456GpKP1r7ApeWytMIT1361e4D+4jLFPZ2lN6RL 4rUeSPFfnxWqNar1frspBMYbF2XKrlFOT+Ta1lOhylwv3fIbT3K8ffwFNPp580sd7X8q me9ysyPkLmbEDCHlGYN3qpxPr33o/1acVm/+EizkWVIsSGqs14mhJfabCEgDSMj0YhgT /5ZA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=Y8AOqNEE2z+8/C4fBu6xT5uIPzpeWScBA5hbmroPZmo=; fh=G173izs5BDUMpWbyuW94+SjYG1wp8PFrHaqaTNdP0ls=; b=U9/6A6ITMNcJQ992Nb3khJU5YeKngjikoHSR2L/3e09fxRuACbG5NNDAwz0++ygafX Mn4cNX9YXt7y/tPuvEvl3N6SXZT+UbHOn9WrfUTu2o+kXrNu04gM9ywvplCvlzRTqcIv SpYfgPvmMQ0RB8mhqkKtS8cw4f332CpGMAnMVXfpJuZoaOCcv/THg4JnPGErYPiZLxP5 bOQYFzKSQP10Wr3bNrds0qaEp9NKZ3OrHyMF7dN6Sv/nNMscroEsmv1NJmi1OAvuUTj+ /PSj773XLhIkZwRp0F7lfdT6UxIQGHvN5j+DEwEOF/lvYh/V0mZPZeXl+YAwLkbRE0Xt BUaQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=qLmfq5aa; arc=pass (i=1 spf=pass spfdomain=mediatek.com dkim=pass dkdomain=mediatek.com dmarc=pass fromdomain=mediatek.com); spf=pass (google.com: domain of linux-kernel+bounces-103191-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-103191-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id e6-20020a17090a684600b0029b97c462e5si473888pjm.2.2024.03.14.04.45.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Mar 2024 04:45:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-103191-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=qLmfq5aa; arc=pass (i=1 spf=pass spfdomain=mediatek.com dkim=pass dkdomain=mediatek.com dmarc=pass fromdomain=mediatek.com); spf=pass (google.com: domain of linux-kernel+bounces-103191-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-103191-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 6216D2849C0 for ; Thu, 14 Mar 2024 11:45:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CC5D16FE06; Thu, 14 Mar 2024 11:45:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="qLmfq5aa" Received: from mailgw02.mediatek.com (unknown [210.61.82.184]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8058A6F065; Thu, 14 Mar 2024 11:45:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=210.61.82.184 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710416705; cv=none; b=t6s4gFtn/46XZdjteA4Nnkv2BBk2VvGf/swAemhk79YB6ck/YKDFXM1TtKyrD+nf5vz8rX6GTq6aa950xUZGPilJjY64kbvmp/a7DUEPQh1JX9sMBPQ6nLsd6ldYPaOWIgqR1L2tY/6yW9p7QWx6KtIuNYz2AQ598/WaqhT43o0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710416705; c=relaxed/simple; bh=SXxtb7bxSKRszoVxuzF4Ucwf11/mZoyMMCwTP5EOnFM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=VH1W0fylXcieO5OT9vXI1b32KGpslxtgpUOxNekkPd7CqNCUmmxtdoILvSFS76lqDtCljC0/NJ4b5Ed7qv2ZGBj3XCKVcenxbL388MHLH+oRE8Egz1iH9NK5RPschih2j8zqkHzVSU5d4VCl5T5YkTSf6uPE9uqh5PtkgER2yUU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=mediatek.com; spf=pass smtp.mailfrom=mediatek.com; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b=qLmfq5aa; arc=none smtp.client-ip=210.61.82.184 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=mediatek.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=mediatek.com X-UUID: 49106a58e1f811ee935d6952f98a51a9-20240314 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=Y8AOqNEE2z+8/C4fBu6xT5uIPzpeWScBA5hbmroPZmo=; b=qLmfq5aaW433KL62H6X/ARRjZexknv8j8OaK7A8VIJgMFNiHz8Kxht99QQopvK1m/QmKJkk88MViSRL+UhPeBHO1s0MrFW42N2n2rVjyoIwSdG7fVAbfbA5Fwe/k5u2pPIsZRhguy0i4CNVHZGuok284S+39anrw9tgcDi6BrB8=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.37,REQID:6453353b-d688-4b03-bae5-b7b76f5ee19b,IP:0,U RL:0,TC:0,Content:-5,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION :release,TS:-5 X-CID-META: VersionHash:6f543d0,CLOUDID:193a6790-e2c0-40b0-a8fe-7c7e47299109,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:102,TC:nil,Content:0,EDM:-3,IP:nil,U RL:0,File:nil,RT:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0,AV:0,LES:1, SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0 X-CID-BVR: 0,NGT X-CID-BAS: 0,NGT,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-UUID: 49106a58e1f811ee935d6952f98a51a9-20240314 Received: from mtkmbs10n2.mediatek.inc [(172.21.101.183)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1847715534; Thu, 14 Mar 2024 19:44:58 +0800 Received: from mtkmbs11n2.mediatek.inc (172.21.101.187) by mtkmbs10n1.mediatek.inc (172.21.101.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.26; Thu, 14 Mar 2024 19:44:57 +0800 Received: from mhfsdcap04.gcn.mediatek.inc (10.17.3.154) by mtkmbs11n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.1118.26 via Frontend Transport; Thu, 14 Mar 2024 19:44:56 +0800 From: Yunfei Dong To: =?UTF-8?q?N=C3=ADcolas=20F=20=2E=20R=20=2E=20A=20=2E=20Prado?= , Nicolas Dufresne , Hans Verkuil , AngeloGioacchino Del Regno , Benjamin Gaignard , Nathan Hebert , Sebastian Fricke CC: Hsin-Yi Wang , Fritz Koenig , Daniel Vetter , Steve Cho , "Yunfei Dong" , , , , , , Subject: [PATCH v2,3/4] media: mediatek: vcodec: flush decoder before remove all source buffer Date: Thu, 14 Mar 2024 19:44:51 +0800 Message-ID: <20240314114452.17532-4-yunfei.dong@mediatek.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240314114452.17532-1-yunfei.dong@mediatek.com> References: <20240314114452.17532-1-yunfei.dong@mediatek.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-TM-AS-Product-Ver: SMEX-14.0.0.3152-9.1.1006-23728.005 X-TM-AS-Result: No-10--4.180300-8.000000 X-TMASE-MatchedRID: LQTn7QLkznoEQqIqKFLtTlu4M/xm4KZebnWMzHijq6Sen0qBdy7fjBXb HvCbSY/6sTCecWdCeaflMF4v3SREo4x1g1lTiexdA9lly13c/gGOJZyIAulM0xQLE16MmfDLS20 1H/juErxAEhD9e0n6VSfyuWB93oCTC9YpJ/fXjNeeAiCmPx4NwBnUJ0Ek6yhjxEHRux+uk8ifEz J5hPndGZnMVq7tIlw2tPfRu/NO6WJzOLRNuFmkzrkqWJxjUSaiqe1i8szqq0zFmp618OSM6Obqo nfkRZEWXfGn12bbCvxioaYV0aSx3Bz+PhojlLUuev0YPTN868QBqq+/+aGCsQhzL04Or2eZVlxr 1FJij9s= X-TM-AS-User-Approved-Sender: No X-TM-AS-User-Blocked-Sender: No X-TMASE-Result: 10--4.180300-8.000000 X-TMASE-Version: SMEX-14.0.0.3152-9.1.1006-23728.005 X-TM-SNTS-SMTP: 6680B778D7103250B9479887C3CEB8CB3823E585258715E9BDE23C31FE0953662000:8 X-MTK: N Flush decoder will reset all driver to init status, lat and core work queue will stop to work. If lat or core work queue in working when remove all source buffer, will lead to remove source buffer again or buff done with one non-existent source buffer. Signed-off-by: Yunfei Dong --- .../mediatek/vcodec/decoder/mtk_vcodec_dec.c | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec.c b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec.c index 3766e2176899..cdd36a5320cd 100644 --- a/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec.c +++ b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec.c @@ -835,17 +835,6 @@ void vb2ops_vdec_stop_streaming(struct vb2_queue *q) ctx->id, q->type, ctx->state, ctx->decoded_frame_cnt); if (q->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) { - while ((src_buf = v4l2_m2m_src_buf_remove(ctx->m2m_ctx))) { - if (src_buf != &ctx->empty_flush_buf.vb) { - struct media_request *req = - src_buf->vb2_buf.req_obj.req; - - if (req) - v4l2_ctrl_request_complete(req, &ctx->ctrl_hdl); - v4l2_m2m_buf_done(src_buf, VB2_BUF_STATE_ERROR); - } - } - if (ctx->state >= MTK_STATE_HEADER) { /* Until STREAMOFF is called on the CAPTURE queue * (acknowledging the event), the driver operates @@ -868,6 +857,17 @@ void vb2ops_vdec_stop_streaming(struct vb2_queue *q) mtk_v4l2_vdec_err(ctx, "DecodeFinal failed, ret=%d", ret); } + while ((src_buf = v4l2_m2m_src_buf_remove(ctx->m2m_ctx))) { + if (src_buf != &ctx->empty_flush_buf.vb) { + struct media_request *req = + src_buf->vb2_buf.req_obj.req; + + if (req) + v4l2_ctrl_request_complete(req, &ctx->ctrl_hdl); + v4l2_m2m_buf_done(src_buf, VB2_BUF_STATE_ERROR); + } + } + ctx->state = MTK_STATE_FLUSH; return; } -- 2.18.0