From patchwork Wed Jun 6 13:17:36 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 9141 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 866D023E4E for ; Wed, 6 Jun 2012 13:19:08 +0000 (UTC) Received: from mail-yw0-f52.google.com (mail-yw0-f52.google.com [209.85.213.52]) by fiordland.canonical.com (Postfix) with ESMTP id 422D8A18191 for ; Wed, 6 Jun 2012 13:19:08 +0000 (UTC) Received: by yhpp61 with SMTP id p61so5374700yhp.11 for ; Wed, 06 Jun 2012 06:19:07 -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=LWDfhWYC6kQqDOr10t//1NJDEHiwxoWoGPpof1fk5Zw=; b=WSoNHNb1iAYPb7hLHfG9bBrh/UjvxBK8s/MZAy3XmGkWl/q2Vz4+dDEtcYATuvF50P SzLwyTlONX1icw+gp3y3p6G0AoLSxrbtM/x1m4gwk8WPt0n0FkO91iQgQF16f9kKhLEb rdSF6j61E4mumdup+br1ngRnb1LCGJMiUu2RpUwHBumtcmOx+ArbnFtOIBL8yf2AOzRY FCh35d0zRxTXkGvS64DCg15EGgnvmTycaZ7I3iTqrtYOIMQBaL9XutZ3c34II1+BVimZ CllUgSGu/0dLGtvfSGYwkyJ5vRq6OsxiRNsrTkzO6czYpC5vs5ToP3QtCYrhwx/g4pd9 rrEQ== Received: by 10.42.155.73 with SMTP id t9mr13667205icw.48.1338988747435; Wed, 06 Jun 2012 06:19:07 -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 v20csp85621ibb; Wed, 6 Jun 2012 06:19:06 -0700 (PDT) Received: by 10.216.144.228 with SMTP id n78mr11597615wej.26.1338988745543; Wed, 06 Jun 2012 06:19:05 -0700 (PDT) Received: from mombin.canonical.com (mombin.canonical.com. [91.189.95.16]) by mx.google.com with ESMTP id o10si2659997wee.110.2012.06.06.06.19.04; Wed, 06 Jun 2012 06:19:05 -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 1ScG8c-0005w7-D6; Wed, 06 Jun 2012 13:19:02 +0000 Received: from mailout1.samsung.com ([203.254.224.24]) by mombin.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1ScG8a-0005vh-50 for linaro-mm-sig@lists.linaro.org; Wed, 06 Jun 2012 13:19:00 +0000 Received: from epcpsbgm1.samsung.com (mailout1.samsung.com [203.254.224.24]) by mailout1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0M57003YV6BM6JM0@mailout1.samsung.com> for linaro-mm-sig@lists.linaro.org; Wed, 06 Jun 2012 22:18:58 +0900 (KST) X-AuditID: cbfee61a-b7f806d0000037be-b9-4fcf58c2e775 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id DF.BE.14270.2C85FCF4; Wed, 06 Jun 2012 22:18:58 +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 <0M5700H2L6B4YS50@mmp1.samsung.com> for linaro-mm-sig@lists.linaro.org; Wed, 06 Jun 2012 22:18:58 +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, 06 Jun 2012 15:17:36 +0200 Message-id: <1338988657-20770-2-git-send-email-m.szyprowski@samsung.com> X-Mailer: git-send-email 1.7.10 In-reply-to: <1338988657-20770-1-git-send-email-m.szyprowski@samsung.com> References: <1338988657-20770-1-git-send-email-m.szyprowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrEJMWRmVeSWpSXmKPExsVy+t9jAd1DEef9Db7dU7H4cuUhkwOjx+1/ j5kDGKO4bFJSczLLUov07RK4Mu7N6WMpuCNb8XHNIaYGxh8SXYycHBICJhI3zk5khrDFJC7c W8/WxcjFISSwiFHi7NXDjCAJIYG1TBKHLpWC2GwChhJdb7vYQGwRgRmMErv60kAamAX2sUh0 bj4B1iAs4CexsOs5SxcjBweLgKrEtPlg9bwCHhIbZr9lhFgmL/H0fh9YnFPAU2LKwfnsELs8 JG6d6GWawMi7gJFhFaNoakFyQXFSeq6hXnFibnFpXrpecn7uJkawz59J7WBc2WBxiFGAg1GJ h/dx2Hl/IdbEsuLK3EOMEhzMSiK8cc5AId6UxMqq1KL8+KLSnNTiQ4zSHCxK4rx9x875Cwmk J5akZqemFqQWwWSZODilGhgV0j7cspJb+2Ol5GklrlyzjeJv90d/Mv+QeXfS/hLu+++VVLf5 Xfy+xN6ksj7pwcF8W4+kpC91z81ZVO7zTpw0W6eH0aNxtTfnkYvTtU1CbBxjZwb8bj78YTI3 y+njHLOc/Nn8fk3aMfdps0L1sZ27322pNbh94OD5arEDnzd69+hPM03QW2CoxFKckWioxVxU nAgA/EnlUvUBAAA= 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] [PATCH 1/2] common: DMA-mapping: add 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: ALoCoQkiiQmMTE+1fvEyopuYfvc07MVmUbihccT8HHBvPAHWqShLyfNC8/f+tBbY/KFILK5lDHS0 This patch adds DMA_ATTR_SKIP_CPU_SYNC attribute to the DMA-mapping subsystem. By default dma_map_{single,page,sg} functions family transfer a given buffer from CPU domain to device domain. Some advanced use cases might require sharing a buffer between more than one device. This requires having a mapping created separately for each device and is usually performed by calling dma_map_{single,page,sg} function more than once for the given buffer with device pointer to each device taking part in the buffer sharing. The first call transfers a buffer from 'CPU' domain to 'device' domain, what synchronizes CPU caches for the given region (usually it means that the cache has been flushed or invalidated depending on the dma direction). However, next calls to dma_map_{single,page,sg}() for other devices will perform exactly the same sychronization operation on the CPU cache. CPU cache sychronization might be a time consuming operation, especially if the buffers are large, so it is highly recommended to avoid it if possible. DMA_ATTR_SKIP_CPU_SYNC allows platform code to skip synchronization of the CPU cache for the given buffer assuming that it has been already transferred to 'device' domain. This attribute can be also used for dma_unmap_{single,page,sg} functions family to force buffer to stay in device domain after releasing a mapping for it. Use this attribute with care! Signed-off-by: Marek Szyprowski --- Documentation/DMA-attributes.txt | 24 ++++++++++++++++++++++++ include/linux/dma-attrs.h | 1 + 2 files changed, 25 insertions(+), 0 deletions(-) diff --git a/Documentation/DMA-attributes.txt b/Documentation/DMA-attributes.txt index 725580d..f503090 100644 --- a/Documentation/DMA-attributes.txt +++ b/Documentation/DMA-attributes.txt @@ -67,3 +67,27 @@ set on each call. Since it is optional for platforms to implement DMA_ATTR_NO_KERNEL_MAPPING, those that do not will simply ignore the attribute and exhibit default behavior. + +DMA_ATTR_SKIP_CPU_SYNC +---------------------- + +By default dma_map_{single,page,sg} functions family transfer a given +buffer from CPU domain to device domain. Some advanced use cases might +require sharing a buffer between more than one device. This requires +having a mapping created separately for each device and is usually +performed by calling dma_map_{single,page,sg} function more than once +for the given buffer with device pointer to each device taking part in +the buffer sharing. The first call transfers a buffer from 'CPU' domain +to 'device' domain, what synchronizes CPU caches for the given region +(usually it means that the cache has been flushed or invalidated +depending on the dma direction). However, next calls to +dma_map_{single,page,sg}() for other devices will perform exactly the +same sychronization operation on the CPU cache. CPU cache sychronization +might be a time consuming operation, especially if the buffers are +large, so it is highly recommended to avoid it if possible. +DMA_ATTR_SKIP_CPU_SYNC allows platform code to skip synchronization of +the CPU cache for the given buffer assuming that it has been already +transferred to 'device' domain. This attribute can be also used for +dma_unmap_{single,page,sg} functions family to force buffer to stay in +device domain after releasing a mapping for it. Use this attribute with +care! diff --git a/include/linux/dma-attrs.h b/include/linux/dma-attrs.h index a37c10c..f83f793 100644 --- a/include/linux/dma-attrs.h +++ b/include/linux/dma-attrs.h @@ -16,6 +16,7 @@ enum dma_attr { DMA_ATTR_WRITE_COMBINE, DMA_ATTR_NON_CONSISTENT, DMA_ATTR_NO_KERNEL_MAPPING, + DMA_ATTR_SKIP_CPU_SYNC, DMA_ATTR_MAX, };