Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp2283139pxb; Thu, 28 Oct 2021 20:57:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxcluCUyugtEVTDklnHOnaW+ZhnGr+/3Ngofq37JZ+lDLaGhmf8YPVibnE4CwkakhmhRVhT X-Received: by 2002:aa7:9113:0:b0:47c:2136:d397 with SMTP id 19-20020aa79113000000b0047c2136d397mr8467004pfh.23.1635479873002; Thu, 28 Oct 2021 20:57:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635479872; cv=none; d=google.com; s=arc-20160816; b=eaSIJtK/4BSsdojx1uKW+vxhgLxd9qMJ7gEXIfYY8TnPUDhbTjJsL5ldz0wH/x5sHG ri8oHmSSYIcZbMhzpShibFOKBSo3X0S2eo+91PjDlx+sNLd4xDQYqhC/sdCH53dNFKMK BwKE1wPqWpdcMy98YinnprsFqsKkwnd+3w4kXz/VQTVc01O77u00dMQ1LfZluXwqmbNM fZjxNLjun6iJF2RVDEtaBBZz5ya2Eik3VKPhi7y8HYmJV7jInsm1LqZhhU1EmbW1ilXp WBuDXeqVMJ0JvoY59aQJhFHNCDHD3CYo7Yg+/WeUWJ6VFTimSThNrJu1HpF92KYKfgAF z17A== 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; bh=305P3/mhIgIt+Nj8GWym9w2Qt8pAO6NvHra+dbAWp7I=; b=tF1RRYTyU9MDp+mLmcn0sI7uBlbk37xmIhHkcOyjsM0Xvg+eAM0S6KBBZQo4+BVV32 9zVrqBdHSbx1sO/fxTqo0WvmB94r+0cwQ+yZKfJqeBb20YnutluL9YwfhItz6tnnIF7L kUqXgdGRIKQFUAa/AFGD7i4C3y59G1aCq8nAqQgfPBOhl0UjvV3N+EXHqUCb1CUrAYRt N+M7MvdpsH7EV9+fFMo3WMkZsukL/amdWFlsZnOinoyNvsKJu9ritmzT4tZZGb1XBPff ecKHvsh3I+PN6tUSbflTjKMIArTgZunlVEmG2RvcVIc0t8guKn/b9zX6wYrbRVFch3Mj aRWg== 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 ha2si5449700pjb.67.2021.10.28.20.57.39; Thu, 28 Oct 2021 20:57:52 -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 S231883AbhJ2D6o (ORCPT + 99 others); Thu, 28 Oct 2021 23:58:44 -0400 Received: from mailgw01.mediatek.com ([60.244.123.138]:41812 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S231873AbhJ2D6W (ORCPT ); Thu, 28 Oct 2021 23:58:22 -0400 X-UUID: 8fa37a61089c4e3093a5365400990aa9-20211029 X-UUID: 8fa37a61089c4e3093a5365400990aa9-20211029 Received: from mtkexhb01.mediatek.inc [(172.21.101.102)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 397708099; Fri, 29 Oct 2021 11:55:49 +0800 Received: from mtkmbs10n2.mediatek.inc (172.21.101.183) by mtkmbs07n2.mediatek.inc (172.21.101.141) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 29 Oct 2021 11:55:48 +0800 Received: from localhost.localdomain (10.17.3.154) by mtkmbs10n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.792.3 via Frontend Transport; Fri, 29 Oct 2021 11:55:46 +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 , Dafna Hirschfeld , Benjamin Gaignard , Daniel Vetter , dri-devel , Irui Wang , , , , , , , , AngeloGioacchino Del Regno Subject: [PATCH v8, 12/17] media: mtk-vcodec: Add new interface to lock different hardware Date: Fri, 29 Oct 2021 11:55:22 +0800 Message-ID: <20211029035527.454-13-yunfei.dong@mediatek.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211029035527.454-1-yunfei.dong@mediatek.com> References: <20211029035527.454-1-yunfei.dong@mediatek.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII 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 Reviewed-By: AngeloGioacchino Del Regno --- 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 28f96e1973ff..0ae6399ba407 100644 --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c @@ -320,7 +320,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) @@ -352,8 +352,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 20712f80bdb5..598205db5120 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