Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp10438557rwl; Wed, 11 Jan 2023 20:34:57 -0800 (PST) X-Google-Smtp-Source: AMrXdXv9FloUd20pqoGgB/J0/nEioNvM3ut8TLd7B8q/X2TEp+zDClrFe9degsqT3BYNW53Clibm X-Received: by 2002:a17:903:24b:b0:187:282d:6990 with SMTP id j11-20020a170903024b00b00187282d6990mr63268939plh.28.1673498097478; Wed, 11 Jan 2023 20:34:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673498097; cv=none; d=google.com; s=arc-20160816; b=hV9sTaADG08ZywLpn1nw8pXuAI/WnnZHrtNJZpTGFz3MLMPlkLPO1Bo76I8bnu96sz +R+2Oyv6Cp1fGfbUTMGdtqmuApQ4TQlL9c5keXqoUAnngfGQNFKic+e7mow+aHl4I6RG qfG4AoxR2Efuymtf0zeJoUCGVGlAPjuIZsnpXUlZX6q3iK6jRUQCXmZHzA1TYfBlVEJP 0L5tPaJvOMSsabsnnRowW9m1k4fNvUxZSO8l6hlVqOlIZ75gW1MJNrr4K8tTP6S25v+C IHUXeARKo+Zm4+kr+6xmMgIYFwqF5gipkgUjw+sSsP+cueIXzXH2Lb0xBGSbuS2VWxyG fS0g== 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=cMIEUK+vAlHILuLLQd0pKye2ILITzg/TKTRlGmjn3lA=; b=maOvagRTvV2j8i4qPXL4qDkGNJaxuor8IAIuHILd1akDR8q2qx9Xp6DP4Oe1rrkmsy SWAGeqmZAqHzKb3lMrQLipgkhaqkSVLfCWcKspiP5b1ZUFdF1SHuruqHq7fnNIR+jL4p k58t2K4ZxZWZywJoWlcSA5k6Mrge5hKLMe5lhHFvGfy1Ha28YPCHjzMeBBK73Z8k0lAi ZGog7WTmdgjrLkwryL4JDAt14tpw7nNOfTKePTmuLS18wjDyDBYLpOTrx8peZmf+IN9n 3m9J60jbl6sRjtTWJAkck1SQeLTIrpGZGARni/tpDG1uFD4aYC43RpPYxvbNH/6siss0 djPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=dqBT91xu; 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 d13-20020a170903230d00b00188f9534a59si16500871plh.306.2023.01.11.20.34.51; Wed, 11 Jan 2023 20:34:57 -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=dqBT91xu; 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 S236532AbjALEMj (ORCPT + 50 others); Wed, 11 Jan 2023 23:12:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48690 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229686AbjALEL7 (ORCPT ); Wed, 11 Jan 2023 23:11:59 -0500 Received: from mailgw02.mediatek.com (unknown [210.61.82.184]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DCC7B4C71C; Wed, 11 Jan 2023 20:11:52 -0800 (PST) X-UUID: 3bc78eea922f11ed945fc101203acc17-20230112 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=cMIEUK+vAlHILuLLQd0pKye2ILITzg/TKTRlGmjn3lA=; b=dqBT91xulAg0+T0QmtkT+1tLapxpJ8HWiBKqmTHUAU2wuU9MP/3RP5ErKKJqmMPEJy6X8xuKq76N0CiLZ1Le5fc//g9Ih3/5qFFgBTg0O6gRtcZ+R+AJb9De3cprl9AjBZ3nhsE/c5gymGQuYBKqJ84s1YX1IIkTVHReJN9qCJU=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.17,REQID:144388a7-3231-46aa-91a5-018106571ed6,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:543e81c,CLOUDID:748295f5-ff42-4fb0-b929-626456a83c14,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 X-CID-BVR: 0,NGT X-UUID: 3bc78eea922f11ed945fc101203acc17-20230112 Received: from mtkmbs11n2.mediatek.inc [(172.21.101.187)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1063300966; Thu, 12 Jan 2023 12:11:48 +0800 Received: from mtkmbs13n2.mediatek.inc (172.21.101.108) by mtkmbs11n2.mediatek.inc (172.21.101.187) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.792.15; Thu, 12 Jan 2023 12:11:46 +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.792.15 via Frontend Transport; Thu, 12 Jan 2023 12:11:45 +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 v3,4/7] media: mediatek: vcodec: add core decode done event Date: Thu, 12 Jan 2023 12:11:37 +0800 Message-ID: <20230112041140.833-5-yunfei.dong@mediatek.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230112041140.833-1-yunfei.dong@mediatek.com> References: <20230112041140.833-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 0da6e3e2ef0b..ce7c82e38103 100644 --- a/drivers/media/platform/mediatek/vcodec/vdec_msg_queue.c +++ b/drivers/media/platform/mediatek/vcodec/vdec_msg_queue.c @@ -196,7 +196,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) { @@ -257,6 +257,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); @@ -281,6 +282,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); + 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 56280d6682c5..a75c04418f52 100644 --- a/drivers/media/platform/mediatek/vcodec/vdec_msg_queue.h +++ b/drivers/media/platform/mediatek/vcodec/vdec_msg_queue.h @@ -76,6 +76,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 + * @core_dec_done: core work queue decode done event */ struct vdec_msg_queue { struct vdec_lat_buf lat_buf[NUM_BUFFER_COUNT]; @@ -90,6 +91,7 @@ struct vdec_msg_queue { atomic_t lat_list_cnt; atomic_t core_list_cnt; + wait_queue_head_t core_dec_done; }; /** -- 2.18.0