From patchwork Fri Mar 14 05:12:38 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cho KyongHo X-Patchwork-Id: 3830961 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 45E449F2BB for ; Fri, 14 Mar 2014 06:00:12 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2400A202EC for ; Fri, 14 Mar 2014 06:00:11 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0B51B20149 for ; Fri, 14 Mar 2014 06:00:10 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WOKQu-0005aJ-Pl; Fri, 14 Mar 2014 05:13:24 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WOKQb-0000fk-T1; Fri, 14 Mar 2014 05:13:05 +0000 Received: from mailout1.samsung.com ([203.254.224.24]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WOKQX-0000dJ-Ak for linux-arm-kernel@lists.infradead.org; Fri, 14 Mar 2014 05:13:03 +0000 Received: from epcpsbgr1.samsung.com (u141.gpu120.samsung.co.kr [203.254.230.141]) by mailout1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0N2E003XDUH37Y30@mailout1.samsung.com> for linux-arm-kernel@lists.infradead.org; Fri, 14 Mar 2014 14:12:39 +0900 (KST) Received: from epcpsbgm2.samsung.com ( [203.254.230.48]) by epcpsbgr1.samsung.com (EPCPMTA) with SMTP id 80.A3.12635.7CF82235; Fri, 14 Mar 2014 14:12:39 +0900 (KST) X-AuditID: cbfee68d-b7fcd6d00000315b-46-53228fc7d547 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id E3.73.28157.6CF82235; Fri, 14 Mar 2014 14:12:39 +0900 (KST) Received: from DO-PULLIP-CHO07.dsn.sec.samsung.com ([12.36.165.149]) by mmp2.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0N2E00FLNUH2GB50@mmp2.samsung.com>; Fri, 14 Mar 2014 14:12:38 +0900 (KST) Date: Fri, 14 Mar 2014 14:12:38 +0900 From: Cho KyongHo To: Linux ARM Kernel , Linux DeviceTree , Linux IOMMU , Linux Kernel , Linux Samsung SOC Subject: [PATCH v11 23/27] iommu/exynos: fix address handling Message-id: <20140314141238.a1c596c349eccf10b869f8d1@samsung.com> X-Mailer: Sylpheed 3.3.0 (GTK+ 2.10.14; i686-pc-mingw32) MIME-version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrIIsWRmVeSWpSXmKPExsVy+t8zA93j/UrBBtcf8FjcuXuO1WL+ESDx 6sgPJosF+60tOmdvYLfoXXCVzWLT42usFpd3zWGzmHF+H5PFhRUb2S2mLDrManH4TTurxck/ vYwW62e8ZrGYeWsNiwO/x5OD85g8ZjdcZPH4d7ifyePOtT1sHpuX1HtMvrGc0aNvyypGj8+b 5DyuHD3DFMAZxWWTkpqTWZZapG+XwJXx5/ImpoKrKhWHr+1gaWCcJ9fFyMkhIWAisXj9V3YI W0ziwr31bF2MXBxCAssYJZbvW8YIU9R6ei4jRGI6o8TxSe2sIAkhgclMEl3nmUFsFgFViVPn HoHF2QS0JFbPPQ7WICLQxiTxtfEQC4jDLDCXWeLjtzlAOzg4hAVs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ilE0tSC5oDgpPddIrzgxt7g0L10vOT93EyM4NTyT3sG4qsHiEKMAB6MSD++Mo4rBQqyJ ZcWVuYcYJTiYlUR4qyKUgoV4UxIrq1KL8uOLSnNSiw8xJgO9PZFZSjQ5H5i28kriDY1NzIws jcwsjEzMzUkTVhLnPdhqHSgkkJ5YkpqdmlqQWgSzhYmDU6qBsefzFsOUj9MnX51uPiPWfs6c dPEyluNe0+TPL3jyX/Nw+jI7XrlNbY0pj2a+Eds4VWnO4+Ds2f0MrxLtH9Vfr669dWu9RfBa o2zjxPdX5uWL7LJdfFXEhDN5h5vcZzY/lnX2G4/wWezfHmm7LlsndHvYhRqJbXE8s27cyzqj 6GB8b7LoNAcJKSWW4oxEQy3mouJEAFEXGGhRAwAA DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140314_011301_694241_2DEC898E X-CRM114-Status: GOOD ( 11.46 ) X-Spam-Score: -6.9 (------) Cc: Kukjin Kim , Prathyush , Grant Grundler , Joerg Roedel , Sachin Kamat , Sylwester Nawrocki , Varun Sethi , Antonios Motakis , Tomasz Figa , Rahul Sharma X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_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 Use of __pa and __va macro is changed to virt_to_phys and phys_to_virt which are recommended in driver code. printk formatting of physical address is also fixed to %pa. Signed-off-by: Cho KyongHo --- drivers/iommu/exynos-iommu.c | 45 +++++++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/drivers/iommu/exynos-iommu.c b/drivers/iommu/exynos-iommu.c index 2beb197..e375501 100644 --- a/drivers/iommu/exynos-iommu.c +++ b/drivers/iommu/exynos-iommu.c @@ -142,7 +142,8 @@ static unsigned long *section_entry(unsigned long *pgtable, unsigned long iova) static unsigned long *page_entry(unsigned long *sent, unsigned long iova) { - return (unsigned long *)__va(lv2table_base(sent)) + lv2ent_offset(iova); + return (unsigned long *)phys_to_virt( + lv2table_base(sent)) + lv2ent_offset(iova); } enum exynos_sysmmu_inttype { @@ -215,7 +216,7 @@ struct sysmmu_drvdata { struct iommu_domain *domain; bool runtime_active; bool suspended; - unsigned long pgtable; + phys_addr_t pgtable; }; static bool set_sysmmu_active(struct sysmmu_drvdata *data) @@ -307,17 +308,17 @@ static void __sysmmu_set_ptbase(void __iomem *sfrbase, static void show_fault_information(const char *name, enum exynos_sysmmu_inttype itype, - unsigned long pgtable_base, unsigned long fault_addr) + phys_addr_t pgtable_base, unsigned long fault_addr) { unsigned long *ent; if ((itype >= SYSMMU_FAULTS_NUM) || (itype < SYSMMU_PAGEFAULT)) itype = SYSMMU_FAULT_UNKNOWN; - pr_err("%s occurred at 0x%lx by %s(Page table base: 0x%lx)\n", - sysmmu_fault_name[itype], fault_addr, name, pgtable_base); + pr_err("%s occurred at %#lx by %s(Page table base: %pa)\n", + sysmmu_fault_name[itype], fault_addr, name, &pgtable_base); - ent = section_entry(__va(pgtable_base), fault_addr); + ent = section_entry(phys_to_virt(pgtable_base), fault_addr); pr_err("\tLv1 entry: 0x%lx\n", *ent); if (lv1ent_page(ent)) { @@ -917,7 +918,7 @@ static void exynos_iommu_domain_destroy(struct iommu_domain *domain) for (i = 0; i < NUM_LV1ENTRIES; i++) if (lv1ent_page(priv->pgtable + i)) kmem_cache_free(lv2table_kmem_cache, - __va(lv2table_base(priv->pgtable + i))); + phys_to_virt(lv2table_base(priv->pgtable + i))); free_pages((unsigned long)priv->pgtable, 2); free_pages((unsigned long)priv->lv2entcnt, 1); @@ -931,11 +932,12 @@ static int exynos_iommu_attach_device(struct iommu_domain *domain, struct exynos_iommu_owner *owner = dev->archdata.iommu; struct exynos_iommu_domain *priv = domain->priv; unsigned long flags; + phys_addr_t pgtable = virt_to_phys(priv->pgtable); int ret; spin_lock_irqsave(&priv->lock, flags); - ret = __exynos_sysmmu_enable(dev, __pa(priv->pgtable), domain); + ret = __exynos_sysmmu_enable(dev, pgtable, domain); if (ret == 0) { list_add_tail(&owner->client, &priv->clients); owner->domain = domain; @@ -943,13 +945,14 @@ static int exynos_iommu_attach_device(struct iommu_domain *domain, spin_unlock_irqrestore(&priv->lock, flags); - if (ret < 0) - dev_err(dev, "%s: Failed to attach IOMMU with pgtable %#x\n", - __func__, __pa(priv->pgtable)); - else - dev_dbg(dev, "%s: Attached IOMMU with pgtable 0x%x%s\n", - __func__, __pa(priv->pgtable), - (ret == 0) ? "" : ", again"); + if (ret < 0) { + dev_err(dev, "%s: Failed to attach IOMMU with pgtable %pa\n", + __func__, &pgtable); + return ret; + } + + dev_dbg(dev, "%s: Attached IOMMU with pgtable %pa %s\n", + __func__, &pgtable, (ret == 0) ? "" : ", again"); return ret; } @@ -975,11 +978,13 @@ static void exynos_iommu_detach_device(struct iommu_domain *domain, spin_unlock_irqrestore(&priv->lock, flags); - if (owner == dev->archdata.iommu) - dev_dbg(dev, "%s: Detached IOMMU with pgtable %#x\n", - __func__, __pa(priv->pgtable)); - else + if (owner == dev->archdata.iommu) { + phys_addr_t pgtable = virt_to_phys(priv->pgtable); + dev_dbg(dev, "%s: Detached IOMMU with pgtable %pa\n", + __func__, &pgtable); + } else { dev_dbg(dev, "%s: No IOMMU is attached\n", __func__); + } } static unsigned long *alloc_lv2entry(unsigned long *sent, unsigned long iova, @@ -998,7 +1003,7 @@ static unsigned long *alloc_lv2entry(unsigned long *sent, unsigned long iova, if (!pent) return ERR_PTR(-ENOMEM); - *sent = mk_lv1ent_page(__pa(pent)); + *sent = mk_lv1ent_page(virt_to_phys(pent)); *pgcounter = NUM_LV2ENTRIES; pgtable_flush(pent, pent + NUM_LV2ENTRIES); pgtable_flush(sent, sent + 1);