From patchwork Wed Nov 21 05:05:55 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cho KyongHo X-Patchwork-Id: 1778141 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 43F753FCAE for ; Wed, 21 Nov 2012 05:08:23 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1Tb2Vg-0004H4-8x; Wed, 21 Nov 2012 05:06:05 +0000 Received: from mailout3.samsung.com ([203.254.224.33]) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1Tb2VZ-0004EB-4X for linux-arm-kernel@lists.infradead.org; Wed, 21 Nov 2012 05:05:59 +0000 Received: from epcpsbgm2.samsung.com (epcpsbgm2 [203.254.230.27]) by mailout3.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MDT008JNNHH2BM0@mailout3.samsung.com> for linux-arm-kernel@lists.infradead.org; Wed, 21 Nov 2012 14:05:56 +0900 (KST) Received: from epcpsbgm2.samsung.com ( [203.254.230.47]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id 69.D9.12699.4316CA05; Wed, 21 Nov 2012 14:05:56 +0900 (KST) X-AuditID: cbfee61b-b7f616d00000319b-e9-50ac61341a57 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id C8.D9.12699.3316CA05; Wed, 21 Nov 2012 14:05:55 +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 <0MDT000GQNHVQH00@mmp2.samsung.com> for linux-arm-kernel@lists.infradead.org; Wed, 21 Nov 2012 14:05:55 +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 v3 06/12] iommu/exynos: allocate lv2 page table from own slab Date: Wed, 21 Nov 2012 14:05:55 +0900 Message-id: <002d01cdc7a5$e32ad9e0$a9808da0$%cho@samsung.com> MIME-version: 1.0 X-Mailer: Microsoft Office Outlook 12.0 Thread-index: Ac3HpeME5AbiW3QuTZStpftTA6bQOw== Content-language: ko DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrAIsWRmVeSWpSXmKPExsVy+t8zfV2TxDUBBr2XWCw2Pb7G6sDosXlJ fQBjFJdNSmpOZllqkb5dAldGS/dH9oIlIhXH5z5gb2C8J9DFyMEhIWAiMf9CfRcjJ5ApJnHh 3nq2LkYuDiGBZYwSlxc0MUIkTCRmzL/DCpGYziix/uwfdghnOZNEy//tYFVsAloSq+ceZwRJ iAj0Mkpc6P/KBOIwC/xglFj85g0zSJWwgK/ExrXLmEBsFgFViZbNHWDdvAK2EhuWzYayBSV+ TL7HAmIzA01dv/M4E4QtL7F5zVtmiLvVJR791QUJiwjoSex/0cQMUSIise/FO0aI8QIS3yYf YoEol5XYdIAZ5BwJgX52iZdL+lggXpOUOLjiBssERrFZSDbPQrJ5FpLNs5CsWMDIsopRNLUg uaA4KT3XSK84Mbe4NC9dLzk/dxMjJFqkdzCuarA4xCjAwajEwyuxb3WAEGtiWXFl7iFGCQ5m JRFeBvk1AUK8KYmVValF+fFFpTmpxYcYfYAun8gsJZqcD4zkvJJ4Q2NjEzMTUxNzS1NzUxzC SuK8zR4pAUIC6YklqdmpqQWpRTDjmDg4pRoYK5bM4lg7IzjA6sLuXTMFl7cah01KKjtRmHWk yDNfv+L0gy1HXH55OsVNuOb0xVPjlm7dZaY5h7slWs6mpPX91l387vGnVNmQKa+/5ldd0noY tFd7vfjBDqvHvGubuISU1fbbRX+9HMkgw2Fjk7e1VJvNzunq4wnzhJis7hTM4b5an17UvihA iaU4I9FQi7moOBEAZrcbWMMCAAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrAIsWRmVeSWpSXmKPExsVy+t9jQV3jxDUBBktf2FhsenyN1YHRY/OS +gDGqAZGm4zUxJTUIoXUvOT8lMy8dFsl7+B453hTMwNDXUNLC3MlhbzE3FRbJRefAF23zByg qUoKZYk5pUChgMTiYiV9O0wTQkPcdC1gGiN0fUOC4HqMDNBAwjrGjJbuj+wFS0Qqjs99wN7A eE+gi5GTQ0LARGLG/DusELaYxIV769m6GLk4hASmM0qsP/uHHcJZziTR8n87I0gVm4CWxOq5 xxlBEiICvYwSF/q/MoE4zAI/GCUWv3nDDFIlLOArsXHtMiYQm0VAVaJlcwdYN6+ArcSGZbOh bEGJH5PvsYDYzEBT1+88zgRhy0tsXvMWaA4H0E3qEo/+6oKERQT0JPa/aGKGKBGR2PfiHeME RoFZSCbNQjJpFpJJs5C0LGBkWcUomlqQXFCclJ5rpFecmFtcmpeul5yfu4kRHI3PpHcwrmqw OMQowMGoxMMrsW91gBBrYllxZe4hRgkOZiURXgb5NQFCvCmJlVWpRfnxRaU5qcWHGH2AHp3I LCWanA9MFHkl8YbGJmZGlkZmFkYm5uY4hJXEeZs9UgKEBNITS1KzU1MLUotgxjFxcEo1MPL9 vb5KUfT/onWtK58kibGdbOLoZ/87b1tr10rudRLS059si3d/9O0xo43R+/vnA2ZNK3e7tb3q 0umLk3ROMF1abbI2cNXTdYbMe+K0+MWd0ioVlrrfWvnFd1ac64kdzq+kessl921ms8vOK+pJ 9rjG6OQcv+PqpRd6aQ811JYkKDb0cD+RTVJiKc5INNRiLipOBACJqcnN8wIAAA== X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20121121_000558_006551_47A63C6B X-CRM114-Status: GOOD ( 11.40 ) 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.33 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 Since kmalloc() does not guarantee the alignment of 1KB when it allocates 1KB, it is required to allocate lv2 page table from own slab that guarantees alignment of 1KB. Change-Id: Ia25642c7c0143d2c50a8ed5a3d0dd9067f324c4e Signed-off-by: KyongHo Cho --- drivers/iommu/exynos-iommu.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/drivers/iommu/exynos-iommu.c b/drivers/iommu/exynos-iommu.c index 4061b17..0bb194e 100644 --- a/drivers/iommu/exynos-iommu.c +++ b/drivers/iommu/exynos-iommu.c @@ -104,6 +104,8 @@ #define REG_PB1_SADDR 0x054 #define REG_PB1_EADDR 0x058 +static struct kmem_cache *lv2table_kmem_cache; + static unsigned long *section_entry(unsigned long *pgtable, unsigned long iova) { return pgtable + lv1ent_offset(iova); @@ -865,7 +867,8 @@ static void exynos_iommu_domain_destroy(struct iommu_domain *domain) for (i = 0; i < NUM_LV1ENTRIES; i++) if (lv1ent_page(priv->pgtable + i)) - kfree(__va(lv2table_base(priv->pgtable + i))); + kmem_cache_free(lv2table_kmem_cache, + __va(lv2table_base(priv->pgtable + i))); free_pages((unsigned long)priv->pgtable, 2); free_pages((unsigned long)priv->lv2entcnt, 1); @@ -959,7 +962,7 @@ static unsigned long *alloc_lv2entry(unsigned long *sent, unsigned long iova, if (lv1ent_fault(sent)) { unsigned long *pent; - pent = kzalloc(LV2TABLE_SIZE, GFP_ATOMIC); + pent = kmem_cache_zalloc(lv2table_kmem_cache, GFP_ATOMIC); BUG_ON((unsigned long)pent & (LV2TABLE_SIZE - 1)); if (!pent) return NULL; @@ -982,7 +985,7 @@ static int lv1set_section(unsigned long *sent, phys_addr_t paddr, short *pgcnt) if (*pgcnt != NUM_LV2ENTRIES) return -EADDRINUSE; - kfree(page_entry(sent, 0)); + kmem_cache_free(lv2table_kmem_cache, page_entry(sent, 0)); *pgcnt = 0; } @@ -1168,10 +1171,23 @@ static int __init exynos_iommu_init(void) { int ret; + lv2table_kmem_cache = kmem_cache_create("exynos-iommu-lv2table", + LV2TABLE_SIZE, LV2TABLE_SIZE, 0, NULL); + if (!lv2table_kmem_cache) { + pr_err("%s: failed to create kmem cache\n", __func__); + return -ENOMEM; + } + ret = platform_driver_register(&exynos_sysmmu_driver); if (ret == 0) - bus_set_iommu(&platform_bus_type, &exynos_iommu_ops); + ret = bus_set_iommu(&platform_bus_type, &exynos_iommu_ops); + + if (ret) { + pr_err("%s: Failed to register exynos-iommu driver.\n", + __func__); + kmem_cache_destroy(lv2table_kmem_cache); + } return ret; }