From patchwork Wed Dec 26 01:53:37 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cho KyongHo X-Patchwork-Id: 1910381 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 DCA103FE37 for ; Wed, 26 Dec 2012 01:57:39 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TngCB-0000vI-Mx; Wed, 26 Dec 2012 01:54:11 +0000 Received: from mailout1.samsung.com ([203.254.224.24]) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TngBj-0000pE-DV for linux-arm-kernel@lists.infradead.org; Wed, 26 Dec 2012 01:53:45 +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 <0MFM005567VRT370@mailout1.samsung.com> for linux-arm-kernel@lists.infradead.org; Wed, 26 Dec 2012 10:53:37 +0900 (KST) Received: from epcpsbgm2.samsung.com ( [203.254.230.48]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id 9C.60.12699.1A85AD05; Wed, 26 Dec 2012 10:53:37 +0900 (KST) X-AuditID: cbfee61b-b7f616d00000319b-79-50da58a1efcf Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id BB.60.12699.1A85AD05; Wed, 26 Dec 2012 10:53:37 +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 <0MFM00M8R7XDL7B0@mmp1.samsung.com> for linux-arm-kernel@lists.infradead.org; Wed, 26 Dec 2012 10:53:37 +0900 (KST) From: Cho KyongHo To: 'Linux ARM Kernel' , 'Linux IOMMU' , 'Linux Kernel' , 'Linux Samsung SOC' Subject: [PATCH v6 03/12] iommu/exynos: allocate lv2 page table from own slab Date: Wed, 26 Dec 2012 10:53:37 +0900 Message-id: <003601cde30b$d24fc140$76ef43c0$%cho@samsung.com> MIME-version: 1.0 X-Mailer: Microsoft Office Outlook 12.0 Thread-index: Ac3jC9H2hrGFZmptTIiRxRqpOc2ItQ== Content-language: ko DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrAIsWRmVeSWpSXmKPExsVy+t8zA92FEbcCDP6dM7fY9PgaqwOjx+Yl 9QGMUVw2Kak5mWWpRfp2CVwZ/b1X2AreCVfcuHObqYFxtUAXIyeHhICJxModq5khbDGJC/fW s3UxcnEICSxjlLi7ayM7TNG5mxMZIRKLGCX+zjvFDOEsZ5LY9PIlWBWbgJbE6rnHGUFsEYG7 jBIvz/OAFDEL/GWU+HTmEFiRsICvxNsl+8CKWARUJT4uP80KYvMK2Ep8ePeJCcIWlPgx+R4L iM0sYCDxflYfK4QtL7F5zVugzRxAJ6lLPPqrC7FLT6Jv6jJ2iBIRiX0v3kGNF5D4NvkQC0S5 rMSmA2A3Swi0s0ssOrob6jNJiYMrbrBMYBSbhWTzLCSbZyHZPAvJigWMLKsYRVMLkguKk9Jz jfSKE3OLS/PS9ZLzczcxQqJFegfjqgaLQ4wCHIxKPLycv24GCLEmlhVX5h5ilOBgVhLhdf4I FOJNSaysSi3Kjy8qzUktPsToA3T5RGYp0eR8YCTnlcQbGhubmJmYmphbmpqb4hBWEudt9kgJ EBJITyxJzU5NLUgtghnHxMEp1cA4p1XJ4vKz24m9S1a1Tez8qMYre1Bunqlx2dJlz5a1vQqd fPTYnzMNmewNu4ql+Mz+l9zT+fUiYWeY84fTGXKPr/CfUe3KeZZ6dW/19OnHch8kl6/Nmxt6 UO5MmmFl500fpY0ms9Kt2dh5bD0Elv3W7pbicHwrPfEMb4ZNptA6yyQN4ysL3ugpsRRnJBpq MRcVJwIADkhMVMMCAAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrPIsWRmVeSWpSXmKPExsVy+t9jAd2FEbcCDI7uMLLY9PgaqwOjx+Yl 9QGMUQ2MNhmpiSmpRQqpecn5KZl56bZK3sHxzvGmZgaGuoaWFuZKCnmJuam2Si4+AbpumTlA U5UUyhJzSoFCAYnFxUr6dpgmhIa46VrANEbo+oYEwfUYGaCBhHWMGf29V9gK3glX3Lhzm6mB cbVAFyMnh4SAicS5mxMZIWwxiQv31rN1MXJxCAksYpT4O+8UM4SznEli08uX7CBVbAJaEqvn HgfrEBG4yyjx8jwPSBGzwF9GiU9nDoEVCQv4Srxdsg+siEVAVeLj8tOsIDavgK3Eh3efmCBs QYkfk++xgNjMAgYS72f1sULY8hKb17wF2swBdJK6xKO/uhC79CT6pi5jhygRkdj34h3jBEaB WUgmzUIyaRaSSbOQtCxgZFnFKJpakFxQnJSea6RXnJhbXJqXrpecn7uJERyLz6R3MK5qsDjE KMDBqMTDy/nrZoAQa2JZcWXuIUYJDmYlEV7nj0Ah3pTEyqrUovz4otKc1OJDjD5Aj05klhJN zgemibySeENjEzMjSyMzCyMTc3McwkrivM0eKQFCAumJJanZqakFqUUw45g4OKUaGDe4SN0V UQhUYTycZmcZpz/3l+f/dxeyU6rCtjx8z7DjcNPyKsNnsy6suaG07N7054Wzsx/mFKw/wZlS /e1DiusTT1GZWVw/EmZNaTfg923dIeDMGuRT8HCtcsf7uqBaz86go7cir/PGncplWCL0eXHl jD9WdxXuOijOqhGd4rnc5oBHyvVFoUosxRmJhlrMRcWJAGRjx5jyAgAA X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20121225_205343_818194_970D74FB X-CRM114-Status: GOOD ( 10.65 ) 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' , 'Hyunwoong Kim' , 'Prathyush' , 'Joerg Roedel' , 'Subash Patel' , 'Rahul Sharma' 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 ef7dbd1..58d2a24 100644 --- a/drivers/iommu/exynos-iommu.c +++ b/drivers/iommu/exynos-iommu.c @@ -101,6 +101,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); @@ -739,7 +741,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); @@ -833,7 +836,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; @@ -856,7 +859,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; } @@ -1044,10 +1047,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; }