dmaengine: rcar-dmac: collection of small missed fixes
Subsystems (2)
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
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.
---
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
@@ -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
PATCH v2 2/3 dmaengine: rcar-dmac: Add missing dma_descriptor_unmap()
In reply to Wolfram SangFrom: 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.
---
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
@@ -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
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 beforedma_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 inrcar_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")Signed-off-by Koichiro Den <[email protected]>[wsa: moved unmap before cookie completion, added Fixes tag]Signed-off-by Wolfram Sang <[email protected]>---
Quoted 31 lines
Change since v1:
* moved unmap beforecookie_complete(Sashiko + humans)
* adjusted commit messagedrivers/dma/sh/rcar-dmac.c | 2 ++ 1 file changed, 2 insertions(+)drivers/dma/sh/rcar-dmac.c +2
-1@@ -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
PATCH v2 3/3 dmaengine: rcar-dmac: Remove redundant dev_err()/dev_err_probe()
In reply to Wolfram SangFrom: 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
@@ -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
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.
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: d460a02aa0ac6ba9e5d87f8462f75d78be83146eBest regards,
Signature · 1 line
~Vinod