From patchwork Wed Jun 13 11:50:14 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 9264 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 AA18F23E53 for ; Wed, 13 Jun 2012 11:51:12 +0000 (UTC) Received: from mail-gh0-f180.google.com (mail-gh0-f180.google.com [209.85.160.180]) by fiordland.canonical.com (Postfix) with ESMTP id 6422BA184BC for ; Wed, 13 Jun 2012 11:51:12 +0000 (UTC) Received: by ghbz12 with SMTP id z12so293612ghb.11 for ; Wed, 13 Jun 2012 04:51:11 -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-auditid :from:to:date:message-id:x-mailer:in-reply-to:references :x-brightmail-tracker:x-tm-as-mml:cc:subject:x-beenthere :x-mailman-version:precedence:list-id:list-unsubscribe:list-archive :list-post:list-help:list-subscribe:mime-version:content-type :content-transfer-encoding:sender:errors-to:x-gm-message-state; bh=Pitct2OBWCANCuZM4evOIqBPF7QyuG0D6T+33QD/pnU=; b=GEXhZBYgpapgZ0syGlIwpwGCEy1XgBO5apSM9on6a6kh+VhaIJvSWJOSvmQ1mgfTuJ DeDhR+EhLybvAd/GtYEpPHfPwlwWLq+9Qgnn+Mt3xELsUySFgoqUzKfL0NxxrvTDYL2g wFTdNIyD0NJFbLhFcW56CzXdjkbGykOQx1afBKyOadayHzLB2z0yBZ+fynRb1rDUVsya dLo9QereGf4CYYaBZeffIJxEoUeVV4wrap/UU4R86pgkcIspcis+vbBrJ5psQsaXQh66 Dby/zZyhFfdvRWCHhSUw5UntBTLGGDvQyvF1QnMnLWXCWG1jydbXdpxF5VBoNQMsNGTS loxw== Received: by 10.50.160.198 with SMTP id xm6mr10322847igb.0.1339588270694; Wed, 13 Jun 2012 04:51:10 -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.231.24.148 with SMTP id v20csp18055ibb; Wed, 13 Jun 2012 04:51:09 -0700 (PDT) Received: by 10.204.156.22 with SMTP id u22mr12769097bkw.22.1339588268587; Wed, 13 Jun 2012 04:51:08 -0700 (PDT) Received: from mombin.canonical.com (mombin.canonical.com. [91.189.95.16]) by mx.google.com with ESMTP id fs20si1341702bkc.139.2012.06.13.04.51.07; Wed, 13 Jun 2012 04:51:08 -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 1Sem6K-00009Q-JL; Wed, 13 Jun 2012 11:51:04 +0000 Received: from mailout4.samsung.com ([203.254.224.34]) by mombin.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1Sem6I-000082-HY for linaro-mm-sig@lists.linaro.org; Wed, 13 Jun 2012 11:51:02 +0000 Received: from epcpsbgm1.samsung.com (mailout4.samsung.com [203.254.224.34]) by mailout4.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0M5K00EYU0X05100@mailout4.samsung.com> for linaro-mm-sig@lists.linaro.org; Wed, 13 Jun 2012 20:51:00 +0900 (KST) X-AuditID: cbfee61a-b7f9f6d0000016a8-94-4fd87ea470f7 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 52.59.05800.4AE78DF4; Wed, 13 Jun 2012 20:51:00 +0900 (KST) Received: from mcdsrvbld02.digital.local ([106.116.37.23]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0M5K00JMG0WB4X70@mmp1.samsung.com> for linaro-mm-sig@lists.linaro.org; Wed, 13 Jun 2012 20:51:00 +0900 (KST) From: Marek Szyprowski To: linux-arm-kernel@lists.infradead.org, linaro-mm-sig@lists.linaro.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org Date: Wed, 13 Jun 2012 13:50:14 +0200 Message-id: <1339588218-24398-3-git-send-email-m.szyprowski@samsung.com> X-Mailer: git-send-email 1.7.10 In-reply-to: <1339588218-24398-1-git-send-email-m.szyprowski@samsung.com> References: <1339588218-24398-1-git-send-email-m.szyprowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrMJMWRmVeSWpSXmKPExsVy+t9jAd0ldTf8Df7tFbD4cuUhkwOjx+1/ j5kDGKO4bFJSczLLUov07RK4Mo7enc1YcEu04sSVT8wNjJOFuhg5OSQETCQO3j/LBGGLSVy4 t56ti5GLQ0hgEaPE/Y9TWSGctUwSOxa1glWxCRhKdL3tYgOxRQRmMErs6ksDKWIW2Mci0bn5 BCNIQlggXuLUmncsXYwcHCwCqhI3FrKAhHkFPCQ6531nhNgmL/H0fh/YHE4BT4nfz/aBzRcC qvk97TDzBEbeBYwMqxhFUwuSC4qT0nMN9YoTc4tL89L1kvNzNzGCvf5MagfjygaLQ4wCHIxK PLwbim74C7EmlhVX5h5ilOBgVhLhfZYNFOJNSaysSi3Kjy8qzUktPsQozcGiJM7bZH3BX0gg PbEkNTs1tSC1CCbLxMEp1cDYsfDMCvtp9fonSu4oBzT2N6u2TJJQNujO39d9tt63kYmR327j 7JWy92JjZ4UcC0/aef+4+6auaxs+ec4xU0kx3O127I0HT8uxu98ernW8ZP24UGja7ITk70/q 5A3ZCjLme63MXH9slmBccMu2jt6NXgku32fsWVrc/nmi2/VXl1YHTp3TXGOqxFKckWioxVxU nAgAxmbrwfYBAAA= X-TM-AS-MML: No Cc: Abhinav Kochhar , Russell King - ARM Linux , Arnd Bergmann , Konrad Rzeszutek Wilk , Benjamin Herrenschmidt , Kyungmin Park , Subash Patel Subject: [Linaro-mm-sig] [PATCHv2 2/6] ARM: dma-mapping: add support for DMA_ATTR_NO_KERNEL_MAPPING attribute 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: , MIME-Version: 1.0 Sender: linaro-mm-sig-bounces@lists.linaro.org Errors-To: linaro-mm-sig-bounces@lists.linaro.org X-Gm-Message-State: ALoCoQn91yIliSEbOidNuieiwuRoo1np6p0kbXnWsAinwNMm11sLkP/WQmDYN1VC48yz+VFFUXz1 This patch adds support for DMA_ATTR_NO_KERNEL_MAPPING attribute for IOMMU allocations, what let drivers to save precious kernel virtual address space for large buffers that are intended to be accessed only from userspace. This patch is heavily based on initial work kindly provided by Abhinav Kochhar . Signed-off-by: Marek Szyprowski Reviewed-by: Kyungmin Park --- arch/arm/mm/dma-mapping.c | 18 +++++++++++++----- 1 files changed, 13 insertions(+), 5 deletions(-) diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c index b3ffcf9..5d8b8b2 100644 --- a/arch/arm/mm/dma-mapping.c +++ b/arch/arm/mm/dma-mapping.c @@ -1071,10 +1071,13 @@ static int __iommu_remove_mapping(struct device *dev, dma_addr_t iova, size_t si return 0; } -static struct page **__iommu_get_pages(void *cpu_addr) +static struct page **__iommu_get_pages(void *cpu_addr, struct dma_attrs *attrs) { struct vm_struct *area; + if (dma_get_attr(DMA_ATTR_NO_KERNEL_MAPPING, attrs)) + return cpu_addr; + area = find_vm_area(cpu_addr); if (area && (area->flags & VM_DMA)) return area->pages; @@ -1099,6 +1102,9 @@ static void *arm_iommu_alloc_attrs(struct device *dev, size_t size, if (*handle == DMA_ERROR_CODE) goto err_buffer; + if (dma_get_attr(DMA_ATTR_NO_KERNEL_MAPPING, attrs)) + return pages; + addr = __iommu_alloc_remap(pages, size, gfp, prot, __builtin_return_address(0)); if (!addr) @@ -1119,7 +1125,7 @@ static int arm_iommu_mmap_attrs(struct device *dev, struct vm_area_struct *vma, { unsigned long uaddr = vma->vm_start; unsigned long usize = vma->vm_end - vma->vm_start; - struct page **pages = __iommu_get_pages(cpu_addr); + struct page **pages = __iommu_get_pages(cpu_addr, attrs); vma->vm_page_prot = __get_dma_pgprot(attrs, vma->vm_page_prot); @@ -1146,7 +1152,7 @@ static int arm_iommu_mmap_attrs(struct device *dev, struct vm_area_struct *vma, void arm_iommu_free_attrs(struct device *dev, size_t size, void *cpu_addr, dma_addr_t handle, struct dma_attrs *attrs) { - struct page **pages = __iommu_get_pages(cpu_addr); + struct page **pages = __iommu_get_pages(cpu_addr, attrs); size = PAGE_ALIGN(size); if (!pages) { @@ -1156,8 +1162,10 @@ void arm_iommu_free_attrs(struct device *dev, size_t size, void *cpu_addr, return; } - unmap_kernel_range((unsigned long)cpu_addr, size); - vunmap(cpu_addr); + if (!dma_get_attr(DMA_ATTR_NO_KERNEL_MAPPING, attrs)) { + unmap_kernel_range((unsigned long)cpu_addr, size); + vunmap(cpu_addr); + } __iommu_remove_mapping(dev, handle, size); __iommu_free_buffer(dev, pages, size);