From: Lubomir Rintel <lkundrak@v3.sk> To: Dan Williams <djbw@fb.com> Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>, linux-arm-kernel@lists.infradead.org, Vinod Koul <vinod.koul@intel.com>, linux-kernel@vger.kernel.org, Lubomir Rintel <lkundrak@v3.sk> Subject: [PATCH 1/2] dma: mv_xor: use proper dma memory management functions Date: Thu, 27 Dec 2012 20:23:47 +0100 [thread overview] Message-ID: <1356636228-23096-1-git-send-email-lkundrak@v3.sk> (raw) 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 <lkundrak@v3.sk> --- 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); -- 1.7.1
WARNING: multiple messages have this Message-ID (diff)
From: lkundrak@v3.sk (Lubomir Rintel) To: linux-arm-kernel@lists.infradead.org Subject: [PATCH 1/2] dma: mv_xor: use proper dma memory management functions Date: Thu, 27 Dec 2012 20:23:47 +0100 [thread overview] Message-ID: <1356636228-23096-1-git-send-email-lkundrak@v3.sk> (raw) 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 <lkundrak@v3.sk> --- 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); -- 1.7.1
next reply other threads:[~2012-12-27 19:43 UTC|newest] Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top 2012-12-27 19:23 Lubomir Rintel [this message] 2012-12-27 19:23 ` [PATCH 1/2] dma: mv_xor: use proper dma memory management functions Lubomir Rintel 2012-12-27 19:23 ` [PATCH 2/2] dma: mv_xor: do not sync the DMA buffer after being deallocated Lubomir Rintel 2012-12-27 19:23 ` Lubomir Rintel 2013-01-04 16:10 ` Thomas Petazzoni 2013-01-04 16:10 ` Thomas Petazzoni 2013-01-13 13:18 ` Lubomir Rintel 2013-01-13 13:18 ` Lubomir Rintel 2013-01-18 7:45 ` Lubomir Rintel 2013-01-18 7:45 ` Lubomir Rintel 2013-01-18 7:46 ` [PATCH 1/3] " Lubomir Rintel 2013-01-18 7:46 ` Lubomir Rintel 2013-01-18 7:46 ` [PATCH 2/3] dma: mv_xor: fix DMA-API error handling sanity check Lubomir Rintel 2013-01-18 7:46 ` Lubomir Rintel 2013-01-18 7:46 ` [PATCH 3/3] dma: mv_xor: get rid of a DMA-API sanity check warning Lubomir Rintel 2013-01-18 7:46 ` Lubomir Rintel
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=1356636228-23096-1-git-send-email-lkundrak@v3.sk \ --to=lkundrak@v3.sk \ --cc=djbw@fb.com \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-kernel@vger.kernel.org \ --cc=thomas.petazzoni@free-electrons.com \ --cc=vinod.koul@intel.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.