Received: by 2002:a05:6358:53a8:b0:117:f937:c515 with SMTP id z40csp3541245rwe; Sun, 16 Apr 2023 22:50:19 -0700 (PDT) X-Google-Smtp-Source: AKy350b9ObkmPCYp/aYxhEQ7vZrCe1MQzBo/6pXs+ETYgvldU3kosCdAuFO/Rgzppf2yvamKRcr3 X-Received: by 2002:a17:90a:94c4:b0:236:73d5:82cf with SMTP id j4-20020a17090a94c400b0023673d582cfmr13798914pjw.9.1681710619336; Sun, 16 Apr 2023 22:50:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681710619; cv=none; d=google.com; s=arc-20160816; b=ZFnPjUGXC8s1VIxDGZHfG7MyFQibEj4tBkpDT1ncdLG7pV6fo8r/8tP5DfdSKd/gne gFocaFdENSje7vdXc/sCwhoAZ97etXvUc5UYLNWwqYyIwiAgeLTHJ5BzsGr/dS50ROxW w0ex8EUZSp0dlkYD3VaPNx3uWN9Ut0bycOpGJ2luCUs9UwAsY4YVt1PTCcY0rABgy2NI PAKwqOVfB3VRkAHwaH1bw/vdZGQ47G53t10FiMc0M9ZEPbFgjZHgW2P3jyy7QKJHM49e 66Sco+FgI85iBqM3h8S0UqJydey+lNRCQEtyHVZ65hecO0hix+1HPgVOL/ZhNJeP78XF M6ig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=QeR9CpCczbRyPimR+qG2haOdePkMQhWTy8Vcp1T4SpM=; b=A7uMvavfKaz/Pa78sRttpfxQyBp87syKYvqNpeKWcLgctOqXBcosR3AUObtULrGAVt peObRoya2ibaxgcVy6Tu4q+ox1cpmuGzu71Y+0uflhy+ssCHakwiScLHqhp/FyYSP6Js KZ0lGk6tXJuibfronGvdA8LL2lcOHXrdXYjDf2hqVcJoTYQdqM3Xt6wC85AxoFT5/Kje RVpJ3j/HIzDG86k0RZqHmWUU7DNMiEcn+MORAiaxjtxloL4HhTo6c9gqpUt8F1s891pb 0kQE0Ygf8CN9i3hfXftskPysMI1GZL8vlhax74lCfH5rEuVBhlAPFSMh9PE1GI8n52Ae Sfjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=Grr9pzJN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id mu16-20020a17090b389000b0023f6ee835cesi11994491pjb.9.2023.04.16.22.50.08; Sun, 16 Apr 2023 22:50:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=Grr9pzJN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229849AbjDQFs4 (ORCPT + 99 others); Mon, 17 Apr 2023 01:48:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36072 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229669AbjDQFse (ORCPT ); Mon, 17 Apr 2023 01:48:34 -0400 Received: from mailgw02.mediatek.com (unknown [210.61.82.184]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2B44326BB; Sun, 16 Apr 2023 22:48:29 -0700 (PDT) X-UUID: 789ec7dadce311edb6b9f13eb10bd0fe-20230417 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=QeR9CpCczbRyPimR+qG2haOdePkMQhWTy8Vcp1T4SpM=; b=Grr9pzJN64s3KMg3OJX2efqjwjVABhUuouQXaEV4m1XZ2x8GrD5jM/NL+yZoMdXHoCSvI/mN+nheY7FaHwl3dyhbhMhpoyp8GmkJMcUjzH7J9UHS4pMmyYxVQteDa5K0+cXIheGkL5114yiylQdyKWyt5rgbcndp5ZJCzVhON5U=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.22,REQID:13f83046-ed02-44eb-ba2a-e5d14541e553,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:120426c,CLOUDID:ba018da1-8fcb-430b-954a-ba3f00fa94a5,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:102,TC:nil,Content:0,EDM:-3,IP:nil,U RL:0,File:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0,AV:0 X-CID-BVR: 0,NGT X-CID-BAS: 0,NGT,0,_ X-UUID: 789ec7dadce311edb6b9f13eb10bd0fe-20230417 Received: from mtkmbs13n2.mediatek.inc [(172.21.101.108)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 25226202; Mon, 17 Apr 2023 13:48:25 +0800 Received: from mtkmbs13n2.mediatek.inc (172.21.101.108) by mtkmbs13n1.mediatek.inc (172.21.101.193) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.25; Mon, 17 Apr 2023 13:48:24 +0800 Received: from mhfsdcap04.gcn.mediatek.inc (10.17.3.154) by mtkmbs13n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.1118.25 via Frontend Transport; Mon, 17 Apr 2023 13:48:23 +0800 From: Yunfei Dong To: Chen-Yu Tsai , Nicolas Dufresne , Hans Verkuil , AngeloGioacchino Del Regno , Benjamin Gaignard , =?UTF-8?q?N=C3=ADcolas=20F=20=2E=20R=20=2E=20A=20=2E=20Prado?= , Yunfei Dong CC: Matthias Brugger , Hsin-Yi Wang , Fritz Koenig , Daniel Vetter , Steve Cho , , , , , , Subject: [PATCH 6/6] media: mediatek: vcodec: using empty lat buffer as the last one Date: Mon, 17 Apr 2023 13:48:16 +0800 Message-ID: <20230417054816.17097-7-yunfei.dong@mediatek.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230417054816.17097-1-yunfei.dong@mediatek.com> References: <20230417054816.17097-1-yunfei.dong@mediatek.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-MTK: N X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Queue the empty lat buffer to core list when driver need to flush decode. It's mean core already decode all existed lat buffer when get empty lat buffer, then wake up core decode done event, the driver will exit when getting core dec done event. Fixes: d227af847ac2 ("media: mediatek: vcodec: add core decode done event") Signed-off-by: Yunfei Dong --- .../platform/mediatek/vcodec/vdec_msg_queue.c | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/drivers/media/platform/mediatek/vcodec/vdec_msg_queue.c b/drivers/media/platform/mediatek/vcodec/vdec_msg_queue.c index a74bd839d7e2..d2e48eefc958 100644 --- a/drivers/media/platform/mediatek/vcodec/vdec_msg_queue.c +++ b/drivers/media/platform/mediatek/vcodec/vdec_msg_queue.c @@ -177,9 +177,6 @@ void vdec_msg_queue_update_ube_wptr(struct vdec_msg_queue *msg_queue, uint64_t u bool vdec_msg_queue_wait_lat_buf_full(struct vdec_msg_queue *msg_queue) { - int ret; - long timeout_jiff; - if (atomic_read(&msg_queue->lat_list_cnt) == NUM_BUFFER_COUNT) { mtk_v4l2_debug(3, "wait buf full: list(%d %d) ready_num:%d status:%d", atomic_read(&msg_queue->lat_list_cnt), @@ -189,19 +186,14 @@ bool vdec_msg_queue_wait_lat_buf_full(struct vdec_msg_queue *msg_queue) return true; } - timeout_jiff = msecs_to_jiffies(1000 * (NUM_BUFFER_COUNT + 2)); - ret = wait_event_timeout(msg_queue->ctx->msg_queue.core_dec_done, - msg_queue->lat_ctx.ready_num == NUM_BUFFER_COUNT, - timeout_jiff); - if (ret) { - mtk_v4l2_debug(3, "success to get lat buf: %d", - msg_queue->lat_ctx.ready_num); - return true; - } + msg_queue->flush_done = false; + vdec_msg_queue_qbuf(&msg_queue->core_ctx, &msg_queue->empty_lat_buf); + wait_event(msg_queue->core_dec_done, msg_queue->flush_done); - mtk_v4l2_err("failed with lat buf isn't full: list(%d %d)", - atomic_read(&msg_queue->lat_list_cnt), - atomic_read(&msg_queue->core_list_cnt)); + mtk_v4l2_debug("flush done => ready_num:%d status:%d list(%d %d)", + msg_queue->lat_ctx.ready_num, msg_queue->status, + atomic_read(&msg_queue->lat_list_cnt), + atomic_read(&msg_queue->core_list_cnt)); return false; } @@ -250,6 +242,14 @@ static void vdec_msg_queue_core_work(struct work_struct *work) if (!lat_buf) return; + if (lat_buf->is_last_frame) { + ctx->msg_queue.status = CONTEXT_LIST_DEC_DONE; + msg_queue->flush_done = true; + wake_up(&ctx->msg_queue.core_dec_done); + + return; + } + ctx = lat_buf->ctx; mtk_vcodec_dec_enable_hardware(ctx, MTK_VDEC_CORE); mtk_vcodec_set_curr_ctx(dev, ctx, MTK_VDEC_CORE); -- 2.18.0