Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp3945026rwb; Sat, 10 Dec 2022 00:22:40 -0800 (PST) X-Google-Smtp-Source: AA0mqf5mYEGewEXuePBDvPQTm3K/tCW5+ka0j20+aUYR10lc1/CBm88mt3ZctfQYnUwGNLNibbVZ X-Received: by 2002:a05:6a20:9b95:b0:9d:efbe:2066 with SMTP id mr21-20020a056a209b9500b0009defbe2066mr12936024pzb.28.1670660560220; Sat, 10 Dec 2022 00:22:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670660560; cv=none; d=google.com; s=arc-20160816; b=V9iOm0CTDvBTqiQBtPLzFVt4wffQ2adZy+bEdMvY38N+qtlfZ4CPFxEBVCMJOzPgWn bOqmMhg/SlC5TR9ECg01PlWDtPCK9fn9/mDBGonGnJo5BshWacblf2uFRlSqUsoHfNrU XjKtdqCLQ5O6rUK62gMjaW6WpF+QCxM3xNr2XEOOPwHkXdw9bRb5sWX4vWHGeFUqt6WM uAWLOlp8qphBtXXDhsf7piQLTRu4ZWaQzk5WHk0bJmqaJJYaomeU2+aEGXx98pIwzitM TzUkWFb2JoC9LrNlnh6LOr8QH4ooBqWAaS7R0MS8kVr4qAqLSwd12GWRg36gVcecXHLn kM8A== 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=VOw6AP+dqwsKppLZIIsKU5kSHbhWeg9EUE99I+EJGB4=; b=MybSL+mJYPDzSKWyrkTEYCDxWVX2Y1bwAB/80IJWL36QLMAvAJoFdvZNF/HFeNAPgW SymxO4sxr8/dReDdrpBLGQSGTlWpc1rr5QYrQRGS7DF1+nUGzYC7l0swUwVDv5aE6bu1 gW6Vv7e+8W1BjhSa79sEO/rf+e0Eo+0W3sq10jx+ZIQDOm/XV6f9Egr4hqOlyaLtVaHO LMqjtLUd8DIUC1H2TRm5RsDBTm6VulmpPFTFHvfvimQ03QLGLKwspo9ziRawFv6yYWaG 5bA/p3oT/I0Fv4TgLA+EvujlfSv60maKW19acak9K46sEuVQD1qU7xFGgSrVTHpA5P+B eHvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=tu6jdsJt; 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 k21-20020a6568d5000000b0046004666d82si3703707pgt.497.2022.12.10.00.22.30; Sat, 10 Dec 2022 00:22:40 -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=tu6jdsJt; 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 S229821AbiLJHcy (ORCPT + 74 others); Sat, 10 Dec 2022 02:32:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54980 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229749AbiLJHci (ORCPT ); Sat, 10 Dec 2022 02:32:38 -0500 Received: from mailgw02.mediatek.com (unknown [210.61.82.184]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E2BC513C; Fri, 9 Dec 2022 23:32:34 -0800 (PST) X-UUID: 861c897e684e41b8bdece7b7c905ac0a-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=VOw6AP+dqwsKppLZIIsKU5kSHbhWeg9EUE99I+EJGB4=; b=tu6jdsJtx4Uzc4GVlcvlC3GvXiGr81Ak3kDoLlfq9j7h0vbNGXcfQGFQ9A6rbPIhw+3+hnlVPZnPQ7s4obISTYt+kPDF4WqM1jbRx3tdpbd56urDstXpiPdwIV6rKUcd2Y0InFEa0TsZJwEU2Yb1AbbPz4e63xG6DbHoKrrWOD8=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.14,REQID:a6dfaacc-c8b5-43c8-9f8c-7e40ff014fc8,IP:0,U RL:0,TC:0,Content:0,EDM:0,RT:0,SF:95,FILE:0,BULK:0,RULE:Release_Ham,ACTION :release,TS:95 X-CID-INFO: VERSION:1.1.14,REQID:a6dfaacc-c8b5-43c8-9f8c-7e40ff014fc8,IP:0,URL :0,TC:0,Content:0,EDM:0,RT:0,SF:95,FILE:0,BULK:0,RULE:Spam_GS981B3D,ACTION :quarantine,TS:95 X-CID-META: VersionHash:dcaaed0,CLOUDID:66e01717-b863-49f8-8228-cbdfeedd1fa4,B ulkID:221210153226DM0RCII6,BulkQuantity:0,Recheck:0,SF:38|28|17|19|48,TC:n il,Content:0,EDM:-3,IP:nil,URL:0,File:nil,Bulk:nil,QS:nil,BEC:nil,COL:0 X-UUID: 861c897e684e41b8bdece7b7c905ac0a-20221210 Received: from mtkmbs10n1.mediatek.inc [(172.21.101.34)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1679060076; Sat, 10 Dec 2022 15:32:25 +0800 Received: from mtkcas11.mediatek.inc (172.21.101.40) by mtkmbs11n2.mediatek.inc (172.21.101.187) 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:23 +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:22 +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 3/5] media: mediatek: vcodec: move lat_buf to the top of core list Date: Sat, 10 Dec 2022 15:32:16 +0800 Message-ID: <20221210073218.17350-4-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=-1.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2,RDNS_NONE, SPF_HELO_PASS,SPF_PASS,UNPARSEABLE_RELAY autolearn=no 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 Current instance will decode done when begin to wait lat buf full, move the lat_buf of current instance to the top of core list to make sure current instance's lat_buf will be used firstly. Fixes: 365e4ba01df4 ("media: mtk-vcodec: Add work queue for core hardware decode") Signed-off-by: Yunfei Dong --- .../platform/mediatek/vcodec/vdec_msg_queue.c | 16 ++++++++++++++++ .../platform/mediatek/vcodec/vdec_msg_queue.h | 2 ++ 2 files changed, 18 insertions(+) diff --git a/drivers/media/platform/mediatek/vcodec/vdec_msg_queue.c b/drivers/media/platform/mediatek/vcodec/vdec_msg_queue.c index 2b88065d4d2a..6275536d5063 100644 --- a/drivers/media/platform/mediatek/vcodec/vdec_msg_queue.c +++ b/drivers/media/platform/mediatek/vcodec/vdec_msg_queue.c @@ -182,9 +182,24 @@ 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) { + struct vdec_lat_buf *buf, *tmp; + struct vdec_msg_queue_ctx *core_ctx; long timeout_jiff; int ret; + core_ctx = &msg_queue->ctx->dev->msg_queue_core_ctx; + spin_lock(&core_ctx->ready_lock); + list_for_each_entry_safe(buf, tmp, &core_ctx->ready_queue, core_list) { + if (buf && buf->ctx == msg_queue->ctx) { + spin_lock(&msg_queue->lat_ctx.ready_lock); + list_move(&buf->core_list, &core_ctx->ready_queue); + spin_unlock(&msg_queue->lat_ctx.ready_lock); + queue_work(buf->ctx->dev->core_workqueue, + &buf->ctx->msg_queue.core_work); + } + } + 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, msg_queue->lat_ctx.ready_num == NUM_BUFFER_COUNT, @@ -268,6 +283,7 @@ int vdec_msg_queue_init(struct vdec_msg_queue *msg_queue, vdec_msg_queue_init_ctx(&msg_queue->lat_ctx, MTK_VDEC_LAT0); INIT_WORK(&msg_queue->core_work, vdec_msg_queue_core_work); + msg_queue->ctx = ctx; atomic_set(&msg_queue->lat_list_cnt, 0); atomic_set(&msg_queue->core_list_cnt, 0); mutex_init(&msg_queue->list_cnt_mutex); diff --git a/drivers/media/platform/mediatek/vcodec/vdec_msg_queue.h b/drivers/media/platform/mediatek/vcodec/vdec_msg_queue.h index 94e01a618c5a..53ad05396c8c 100644 --- a/drivers/media/platform/mediatek/vcodec/vdec_msg_queue.h +++ b/drivers/media/platform/mediatek/vcodec/vdec_msg_queue.h @@ -72,6 +72,7 @@ struct vdec_lat_buf { * @wdma_wptr_addr: ube write point * @core_work: core hardware work * @lat_ctx: used to store lat buffer list + * @ctx: point to mtk_vcodec_ctx * * @lat_list_cnt: used to record each instance lat list count * @core_list_cnt: used to record each instance core list count @@ -86,6 +87,7 @@ struct vdec_msg_queue { struct work_struct core_work; struct vdec_msg_queue_ctx lat_ctx; + struct mtk_vcodec_ctx *ctx; atomic_t lat_list_cnt; atomic_t core_list_cnt; -- 2.18.0