From patchwork Wed Jun 13 11:50:18 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 9268 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 05F9E23E53 for ; Wed, 13 Jun 2012 11:51:36 +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 CA399A184BD for ; Wed, 13 Jun 2012 11:51:35 +0000 (UTC) Received: by mail-gh0-f180.google.com with SMTP id z12so293612ghb.11 for ; Wed, 13 Jun 2012 04:51:35 -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=X5+BsDbXDs7hdNex/pQdO3MMbRin2JaYiWmjVqExrOs=; b=VWJYJ9B1RrDck7DYoQl9M6hWyEaVpPh4U29qs4wKjWalFlfvFhEPE4izkon/ELqChJ IIYm/7xJaiSqpnBw0DmPWljECblLmjJ8Nmx/sYqj6xzp99AzX8+aWgN3DTb172rN7iFO 1Da0meWRm9HUVkBP4Not7e7c+Nnc1vhyh0mvwxT1L8Hgh+niHeBboY9RqTlxtkoZo5pu V2W3w6gglX2otlSx0nhSUIfRkC9OwYu9GB8y7Ao00vV8PaW0RJH5lMEYmuvZ6Cqd4ttE 7Xey+R5Js7kP97KzULQXeM5tweR7zgcYlcFqUDvlg1NsfuLjDhWZkvEOws37kVrt398b ue9A== Received: by 10.50.46.232 with SMTP id y8mr10150637igm.57.1339588295432; Wed, 13 Jun 2012 04:51:35 -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 v20csp18094ibb; Wed, 13 Jun 2012 04:51:34 -0700 (PDT) Received: by 10.204.128.207 with SMTP id l15mr13469985bks.100.1339588293971; Wed, 13 Jun 2012 04:51:33 -0700 (PDT) Received: from mombin.canonical.com (mombin.canonical.com. [91.189.95.16]) by mx.google.com with ESMTP id gw17si1370636bkc.65.2012.06.13.04.51.32; Wed, 13 Jun 2012 04:51:33 -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-0000Kr-V9; Wed, 13 Jun 2012 11:51:31 +0000 Received: from mailout2.samsung.com ([203.254.224.25]) by mombin.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1Sem6j-0000Jx-Hl for linaro-mm-sig@lists.linaro.org; Wed, 13 Jun 2012 11:51:30 +0000 Received: from epcpsbgm1.samsung.com (mailout2.samsung.com [203.254.224.25]) by mailout2.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0M5K00HXQ0XSYYL0@mailout2.samsung.com> for linaro-mm-sig@lists.linaro.org; Wed, 13 Jun 2012 20:51:28 +0900 (KST) X-AuditID: cbfee61a-b7f9f6d0000016a8-f2-4fd87ec0a33f Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id A2.69.05800.0CE78DF4; Wed, 13 Jun 2012 20:51:28 +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:28 +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:18 +0200 Message-id: <1339588218-24398-7-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+NgFnrCJMWRmVeSWpSXmKPExsVy+t9jAd0DdTf8DXZNFrH4cuUhkwOjx+1/ j5kDGKO4bFJSczLLUov07RK4MlZ9/MlWMEmpoqNrOlMD43/pLkZODgkBE4lPB14xQdhiEhfu rWfrYuTiEBJYxCjxdGEnI4SzlkmiZ2ozG0gVm4ChRNfbLjBbRGAGo8SuvjSQImaBfSwSnZtP MIIkhAWiJSZdvQBmswioSlx7togFxOYV8JD48Wgt1Dp5iaf3+8AGcQp4Svx+tg8sLgRU83va YeYJjLwLGBlWMYqmFiQXFCel5xrqFSfmFpfmpesl5+duYgT7/ZnUDsaVDRaHGAU4GJV4eDcU 3fAXYk0sK67MPcQowcGsJML7LBsoxJuSWFmVWpQfX1Sak1p8iFGag0VJnLfJ+oK/kEB6Yklq dmpqQWoRTJaJg1OqgVEtyEF6zv4Kg+LSXc/DuNd8lTzTfPRTJavT4juhr/Zlrv8meFyNlaP7 6reL7Usefvy6rnOS1priNt+yPWqTa2cXeqnYLXp+xXLq/aSJP/Tl3XvWLjrjPNVPTIQ7NJkh +85SswzxecEpayJd8o80LajeutHE2f7hveSfW4Na2VUPv57SVPZgq68SS3FGoqEWc1FxIgDM AFhR9wEAAA== 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 6/6] ARM: dma-mapping: add support for DMA_ATTR_SKIP_CPU_SYNC 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: ALoCoQlgpb9cin+Jr8Wnw6vlgDvnBCJvDEnVMNGqhTPiEOsE05oV+KE3tZ/eVt/7JBAXiQ1NHKER This patch adds support for DMA_ATTR_SKIP_CPU_SYNC attribute for dma_(un)map_(single,page,sg) functions family. It lets dma mapping clients to create a mapping for the buffer for the given device without performing a CPU cache synchronization. CPU cache synchronization can be skipped for the buffers which it is known that they are already in 'device' domain (CPU caches have been already synchronized or there are only coherent mappings for the buffer). For advanced users only, please use it with care. Signed-off-by: Marek Szyprowski Reviewed-by: Kyungmin Park --- arch/arm/mm/dma-mapping.c | 20 +++++++++++--------- 1 files changed, 11 insertions(+), 9 deletions(-) diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c index 3840997..939cdc2 100644 --- a/arch/arm/mm/dma-mapping.c +++ b/arch/arm/mm/dma-mapping.c @@ -73,7 +73,7 @@ static dma_addr_t arm_dma_map_page(struct device *dev, struct page *page, unsigned long offset, size_t size, enum dma_data_direction dir, struct dma_attrs *attrs) { - if (!arch_is_coherent()) + if (!arch_is_coherent() && !dma_get_attr(DMA_ATTR_SKIP_CPU_SYNC, attrs)) __dma_page_cpu_to_dev(page, offset, size, dir); return pfn_to_dma(dev, page_to_pfn(page)) + offset; } @@ -96,7 +96,7 @@ static void arm_dma_unmap_page(struct device *dev, dma_addr_t handle, size_t size, enum dma_data_direction dir, struct dma_attrs *attrs) { - if (!arch_is_coherent()) + if (!arch_is_coherent() && !dma_get_attr(DMA_ATTR_SKIP_CPU_SYNC, attrs)) __dma_page_dev_to_cpu(pfn_to_page(dma_to_pfn(dev, handle)), handle & ~PAGE_MASK, size, dir); } @@ -1206,7 +1206,7 @@ static int arm_iommu_get_sgtable(struct device *dev, struct sg_table *sgt, */ static int __map_sg_chunk(struct device *dev, struct scatterlist *sg, size_t size, dma_addr_t *handle, - enum dma_data_direction dir) + enum dma_data_direction dir, struct dma_attrs *attrs) { struct dma_iommu_mapping *mapping = dev->archdata.mapping; dma_addr_t iova, iova_base; @@ -1225,7 +1225,8 @@ static int __map_sg_chunk(struct device *dev, struct scatterlist *sg, phys_addr_t phys = page_to_phys(sg_page(s)); unsigned int len = PAGE_ALIGN(s->offset + s->length); - if (!arch_is_coherent()) + if (!arch_is_coherent() && + !dma_get_attr(DMA_ATTR_SKIP_CPU_SYNC, attrs)) __dma_page_cpu_to_dev(sg_page(s), s->offset, s->length, dir); ret = iommu_map(mapping->domain, iova, phys, len, 0); @@ -1272,7 +1273,7 @@ int arm_iommu_map_sg(struct device *dev, struct scatterlist *sg, int nents, if (s->offset || (size & ~PAGE_MASK) || size + s->length > max) { if (__map_sg_chunk(dev, start, size, &dma->dma_address, - dir) < 0) + dir, attrs) < 0) goto bad_mapping; dma->dma_address += offset; @@ -1285,7 +1286,7 @@ int arm_iommu_map_sg(struct device *dev, struct scatterlist *sg, int nents, } size += s->length; } - if (__map_sg_chunk(dev, start, size, &dma->dma_address, dir) < 0) + if (__map_sg_chunk(dev, start, size, &dma->dma_address, dir, attrs) < 0) goto bad_mapping; dma->dma_address += offset; @@ -1319,7 +1320,8 @@ void arm_iommu_unmap_sg(struct device *dev, struct scatterlist *sg, int nents, if (sg_dma_len(s)) __iommu_remove_mapping(dev, sg_dma_address(s), sg_dma_len(s)); - if (!arch_is_coherent()) + if (!arch_is_coherent() && + !dma_get_attr(DMA_ATTR_SKIP_CPU_SYNC, attrs)) __dma_page_dev_to_cpu(sg_page(s), s->offset, s->length, dir); } @@ -1381,7 +1383,7 @@ static dma_addr_t arm_iommu_map_page(struct device *dev, struct page *page, dma_addr_t dma_addr; int ret, len = PAGE_ALIGN(size + offset); - if (!arch_is_coherent()) + if (!arch_is_coherent() && !dma_get_attr(DMA_ATTR_SKIP_CPU_SYNC, attrs)) __dma_page_cpu_to_dev(page, offset, size, dir); dma_addr = __alloc_iova(mapping, len); @@ -1420,7 +1422,7 @@ static void arm_iommu_unmap_page(struct device *dev, dma_addr_t handle, if (!iova) return; - if (!arch_is_coherent()) + if (!arch_is_coherent() && !dma_get_attr(DMA_ATTR_SKIP_CPU_SYNC, attrs)) __dma_page_dev_to_cpu(page, offset, size, dir); iommu_unmap(mapping->domain, iova, len);