Skip to contentSkip to conversation

dmaengine: rcar-dmac: collection of small missed fixes

PATCH Applied Wolfram Sang 3 participants 7 messages Oct 12 – Nov 20

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

v2 cover dmaengine: rcar-dmac: collection of small missed fixes

While working on this driver, I found that there were these small fixes contributed in the past but they have not been applied yet. So, I collected and rebased them, added review tags and minorly improved the commit messages. For v2, I addressed review comments. Changes are described per patch. Please apply.

Tested on a Renesas R-Car X5H Ironhide board and R-Car V4H SparrowHawk.

Koichiro Den (1):
dmaengine: rcar-dmac: Add missing dma_descriptor_unmap()

Pan Chuang (1):
dmaengine: rcar-dmac: Remove redundant dev_err()/dev_err_probe()

Zhang Shurong (1):
dmaengine: rcar-dmac: Fix PM usage counter imbalance

 drivers/dma/sh/rcar-dmac.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
Signature · 1 line
2.53.0
#1 lore raw

PATCH v2 1/3 dmaengine: rcar-dmac: Fix PM usage counter imbalance

From: Zhang Shurong <[email protected]>

pm_runtime_get_sync will increment pm usage counter even it failed. Forgetting to putting operation will result in reference leak here. We fix it by replacing it with pm_runtime_resume_and_get to keep usage counter balanced.

Fixes 87244fe5abdf ("dmaengine: rcar-dmac: Add Renesas R-Car Gen2 DMA Controller (DMAC) driver")

---

Change since v1:
* added Laurent's tag (thanks!)

 drivers/dma/sh/rcar-dmac.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/dma/sh/rcar-dmac.c +1 -1
index 3ad8aba5dcd4..5b54f1c4ce15 100644
@@ -1070,7 +1070,7 @@ static int rcar_dmac_alloc_chan_resources(struct dma_chan *chan)
 	if (ret < 0)
 		return -ENOMEM;
 
-	return pm_runtime_get_sync(chan->device->dev);
+	return pm_runtime_resume_and_get(chan->device->dev);
 }
 
 static void rcar_dmac_free_chan_resources(struct dma_chan *chan)
Signature · 1 line
2.53.0
#2 lore raw

PATCH v2 2/3 dmaengine: rcar-dmac: Add missing dma_descriptor_unmap()

In reply to Wolfram Sang

From: Koichiro Den <[email protected]>

Call dma_descriptor_unmap() right before dma_cookie_complete() in the threaded IRQ completion path. Without this, streaming DMA mappings attached to the descriptor are never released and may eventually exhaust DMA mapping resources (e.g. IOVA with an IOMMU or bounce-buffer slots with SWIOTLB), leading to dma_map_* failures.

Also ensure dma_descriptor_unmap() is called in rcar_dmac_chan_reinit() (error/terminate path) to avoid the same type of leaks.

Fixes 87244fe5abdf ("dmaengine: rcar-dmac: Add Renesas R-Car Gen2 DMA Controller (DMAC) driver")
[wsa: moved unmap before cookie completion, added Fixes tag]

---

Change since v1:
* moved unmap before cookie_complete (Sashiko + humans)
* adjusted commit message

 drivers/dma/sh/rcar-dmac.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/dma/sh/rcar-dmac.c +2 -0
index 5b54f1c4ce15..78a913c4c0d8 100644
@@ -844,6 +844,7 @@ static void rcar_dmac_chan_reinit(struct rcar_dmac_chan *chan)
 
 	list_for_each_entry_safe(desc, _desc, &descs, node) {
 		list_del(&desc->node);
+		dma_descriptor_unmap(&desc->async_tx);
 		rcar_dmac_desc_put(chan, desc);
 	}
 }
