From patchwork Thu Nov 22 11:33:15 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cho KyongHo X-Patchwork-Id: 1783531 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 F0A203FC64 for ; Thu, 22 Nov 2012 11:37:32 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TbV30-0006rT-33; Thu, 22 Nov 2012 11:34:22 +0000 Received: from mailout3.samsung.com ([203.254.224.33]) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TbV27-0006W9-Cs for linux-arm-kernel@lists.infradead.org; Thu, 22 Nov 2012 11:33:29 +0000 Received: from epcpsbgm1.samsung.com (epcpsbgm1 [203.254.230.26]) by mailout3.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MDW00HDY034OCP0@mailout3.samsung.com> for linux-arm-kernel@lists.infradead.org; Thu, 22 Nov 2012 20:33:15 +0900 (KST) Received: from epcpsbgm1.samsung.com ( [203.254.230.51]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id CE.15.01231.B7D0EA05; Thu, 22 Nov 2012 20:33:15 +0900 (KST) X-AuditID: cbfee61a-b7fa66d0000004cf-f5-50ae0d7b50af Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 1E.15.01231.B7D0EA05; Thu, 22 Nov 2012 20:33:15 +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 <0MDW00EXD03FQ180@mmp2.samsung.com> for linux-arm-kernel@lists.infradead.org; Thu, 22 Nov 2012 20:33:15 +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 v4 06/12] iommu/exynos: allocate lv2 page table from own slab Date: Thu, 22 Nov 2012 20:33:15 +0900 Message-id: <002701cdc8a5$294e2a80$7bea7f80$%cho@samsung.com> MIME-version: 1.0 X-Mailer: Microsoft Office Outlook 12.0 Thread-index: Ac3IpSkv3Ig/Wl/7SBmsKMOe6FrDGQ== Content-language: ko DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrAIsWRmVeSWpSXmKPExsVy+t8zY91q3nUBBq97pSw2Pb7G6sDosXlJ fQBjFJdNSmpOZllqkb5dAlfG/putrAXvhCv6D7QzNjCuFuhi5OSQEDCRWDFhBQuELSZx4d56 ti5GLg4hgWWMEg8XrGWBKVrVfpUdIjGdUeLn5EXMIAkhgeVMEndmiIPYbAJaEqvnHmcEKRIR 6GWUuND/lQnEYRb4wSgxffMvsFHCAr4S3W+/sYPYLAKqEt+2PQWbxCtgK/H/zQp2CFtQ4sfk e2D1zEBT1+88zgRhy0tsXvMWqJ4D6CR1iUd/dUHCIgJ6ErvWP2OGKBGR2PfiHSPEeAGJb5MP sUCUy0psOsAMco6EQD+7xLIX7awQn0lKHFxxg2UCo9gsJJtnIdk8C8nmWUhWLGBkWcUomlqQ XFCclJ5rqFecmFtcmpeul5yfu4kREi1SOxhXNlgcYhTgYFTi4dV0XhsgxJpYVlyZe4hRgoNZ SYT3Hve6ACHelMTKqtSi/Pii0pzU4kOMPkCXT2SWEk3OB0ZyXkm8obGxiZmJqYm5pam5KQ5h JXHeZo+UACGB9MSS1OzU1ILUIphxTBycUg2M6S1hiumTVu++NHXrE2vj9p+LbtXs6t20unvG /G7XM+qSjNvvCx6MCXvwis+L39KS8foyu7gJ5+tuLHrZuXjDrx45pfiA3fsjDqbEJphJvv7U ySTUvynoftaCJq+UHf1LWdbaBy676KLz4r3B0We/7XdpXThzT3z//VVhe7LsmC7NDHsstT/a QomlOCPRUIu5qDgRAEfHP6HDAgAA X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrPIsWRmVeSWpSXmKPExsVy+t9jQd1q3nUBBmvXillsenyN1YHRY/OS +gDGqAZGm4zUxJTUIoXUvOT8lMy8dFsl7+B453hTMwNDXUNLC3MlhbzE3FRbJRefAF23zByg qUoKZYk5pUChgMTiYiV9O0wTQkPcdC1gGiN0fUOC4HqMDNBAwjrGjP03W1kL3glX9B9oZ2xg XC3QxcjJISFgIrGq/So7hC0mceHeerYuRi4OIYHpjBI/Jy9iBkkICSxnkrgzQxzEZhPQklg9 9zgjSJGIQC+jxIX+r0wgDrPAD0aJ6Zt/sYBUCQv4SnS//QY2lkVAVeLbtqdgk3gFbCX+v1nB DmELSvyYfA+snhlo6vqdx5kgbHmJzWveAtVzAJ2kLvHory5IWERAT2LX+mfMECUiEvtevGOc wCgwC8mkWUgmzUIyaRaSlgWMLKsYRVMLkguKk9JzDfWKE3OLS/PS9ZLzczcxgmPxmdQOxpUN FocYBTgYlXh4NZ3XBgixJpYVV+YeYpTgYFYS4b3HvS5AiDclsbIqtSg/vqg0J7X4EKMP0KMT maVEk/OBaSKvJN7Q2MTMyNLIzMLIxNwch7CSOG+zR0qAkEB6YklqdmpqQWoRzDgmDk6pBsYd 7HGW555+vyokc698fp6+6pnpC+9625v+d9/p/dfQK726fn3w3ystSyw2GXrLWVUvq9CR22a/ 1LhEupL3RdOEQ36PLe6pWrEee3wumMHErb15fsJ76WfnqzVDToouXne8pfHc3KZ9xux7K3b/ EP0gsf5et8iM0pNZie43NZQWStgabbvNckGJpTgj0VCLuag4EQAUEU1G8gIAAA== X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20121122_063327_923816_F81C64BB X-CRM114-Status: GOOD ( 10.92 ) 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 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; }