Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp78657imu; Wed, 2 Jan 2019 02:41:41 -0800 (PST) X-Google-Smtp-Source: ALg8bN5LbYu9jqCsElvca+dL9a37eV9OUwn18j9cozcGIrtUF4KNPi1ktcUPH3z5XrBXPz2/pzY2 X-Received: by 2002:a62:15d5:: with SMTP id 204mr44559935pfv.103.1546425701832; Wed, 02 Jan 2019 02:41:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546425701; cv=none; d=google.com; s=arc-20160816; b=TOwtVZ8exsbJ2amfqS06uob+GY9ltISYdyHDIUeo9dECFD31fqfAPYSyGn14W7EP3R OOmLD8DBu8OL8B7cXfR050OlW9q7x10v+I3gfNt5zEeUkuZxHFNV7SPQYPr+tZOJRmyU lZocTZ4ayQzDy84yIo+abaMEDO9Ou5IL0SnzOoz6MOoiBf+Xdp+r3IXD40ojGdbDgSbX RojFipx2pxQyz9akgvFctcxMWEqoVIx+EP2xoFmN3W4/0Mr3I7wlZKnhgp6IZ9TiO7yN dZHkdSMkvYMZ4Qe4/ioN64xnf6//Hn/1mR31gV3Dst14o0+emJkAWScNCsaoGRxVBuEK nZBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :references:in-reply-to:date:cc:to:from:subject:message-id; bh=7BNMl0YObCGaJ1Jf0zE7kYHsa5OiFOdbAqI+2hpScSM=; b=rjQFeLS6aCdl5rl9+w2H+G2RyDBUVd9zamnl9JbUXWnJfbsbt5Cgz6YP4Ux3MoHK8H QVWi6U4lWLdpykwYF2mjqcgS4V6ny62hKaQERjiUsH6iz/x83hJvZqD2ITvRoLOTEzTk UePG8wKOsE4nfmlGueRV0UZdcoltOWqE9o/0QgwlV5ISYfJvas7jnRHmwGt+a5xvCWeE 9JsS3CfSroPc67H/yXeq0ayvyAChjdDkCTdiZikdYVehsfvh7GxuT7N11Ng5Hx9/2Eqx XZamgjxnIHXB+BtKZDmGVtw9FB/pKdme9mWvWz5jeuEi0wp6Cyzds7Ccs6XzDMAkuNDU v1hw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u30si12007860pgn.170.2019.01.02.02.41.26; Wed, 02 Jan 2019 02:41:41 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728200AbfABJdo (ORCPT + 99 others); Wed, 2 Jan 2019 04:33:44 -0500 Received: from mailgw02.mediatek.com ([1.203.163.81]:20537 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726782AbfABJdn (ORCPT ); Wed, 2 Jan 2019 04:33:43 -0500 X-UUID: 2c62b20328dd418f82c946b7842ab049-20190102 X-UUID: 2c62b20328dd418f82c946b7842ab049-20190102 Received: from mtkcas35.mediatek.inc [(172.27.4.250)] by mailgw02.mediatek.com (envelope-from ) (mailgw01.mediatek.com ESMTP with TLS) with ESMTP id 1227216572; Wed, 02 Jan 2019 17:33:39 +0800 Received: from MTKCAS36.mediatek.inc (172.27.4.186) by MTKMBS31N2.mediatek.inc (172.27.4.87) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Wed, 2 Jan 2019 17:33:35 +0800 Received: from [10.17.3.153] (10.17.3.153) by MTKCAS36.mediatek.inc (172.27.4.170) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Wed, 2 Jan 2019 17:33:34 +0800 Message-ID: <1546421615.32203.14.camel@mhfsdcap03> Subject: Re: [PATCH v5 09/20] iommu/mediatek: Refine protect memory definition From: Yong Wu To: Nicolas Boichat , Matthias Brugger CC: Joerg Roedel , Robin Murphy , "Rob Herring" , Tomasz Figa , Will Deacon , , , , lkml , linux-arm Mailing List , , Arnd Bergmann , Yingjoe Chen , Date: Wed, 2 Jan 2019 17:33:35 +0800 In-Reply-To: References: <1546314952-15990-1-git-send-email-yong.wu@mediatek.com> <1546314952-15990-10-git-send-email-yong.wu@mediatek.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.2.3-0ubuntu6 Content-Transfer-Encoding: 7bit MIME-Version: 1.0 X-MTK: N Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 2019-01-02 at 14:23 +0800, Nicolas Boichat wrote: > On Tue, Jan 1, 2019 at 11:58 AM Yong Wu wrote: > > > > The protect memory setting is a little different in the different SoCs. > > In the register REG_MMU_CTRL_REG(0x110), the TF_PROT(translation fault > > protect) shift bit is normally 4 while it shift 5 bits only in the > > mt8173. This patch delete the complex MACRO and use a common if-else > > instead. > > > > Also, use "F_MMU_TF_PROT_TO_PROGRAM_ADDR" instead of the hard code(2) > > which means the M4U will output the dirty data to the programmed > > address that we allocated dynamically when translation fault occurs. > > > > Signed-off-by: Yong Wu > > --- > > @Nicalos, I don't put it in the plat_data since only the previous mt8173 > > shift 5. As I know, the latest SoC always use the new setting like mt2712 > > and mt8183. Thus, I think it is unnecessary to put it in plat_data and > > let all the latest SoC set it. Hence, I still keep "== mt8173" for this > > like the reg REG_MMU_CTRL_REG. > > Should be ok this way. But maybe one way to avoid hard-coding 4/5 > below is to have 2 macros: > > #define F_MMU_TF_PROT_TO_PROGRAM_ADDR (2 << 4) > #define F_MMU_TF_PROT_TO_PROGRAM_ADDR_MT8173 (2 << 5) > > And still use the if below? Thanks for your quick review. OK for me. I will wait Matthias's review for memory/ part. then send the next version. > > > --- > > drivers/iommu/mtk_iommu.c | 12 +++++------- > > 1 file changed, 5 insertions(+), 7 deletions(-) > > > > diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c > > index eca1536..35a1263 100644 > > --- a/drivers/iommu/mtk_iommu.c > > +++ b/drivers/iommu/mtk_iommu.c > > @@ -53,11 +53,7 @@ > > > > #define REG_MMU_CTRL_REG 0x110 > > #define F_MMU_PREFETCH_RT_REPLACE_MOD BIT(4) > > -#define F_MMU_TF_PROTECT_SEL_SHIFT(data) \ > > - ((data)->plat_data->m4u_plat == M4U_MT2712 ? 4 : 5) > > -/* It's named by F_MMU_TF_PROT_SEL in mt2712. */ > > -#define F_MMU_TF_PROTECT_SEL(prot, data) \ > > - (((prot) & 0x3) << F_MMU_TF_PROTECT_SEL_SHIFT(data)) > > +#define F_MMU_TF_PROT_TO_PROGRAM_ADDR 2 > > > > #define REG_MMU_IVRP_PADDR 0x114 > > > > @@ -521,9 +517,11 @@ static int mtk_iommu_hw_init(const struct mtk_iommu_data *data) > > return ret; > > } > > > > - regval = F_MMU_TF_PROTECT_SEL(2, data); > > if (data->plat_data->m4u_plat == M4U_MT8173) > > - regval |= F_MMU_PREFETCH_RT_REPLACE_MOD; > > + regval = F_MMU_PREFETCH_RT_REPLACE_MOD | > > + (F_MMU_TF_PROT_TO_PROGRAM_ADDR << 5); > > + else > > + regval = F_MMU_TF_PROT_TO_PROGRAM_ADDR << 4; > > writel_relaxed(regval, data->base + REG_MMU_CTRL_REG); > > > > regval = F_L2_MULIT_HIT_EN | > > -- > > 1.9.1 > >