@@ -1653,6 +1654,7 @@ static irqreturn_t rcar_dmac_isr_channel_thread(int irq, void *dev)
 	while (!list_empty(&chan->desc.done)) {
 		desc = list_first_entry(&chan->desc.done, struct rcar_dmac_desc,
 					node);
+		dma_descriptor_unmap(&desc->async_tx);
 		dma_cookie_complete(&desc->async_tx);
 		list_del(&desc->node);
 
Signature · 1 line
2.53.0
Reviewed-by on v2 2/3
#3 lore raw

Re: [PATCH v2 2/3] dmaengine: rcar-dmac: Add missing dma_descriptor_unmap()

Quoted 8 lines · Wolfram Sang

From: Koichiro Den <[email protected]>

Call dma_descriptor_unmap() right before dma_cookie_complete() in the threaded IRQ completion path. Without this, streaming DMA mappings attached to the descriptor are never released and may eventually exhaust DMA mapping resources (e.g. IOVA with an IOMMU or bounce-buffer slots with SWIOTLB), leading to dma_map_* failures.

Quoted 8 lines

Also ensure dma_descriptor_unmap() is called in rcar_dmac_chan_reinit() (error/terminate path) to avoid the same type of leaks.

Fixes 87244fe5abdf ("dmaengine: rcar-dmac: Add Renesas R-Car Gen2 DMA Controller (DMAC) driver")
[wsa: moved unmap before cookie completion, added Fixes tag]

---

Quoted 31 lines

Change since v1:
* moved unmap before cookie_complete (Sashiko + humans)
* adjusted commit message

 drivers/dma/sh/rcar-dmac.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/dma/sh/rcar-dmac.c +2 -1
index 5b54f1c4ce15..78a913c4c0d8 100644
@@ -844,6 +844,7 @@ static void rcar_dmac_chan_reinit(struct rcar_dmac_chan *chan)
 
 	list_for_each_entry_safe(desc, _desc, &descs, node) {
 		list_del(&desc->node);
+		dma_descriptor_unmap(&desc->async_tx);
 		rcar_dmac_desc_put(chan, desc);
 	}
 }
@@ -1653,6 +1654,7 @@ static irqreturn_t rcar_dmac_isr_channel_thread(int irq, void *dev)
 	while (!list_empty(&chan->desc.done)) {
 		desc = list_first_entry(&chan->desc.done, struct rcar_dmac_desc,
 					node);
+		dma_descriptor_unmap(&desc->async_tx);
 		dma_cookie_complete(&desc->async_tx);
 		list_del(&desc->node);
 
--

2.53.0

#4 lore raw

PATCH v2 3/3 dmaengine: rcar-dmac: Remove redundant dev_err()/dev_err_probe()

In reply to Wolfram Sang

From: Pan Chuang <[email protected]>

The devm_request_threaded_irq() now automatically logs detailed error messages on failure. This eliminates the need for driver-specific dev_err() and dev_err_probe() calls that previously printed generic messages.

---

Change since v1:
* none

 drivers/dma/sh/rcar-dmac.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/dma/sh/rcar-dmac.c +1 -4
index 78a913c4c0d8..73b15045ad92 100644
@@ -1797,11 +1797,8 @@ static int rcar_dmac_chan_probe(struct rcar_dmac *dmac,
 					rcar_dmac_isr_channel,
 					rcar_dmac_isr_channel_thread, 0,
 					irqname, rchan);
-	if (ret) {
-		dev_err(dmac->dev, "failed to request IRQ %u (%d)\n",
-			rchan->irq, ret);
+	if (ret)
 		return ret;
-	}
 
 	return 0;
 }
Signature · 1 line
2.53.0
#5 lore raw
In reply to Wolfram Sang
Quoted 7 lines · Wolfram Sang

While working on this driver, I found that there were these small fixes contributed in the past but they have not been applied yet. So, I collected and rebased them, added review tags and minorly improved the commit messages. For v2, I addressed review comments. Changes are described per patch. Please apply.

Tested on a Renesas R-Car X5H Ironhide board and R-Car V4H SparrowHawk.

Still applies cleanly on top of v7.4-rc1.

maintainer Applied
#6 lore raw
In reply to Wolfram Sang
Quoted 9 lines · Wolfram Sang

While working on this driver, I found that there were these small fixes contributed in the past but they have not been applied yet. So, I collected and rebased them, added review tags and minorly improved the commit messages. For v2, I addressed review comments. Changes are described per patch. Please apply.

Tested on a Renesas R-Car X5H Ironhide board and R-Car V4H SparrowHawk.

[...]

Applied, thanks!

[1/3] dmaengine: rcar-dmac: Fix PM usage counter imbalance

      commit: d3c108c095712a3b7eab292ef7ea9a57ff5cd5d7
[2/3] dmaengine: rcar-dmac: Add missing dma_descriptor_unmap()
      commit: 0ca154b10168d8874b871edf5510640c51b326c3
[3/3] dmaengine: rcar-dmac: Remove redundant dev_err()/dev_err_probe()
      commit: d460a02aa0ac6ba9e5d87f8462f75d78be83146e

Best regards,

Signature · 1 line
~Vinod