From patchwork Tue Mar 4 10:32:33 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Simon Kagstrom X-Patchwork-Id: 326207 Return-Path: X-Original-To: incoming-imx@patchwork.ozlabs.org Delivered-To: patchwork-incoming-imx@bilbo.ozlabs.org Received: from casper.infradead.org (unknown [IPv6:2001:770:15f::2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 7E3BB2C01AE for ; Tue, 4 Mar 2014 21:33:23 +1100 (EST) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WKmer-0005Ml-2x; Tue, 04 Mar 2014 10:33:09 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WKmeo-000749-QT; Tue, 04 Mar 2014 10:33:06 +0000 Received: from ernst.netinsight.se ([194.16.221.21]) by merlin.infradead.org with smtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WKmel-00073i-9e for linux-arm-kernel@lists.infradead.org; Tue, 04 Mar 2014 10:33:04 +0000 Received: from marrow.netinsight.se (unverified [10.100.3.78]) by ernst.netinsight.se (EMWAC SMTPRS 0.83) with SMTP id ; Tue, 04 Mar 2014 11:32:33 +0100 Date: Tue, 4 Mar 2014 11:32:33 +0100 From: Simon =?UTF-8?B?S8OlZ3N0csO2bQ==?= To: linux-arm-kernel@lists.infradead.org Subject: BUG_ON for DMA-bounce and bidirectional mappings (e100 on IXP4xx) Message-ID: <20140304113233.14c95fe0@marrow.netinsight.se> X-Mailer: Claws Mail 3.9.3 (GTK+ 2.24.10; x86_64-pc-linux-gnu) MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140304_053303_586088_8EA9D886 X-CRM114-Status: UNSURE ( 6.99 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [194.16.221.21 listed in list.dnswl.org] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org List-Id: linux-imx-kernel.lists.patchwork.ozlabs.org (Sorry, sent to wrong mailing list address) Hi! We have a IXP4xx-based board which has an e100 NIC. During bootup, we trigger a BUG_ON in dmabounce.c because the mapped direction doesn't match the synced one. e100.c maps buffers bidirectional, but the sync is done fromdevice. Krzysztof HaƂasa sent a patch 2012-09-20 which excludes bidirectional mappings from the sync BUG_ONs, as seen below. We need that patch for our board to boot. The patch in full is available at http://patchwork.ozlabs.org/patch/185486/ This was never applied, but also received no comments. Does the patch make sense? For further reference, the e100 BUG_ON was discussed here a few years ago: http://comments.gmane.org/gmane.linux.ports.arm.kernel/48922 there is a e100 patch there from Jesse Brandeburg which changes the mapping, however with that patch the NIC stops receiving traffic after a while. Thanks, // Simon --- 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,