From patchwork Fri Aug 24 08:29:02 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hiroshi Doyu X-Patchwork-Id: 10916 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id DB8F523FA4 for ; Fri, 24 Aug 2012 08:30:13 +0000 (UTC) Received: from mail-iy0-f180.google.com (mail-iy0-f180.google.com [209.85.210.180]) by fiordland.canonical.com (Postfix) with ESMTP id 94C66A187D4 for ; Fri, 24 Aug 2012 08:29:56 +0000 (UTC) Received: by iafj25 with SMTP id j25so671343iaf.11 for ; Fri, 24 Aug 2012 01:30:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf :x-pgp-universal:from:to:date:message-id:x-mailer:in-reply-to :references:mime-version:cc:subject:x-beenthere:x-mailman-version :precedence:list-id:list-unsubscribe:list-archive:list-post :list-help:list-subscribe:content-type:content-transfer-encoding :sender:errors-to:x-gm-message-state; bh=XZIEfDFreMfDxZAHYIP8kgoxk9jF+MvpczvR/qQLd10=; b=KFP8j6D80rGLdPh5M7yPcD/cDb4IUgKlb8e3ddoX4drSEQG6eocypKnWXymgsmy1rm G10cj+CwM0c6swvDyler9cdd5LgeQ80Y9SdLWzBStD8A1IZCvgN5qtgDdMhymMoy8Kno cQfRstI4+HYvTKtt1jMUPcsBaVqqxn5zl+E+p/YWqj3hAvOP98/9PkIrNwYdNZU50WTo 2KmGpVtYAYEjfG+s3i7cWiueYG2VHPbUw7a99T+JdFjpk+F5By3jv2Uk0YjnaIm1srlH oV3p1AJT3X1HdW/m1pG2rm4tHly6seUjicTxaamIaEpYen7q2b23+pKzcAHs0B3ix6xT LMFQ== Received: by 10.50.87.164 with SMTP id az4mr1241489igb.43.1345797012786; Fri, 24 Aug 2012 01:30:12 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.50.184.232 with SMTP id ex8csp307504igc; Fri, 24 Aug 2012 01:30:11 -0700 (PDT) Received: by 10.204.133.196 with SMTP id g4mr1599149bkt.89.1345797011147; Fri, 24 Aug 2012 01:30:11 -0700 (PDT) Received: from mombin.canonical.com (mombin.canonical.com. [91.189.95.16]) by mx.google.com with ESMTP id hc18si6630482bkc.70.2012.08.24.01.30.09; Fri, 24 Aug 2012 01:30:10 -0700 (PDT) Received-SPF: neutral (google.com: 91.189.95.16 is neither permitted nor denied by best guess record for domain of linaro-mm-sig-bounces@lists.linaro.org) client-ip=91.189.95.16; Authentication-Results: mx.google.com; spf=neutral (google.com: 91.189.95.16 is neither permitted nor denied by best guess record for domain of linaro-mm-sig-bounces@lists.linaro.org) smtp.mail=linaro-mm-sig-bounces@lists.linaro.org Received: from localhost ([127.0.0.1] helo=mombin.canonical.com) by mombin.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1T4pHM-0003vs-3I; Fri, 24 Aug 2012 08:30:08 +0000 Received: from hqemgate03.nvidia.com ([216.228.121.140]) by mombin.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1T4pHK-0003df-4E for linaro-mm-sig@lists.linaro.org; Fri, 24 Aug 2012 08:30:06 +0000 Received: from hqnvupgp06.nvidia.com (Not Verified[216.228.121.13]) by hqemgate03.nvidia.com id ; Fri, 24 Aug 2012 01:31:10 -0700 Received: from hqemhub02.nvidia.com ([172.17.108.22]) by hqnvupgp06.nvidia.com (PGP Universal service); Fri, 24 Aug 2012 01:29:55 -0700 X-PGP-Universal: processed; by hqnvupgp06.nvidia.com on Fri, 24 Aug 2012 01:29:55 -0700 Received: from hqnvemgw02.nvidia.com (172.16.227.111) by hqemhub02.nvidia.com (172.20.150.31) with Microsoft SMTP Server id 8.3.264.0; Fri, 24 Aug 2012 01:29:55 -0700 Received: from daphne.nvidia.com (Not Verified[172.16.212.96]) by hqnvemgw02.nvidia.com with MailMarshal (v6,7,2,8378) id ; Fri, 24 Aug 2012 01:30:46 -0700 Received: from oreo.Nvidia.com (dhcp-10-21-25-186.nvidia.com [10.21.25.186]) by daphne.nvidia.com (8.13.8+Sun/8.8.8) with ESMTP id q7O8TWAw024274; Fri, 24 Aug 2012 01:29:51 -0700 (PDT) From: Hiroshi Doyu To: Date: Fri, 24 Aug 2012 11:29:02 +0300 Message-ID: <1345796945-21115-2-git-send-email-hdoyu@nvidia.com> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: <1345796945-21115-1-git-send-email-hdoyu@nvidia.com> References: <1345796945-21115-1-git-send-email-hdoyu@nvidia.com> MIME-Version: 1.0 Cc: linux@arm.linux.org.uk, arnd@arndb.de, konrad.wilk@oracle.com, minchan@kernel.org, linux-kernel@vger.kernel.org, linaro-mm-sig@lists.linaro.org, linux-mm@kvack.org, kyungmin.park@samsung.com, pullip.cho@samsung.com, linux-arm-kernel@lists.infradead.org Subject: [Linaro-mm-sig] [v3 1/4] ARM: dma-mapping: atomic_pool with struct page **pages X-BeenThere: linaro-mm-sig@lists.linaro.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Unified memory management interest group." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linaro-mm-sig-bounces@lists.linaro.org Errors-To: linaro-mm-sig-bounces@lists.linaro.org X-Gm-Message-State: ALoCoQlZJK8CyM2eHrkZCtJJifM3LxvVekLzByJD85L8GxvQDcjDk4UfLpjZZFlPneta1Rp3XS9A struct page **pages is necessary to align with non atomic path in __iommu_get_pages(). atomic_pool() has the intialized **pages instead of just *page. Signed-off-by: Hiroshi Doyu --- arch/arm/mm/dma-mapping.c | 17 +++++++++++++---- 1 files changed, 13 insertions(+), 4 deletions(-) diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c index 601da7a..b14ee64 100644 --- a/arch/arm/mm/dma-mapping.c +++ b/arch/arm/mm/dma-mapping.c @@ -296,7 +296,7 @@ struct dma_pool { unsigned long *bitmap; unsigned long nr_pages; void *vaddr; - struct page *page; + struct page **pages; }; static struct dma_pool atomic_pool = { @@ -335,12 +335,16 @@ static int __init atomic_pool_init(void) unsigned long nr_pages = pool->size >> PAGE_SHIFT; unsigned long *bitmap; struct page *page; + struct page **pages; void *ptr; int bitmap_size = BITS_TO_LONGS(nr_pages) * sizeof(long); + size_t size = nr_pages * sizeof(struct page *); - bitmap = kzalloc(bitmap_size, GFP_KERNEL); + size += bitmap_size; + bitmap = kzalloc(size, GFP_KERNEL); if (!bitmap) goto no_bitmap; + pages = (void *)bitmap + bitmap_size; if (IS_ENABLED(CONFIG_CMA)) ptr = __alloc_from_contiguous(NULL, pool->size, prot, &page); @@ -348,9 +352,14 @@ static int __init atomic_pool_init(void) ptr = __alloc_remap_buffer(NULL, pool->size, GFP_KERNEL, prot, &page, NULL); if (ptr) { + int i; + + for (i = 0; i < nr_pages; i++) + pages[i] = page + i; + spin_lock_init(&pool->lock); pool->vaddr = ptr; - pool->page = page; + pool->pages = pages; pool->bitmap = bitmap; pool->nr_pages = nr_pages; pr_info("DMA: preallocated %u KiB pool for atomic coherent allocations\n", @@ -481,7 +490,7 @@ static void *__alloc_from_pool(size_t size, struct page **ret_page) if (pageno < pool->nr_pages) { bitmap_set(pool->bitmap, pageno, count); ptr = pool->vaddr + PAGE_SIZE * pageno; - *ret_page = pool->page + pageno; + *ret_page = pool->pages[pageno]; } else { pr_err_once("ERROR: %u KiB atomic DMA coherent pool is too small!\n" "Please increase it with coherent_pool= kernel parameter!\n",