Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp3148653ybi; Mon, 10 Jun 2019 05:22:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqzlzTQuuwwLK3RiBF6Nwbf3Dhbe3fUWXeqqaUXQE58wun/AeGTPQDEtHz4AU8kJwb8zr274 X-Received: by 2002:a65:65c9:: with SMTP id y9mr15581237pgv.76.1560169370695; Mon, 10 Jun 2019 05:22:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560169370; cv=none; d=google.com; s=arc-20160816; b=tFMIsjb6KiyxTSv6uHIamnV22o32rxDTjmLQ5Id53IP5qfdOF1LntIEd8+6wOhYPrB NDltJO//chkVlicpOwOjQ6Zmoo1P7k3E6ZJ/9XWhkgMYexzwWkSiRfN+38R/Tx3+jXNb baPukQq9cXtukETIhQ1y1foUSGNIsUiOvknjt5mggBIFxaEqjv8wRSenMPDR7g/R14QQ RKmt1S8gJA34KyDzRN2Mec63D9sACRJ2QvOXRs2Fel29hSgEJoSzbgsOL7KTliJQPegq cCuY22oCsqR0jtaTK3E6LPJ96dyr9Icku4aKhCDPXz7tnrHI6Le2k/HrnlrbWv7gzwxj dbeg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=mhPsgHmggNpZ9hEzZfKC5lHo7f/TEgrDrC4kmucTUIc=; b=f6pgtEDv2YbHZnIdQvc7f+Z+2hfN44qMVfAeqswubka4yU4WnMFsikFTyzAnSYTxyQ +H2o13maiox31GylRLxJz0gT1/f1478vbzS/6wdDHVgMK1G+2d149fkaJr5+Wf8l2FE4 XEIJTutNnHjH0buU/nyUe0fOn62wsXtg3z1VeR998rF0XG8XVyGJmIvBxRWHvacBqRv7 md/dPI46Y2fn5mrvH6ZRXn2AXcrdnB0NrPZoOFSzShwBCHflZWq7DDdUVHskDUpuV85k gvvUsdumXPSdZHnRnwcg6RORbQ4mw3oNO6+W7w6wepvttdXR3kOAlx3vkUl4O1z0g3ak Zmgw== 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 u188si9963605pfu.228.2019.06.10.05.22.35; Mon, 10 Jun 2019 05:22:50 -0700 (PDT) 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 S2389939AbfFJMUc (ORCPT + 99 others); Mon, 10 Jun 2019 08:20:32 -0400 Received: from mailgw02.mediatek.com ([210.61.82.184]:40186 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S2388833AbfFJMUc (ORCPT ); Mon, 10 Jun 2019 08:20:32 -0400 X-UUID: aeb0bf89dd554b35b44f21598cdf5ea1-20190610 X-UUID: aeb0bf89dd554b35b44f21598cdf5ea1-20190610 Received: from mtkcas07.mediatek.inc [(172.21.101.84)] by mailgw02.mediatek.com (envelope-from ) (mhqrelay.mediatek.com ESMTP with TLS) with ESMTP id 682021958; Mon, 10 Jun 2019 20:20:22 +0800 Received: from mtkcas07.mediatek.inc (172.21.101.84) by mtkmbs01n2.mediatek.inc (172.21.101.79) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Mon, 10 Jun 2019 20:20:14 +0800 Received: from localhost.localdomain (10.17.3.153) by mtkcas07.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Mon, 10 Jun 2019 20:20:13 +0800 From: Yong Wu To: Joerg Roedel , Matthias Brugger , Robin Murphy , Rob Herring CC: Evan Green , Tomasz Figa , Will Deacon , , , , , , , , , , Nicolas Boichat , , Matthias Kaehlcke Subject: [PATCH v7 09/21] iommu/mediatek: Refine protect memory definition Date: Mon, 10 Jun 2019 20:17:48 +0800 Message-ID: <1560169080-27134-10-git-send-email-yong.wu@mediatek.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1560169080-27134-1-git-send-email-yong.wu@mediatek.com> References: <1560169080-27134-1-git-send-email-yong.wu@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain X-TM-SNTS-SMTP: B76A71C61B0AF56690B9C8B9C619A07BF8CEB2F469DA3D24613E857D9D17A6272000:8 X-MTK: N Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Signed-off-by: Yong Wu Reviewed-by: Evan Green --- drivers/iommu/mtk_iommu.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c index ad838b9..d38dfa2 100644 --- a/drivers/iommu/mtk_iommu.c +++ b/drivers/iommu/mtk_iommu.c @@ -52,12 +52,9 @@ #define REG_MMU_DCM_DIS 0x050 #define REG_MMU_CTRL_REG 0x110 +#define F_MMU_TF_PROT_TO_PROGRAM_ADDR (2 << 4) #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_MT8173 (2 << 5) #define REG_MMU_IVRP_PADDR 0x114 @@ -519,9 +516,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_MT8173; + else + regval = F_MMU_TF_PROT_TO_PROGRAM_ADDR; writel_relaxed(regval, data->base + REG_MMU_CTRL_REG); regval = F_L2_MULIT_HIT_EN | -- 1.9.1