From patchwork Tue Nov 20 07:30:26 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cho KyongHo X-Patchwork-Id: 1771561 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 0173A3FC5A for ; Tue, 20 Nov 2012 07:36:10 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TaiKv-0004dE-G8; Tue, 20 Nov 2012 07:33:37 +0000 Received: from mailout3.samsung.com ([203.254.224.33]) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TaiIA-0003CW-5r for linux-arm-kernel@lists.infradead.org; Tue, 20 Nov 2012 07:30:51 +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 <0MDR00J6AZHR41P0@mailout3.samsung.com> for linux-arm-kernel@lists.infradead.org; Tue, 20 Nov 2012 16:30:26 +0900 (KST) Received: from epcpsbgm2.samsung.com ( [203.254.230.50]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id 46.DD.12699.2913BA05; Tue, 20 Nov 2012 16:30:26 +0900 (KST) X-AuditID: cbfee61b-b7f616d00000319b-1f-50ab3192fa10 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id A5.DD.12699.2913BA05; Tue, 20 Nov 2012 16:30:26 +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 <0MDR009R1ZIQT410@mmp2.samsung.com> for linux-arm-kernel@lists.infradead.org; Tue, 20 Nov 2012 16:30:26 +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 v6 06/12] iommu/exynos: allocate lv2 page table from own slab Date: Tue, 20 Nov 2012 16:30:26 +0900 Message-id: <002001cdc6f0$e8eb2e30$bac18a90$%cho@samsung.com> MIME-version: 1.0 X-Mailer: Microsoft Office Outlook 12.0 Thread-index: Ac3G8OjSUX3qtyUFQ7WrGtUMXUhngQ== Content-language: ko DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrPIsWRmVeSWpSXmKPExsVy+t8zI91JhqsDDL6907XY9PgaqwOjx+Yl 9QGMUVw2Kak5mWWpRfp2CVwZ/8/NYCx4J1xx4KdNA+NqgS5GTg4JAROJP4v/skPYYhIX7q1n 62Lk4hASWMYoMXtLCwtM0ZctL5kgEtMZJS60dTCBJIQEljNJPJ/NC2KzCWhJrJ57nBGkSESg F6io/ytYB7PAD0aJ6Zt/gY0SFvCV+DjhBCuIzSKgKrFmZTtYnFfAVuJBxxEmCFtQ4sfke2Bx ZqCp63ceZ4Kw5SU2r3nL3MXIAXSSusSjv7ogYREBPYnWZ98ZIUpEJPa9eMcIMV5A4tvkQywQ 5bISmw4wg5wjIdDNLrFxxiUmiM8kJQ6uuMEygVFsFpLNs5BsnoVk8ywkKxYwsqxiFE0tSC4o TkrPNdIrTswtLs1L10vOz93ECIkV6R2MqxosDjEKcDAq8fA+TFgVIMSaWFZcmXuIUYKDWUmE t6kcKMSbklhZlVqUH19UmpNafIjRB+jyicxSosn5wDjOK4k3NDY2MTMxNTG3NDU3xSGsJM7b 7JESICSQnliSmp2aWpBaBDOOiYNTqoGxr6WoMsBlVYH04r0HXzJvaDvwPFtRfn7Z9a4JR/8G T7wu/CBl96EbBtJSvFsLr5oWJ6f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709E3 X-CRM114-CacheID: sfid-20121120_023046_678792_02A819B5 X-CRM114-Status: GOOD ( 11.13 ) 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. 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 b939b6e..0191ab5 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); @@ -868,7 +870,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); @@ -962,7 +965,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; @@ -985,7 +988,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; } @@ -1171,10 +1174,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; }