From patchwork Thu Nov 22 11:33:08 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cho KyongHo X-Patchwork-Id: 1783491 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork1.kernel.org (Postfix) with ESMTP id B20953FC64 for ; Thu, 22 Nov 2012 11:36:04 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TbV1t-0006Uo-PG; Thu, 22 Nov 2012 11:33:13 +0000 Received: from mailout1.samsung.com ([203.254.224.24]) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TbV1q-0006U7-9Q for linux-arm-kernel@lists.infradead.org; Thu, 22 Nov 2012 11:33:11 +0000 Received: from epcpsbgm2.samsung.com (epcpsbgm2 [203.254.230.27]) by mailout1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MDW00H2E034IYC0@mailout1.samsung.com> for linux-arm-kernel@lists.infradead.org; Thu, 22 Nov 2012 20:33:09 +0900 (KST) Received: from epcpsbgm2.samsung.com ( [203.254.230.50]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id 7D.E7.12699.57D0EA05; Thu, 22 Nov 2012 20:33:09 +0900 (KST) X-AuditID: cbfee61b-b7f616d00000319b-9f-50ae0d759ed4 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id DC.E7.12699.57D0EA05; Thu, 22 Nov 2012 20:33:09 +0900 (KST) Received: from DOPULLIPCHO06 ([12.23.118.152]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MDW00HF8038FU90@mmp1.samsung.com> for linux-arm-kernel@lists.infradead.org; Thu, 22 Nov 2012 20:33:09 +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 v4 05/12] iommu/exynos: pass version information from DT Date: Thu, 22 Nov 2012 20:33:08 +0900 Message-id: <002601cdc8a5$25a287a0$70e796e0$%cho@samsung.com> MIME-version: 1.0 X-Mailer: Microsoft Office Outlook 12.0 Thread-index: Ac3IpSWFWDWKBeisSVWyROUxJyZikg== Content-language: ko DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrAIsWRmVeSWpSXmKPExsVy+t8zI91S3nUBBqe6BS02Pb7G6sDosXlJ fQBjFJdNSmpOZllqkb5dAlfG+YmvGAsuy1a8X7CRuYHxn3gXIyeHhICJRPOiGcwQtpjEhXvr 2boYuTiEBJYxSuzedo8ZpmjutjuMEIlFjBJvDi1ihXCWM0k83rKPEaSKTUBLYvXc42BVIgK9 jBIX+r8ygTjMAj8YJaZv/sUCUiUs4CFx4cw2sLksAqoSR/9uZwexeQVsJdbO/8UGYQtK/Jh8 D6yeGWjq+p3HmSBseYnNa94C9XIA3aQu8eivLogpIqAn0TaTF6JCRGLfi3eMENMFJL5NPsQC US0rsekAM8g1EgLd7BIbzixhgvhMUuLgihssExjFZiFZPAvJ4llIFs9CsmIBI8sqRtHUguSC 4qT0XCO94sTc4tK8dL3k/NxNjJBokd7BuKrB4hCjAAejEg9vhsHaACHWxLLiytxDjBIczEoi vPe41wUI8aYkVlalFuXHF5XmpBYfYvQBunwis5Rocj4wkvNK4g2NjU3MTExNzC1NzU1xCCuJ 8zZ7pAQICaQnlqRmp6YWpBbBjGPi4JRqYKwJO3DSsJTTO43N6OfbsLNnql7vcXU2C32lKjn5 3u8rHR5pN49F6K2ZGvPy80Sld/U3nueG/J0q6H7Pb2f+1n/TfkZeaz/B7h+uf6s8+G72MTar NsafD97tamSX3int+t11V8Da/XKTFwbUr1e+aRf4Z+q6rUkJYU++1V/yDpVzZNXgiwwV36zE UpyRaKjFXFScCACGr2FQwwIAAA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrPIsWRmVeSWpSXmKPExsVy+t9jAd1S3nUBBisaeSw2Pb7G6sDosXlJ fQBjVAOjTUZqYkpqkUJqXnJ+SmZeuq2Sd3C8c7ypmYGhrqGlhbmSQl5ibqqtkotPgK5bZg7Q VCWFssScUqBQQGJxsZK+HaYJoSFuuhYwjRG6viFBcD1GBmggYR1jxvmJrxgLLstWvF+wkbmB 8Z94FyMnh4SAicTcbXcYIWwxiQv31rN1MXJxCAksYpR4c2gRK4SznEni8ZZ9YFVsAloSq+ce ZwRJiAj0Mkpc6P/KBOIwC/xglJi++RcLSJWwgIfEhTPbmEFsFgFViaN/t7OD2LwCthJr5/9i g7AFJX5MvgdWzww0df3O40wQtrzE5jVvgXo5gG5Sl3j0VxfEFBHQk2ibyQtRISKx78U7xgmM ArOQDJqFZNAsJINmIWlZwMiyilE0tSC5oDgpPddIrzgxt7g0L10vOT93EyM4Fp9J72Bc1WBx iFGAg1GJhzfDYG2AEGtiWXFl7iFGCQ5mJRHee9zrAoR4UxIrq1KL8uOLSnNSiw8x+gD9OZFZ SjQ5H5gm8kriDY1NzIwsjcwsjEzMzXEIK4nzNnukBAgJpCeWpGanphakFsGMY+LglGpgZHsV urHOcv26Oo743ez7VKcxNdkqNdg8FGYKr2aXDnX2+vP9iLxKlN/XNMPsiN8eN84/faMoy/KL yVuW7983/6L+DbOUt0jcWbrYgjWyVub57KviFnHnZrRf+N3IGvT4o8km+2VNMn+XdNu+f9Ry 9NU5K+dX83es3rJ0cschO7nY0BumnJOdlFiKMxINtZiLihMBcg+4jfICAAA= X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20121122_063310_879657_28DB3CD4 X-CRM114-Status: GOOD ( 15.50 ) 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.24 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 53972c8..4061b17 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)) {