From patchwork Tue Nov 20 07:30:20 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cho KyongHo X-Patchwork-Id: 1771531 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork2.kernel.org (Postfix) with ESMTP id AEF20DF2AB for ; Tue, 20 Nov 2012 07:34:39 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TaiJb-0003q8-AM; Tue, 20 Nov 2012 07:32:15 +0000 Received: from mailout4.samsung.com ([203.254.224.34]) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TaiHz-00037h-JW for linux-arm-kernel@lists.infradead.org; Tue, 20 Nov 2012 07:30:38 +0000 Received: from epcpsbgm1.samsung.com (epcpsbgm1 [203.254.230.26]) by mailout4.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MDR00JGWZHYRQQ0@mailout4.samsung.com> for linux-arm-kernel@lists.infradead.org; Tue, 20 Nov 2012 16:30:21 +0900 (KST) Received: from epcpsbgm1.samsung.com ( [203.254.230.47]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id B6.38.01231.D813BA05; Tue, 20 Nov 2012 16:30:21 +0900 (KST) X-AuditID: cbfee61a-b7fa66d0000004cf-cb-50ab318d1ac6 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id C5.38.01231.D813BA05; Tue, 20 Nov 2012 16:30:21 +0900 (KST) Received: from DOPULLIPCHO06 ([12.23.118.152]) by mmp2.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MDR009P5ZIKT410@mmp2.samsung.com> for linux-arm-kernel@lists.infradead.org; Tue, 20 Nov 2012 16:30:21 +0900 (KST) From: Cho KyongHo To: linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 05/12] iommu/exynos: pass version information from DT Date: Tue, 20 Nov 2012 16:30:20 +0900 Message-id: <001f01cdc6f0$e5b2bf80$b1183e80$%cho@samsung.com> MIME-version: 1.0 X-Mailer: Microsoft Office Outlook 12.0 Thread-index: Ac3G8OV1UpEPD/dGQlygnrfyCUZAgA== Content-language: ko DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrPIsWRmVeSWpSXmKPExsVy+t8zfd1ew9UBBt+mSVpsenyN1YHRY/OS +gDGKC6blNSczLLUIn27BK6M2wuSCy7LVhy/ydvA+E+8i5GTQ0LARGLj4UNMELaYxIV769m6 GLk4hASWMUpc+PGNCaZo+tE2ZojEdEaJf79bWSCc5UwSC699YgWpYhPQklg99zgjSEJEoBeo vf8rE4jDLPCDUWLxmzfMIFXCAh4S045MZwSxWQRUJT5M+AO2g1fAVmLapV5GCFtQ4sfkeywg NjPQ1PU7jzNB2PISm9e8BZrDAXSTusSjv7ogYREBPYnjJydClYhI7HvxDmq8gMS3yYdYIMpl JTYdAPtAQqCdXeJW4yRGiNckJQ6uuMEygVFsFpLNs5BsnoVk8ywkKxYwsqxiFE0tSC4oTkrP NdQrTswtLs1L10vOz93ECIkVqR2MKxssDjEKcDAq8fA+TFgVIMSaWFZcmXuIUYKDWUmEt6kc KMSbklhZlVqUH19UmpNafIjRB+jyicxSosn5wDjOK4k3NDY2MTMxNTG3NDU3xSGsJM7b7JES ICSQnliSmp2aWpBaBDOOiYNTqoHRvUj79M1Pn22lQ+QXr5wQ5ZDDrtj35/SUd2cmcGsvOXR1 ip3DXY4VES9iXjvMC1HJFJBl32V7YmW1v2vc65jJvL93ZoVl3ez3lqn5GSWp0Srha+m86MPj qv7mf/dWxxZ7P9FiOn03q8773oHoc0YKxybnmdwzO9ziFsf/TvyORB/XrmXzT7opsRRnJBpq MRcVJwIAcWP97cICAAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrHIsWRmVeSWpSXmKPExsVy+t9jQd1ew9UBBlfWCltsenyN1YHRY/OS +gDGqAZGm4zUxJTUIoXUvOT8lMy8dFsl7+B453hTMwNDXUNLC3MlhbzE3FRbJRefAF23zByg qUoKZYk5pUChgMTiYiV9O0wTQkPcdC1gGiN0fUOC4HqMDNBAwjrGjNsLkgsuy1Ycv8nbwPhP vIuRk0NCwERi+tE2ZghbTOLCvfVsXYxcHEIC0xkl/v1uZYFwljNJLLz2iRWkik1AS2L13OOM IAkRgV5GiQv9X5lAHGaBH4wSi9+8AZslLOAhMe3IdEYQm0VAVeLDhD9MIDavgK3EtEu9jBC2 oMSPyfdYQGxmoKnrdx5ngrDlJTaveQs0hwPoJnWJR391QcIiAnoSx09OhCoRkdj34h3jBEaB WUgmzUIyaRaSSbOQtCxgZFnFKJpakFxQnJSea6hXnJhbXJqXrpecn7uJERyJz6R2MK5ssDjE KMDBqMTD+zBhVYAQa2JZcWXuIUYJDmYlEd6mcqAQb0piZVVqUX58UWlOavEhRh+gRycyS4km 5wOTRF5JvKGxiZmRpZGZhZGJuTkOYSVx3maPlAAhgfTEktTs1NSC1CKYcUwcnFINjE2/Tq10 zg977q7ZmplxPG8Tx5FXfTLNz64obW7+8mt2sHTizK7kxZ3uQsc8dBt2BYu8WJkvq+MknlWa dX5r74ff/K9jolW3nN5UMMPv1Y+E12qHrnx8+ybM8rsw32Ltx/Lut31zJxvc1Y48bLe5+Q4v y95D6adelM2OChRakZDI+tOh83bKbCWW4oxEQy3mouJEAGGP+WPxAgAA X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20121120_023036_491168_6D2029DB X-CRM114-Status: GOOD ( 16.12 ) X-Spam-Score: -7.6 (-------) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-7.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at http://www.dnswl.org/, high trust [203.254.224.34 listed in list.dnswl.org] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.7 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.0 T_MANY_HDRS_LCASE Odd capitalization of multiple message headers Cc: 'Kukjin Kim' , prathyush.k@samsung.com, 'Joerg Roedel' , sw0312.kim@samsung.com, 'Subash Patel' , 'Sanghyun Lee' , rahul.sharma@samsung.com X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org System MMUs in some implementation of Exynos core does not include correct version information in the System MMU. If the version information is not correct, exynos-iommu driver cannot take advantages of feature of higher versions of System MMu like prefetching page table entries prior to TLB miss. This commit allows passing version information from DT to the driver. If DT does not pass version information, the driver will read the information from System MMU. Signed-off-by: KyongHo Cho --- drivers/iommu/exynos-iommu.c | 40 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/drivers/iommu/exynos-iommu.c b/drivers/iommu/exynos-iommu.c index 8cffeff..b939b6e 100644 --- a/drivers/iommu/exynos-iommu.c +++ b/drivers/iommu/exynos-iommu.c @@ -96,6 +96,9 @@ #define REG_MMU_VERSION 0x034 +#define MMU_MAJ_VER(reg) (reg >> 28) +#define MMU_MIN_VER(reg) ((reg >> 21) & 0x7F) + #define REG_PB0_SADDR 0x04C #define REG_PB0_EADDR 0x050 #define REG_PB1_SADDR 0x054 @@ -165,6 +168,12 @@ struct exynos_iommu_domain { spinlock_t pgtablelock; /* lock for modifying page table @ pgtable */ }; +struct sysmmu_version { + unsigned char major; /* major = 0 means that driver must use MMU_VERSION + register instead of this structure */ + unsigned char minor; +}; + struct sysmmu_drvdata { struct list_head node; /* entry of exynos_iommu_domain.clients */ struct device *sysmmu; /* System MMU's device descriptor */ @@ -172,6 +181,7 @@ struct sysmmu_drvdata { int nsfrs; struct clk *clk; int activations; + struct sysmmu_version ver; rwlock_t lock; struct iommu_domain *domain; sysmmu_fault_handler_t fault_handler; @@ -198,6 +208,25 @@ static bool is_sysmmu_active(struct sysmmu_drvdata *data) return data->activations > 0; } +static unsigned int __sysmmu_version(struct sysmmu_drvdata *drvdata, + int idx, unsigned int *minor) +{ + unsigned int major; + + if (drvdata->ver.major == 0) { + major = readl( + drvdata->sfrbases[idx] + REG_MMU_VERSION); + if (minor) + *minor = MMU_MIN_VER(major); + major = MMU_MAJ_VER(major); + } else { + major = drvdata->ver.major; + if (minor) + *minor = drvdata->ver.minor; + } + return major; +} + static void sysmmu_unblock(void __iomem *sfrbase) { __raw_writel(CTRL_ENABLE, sfrbase + REG_MMU_CTRL); @@ -262,7 +291,7 @@ void exynos_sysmmu_set_prefbuf(struct device *dev, goto finish; for (i = 0; i < data->nsfrs; i++) { - if ((readl(data->sfrbases[i] + REG_MMU_VERSION) >> 28) == 3) { + if (__sysmmu_version(data, i, NULL) == 3) { if (!sysmmu_block(data->sfrbases[i])) continue; @@ -460,7 +489,7 @@ static int __exynos_sysmmu_enable(struct sysmmu_drvdata *data, for (i = 0; i < data->nsfrs; i++) { __sysmmu_set_ptbase(data->sfrbases[i], pgtable); - if ((readl(data->sfrbases[i] + REG_MMU_VERSION) >> 28) == 3) { + if (__sysmmu_version(data, i, NULL) == 3) { /* System MMU version is 3.x */ __raw_writel((1 << 12) | (2 << 28), data->sfrbases[i] + REG_MMU_CFG); @@ -618,8 +647,15 @@ static int __init __sysmmu_setup(struct device *sysmmu, const char *compat; struct platform_device *pmaster = NULL; u32 master_inst_no = -1; + u32 ver[2]; int ret; + if (!of_property_read_u32_array(sysmmu->of_node, "version", ver, 2)) { + drvdata->ver.major = (unsigned char)ver[0]; + drvdata->ver.minor = (unsigned char)ver[1]; + dev_dbg(sysmmu, "Found version %d.%d\n", ver[0], ver[1]); + } + master_node = of_parse_phandle(sysmmu->of_node, "mmu-master", 0); if (!master_node && !of_property_read_string( sysmmu->of_node, "mmu-master-compat", &compat)) {