Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp3929781rwb; Sat, 10 Dec 2022 00:04:41 -0800 (PST) X-Google-Smtp-Source: AA0mqf70xQSG92gGI7ebl1W0oOydQLjAbkoBfDjrcw1xnJOj3sLmdTciL0Kh9MC4+7BdHnmYDOGL X-Received: by 2002:a17:903:40c3:b0:18d:61f6:e254 with SMTP id t3-20020a17090340c300b0018d61f6e254mr3599177pld.33.1670659481382; Sat, 10 Dec 2022 00:04:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670659481; cv=none; d=google.com; s=arc-20160816; b=I+6FGKDcY9GPCBqz5Gr+5ZFEsAvN2a/hyNSpOkySoFg0vyv0UMl1iwBeSoawYeLZ9R ZAyXEXhqP0BUawI8jS6VbwPqvlt0Kor+P2gKeBjaVe2u5XVXutcGLzpPtGZXlWSSMXBA Bv5PccrKk1RX0/XiOxg9sjm1AYAfUZ6b9oF6/QiSR/mw5uh1+ZTS8wozi2z4kGR7b1up Rtf3xQsefR45NRfNjBPPxbvQazMqE/dopTK5VJpTJs5EyEBXNnIvwoCqvkf3KXEowYou hN6rbfzIZaUJU+f9vqvaRpWYpX/DK7LaHhbmZZ//93lRQXM1nkgzmhXuzpDIqcNunpve rskg== 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=ecg1Ipv3buo16sdVZWJCgG3SlQX6vGOmvjh9A8JgIBs=; b=RB+wqTlteke8VXt7howqRflLwghUhhv/NX1LtfrBugIV5hUxttuo6dBR4VWTolSn5M 6VXlllK/DxVREQ6Cyhh6AZbRfFI15psxNnh7uXTI93+ZFC2ORTptgnm00uyXF9trpGj9 OQKkJcDa/SuVBX24CaN5U230k4qAxIyqPAjva8BShBnxE3DJEpN2Lo10e6BMeLu2U6Ps 2mA54z1NvxY/wy4pZ7x3M+U5Aj+jApoy1BWDL5UMUUUebP4ZdZ2XeZxsBENN6bBEQlkx h4gVzaTx7lbfmKIVIT+Gi3LpLRrN4YaPnmyXMg49US14tT2x4nIlYpp5qsPeQtjyXc4G 7Anw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=BYwVbyXB; 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 p13-20020a170902f08d00b00176d347e9aesi3452308pla.366.2022.12.10.00.04.29; Sat, 10 Dec 2022 00:04:41 -0800 (PST) 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=BYwVbyXB; 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 S229793AbiLJHcr (ORCPT + 74 others); Sat, 10 Dec 2022 02:32:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54924 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229750AbiLJHci (ORCPT ); Sat, 10 Dec 2022 02:32:38 -0500 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F384025E89; Fri, 9 Dec 2022 23:32:32 -0800 (PST) X-UUID: fd40ca88b7d7474f8f8532cd1a1bbf06-20221210 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=ecg1Ipv3buo16sdVZWJCgG3SlQX6vGOmvjh9A8JgIBs=; b=BYwVbyXB205wzsUBh2eyVzao3L0T6rcrIMidbF8HvDHiswxnvBfKtPh3h3wlk4iqgKllTJEZ2q74N90/KvzEghMl7UAvxe9L+JUIIJcn8N1bKmOTNqhjix2cdQSzBcQd2zBX8eNzAeTirjFwMdwFChQbiXrWqrizy/oGrP6tFPk=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.14,REQID:ceb39d6e-710a-4fa3-9787-40b81d301bd9,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:dcaaed0,CLOUDID:43a631d2-652d-43fd-a13a-a5dd3c69a43d,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 X-UUID: fd40ca88b7d7474f8f8532cd1a1bbf06-20221210 Received: from mtkexhb02.mediatek.inc [(172.21.101.103)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1022282198; Sat, 10 Dec 2022 15:32:26 +0800 Received: from mtkcas11.mediatek.inc (172.21.101.40) by mtkmbs13n2.mediatek.inc (172.21.101.108) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.2.792.15; Sat, 10 Dec 2022 15:32:24 +0800 Received: from localhost.localdomain (10.17.3.154) by mtkcas11.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Sat, 10 Dec 2022 15:32:23 +0800 From: Yunfei Dong To: Yunfei Dong , Chen-Yu Tsai , Nicolas Dufresne , Hans Verkuil , AngeloGioacchino Del Regno , Benjamin Gaignard , Tiffany Lin CC: Mauro Carvalho Chehab , Matthias Brugger , Hsin-Yi Wang , Fritz Koenig , Daniel Vetter , Steve Cho , , , , , , Subject: [PATCH 4/5] media: mediatek: vcodec: add core decode done event Date: Sat, 10 Dec 2022 15:32:17 +0800 Message-ID: <20221210073218.17350-5-yunfei.dong@mediatek.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221210073218.17350-1-yunfei.dong@mediatek.com> References: <20221210073218.17350-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,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 Need to make sure core decode done before current instance is free. Fixes: 365e4ba01df4 ("media: mtk-vcodec: Add work queue for core hardware decode") Signed-off-by: Yunfei Dong --- drivers/media/platform/mediatek/vcodec/vdec_msg_queue.c | 4 +++- drivers/media/platform/mediatek/vcodec/vdec_msg_queue.h | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/media/platform/mediatek/vcodec/vdec_msg_queue.c b/drivers/media/platform/mediatek/vcodec/vdec_msg_queue.c index 6275536d5063..9bbbd3fa20eb 100644 --- a/drivers/media/platform/mediatek/vcodec/vdec_msg_queue.c +++ b/drivers/media/platform/mediatek/vcodec/vdec_msg_queue.c @@ -201,7 +201,7 @@ bool vdec_msg_queue_wait_lat_buf_full(struct vdec_msg_queue *msg_queue) spin_unlock(&core_ctx->ready_lock); timeout_jiff = msecs_to_jiffies(1000 * (NUM_BUFFER_COUNT + 2)); - ret = wait_event_timeout(msg_queue->lat_ctx.ready_to_use, + 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) { @@ -262,6 +262,7 @@ static void vdec_msg_queue_core_work(struct work_struct *work) mtk_vcodec_dec_disable_hardware(ctx, MTK_VDEC_CORE); vdec_msg_queue_qbuf(&ctx->msg_queue.lat_ctx, lat_buf); + wake_up_all(&ctx->msg_queue.core_dec_done); if (atomic_read(&lat_buf->ctx->msg_queue.core_list_cnt)) { mtk_v4l2_debug(3, "re-schedule to decode for core: %d", dev->msg_queue_core_ctx.ready_num); @@ -287,6 +288,7 @@ int vdec_msg_queue_init(struct vdec_msg_queue *msg_queue, atomic_set(&msg_queue->lat_list_cnt, 0); atomic_set(&msg_queue->core_list_cnt, 0); mutex_init(&msg_queue->list_cnt_mutex); + init_waitqueue_head(&msg_queue->core_dec_done); msg_queue->wdma_addr.size = vde_msg_queue_get_trans_size(ctx->picinfo.buf_w, diff --git a/drivers/media/platform/mediatek/vcodec/vdec_msg_queue.h b/drivers/media/platform/mediatek/vcodec/vdec_msg_queue.h index 53ad05396c8c..0944b6436fb6 100644 --- a/drivers/media/platform/mediatek/vcodec/vdec_msg_queue.h +++ b/drivers/media/platform/mediatek/vcodec/vdec_msg_queue.h @@ -77,6 +77,7 @@ struct vdec_lat_buf { * @lat_list_cnt: used to record each instance lat list count * @core_list_cnt: used to record each instance core list count * @list_cnt_mutex: used to protect list count + * @core_dec_done: core work queue decode done event */ struct vdec_msg_queue { struct vdec_lat_buf lat_buf[NUM_BUFFER_COUNT]; @@ -93,6 +94,7 @@ struct vdec_msg_queue { atomic_t core_list_cnt; /* Protects access to lat and core list cnt */ struct mutex list_cnt_mutex; + wait_queue_head_t core_dec_done; }; /** -- 2.18.0