Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp3907794rwb; Fri, 9 Dec 2022 23:37:41 -0800 (PST) X-Google-Smtp-Source: AA0mqf4bRO0oIwr+VkxNJbArZbdYvaREH+OpncMWm9nEnmLYGFE7IbasT3yAbsIvpA6lTjjmOST2 X-Received: by 2002:a17:907:d091:b0:7bf:7aa7:38c3 with SMTP id vc17-20020a170907d09100b007bf7aa738c3mr7913037ejc.62.1670657861565; Fri, 09 Dec 2022 23:37:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670657861; cv=none; d=google.com; s=arc-20160816; b=z2W+0ryG5FcrJlfACZsG/FUxbjLyyaf/QPMItXFJIms7/S9Qfndc1yDBRfB7NMcYY3 OOd1qnd6LaatQolYmSUaXIzLBHLs8O7bkSH83KZvgGnOUp1LETVOy7UM+xue6TtSZPmW bF4vCSfmAHcHqvFbK5rh4uol9TgdItvGQeSGv0ODivwSJyRhxae2daWI+RE5F3iTuLp3 lE5dCxe+Y+RVyi/5Whn0MdsMKv+2x9xdew3PwDtcKpbTpl+M13VIAHZktKn9FtUV6bBL 0UZmKxc1ym1CwsA74Bp6AbKHUE+ewwPkd9TWHYEvwN4f8y96FNsIS617BtjDFEkmFYqI 58Gw== 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=YXm7IiRh/S8ttqiZj2NLiwg/hF3EgrsbC+UQ+b2o5bc=; b=afI9ZRMFN7IyFCE3LyjDCrL/WKEx0BFSdEuGyyKSReElO23GE5+5Q0uEUfgdCXmbEm x3SaIembMb3qQjmEDgY11xFC6GTMFh41M0wCW1E+R4x/UH6S9VLcuqUd3Di3y4yjuGJf hamIMwix1o8EwoKRN6S3MuFaPj762vzVwRJoqZf+uZSDy6eq9bXp7qN0Up6WR0Z18RnK qk2Kkfsas+1eolui6Xb0V86EIqyJibhTYy5foL6UKHPTtZ8NNhC0SemZKARI/3VkbXzI PVbAwr4GXZGI4aEeaJC7VmQLTCus3TMdbnvREj1DIdVpjIig9Eb/Ug2q+2UI8YkYVFZb s1yQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b="h/Xe8SaM"; 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 dt22-20020a170907729600b007ae1052555dsi1871404ejc.436.2022.12.09.23.37.22; Fri, 09 Dec 2022 23:37: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="h/Xe8SaM"; 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 S229721AbiLJHcm (ORCPT + 74 others); Sat, 10 Dec 2022 02:32:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54978 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229738AbiLJHci (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 DBEC4FD; Fri, 9 Dec 2022 23:32:34 -0800 (PST) X-UUID: 4252be373d7844958154b945cf10f50f-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=YXm7IiRh/S8ttqiZj2NLiwg/hF3EgrsbC+UQ+b2o5bc=; b=h/Xe8SaMT9uO/mnW5RafqFRwI4smljAanjqoGVQVlgW2zprK7WuW7gLYSRoIP9Z/GaefkGcY/Ckgh8Vtxiq8HOhqMFObRTp/fY0KKyHuQZpeEFi79jPhF08c3LFFrmc0qDtp3gZ9Z9u/AFoaMLoc21hrKOHC0PTlaORaWiDHpow=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.14,REQID:f5412007-d4b2-45de-9a02-64314a55ed12,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:f6e4dc24-4387-4253-a41d-4f6f2296b154,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: 4252be373d7844958154b945cf10f50f-20221210 Received: from mtkexhb01.mediatek.inc [(172.21.101.102)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1047213448; Sat, 10 Dec 2022 15:32:27 +0800 Received: from mtkcas11.mediatek.inc (172.21.101.40) by mtkmbs10n1.mediatek.inc (172.21.101.34) 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:25 +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:24 +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 5/5] media: mediatek: vcodec: remove unused lat_buf Date: Sat, 10 Dec 2022 15:32:18 +0800 Message-ID: <20221210073218.17350-6-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 Remove unused lat_buf from core list, or leading to core list access NULL point. Fixes: 365e4ba01df4 ("media: mtk-vcodec: Add work queue for core hardware decode") Signed-off-by: Yunfei Dong --- .../platform/mediatek/vcodec/vdec_msg_queue.c | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/drivers/media/platform/mediatek/vcodec/vdec_msg_queue.c b/drivers/media/platform/mediatek/vcodec/vdec_msg_queue.c index 9bbbd3fa20eb..3f18eca7dbdd 100644 --- a/drivers/media/platform/mediatek/vcodec/vdec_msg_queue.c +++ b/drivers/media/platform/mediatek/vcodec/vdec_msg_queue.c @@ -185,7 +185,7 @@ 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; + int ret, count = 0; core_ctx = &msg_queue->ctx->dev->msg_queue_core_ctx; spin_lock(&core_ctx->ready_lock); @@ -209,8 +209,22 @@ bool vdec_msg_queue_wait_lat_buf_full(struct vdec_msg_queue *msg_queue) msg_queue->lat_ctx.ready_num); return true; } - mtk_v4l2_err("failed with lat buf isn't full: %d", - msg_queue->lat_ctx.ready_num); + + 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) { + count++; + spin_lock(&msg_queue->lat_ctx.ready_lock); + list_del(&buf->core_list); + spin_unlock(&msg_queue->lat_ctx.ready_lock); + } + } + spin_unlock(&core_ctx->ready_lock); + + mtk_v4l2_err("failed with lat buf isn't full: list(%d %d) count:%d", + atomic_read(&msg_queue->lat_list_cnt), + atomic_read(&msg_queue->core_list_cnt), count); + return false; } -- 2.18.0