Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3048919pxb; Mon, 18 Oct 2021 07:16:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwwuyTtyA3eZlAzrQ5O66HR/t00/4zCIIOWlrU/njfgSKlPHiag1fLjeE0BvgKKvmqSiRao X-Received: by 2002:adf:97cc:: with SMTP id t12mr35658613wrb.189.1634566617404; Mon, 18 Oct 2021 07:16:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634566617; cv=none; d=google.com; s=arc-20160816; b=IpPTSI4GSwLKKJzbtdXSCzKh3dOn8MAtyqHXdP1iwKvAnhqRwzzepUJdq79Ban0a6A nX9vIvVMHEKaWJ1AGG3OHOS4rMZ0nj1iwyv0+q0wZ6b/TnSV8auRSNlgPjK6HDmtbalq mslZ5N9tS0My/eeqUjnR0n+mtiZ4g6Hh39S8+vl3rxTkwU2Yl9FFnYhPLeqeNawCO3He zU/U0XNoXzqfV4YZIlcJH5XU4t11k5ryfwQvC5pHeiD0xr8PyaEpZrIdlwuLIEbLacxi 2qLA0vQF2YLXDuyVBiyD9OGb2u6st5+/SfTblVzZsOFEuxmE7WrkmtJzn0htc+1z69Ih TzxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=cHqJZKEwI5BoBaQH9Tm50KaYeviaxU6UGY7M+wtrFa8=; b=SH2SnEBeG1rmjTAoxxX0/KUFPPQEpD0dstPQBhPNob/MdnoMnZkOhmlCTcaC1A0i9q MnUs4mdH02UT1Mrd5OPV72hyav8jRSba6xXKfkqF0M69pIG1OVmTR8oq2yTYIDONAUVb W7W+b+gZL7mkaGtr5RHsloLtjf9n825LDIMBvk0532YMWbUBapYbMEPq0rwuLojnyfTm r8C14AzzaycPie16mJFja59AZbt2ZbykG0en1LvgYsWLGLPOw5GDb9qwRn8Jz0koZNR3 vXfdry9S59MJbNmzB2wkU8YWpSkN/A9n7ZgzQ1Q24PgL1u+KclbkDsW2waDCFjkIGCMG zKiw== 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=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id sb2si20567275ejb.325.2021.10.18.07.16.30; Mon, 18 Oct 2021 07:16:57 -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=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232320AbhJROQQ (ORCPT + 99 others); Mon, 18 Oct 2021 10:16:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44420 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233491AbhJROQE (ORCPT ); Mon, 18 Oct 2021 10:16:04 -0400 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e3e3]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4143FC07E5FD; Mon, 18 Oct 2021 06:50:21 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: kholk11) with ESMTPSA id 27FA91F4167F Subject: Re: [PATCH v8 4/7] soc: mediatek: mutex: add functions that operate registers by CMDQ To: Moudy Ho , Mauro Carvalho Chehab , Rob Herring , Matthias Brugger , Hans Verkuil , Jernej Skrabec Cc: Maoguang Meng , daoyuan huang , Ping-Hsun Wu , Geert Uytterhoeven , Rob Landley , Laurent Pinchart , linux-media@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, tfiga@chromium.org, drinkcat@chromium.org, acourbot@chromium.org, pihsun@chromium.org, menghui.lin@mediatek.com, sj.huang@mediatek.com, allen-kh.cheng@mediatek.com, randy.wu@mediatek.com, srv_heupstream@mediatek.com, hsinyi@google.com References: <20211015123832.17914-1-moudy.ho@mediatek.com> <20211015123832.17914-5-moudy.ho@mediatek.com> From: AngeloGioacchino Del Regno Message-ID: Date: Mon, 18 Oct 2021 15:50:17 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: <20211015123832.17914-5-moudy.ho@mediatek.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > Considering that some functions have timing requirements > in specific situation, this patch adds several interface that > operate registers by CMDQ. > > Signed-off-by: Moudy Ho > --- > drivers/soc/mediatek/mtk-mutex.c | 63 +++++++++++++++++++++++++- > include/linux/soc/mediatek/mtk-mutex.h | 6 +++ > 2 files changed, 68 insertions(+), 1 deletion(-) > > diff --git a/drivers/soc/mediatek/mtk-mutex.c b/drivers/soc/mediatek/mtk-mutex.c > index adab4c9edc16..874d4c60b844 100644 > --- a/drivers/soc/mediatek/mtk-mutex.c > +++ b/drivers/soc/mediatek/mtk-mutex.c > @@ -7,10 +7,12 @@ > #include > #include > #include > +#include > #include > #include > #include > #include > +#include > > #define MT2701_MUTEX0_MOD0 0x2c > #define MT2701_MUTEX0_SOF0 0x30 > @@ -143,6 +145,8 @@ struct mtk_mutex_ctx { > void __iomem *regs; > struct mtk_mutex mutex[10]; > const struct mtk_mutex_data *data; > + phys_addr_t addr; > + u8 subsys_id; > }; > > static const unsigned int mt2701_mutex_mod[DDP_COMPONENT_ID_MAX] = { > @@ -442,6 +446,25 @@ void mtk_mutex_remove_comp(struct mtk_mutex *mutex, > } > EXPORT_SYMBOL_GPL(mtk_mutex_remove_comp); > > +void mtk_mutex_add_mod_by_cmdq(struct mtk_mutex *mutex, u32 mod, > + struct mmsys_cmdq_cmd *cmd) > +{ > + struct mtk_mutex_ctx *mtx = container_of(mutex, struct mtk_mutex_ctx, > + mutex[mutex->id]); > + unsigned int offset; > + > + WARN_ON(&mtx->mutex[mutex->id] != mutex); > + > + offset = DISP_REG_MUTEX_MOD(mtx->data->mutex_mod_reg, mutex->id); > + cmdq_pkt_write_mask(cmd->pkt, mtx->subsys_id, mtx->addr + offset, > + mod, mtx->data->mutex_mdp_mod_mask); > + > + offset = DISP_REG_MUTEX_SOF(mtx->data->mutex_sof_reg, mutex->id); > + cmdq_pkt_write_mask(cmd->pkt, mtx->subsys_id, mtx->addr + offset, > + 0, mtx->data->mutex_mdp_sof_mask); > +} > +EXPORT_SYMBOL_GPL(mtk_mutex_add_mod_by_cmdq); > + > void mtk_mutex_enable(struct mtk_mutex *mutex) > { > struct mtk_mutex_ctx *mtx = container_of(mutex, struct mtk_mutex_ctx, > @@ -453,6 +476,20 @@ void mtk_mutex_enable(struct mtk_mutex *mutex) > } > EXPORT_SYMBOL_GPL(mtk_mutex_enable); > > +void mtk_mutex_enable_by_cmdq(struct mtk_mutex *mutex, > + struct mmsys_cmdq_cmd *cmd) > +{ > + struct mtk_mutex_ctx *mtx = container_of(mutex, struct mtk_mutex_ctx, > + mutex[mutex->id]); > + > + WARN_ON(&mtx->mutex[mutex->id] != mutex); > + > + cmdq_pkt_write_mask(cmd->pkt, mtx->subsys_id, > + mtx->addr + DISP_REG_MUTEX_EN(mutex->id), > + 0x1, 0x00000001); (don't use this definition name if not appropriate) #define MTK_MUTEX_ENABLE BIT(0) cmdq_pkt_write_mask(cmd->pkt, mtx->subsys_id, mtx->addr + DISP_REG_MUTEX_EN(mutex->id), MTK_MUTEX_ENABLE, MTK_MUTEX_ENABLE); ...or anyway remove leading zeros. > +} > +EXPORT_SYMBOL_GPL(mtk_mutex_enable_by_cmdq); > + > void mtk_mutex_disable(struct mtk_mutex *mutex) > { > struct mtk_mutex_ctx *mtx = container_of(mutex, struct mtk_mutex_ctx, > @@ -464,6 +501,20 @@ void mtk_mutex_disable(struct mtk_mutex *mutex) > } > EXPORT_SYMBOL_GPL(mtk_mutex_disable); > > +void mtk_mutex_disable_by_cmdq(struct mtk_mutex *mutex, > + struct mmsys_cmdq_cmd *cmd) > +{ > + struct mtk_mutex_ctx *mtx = container_of(mutex, struct mtk_mutex_ctx, > + mutex[mutex->id]); > + > + WARN_ON(&mtx->mutex[mutex->id] != mutex); > + > + cmdq_pkt_write_mask(cmd->pkt, mtx->subsys_id, > + mtx->addr + DISP_REG_MUTEX_EN(mutex->id), > + 0x0, 0x00000001); cmdq_pkt_write_mask(cmd->pkt, mtx->subsys_id, mtx->addr + DISP_REG_MUTEX_EN(mutex->id), 0, MTK_MUTEX_ENABLE); > +} > +EXPORT_SYMBOL_GPL(mtk_mutex_disable_by_cmdq); > + Regards, - Angelo