Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp4270362pxv; Tue, 27 Jul 2021 03:13:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyQWJl0ZoGSDWSQjcEUDfX4xpeb8E7qIHjn8pOTmJi67Umrw/w8SPvXvfgwiP0fQeNg6OCo X-Received: by 2002:a02:cc19:: with SMTP id n25mr20913816jap.140.1627380806653; Tue, 27 Jul 2021 03:13:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627380806; cv=none; d=google.com; s=arc-20160816; b=XLpRwyuIva2Tzw4CEM4RVBrWoxzbUx2VolHKVr28jTrk3hZyV/U392vSOezZ95+la7 fQbtiSRYnQV2GzkttqNZT/F5jMhgoFHB2O3MOIwIKG9gwAUNsXbrvOLU+PUkGcUvWY2y qobAJsnyS5oLcVj/loxrG1HYxjBwK0tKqsd32KW+2lIJsjtd+KNZFkHyIUqnzvbToJmq MWmcLPwRliisIN+3EDO5wV8UQeXIsZXESpdk4NWLs2rmeIn2JV/m7PYewTRtj+Kx2hVY 2fBGtZXJPH+rWgrnnccUPMnCe2fCtl/Ab8GRRnY+5/PqYGRziVTcwpKc2zjmtZqhXAQt e8wA== 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=9Fb522WjjswT+03pxT9+dlvvyeGAufq6okBOqTN0vhM=; b=wD5VQRlU2/mwYCQ9PUY3y4h1rp9ME9KlxGuDbiOa7ZCt2xsxezNMK7XNMruPb//RKC xaiF/PwJ0p/3cIbz/DKAIF2dkF0sgJJjRv2f3OIwPMa2aWGY5KgHzbXf1LIIYweU5uIt yDWtpqqrrF/3lnzGook8eW2xJs0xnqLVorxUpD8fX02AyonzZ5QjcTiGo7C1Oa9eSGMX 6IxrmDaxorX3SF6TNp9uhSvLyfaomXITKSZ96J8Wyn/al7zFJPcg6GrbDqpx98LlSCMT SpK0wDh6ZDFi31xb4OMv7FRj+VF4r7EmdiQkQFZv9oZDpY1wuTrshplZdefR4JxRG2b6 DiXQ== 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 t11si2989816ils.106.2021.07.27.03.13.15; Tue, 27 Jul 2021 03:13:26 -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 S236440AbhG0KMC (ORCPT + 99 others); Tue, 27 Jul 2021 06:12:02 -0400 Received: from mailgw02.mediatek.com ([210.61.82.184]:43946 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S236200AbhG0KLq (ORCPT ); Tue, 27 Jul 2021 06:11:46 -0400 X-UUID: 1ead997815394da2b4972ccc3940e3e0-20210727 X-UUID: 1ead997815394da2b4972ccc3940e3e0-20210727 Received: from mtkcas10.mediatek.inc [(172.21.101.39)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1332352023; Tue, 27 Jul 2021 18:11:41 +0800 Received: from mtkcas07.mediatek.inc (172.21.101.84) by mtkmbs02n2.mediatek.inc (172.21.101.101) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 27 Jul 2021 18:11:38 +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; Tue, 27 Jul 2021 18:11:38 +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 v3, 10/15] media: mtk-vcodec: Add new interface to lock different hardware Date: Tue, 27 Jul 2021 18:10:46 +0800 Message-ID: <20210727101051.24418-11-yunfei.dong@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20210727101051.24418-1-yunfei.dong@mediatek.com> References: <20210727101051.24418-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 --- v3: no changes --- 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 7d4c3afcd301..6075d1ae2917 100644 --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c @@ -382,7 +382,7 @@ static int mtk_vcodec_probe(struct platform_device *pdev) phandle rproc_phandle; enum mtk_vcodec_fw_type fw_type; struct device_node *comp_node; - int ret; + int i, ret; dev = devm_kzalloc(&pdev->dev, sizeof(*dev), GFP_KERNEL); if (!dev) @@ -422,7 +422,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 a34514597a10..95b21f0d5892 100644 --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h @@ -501,7 +501,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