Skip to contentSkip to conversation

dmaengine: rcar-dmac: unmap slave resource when channel is freed

PATCH Applied Niklas Söderlund 3 participants 3 messages Jan 11, 2017 – Jan 13, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dmaengine: rcar-dmac: unmap slave resource when channel is freed

The slave mapping should be removed together with other channel resources when the channel is freed. If it's not unmapped it will hang around forever after the channel is freed.

Fixes 9f878603dbdb7db3 ("dmaengine: rcar-dmac: add iommu support for slave transfers")
---
 drivers/dma/sh/rcar-dmac.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/dma/sh/rcar-dmac.c +8 -0
index 2e441d0ccd79..4c357d475465 100644
@@ -986,6 +986,7 @@ static void rcar_dmac_free_chan_resources(struct dma_chan *chan)
 {
 	struct rcar_dmac_chan *rchan = to_rcar_dmac_chan(chan);
 	struct rcar_dmac *dmac = to_rcar_dmac(chan->device);
+	struct rcar_dmac_chan_map *map = &rchan->map;
 	struct rcar_dmac_desc_page *page, *_page;
 	struct rcar_dmac_desc *desc;
 	LIST_HEAD(list);
@@ -1019,6 +1020,13 @@ static void rcar_dmac_free_chan_resources(struct dma_chan *chan)
 		free_page((unsigned long)page);
 	}
 
+	/* Remove slave mapping if present. */
+	if (map->slave.xfer_size) {
+		dma_unmap_resource(chan->device->dev, map->addr,
+				   map->slave.xfer_size, map->dir, 0);
+		map->slave.xfer_size = 0;
+	}
+
 	pm_runtime_put(chan->device->dev);
 }
 
Signature · 1 line
2.11.0
Reviewed-by on v1 1/1
#1 lore raw

Hi Niklas,

Thank you for the patch.

Quoted 8 lines · On Wednesday 11 Jan 2017 15:39:31 Niklas Söderlund wrote:

The slave mapping should be removed together with other channel resources when the channel is freed. If it's not unmapped it will hang around forever after the channel is freed.

Fixes 9f878603dbdb7db3 ("dmaengine: rcar-dmac: add iommu support for slave

transfers") Reported-by: Laurent Pinchart
<[email protected]>

Quoted 29 lines
---
 drivers/dma/sh/rcar-dmac.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/dma/sh/rcar-dmac.c +8 -0
index 2e441d0ccd79..4c357d475465 100644
@@ -986,6 +986,7 @@ static void rcar_dmac_free_chan_resources(struct
 dma_chan *chan) {
 	struct rcar_dmac_chan *rchan = to_rcar_dmac_chan(chan);
 	struct rcar_dmac *dmac = to_rcar_dmac(chan->device);
+	struct rcar_dmac_chan_map *map = &rchan->map;
 	struct rcar_dmac_desc_page *page, *_page;
 	struct rcar_dmac_desc *desc;
 	LIST_HEAD(list);
@@ -1019,6 +1020,13 @@ static void rcar_dmac_free_chan_resources(struct
 dma_chan *chan) free_page((unsigned long)page);
 	}
 
+	/* Remove slave mapping if present. */
+	if (map->slave.xfer_size) {
+		dma_unmap_resource(chan->device->dev, map->addr,
+				   map->slave.xfer_size, map->dir, 0);
+		map->slave.xfer_size = 0;
+	}
+
 	pm_runtime_put(chan->device->dev);
 }
Signature · 3 lines
Regards,

Laurent Pinchart
Applied
#2 lore raw
In reply to Niklas Söderlund
Quoted 3 lines · Niklas S�derlund

The slave mapping should be removed together with other channel resources when the channel is freed. If it's not unmapped it will hang around forever after the channel is freed.

Applied, thanks

Signature · 1 line
~Vinod