From patchwork Sun Mar 23 00:38:41 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Halasa X-Patchwork-Id: 3878131 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 1A40FBF540 for ; Sun, 23 Mar 2014 00:39:18 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4975A2020E for ; Sun, 23 Mar 2014 00:39:17 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 464DB20160 for ; Sun, 23 Mar 2014 00:39:16 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WRWRP-0000GZ-83; Sun, 23 Mar 2014 00:39:07 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WRWRM-0000zD-JK; Sun, 23 Mar 2014 00:39:04 +0000 Received: from inx.pm.waw.pl ([195.116.170.130]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WRWRK-0000yZ-FV for linux-arm-kernel@lists.infradead.org; Sun, 23 Mar 2014 00:39:02 +0000 Received: by inx.pm.waw.pl (Postfix, from userid 2530) id 34C7029936; Sun, 23 Mar 2014 01:31:05 +0100 (CET) From: Krzysztof Halasa To: linux-arm-kernel@lists.infradead.org Subject: [PATCH 3/3] ARM: Fix DMA-bounce code to allow sync from_device and to_device with bidirectional mappings. References: Date: Sun, 23 Mar 2014 01:38:41 +0100 In-Reply-To: (Krzysztof Halasa's message of "Sun, 23 Mar 2014 00:44:09 +0100") Message-ID: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140322_203902_651460_4C65C973 X-CRM114-Status: UNSURE ( 7.71 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -1.9 (-) Cc: Simon =?utf-8?B?S8OlZ3N0csO2bQ==?= , arm@kernel.org, Russell King - ARM Linux , Arnd Bergmann X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This is equivalent of a more generic change to lib/dma-debug.c which is present since v2.6.33: commit 42d53b4ff7d61487d18274ebdf1f70c1aef6f122 dma-debug: allow DMA_BIDIRECTIONAL mappings to be synced with DMA_FROM_DEVICE and DMA_TO_DEVICE. There is no need to perform full BIDIR sync (copying the buffers in case of swiotlb and similar schemes) if we know that the owner (CPU or device) hasn't altered the data. Addresses the false-positive reported at http://bugzilla.kernel.org/show_bug.cgi?id=14169 Signed-off-by: Krzysztof Ha?asa Tested-by: Simon Kagstrom Acked-by: Arnd Bergmann diff --git a/arch/arm/common/dmabounce.c b/arch/arm/common/dmabounce.c index 1143c4d..b4c17cf 100644 --- a/arch/arm/common/dmabounce.c +++ b/arch/arm/common/dmabounce.c @@ -375,7 +375,7 @@ static int __dmabounce_sync_for_cpu(struct device *dev, dma_addr_t addr, off = addr - buf->safe_dma_addr; - BUG_ON(buf->direction != dir); + BUG_ON(buf->direction != dir && buf->direction != DMA_BIDIRECTIONAL); dev_dbg(dev, "%s: unsafe buffer %p (dma=%#x off=%#lx) mapped to %p (dma=%#x)\n", __func__, buf->ptr, virt_to_dma(dev, buf->ptr), off, @@ -415,7 +415,7 @@ static int __dmabounce_sync_for_device(struct device *dev, dma_addr_t addr, off = addr - buf->safe_dma_addr; - BUG_ON(buf->direction != dir); + BUG_ON(buf->direction != dir && buf->direction != DMA_BIDIRECTIONAL); dev_dbg(dev, "%s: unsafe buffer %p (dma=%#x off=%#lx) mapped to %p (dma=%#x)\n", __func__, buf->ptr, virt_to_dma(dev, buf->ptr), off,