Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp4090772pxt; Tue, 10 Aug 2021 20:02:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwj5+jEcyJGamFUIxYUSCo7iORKSGory1BXDYvil5vovA5tIDPwJoHjnMgKsUoppxjfCzbD X-Received: by 2002:aa7:db94:: with SMTP id u20mr8560682edt.381.1628650951899; Tue, 10 Aug 2021 20:02:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628650951; cv=none; d=google.com; s=arc-20160816; b=gPvriQMqWp2RcJtR5AMfIg7xU8bydjo0pZBMby+qRCWKOta8XR8NVW1qZkJ4DqvWpD ta0YV/4JxcfUMq3j3iKH+3u4KBIwpAA9J1xAKYoBwynEthn2E7CO6BAYXUc0ubsXSkUl alvDS9GLyA3UKxU4JXKduIMiussKieWWeZ0oLe3qrm4IRffLi/ii4QIqdo1G1T7jEzCH Vfpnqx4EutUChrHp8pm/TxoIODr9FYuID6QmqlVKeK6OeT8yfZdQ3A3+BnaWneuSmvyZ s/R4hJNPVG/50py0NwALCNs/c3iuJxVLkOYfhjynUQpaGuHnLy4PD2C4RSSinOGXVvso dS3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=fKdkwQDNPoh6b3wtt/uPy8TC6NgZnHixOfv2tof+X+M=; b=aWvqzpbQR0VF0USnLykli23O4Ta+qMg930jttqiv0BRO8wFX2jbFf7uDQI9K6daxAM 2UsiGxiQRN5fKV8WCbBuJYXKKubOjeddhx8oQxIDTz0LTp8oruQS/9BuZD35BwGHswUJ 8XP1DYhyu+I6E4StgB4ni8Z3+UF+RjVjP+wdLYotD5tK7zz36xbvsUXXEWUZhStmqChf tzMyM5SSgXsZBo4FVa3zSv75wZPvZId61YLTn7+YcaCSirEtwcT0QHO3fML3OSpxTroV Suwozh3XlhEtzRclhfG4TMdqXw9UPHYrldK8twMpgoM5wJyJxf28Z61AmHIsoNesetEu nLxw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cm19si22731141edb.410.2021.08.10.20.02.03; Tue, 10 Aug 2021 20:02:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233117AbhHKC7w (ORCPT + 99 others); Tue, 10 Aug 2021 22:59:52 -0400 Received: from mailgw02.mediatek.com ([210.61.82.184]:49560 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S232184AbhHKC7O (ORCPT ); Tue, 10 Aug 2021 22:59:14 -0400 X-UUID: 63d2133adb9b4011a188ccf9173ae07f-20210811 X-UUID: 63d2133adb9b4011a188ccf9173ae07f-20210811 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 1962693669; Wed, 11 Aug 2021 10:58:47 +0800 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by mtkmbs02n1.mediatek.inc (172.21.101.77) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 11 Aug 2021 10:58:45 +0800 Received: from localhost.localdomain (10.17.3.153) by MTKCAS06.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Wed, 11 Aug 2021 10:58:44 +0800 From: Yunfei Dong To: Yunfei Dong , Alexandre Courbot , Hans Verkuil , Tzung-Bi Shih , Tiffany Lin , Andrew-CT Chen , Mauro Carvalho Chehab , Rob Herring , Matthias Brugger , Tomasz Figa CC: Hsin-Yi Wang , Fritz Koenig , Irui Wang , , , , , , , , George Sun Subject: [PATCH v5, 10/15] media: mtk-vcodec: Add new interface to lock different hardware Date: Wed, 11 Aug 2021 10:57:56 +0800 Message-ID: <20210811025801.21597-11-yunfei.dong@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20210811025801.21597-1-yunfei.dong@mediatek.com> References: <20210811025801.21597-1-yunfei.dong@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org For add new hardware, not only need to lock lat hardware, also need to lock core hardware in case of different instance start to decoder at the same time. Signed-off-by: Yunfei Dong --- v5: no changes --- drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c | 4 ++-- drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c | 6 +++--- drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c index 2b334a8a81c6..130ecef2e766 100644 --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c @@ -105,12 +105,12 @@ static int vidioc_decoder_cmd(struct file *file, void *priv, void mtk_vdec_unlock(struct mtk_vcodec_ctx *ctx) { - mutex_unlock(&ctx->dev->dec_mutex); + mutex_unlock(&ctx->dev->dec_mutex[ctx->hw_id]); } void mtk_vdec_lock(struct mtk_vcodec_ctx *ctx) { - mutex_lock(&ctx->dev->dec_mutex); + mutex_lock(&ctx->dev->dec_mutex[ctx->hw_id]); } void mtk_vcodec_dec_release(struct mtk_vcodec_ctx *ctx) diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c index 109f7de126a1..e448cb238c7f 100644 --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c @@ -373,7 +373,7 @@ static int mtk_vcodec_probe(struct platform_device *pdev) struct video_device *vfd_dec; phandle rproc_phandle; enum mtk_vcodec_fw_type fw_type; - int ret; + int i, ret; dev = devm_kzalloc(&pdev->dev, sizeof(*dev), GFP_KERNEL); if (!dev) @@ -405,8 +405,8 @@ static int mtk_vcodec_probe(struct platform_device *pdev) goto err_dec_pm; } - mutex_init(&dev->dec_mutex); - mutex_init(&dev->dev_mutex); + for (i = 0; i < MTK_VDEC_HW_MAX; i++) + mutex_init(&dev->dec_mutex[i]); spin_lock_init(&dev->irqlock); snprintf(dev->v4l2_dev.name, sizeof(dev->v4l2_dev.name), "%s", diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h b/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h index a8242389ad24..f1e63acaec76 100644 --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h @@ -496,7 +496,7 @@ struct mtk_vcodec_dev { int dec_irq; int enc_irq; - struct mutex dec_mutex; + struct mutex dec_mutex[MTK_VDEC_HW_MAX]; struct mutex enc_mutex; struct mtk_vcodec_pm pm; -- 2.25.1