From patchwork Fri Jul 26 11:28:49 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cho KyongHo X-Patchwork-Id: 2834006 Return-Path: X-Original-To: patchwork-linux-samsung-soc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 20C91C0319 for ; Fri, 26 Jul 2013 11:29:01 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 22A34201B5 for ; Fri, 26 Jul 2013 11:29:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 22846201B3 for ; Fri, 26 Jul 2013 11:28:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758722Ab3GZL2x (ORCPT ); Fri, 26 Jul 2013 07:28:53 -0400 Received: from mailout4.samsung.com ([203.254.224.34]:51060 "EHLO mailout4.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758567Ab3GZL2w (ORCPT ); Fri, 26 Jul 2013 07:28:52 -0400 Received: from epcpsbgr2.samsung.com (u142.gpu120.samsung.co.kr [203.254.230.142]) by mailout4.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MQJ00HTBJVQZ8R0@mailout4.samsung.com>; Fri, 26 Jul 2013 20:28:50 +0900 (KST) Received: from epcpsbgm2.samsung.com ( [203.254.230.51]) by epcpsbgr2.samsung.com (EPCPMTA) with SMTP id 67.3F.08825.27D52F15; Fri, 26 Jul 2013 20:28:50 +0900 (KST) X-AuditID: cbfee68e-b7f276d000002279-17-51f25d72793a Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id E9.AC.31505.27D52F15; Fri, 26 Jul 2013 20:28:50 +0900 (KST) Received: from DOPULLIPCHO07 ([12.23.118.94]) by mmp2.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MQJ006DWJW1SP40@mmp2.samsung.com>; Fri, 26 Jul 2013 20:28:50 +0900 (KST) From: Cho KyongHo To: 'Linux ARM Kernel' , 'Linux IOMMU' , 'Linux Kernel' , 'Linux Samsung SOC' Cc: 'Hyunwoong Kim' , 'Joerg Roedel' , 'Kukjin Kim' , 'Prathyush' , 'Rahul Sharma' , 'Subash Patel' , 'Keyyoung Park' , 'Grant Grundler' , 'Antonios Motakis' , kvmarm@lists.cs.columbia.edu, 'Sachin Kamat' Subject: [PATCH v8 08/12] iommu/exynos: remove prefetch buffer setting when enabling System MMU Date: Fri, 26 Jul 2013 20:28:49 +0900 Message-id: <003e01ce89f3$4cdb45e0$e691d1a0$@samsung.com> MIME-version: 1.0 Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7bit X-Mailer: Microsoft Outlook 14.0 Thread-index: Ac6J8btIHglpVUGYQ3ehne12BgN9Pw== Content-language: ko X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpjleLIzCtJLcpLzFFi42I5/e+ZsW5R7KdAgxmHVC3u3D3HavHqyA8m iwX7rS06Z29gt9h8cB2LRe+Cq2wWjfcmsFl8PHWc3WLT42usFpd3zWGzmHF+H5PFhRUb2S2m LDrManHyTy+jRcv1XiYHfo8nB+cxecxuuMjicefaHjaP85vWMHtsXlLvMfnGckaPvi2rGD0+ b5LzuHL0DFMAZxSXTUpqTmZZapG+XQJXRvf0d6wFs4QrXu/dwNjAeIS/i5GTQ0LAROLxod+s ELaYxIV769m6GLk4hASWMUpM7t3BClP05uJ5JojEdEaJN6tPMUI4fxklFi1pZQepYhPQklg9 9zgjiC0icJdR4uV5HpAiZoHbzBLTfr4CSwgLJEpse7APbCyLgKrEu7PrwWxeAUuJyy+6WSBs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xrxj nMAoMAvJqFlIRs1CMmoWkpYFjCyrGEVTC5ILipPSc430ihNzi0vz0vWS83M3MYKTzDPpHYyr GiwOMQpwMCrx8Co4fQwUYk0sK67MPcQowcGsJMJ73ftToBBvSmJlVWpRfnxRaU5q8SHGZKBP JzJLiSbnAxNgXkm8obGJmZGlkZmFkYm5OWnCSuK8B1utA4UE0hNLUrNTUwtSi2C2MHFwSjUw it3a9ubIuvkqphuWPRXvEZm64fm0uWv4ujhjzf4m5f51fDGnOO7+ziU25d/59/vXiTH+X8WY /2BmVkDlO/6Nlf3ud58whnwJvPz1eumhhbvXSLTLtidl7StU/Xf3z9tEs4v7//cU19RZf2Bf UWHXkGP3z8/rvMdOycvz8q8+vxoVeLDsW8DEHUosxRmJhlrMRcWJACMErot2AwAA DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Spam-Status: No, score=-8.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Prefetch buffer must be handled accurately, exact range of a buffer, frame by frame manually. Otherwise, it may causes page fault or deadlock in System MMU. Thus this patch removes prefetch buffer setting when System MMU is initialized(enabled). Signed-off-by: Cho KyongHo Reviewed-by: Grant Grundler --- drivers/iommu/exynos-iommu.c | 32 +++++++++++++++++++++++++++----- 1 files changed, 27 insertions(+), 5 deletions(-) diff --git a/drivers/iommu/exynos-iommu.c b/drivers/iommu/exynos-iommu.c index cfc02ed..87f6bb7 100644 --- a/drivers/iommu/exynos-iommu.c +++ b/drivers/iommu/exynos-iommu.c @@ -80,6 +80,8 @@ #define CTRL_BLOCK 0x7 #define CTRL_DISABLE 0x0 +#define CFG_FLPDCACHE (1 << 20) /* System MMU 3.2+ only */ + #define REG_MMU_CTRL 0x000 #define REG_MMU_CFG 0x004 #define REG_MMU_STATUS 0x008 @@ -96,6 +98,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 @@ -200,6 +205,22 @@ static bool is_sysmmu_active(struct sysmmu_drvdata *data) return data->activations > 0; } +static unsigned int __sysmmu_version(struct sysmmu_drvdata *data, + int idx, unsigned int *minor) +{ + unsigned long major; + + major = readl(data->sfrbases[idx] + REG_MMU_VERSION); + + if (minor) + *minor = MMU_MIN_VER(major); + + if (MMU_MAJ_VER(major) > 3) + return 1; + + return MMU_MAJ_VER(major); +} + static void sysmmu_unblock(void __iomem *sfrbase) { __raw_writel(CTRL_ENABLE, sfrbase + REG_MMU_CTRL); @@ -460,14 +481,15 @@ static int __exynos_sysmmu_enable(struct sysmmu_drvdata *data, data->pgtable = pgtable; for (i = 0; i < data->nsfrs; i++) { + unsigned int min; + __sysmmu_set_ptbase(data->sfrbases[i], pgtable); - if ((readl(data->sfrbases[i] + REG_MMU_VERSION) >> 28) == 3) { - /* System MMU version is 3.x */ - __raw_writel((1 << 12) | (2 << 28), + if ((__sysmmu_version(data, i, &min) == 3) && (min > 1)) { + unsigned long cfg; + cfg = __raw_readl(data->sfrbases[i] + REG_MMU_CFG); + __raw_writel(cfg | CFG_FLPDCACHE, data->sfrbases[i] + REG_MMU_CFG); - __sysmmu_set_prefbuf(data->sfrbases[i], 0, -1, 0); - __sysmmu_set_prefbuf(data->sfrbases[i], 0, -1, 1); } __raw_writel(CTRL_ENABLE, data->sfrbases[i] + REG_MMU_CTRL);