Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp5281980pxv; Tue, 6 Jul 2021 23:24:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw+Z/B7fJOqCbHzB5zHnVo85BC0dusnmpQwGPMwMGLLcymZ3mvLue0FwBqB+d2rkhHw/s+M X-Received: by 2002:a17:907:b19:: with SMTP id h25mr5387292ejl.414.1625639047213; Tue, 06 Jul 2021 23:24:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625639047; cv=none; d=google.com; s=arc-20160816; b=nlIs2/7+FyKX0hYRWWleyHXDV7mk5YLW22MIKaYpsKe42UTyh6s04KkC5iS7V4B2+S FXl2McUPvqQRAmSYJdOc96VSbqNdk0sU7NxpyJmzY+ZQGSh2F1MagAlOm6TPT4t6PwTb 5xnRhSgrbiqQr1rsJPFEMXy+dsNeIqI880OHQQSQ7xZ0z8NN/9N7ro88pgG5+ygLzJE1 3Fb6JKpov1M/TWUSH6bMXyjatzDcUferz+cUXIFqObzBFx3Ohl2LD3us4XwtbWjuAJzK OVb6SEexB3QV37KEa+AefCEfCTwYzMU2kcFKl6YHlB+h6nkoyk8IjpjuM+pv7kqdJjWv ofaQ== 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=xb2TziNbB4NZ5GwpaXeaLZMVW2mSMuMqOEMS/UrAqVE=; b=haytGQVHTJdP9Lo1l7+hj8PA/Jp6vxvXYz0j4c6pE6vFHHf5TUM4wX6Bd5/pKXEY13 tZiBDBlhAi1pP/sMgT2vte9bhKy09IlF+infskM2mZlGtdO6N+Vee8rCfu10dn/Ze4ke 1oa8d1gc4SPraxlbndxCcpg782TMMgEAU6i09g9gxXt390RsQKEqAFgUkeu4s1XbrXC4 RLp10PWqpKJSf4UtN6LNcu/zKtVUIaBNFZ+b6wvTVLAckm5oQxR78u3HKDYai6URKrEu JLWOxCPtNqH3LdDhamSdfE5qUzkbGC65//+T4xy0VRNPa6M5vhvR2Yuwe8zuROHaxprH tKOg== 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 8si20936379ejx.637.2021.07.06.23.23.44; Tue, 06 Jul 2021 23:24:07 -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 S230465AbhGGGZV (ORCPT + 99 others); Wed, 7 Jul 2021 02:25:21 -0400 Received: from mailgw01.mediatek.com ([60.244.123.138]:49836 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S230356AbhGGGZN (ORCPT ); Wed, 7 Jul 2021 02:25:13 -0400 X-UUID: 28f9fdc9b5804c60a56b5a523d8c5af7-20210707 X-UUID: 28f9fdc9b5804c60a56b5a523d8c5af7-20210707 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 638275221; Wed, 07 Jul 2021 14:22:28 +0800 Received: from mtkcas07.mediatek.inc (172.21.101.84) by mtkmbs08n2.mediatek.inc (172.21.101.56) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 7 Jul 2021 14:22:26 +0800 Received: from localhost.localdomain (10.17.3.153) by mtkcas07.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Wed, 7 Jul 2021 14:22:26 +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 , , , , , , , Subject: [PATCH v1, 09/14] media: mtk-vcodec: Add new interface to lock different hardware Date: Wed, 7 Jul 2021 14:21:52 +0800 Message-ID: <20210707062157.21176-10-yunfei.dong@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20210707062157.21176-1-yunfei.dong@mediatek.com> References: <20210707062157.21176-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 --- drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c | 4 ++-- drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c | 5 +++-- drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h | 2 +- 3 files changed, 6 insertions(+), 5 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 b13fb69c6e2f..f156a943ca62 100644 --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c @@ -386,7 +386,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) @@ -423,7 +423,8 @@ static int mtk_vcodec_probe(struct platform_device *pdev) goto err_res; } - mutex_init(&dev->dec_mutex); + for (i = 0; i < MTK_VDEC_HW_MAX; i++) + mutex_init(&dev->dec_mutex[i]); mutex_init(&dev->dev_mutex); spin_lock_init(&dev->irqlock); diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h b/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h index b42e0c7e0731..68b3fbcd95b0 100644 --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h @@ -508,7 +508,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.18.0