From patchwork Thu Dec 27 19:23:47 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lubomir Rintel X-Patchwork-Id: 1913621 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork1.kernel.org (Postfix) with ESMTP id 3FC2F3FC66 for ; Thu, 27 Dec 2012 19:46:50 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1ToJNH-0002gl-1E; Thu, 27 Dec 2012 19:44:15 +0000 Received: from norkia.v3.sk ([91.210.183.14]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1ToJN0-0002da-J7 for linux-arm-kernel@lists.infradead.org; Thu, 27 Dec 2012 19:43:59 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by norkia.v3.sk (Postfix) with ESMTP id 34FA812A0E6; Thu, 27 Dec 2012 20:24:00 +0100 (CET) X-Virus-Scanned: amavisd-new at v3.sk Received: from norkia.v3.sk ([127.0.0.1]) by localhost (norkia.v3.sk [127.0.0.1]) (amavisd-new, port 10024) with SMTP id 9bwkmpCQWbBg; Thu, 27 Dec 2012 20:23:52 +0100 (CET) Received: from localhost.localdomain (unknown [194.213.40.134]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: lkundrak@v3.sk) by norkia.v3.sk (Postfix) with ESMTP id 9CF5912A0E5; Thu, 27 Dec 2012 20:23:52 +0100 (CET) From: Lubomir Rintel To: Dan Williams Subject: [PATCH 1/2] dma: mv_xor: use proper dma memory management functions Date: Thu, 27 Dec 2012 20:23:47 +0100 Message-Id: <1356636228-23096-1-git-send-email-lkundrak@v3.sk> X-Mailer: git-send-email 1.7.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20121227_144359_055194_68B45445 X-CRM114-Status: GOOD ( 11.64 ) 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 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: Thomas Petazzoni , Vinod Koul , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Lubomir Rintel X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Caught by self-check with DMA_API_DEBUG: WARNING: at lib/dma-debug.c:878 check_unmap+0x37c/0x748() mv_xor mv_xor.0: DMA-API: device driver frees DMA memory with wrong function [device address=0x000000001f3a1a40] [size=2000 bytes] [mapped as single] [unmapped as page] Signed-off-by: Lubomir Rintel --- drivers/dma/mv_xor.c | 22 +++++++++++++++------- 1 files changed, 15 insertions(+), 7 deletions(-) diff --git a/drivers/dma/mv_xor.c b/drivers/dma/mv_xor.c index ac71f55..39387df 100644 --- a/drivers/dma/mv_xor.c +++ b/drivers/dma/mv_xor.c @@ -306,9 +306,7 @@ mv_xor_run_tx_complete_actions(struct mv_xor_desc_slot *desc, desc->async_tx.callback( desc->async_tx.callback_param); - /* unmap dma addresses - * (unmap_single vs unmap_page?) - */ + /* unmap dma addresses */ if (desc->group_head && desc->unmap_len) { struct mv_xor_desc_slot *unmap = desc->group_head; struct device *dev = mv_chan_to_devp(mv_chan); @@ -327,7 +325,11 @@ mv_xor_run_tx_complete_actions(struct mv_xor_desc_slot *desc, dir = DMA_BIDIRECTIONAL; else dir = DMA_FROM_DEVICE; - dma_unmap_page(dev, dest, len, dir); + + if (flags & DMA_COMPL_DEST_UNMAP_SINGLE) + dma_unmap_single(dev, dest, len, dir); + else + dma_unmap_page(dev, dest, len, dir); } if (!(flags & DMA_COMPL_SKIP_SRC_UNMAP)) { @@ -336,8 +338,12 @@ mv_xor_run_tx_complete_actions(struct mv_xor_desc_slot *desc, src_cnt); if (addr == dest) continue; - dma_unmap_page(dev, addr, len, - DMA_TO_DEVICE); + if (flags & DMA_COMPL_SRC_UNMAP_SINGLE) + dma_unmap_single(dev, addr, len, + DMA_TO_DEVICE); + else + dma_unmap_page(dev, addr, len, + DMA_TO_DEVICE); } } desc->group_head = NULL; @@ -938,7 +944,9 @@ static int mv_xor_memcpy_self_test(struct mv_xor_chan *mv_chan) MV_XOR_TEST_SIZE, DMA_TO_DEVICE); tx = mv_xor_prep_dma_memcpy(dma_chan, dest_dma, src_dma, - MV_XOR_TEST_SIZE, 0); + MV_XOR_TEST_SIZE, + DMA_COMPL_SRC_UNMAP_SINGLE | + DMA_COMPL_DEST_UNMAP_SINGLE); cookie = mv_xor_tx_submit(tx); mv_xor_issue_pending(dma_chan); async_tx_ack(tx);