From patchwork Wed Aug 22 10:20:28 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hiroshi Doyu X-Patchwork-Id: 10866 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 C334523E1B for ; Wed, 22 Aug 2012 10:21:02 +0000 (UTC) Received: from mail-gg0-f180.google.com (mail-gg0-f180.google.com [209.85.161.180]) by fiordland.canonical.com (Postfix) with ESMTP id 31B39A18D1E for ; Wed, 22 Aug 2012 10:20:51 +0000 (UTC) Received: by ggmi2 with SMTP id i2so531539ggm.11 for ; Wed, 22 Aug 2012 03:21:01 -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=MZVvhVa9scyL70ivghwy0H5hA2HVneUEnNvtksG/pyo=; b=FLGG2j53M3K5hJErCFuyvTMfsVohZPnCn9IrAyJjlf+dfuUl5ZwjBmv8ryomJypdZP B5BbfIeoSJ1ERFHd8Sh25Fdi8tn6IEy6aTA/6OC/Jo8C7hrPUAjprCjN7N4ZUFiqgPZX RXBccNHaV/R7vqrkdYL1U8WlXFpNMlhNg+PQLKZK0qEyD3iHA1pAxfi4x9jcKUaFBTGS tzUwhf5sGtXSYnLrpQMzHDVaFyD6fernebzuu6Xon4r7/TCyINWtdUPst+nlqUt8ZPeR FnItoR7lN2iDU0yfH1Pkf0RyQrMLsNrOH4+h8PyIlvmhujZ6KX8SsqBRlvBNNoLa7zJ4 X2VQ== Received: by 10.50.180.129 with SMTP id do1mr1516458igc.28.1345630861408; Wed, 22 Aug 2012 03:21:01 -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 ex8csp194233igc; Wed, 22 Aug 2012 03:21:00 -0700 (PDT) Received: by 10.216.227.205 with SMTP id d55mr11675455weq.23.1345630860037; Wed, 22 Aug 2012 03:21:00 -0700 (PDT) Received: from mombin.canonical.com (mombin.canonical.com. [91.189.95.16]) by mx.google.com with ESMTP id gz8si46913799wib.15.2012.08.22.03.20.58; Wed, 22 Aug 2012 03:21:00 -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 1T483U-0003ne-OX; Wed, 22 Aug 2012 10:20:56 +0000 Received: from hqemgate04.nvidia.com ([216.228.121.35]) by mombin.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1T483S-0003n5-TD for linaro-mm-sig@lists.linaro.org; Wed, 22 Aug 2012 10:20:55 +0000 Received: from hqnvupgp05.nvidia.com (Not Verified[216.228.121.13]) by hqemgate04.nvidia.com id ; Wed, 22 Aug 2012 03:20:09 -0700 Received: from hqemhub01.nvidia.com ([172.17.108.22]) by hqnvupgp05.nvidia.com (PGP Universal service); Wed, 22 Aug 2012 03:20:48 -0700 X-PGP-Universal: processed; by hqnvupgp05.nvidia.com on Wed, 22 Aug 2012 03:20:48 -0700 Received: from hqnvemgw01.nvidia.com (172.20.150.20) by hqemhub01.nvidia.com (172.20.150.30) with Microsoft SMTP Server id 8.3.264.0; Wed, 22 Aug 2012 03:20:47 -0700 Received: from daphne.nvidia.com (Not Verified[172.16.212.96]) by hqnvemgw01.nvidia.com with MailMarshal (v6,7,2,8378) id ; Wed, 22 Aug 2012 03:20:47 -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 q7MAKWeq027973; Wed, 22 Aug 2012 03:20:44 -0700 (PDT) From: Hiroshi Doyu To: Marek Szyprowski Date: Wed, 22 Aug 2012 13:20:28 +0300 Message-ID: <1345630830-9586-3-git-send-email-hdoyu@nvidia.com> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: <1345630830-9586-1-git-send-email-hdoyu@nvidia.com> References: <1345630830-9586-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" , "linux-arm-kernel@lists.infradead.org" Subject: [Linaro-mm-sig] [RFC 2/4] ARM: dma-mapping: IOMMU allocates pages from pool with GFP_ATOMIC 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: ALoCoQljMte9yG8eyB66eejFLfCAQWbFm1IKHdeJVGDzcbMvMA6EN1L1L59jPQ3h7/oGAWeSXdBC Makes use of the same atomic pool from DMA, and skips kernel page mapping which can involves sleep'able operation at allocating a kernel page table. Signed-off-by: Hiroshi Doyu --- arch/arm/mm/dma-mapping.c | 22 ++++++++++++++++++---- 1 files changed, 18 insertions(+), 4 deletions(-) diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c index aec0c06..9260107 100644 --- a/arch/arm/mm/dma-mapping.c +++ b/arch/arm/mm/dma-mapping.c @@ -1028,7 +1028,6 @@ static struct page **__iommu_alloc_buffer(struct device *dev, size_t size, struct page **pages; int count = size >> PAGE_SHIFT; int array_size = count * sizeof(struct page *); - int err; if (array_size <= PAGE_SIZE) pages = kzalloc(array_size, gfp); @@ -1037,9 +1036,20 @@ static struct page **__iommu_alloc_buffer(struct device *dev, size_t size, if (!pages) return NULL; - err = __alloc_fill_pages(&pages, count, gfp); - if (err) - goto error + if (gfp & GFP_ATOMIC) { + struct page *page; + int i; + void *addr = __alloc_from_pool(size, &page); + if (!addr) + goto err_out; + + for (i = 0; i < count; i++) + pages[i] = page + i; + } else { + int err = __alloc_fill_pages(&pages, count, gfp); + if (err) + goto error; + } return pages; error: @@ -1055,6 +1065,10 @@ static int __iommu_free_buffer(struct device *dev, struct page **pages, size_t s int count = size >> PAGE_SHIFT; int array_size = count * sizeof(struct page *); int i; + + if (__free_from_pool(page_address(pages[0]), size)) + return 0; + for (i = 0; i < count; i++) if (pages[i]) __free_pages(pages[i], 0);