From patchwork Fri Jul 5 12:29:22 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cho KyongHo X-Patchwork-Id: 2824154 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 7828F9F7D6 for ; Fri, 5 Jul 2013 12:34:47 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 774C02012E for ; Fri, 5 Jul 2013 12:34:46 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 045BF20123 for ; Fri, 5 Jul 2013 12:34:45 +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 1Uv5A6-0002sD-TN; Fri, 05 Jul 2013 12:30:56 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Uv59W-0006fZ-3N; Fri, 05 Jul 2013 12:30:18 +0000 Received: from mailout4.samsung.com ([203.254.224.34]) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Uv58t-0006Yf-JT for linux-arm-kernel@lists.infradead.org; Fri, 05 Jul 2013 12:29:40 +0000 Received: from epcpsbgr2.samsung.com (u142.gpu120.samsung.co.kr [203.254.230.142]) by mailout4.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MPG00J62QNZFSG0@mailout4.samsung.com> for linux-arm-kernel@lists.infradead.org; Fri, 05 Jul 2013 21:29:23 +0900 (KST) Received: from epcpsbgm2.samsung.com ( [203.254.230.49]) by epcpsbgr2.samsung.com (EPCPMTA) with SMTP id 2E.83.08825.32CB6D15; Fri, 05 Jul 2013 21:29:23 +0900 (KST) X-AuditID: cbfee68e-b7f276d000002279-87-51d6bc23fb6e Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id 7A.B5.21068.22CB6D15; Fri, 05 Jul 2013 21:29:23 +0900 (KST) Received: from DOPULLIPCHO07 ([12.23.118.94]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MPG00KLUQOY6X20@mmp1.samsung.com>; Fri, 05 Jul 2013 21:29:22 +0900 (KST) From: Cho KyongHo To: 'Linux ARM Kernel' , 'Linux IOMMU' , 'Linux Kernel' , 'Linux Samsung SOC' Subject: [PATCH v7 4/9] iommu/exynos: allocate lv2 page table from own slab Date: Fri, 05 Jul 2013 21:29:22 +0900 Message-id: <002c01ce797b$47a1fde0$d6e5f9a0$@samsung.com> MIME-version: 1.0 X-Mailer: Microsoft Outlook 14.0 Thread-index: Ac55d6nbz05YrQSpTiGFdAu6bwYANw== Content-language: ko X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrFIsWRmVeSWpSXmKPExsVy+t8zQ13lPdcCDab957B4deQHk8WC/dYW nbM3sFtsPriOxaJ3wVU2i8Z7E9gsNj2+xmpxedccNosZ5/cxWVxYsZHdYsqiw6wWLdd7mRx4 PJ4cnMfkMbvhIovHnWt72Dw2L6n3mHxjOaNH35ZVjB6fN8kFsEdx2aSk5mSWpRbp2yVwZaxY eYatoFOkYt2aj6wNjAcFuhg5OSQETCQWHDzPCmGLSVy4t56ti5GLQ0hgGaPE3tZJLDBF967s YO9i5ABKLGKUuGABUfOXUeL+oj/MIDVsAloSq+ceZwSxRQTuMkq8PM8DUsQscINJYsOnNrBB wgLeEjsvTWMDsVkEVCXmzNoA1sArYCnxe8MP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QEjyypG0dSC 5ILipPRcI73ixNzi0rx0veT83E2M4HTxTHoH46oGi0OMAhyMSjy8D+qvBgqxJpYVV+YeYpTg YFYS4bVPuBYoxJuSWFmVWpQfX1Sak1p8iDEZ6NOJzFKiyfnAVJZXEm9obGJmZGlkZmFkYm5O mrCSOO/BVutAIYH0xJLU7NTUgtQimC1MHJxSDYwis4+7Hovdsy3bwupIwHrRmk1H9ezeMYkd kItb41DBelZ9acErDjkD48vrcqX8ZnyQOnD3+/mQ9PnnV1UE/G95lLvy+5UjoSJ5c+O70hUz f/R7eO1f7DBX7JaEeniWgc7s8OPPWbaZ1f5cfT975sb4JTw5CVXfdPQEqurbfJe8nv3z5exc z0lKLMUZiYZazEXFiQCsA+XJWwMAAA== 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-20130705_082939_935070_254821F5 X-CRM114-Status: GOOD ( 11.25 ) X-Spam-Score: -7.1 (-------) Cc: 'Kukjin Kim' , 'Hyunwoong Kim' , 'Prathyush' , 'Grant Grundler' , 'Joerg Roedel' , 'Keyyoung Park' , 'Subash Patel' , '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.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, 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 Since kmalloc() does not guarantee that the allignment of 1KiB when it allocates 1KiB, it is required to allocate lv2 page table from own slab that guarantees alignment of 1KiB Signed-off-by: Cho KyongHo --- drivers/iommu/exynos-iommu.c | 24 ++++++++++++++++++++---- 1 files changed, 20 insertions(+), 4 deletions(-) diff --git a/drivers/iommu/exynos-iommu.c b/drivers/iommu/exynos-iommu.c index 2bfe9fa..390f8b7 100644 --- a/drivers/iommu/exynos-iommu.c +++ b/drivers/iommu/exynos-iommu.c @@ -100,6 +100,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); @@ -765,7 +767,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); @@ -859,7 +862,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 ERR_PTR(-ENOMEM); @@ -884,7 +887,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; } @@ -1088,10 +1091,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; }