* [PATCH] DMA: nbpfaxi: check for errors from dma_map_single
@ 2016-10-05 14:51 Jesper Nilsson
2016-10-18 14:59 ` Vinod Koul
0 siblings, 1 reply; 2+ messages in thread
From: Jesper Nilsson @ 2016-10-05 14:51 UTC (permalink / raw)
To: Dan Williams, Vinod Koul, dmaengine, Guennadi Liakhovetski,
linux-kernel
Check for error return from dma_map_single.
Move the addition of the node to the list to after we check
for error, so we can reuse the list in unmapping.
Found by enabling CONFIG_DMA_API_DEBUG.
Signed-off-by: Jesper Nilsson <jesper.nilsson@axis.com>
---
drivers/dma/nbpfaxi.c | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/drivers/dma/nbpfaxi.c b/drivers/dma/nbpfaxi.c
index 42ac2ff..4f5dd2e 100644
--- a/drivers/dma/nbpfaxi.c
+++ b/drivers/dma/nbpfaxi.c
@@ -731,10 +731,15 @@ static int __nbpf_desc_page_alloc(struct nbpf_channel *chan, gfp_t gfp)
i < ARRAY_SIZE(dpage->ldesc);
i++, ldesc++, hwdesc++) {
ldesc->hwdesc = hwdesc;
- list_add_tail(&ldesc->node, &lhead);
ldesc->hwdesc_dma_addr = dma_map_single(dchan->device->dev,
hwdesc, sizeof(*hwdesc), DMA_TO_DEVICE);
+ if (dma_mapping_error(dchan->device->dev,
+ ldesc->hwdesc_dma_addr)) {
+ goto unmap_err;
+ }
+ list_add_tail(&ldesc->node, &lhead);
+
dev_dbg(dev, "%s(): mapped 0x%p to %pad\n", __func__,
hwdesc, &ldesc->hwdesc_dma_addr);
}
@@ -754,6 +759,14 @@ static int __nbpf_desc_page_alloc(struct nbpf_channel *chan, gfp_t gfp)
list_add(&dpage->node, &chan->desc_page);
return ARRAY_SIZE(dpage->desc);
+unmap_err:
+ list_for_each_entry(ldesc, &lhead, node) {
+ dma_unmap_single(dchan->device->dev,
+ ldesc->hwdesc_dma_addr,
+ sizeof(*ldesc->hwdesc),
+ DMA_TO_DEVICE);
+ }
+ return -ENOMEM;
}
static void __nbpf_desc_put(struct nbpf_desc *desc)
--
2.1.4
/^JN - Jesper Nilsson
--
Jesper Nilsson -- jesper.nilsson@axis.com
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] DMA: nbpfaxi: check for errors from dma_map_single
2016-10-05 14:51 [PATCH] DMA: nbpfaxi: check for errors from dma_map_single Jesper Nilsson
@ 2016-10-18 14:59 ` Vinod Koul
0 siblings, 0 replies; 2+ messages in thread
From: Vinod Koul @ 2016-10-18 14:59 UTC (permalink / raw)
To: Jesper Nilsson
Cc: Dan Williams, dmaengine, Guennadi Liakhovetski, linux-kernel
On Wed, Oct 05, 2016 at 04:51:32PM +0200, Jesper Nilsson wrote:
> Check for error return from dma_map_single.
> Move the addition of the node to the list to after we check
> for error, so we can reuse the list in unmapping.
>
> Found by enabling CONFIG_DMA_API_DEBUG.
Sorry this doesnt apply for me, cna you rebase and resend.
While at it, please use right subsystem name. dmaengine: nbpfaxi:...
--
~Vinod
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-10-18 14:50 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-10-05 14:51 [PATCH] DMA: nbpfaxi: check for errors from dma_map_single Jesper Nilsson
2016-10-18 14:59 ` Vinod Koul
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).