From patchwork Wed Jun 13 11:50:17 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 9267 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 335CE23E53 for ; Wed, 13 Jun 2012 11:51:35 +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 03A86A184BC for ; Wed, 13 Jun 2012 11:51:34 +0000 (UTC) Received: by mail-gh0-f180.google.com with SMTP id z12so293612ghb.11 for ; Wed, 13 Jun 2012 04:51:34 -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=+CiQgpSkzLqsPsoxp2tLudv6IDRxIemOT8EnSClTl+0=; b=NRvmgGSzan8CPzr1Szk10D9pyXmXDo/uAHjbL3ONxOZwKI9gvcaJ5e3W2UTuW5VFbz BBjWtjiEHmrkUBT0CO5G3PMFwC1ceQQlBcw2UmijwmU+WmFyGYp+Bn8QksFcCzUKX1Yh AoCfE3Bzrgv1wp084OGNhRLnNxFDf8JnWUnSE4QOx3xkZ331TOWzhGOllPankweRL3ej iD6FbMh45P3hyO+zC/jNvCfQHIsvoy0JdZtKn4yU4P6MF3sc/2H/MjdSyuIrwTFDQalC r8V/GQ94luAfhuB9qgtmEcZz42vVQfc1p+TOe3HaSTbzxtJFzNcH0AF7Y+znA3xf6o7v dtJg== Received: by 10.50.57.167 with SMTP id j7mr10146637igq.53.1339588290792; Wed, 13 Jun 2012 04:51:30 -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 v20csp18086ibb; Wed, 13 Jun 2012 04:51:29 -0700 (PDT) Received: by 10.180.83.168 with SMTP id r8mr37335094wiy.22.1339588289367; Wed, 13 Jun 2012 04:51:29 -0700 (PDT) Received: from mombin.canonical.com (mombin.canonical.com. [91.189.95.16]) by mx.google.com with ESMTP id n17si3714585wee.127.2012.06.13.04.51.27; Wed, 13 Jun 2012 04:51:29 -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 1Sem6g-0000IR-6X; Wed, 13 Jun 2012 11:51:26 +0000 Received: from mailout1.samsung.com ([203.254.224.24]) by mombin.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1Sem6e-0000Gf-6j for linaro-mm-sig@lists.linaro.org; Wed, 13 Jun 2012 11:51:24 +0000 Received: from epcpsbgm2.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 <0M5K00F340XKHI30@mailout1.samsung.com> for linaro-mm-sig@lists.linaro.org; Wed, 13 Jun 2012 20:51:20 +0900 (KST) X-AuditID: cbfee61b-b7fcc6d000003a7a-39-4fd87eb8d11c Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id 13.A5.14970.8BE78DF4; Wed, 13 Jun 2012 20:51:20 +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:20 +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:17 +0200 Message-id: <1339588218-24398-6-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+NgFnrEJMWRmVeSWpSXmKPExsVy+t9jAd0ddTf8DR6s0Lb4cuUhkwOjx+1/ j5kDGKO4bFJSczLLUov07RK4MuZPZy+YIlfx+VUXWwPjaskuRk4OCQETiZPrOpggbDGJC/fW s3UxcnEICSxilFj8voMdJCEksJZJ4v8PORCbTcBQouttFxuILSIwg1FiV18aSAOzwD4Wic7N JxhBEsICARKXbrWAFbEIqEoceroVLM4r4CFxedoGVoht8hJP7/eB1XAKeEr8fraPCWKZh8Tv aYeZJzDyLmBkWMUomlqQXFCclJ5rpFecmFtcmpeul5yfu4kR7PNn0jsYVzVYHGIU4GBU4uHN AIaCEGtiWXFl7iFGCQ5mJRHeZ9lAId6UxMqq1KL8+KLSnNTiQ4zSHCxK4rxN1hf8hQTSE0tS s1NTC1KLYLJMHJxSDYwtpzJf/UyMzo+02ZFYKstvwsJuvuJz1AOlsP3X8z5sFnqQF/ww277P oUDf6fKhqmvrukrX+mqx3D/z6ruYcs4TjT2au+++/1m25JVz7M0Xm7m8bFoYytbwSyjsYJ26 e52Xjqa6hPD/M98956zaVrGhsFNF9abn4tCsDp9lN/zP6PifSjzo/0mJpTgj0VCLuag4EQBQ sarw9QEAAA== 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 5/6] 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: ALoCoQmQk5sWBnfKSRXmZg9oaIqIyALs1xgJ2BfDyktPi9imhwuu3NsMgUFBEnNzslGi6j9xDB74 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 Reviewed-by: Kyungmin Park --- 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, };