From: Rosen Penev <rosenp@gmail.com>
To: dmaengine@vger.kernel.org
Cc: Vinod Koul <vkoul@kernel.org>, Frank Li <Frank.Li@kernel.org>,
linux-kernel@vger.kernel.org (open list)
Subject: [PATCH 3/3] dma: mv_xor: use devm for dma pool and irq
Date: Tue, 9 Jun 2026 23:57:37 -0700 [thread overview]
Message-ID: <20260610065737.118211-4-rosenp@gmail.com> (raw)
In-Reply-To: <20260610065737.118211-1-rosenp@gmail.com>
Replace dma_alloc_wc with dmam_alloc_attrs and request_irq
with devm_request_irq. This eliminates the need for
manual cleanup of the dma pool and irq in both the channel
remove function and the channel add error labels, removing
the err_free_irq and err_free_dma labels entirely.
Assisted-by: opencode:big-pickle
Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
drivers/dma/mv_xor.c | 23 +++++++----------------
1 file changed, 7 insertions(+), 16 deletions(-)
diff --git a/drivers/dma/mv_xor.c b/drivers/dma/mv_xor.c
index 3fc39cca7cbd..2ac7f01155fe 100644
--- a/drivers/dma/mv_xor.c
+++ b/drivers/dma/mv_xor.c
@@ -1013,8 +1013,6 @@ static int mv_xor_channel_remove(struct mv_xor_chan *mv_chan)
dma_async_device_unregister(&mv_chan->dmadev);
- dma_free_wc(dev, MV_XOR_POOL_SIZE,
- mv_chan->dma_desc_pool_virt, mv_chan->dma_desc_pool);
dma_unmap_single(dev, mv_chan->dummy_src_addr,
MV_XOR_MIN_BYTE_COUNT, DMA_FROM_DEVICE);
dma_unmap_single(dev, mv_chan->dummy_dst_addr,
@@ -1025,8 +1023,6 @@ static int mv_xor_channel_remove(struct mv_xor_chan *mv_chan)
list_del(&chan->device_node);
}
- free_irq(mv_chan->irq, mv_chan);
-
return 0;
}
@@ -1077,8 +1073,8 @@ mv_xor_channel_add(struct mv_xor_device *xordev,
* requires that we explicitly flush the writes
*/
mv_chan->dma_desc_pool_virt =
- dma_alloc_wc(&pdev->dev, MV_XOR_POOL_SIZE, &mv_chan->dma_desc_pool,
- GFP_KERNEL);
+ dmam_alloc_attrs(&pdev->dev, MV_XOR_POOL_SIZE, &mv_chan->dma_desc_pool,
+ GFP_KERNEL, DMA_ATTR_WRITE_COMBINE);
if (!mv_chan->dma_desc_pool_virt) {
ret = -ENOMEM;
goto err_unmap_dst;
@@ -1112,10 +1108,10 @@ mv_xor_channel_add(struct mv_xor_device *xordev,
/* clear errors before enabling interrupts */
mv_chan_clear_err_status(mv_chan);
- ret = request_irq(mv_chan->irq, mv_xor_interrupt_handler,
+ ret = devm_request_irq(&pdev->dev, mv_chan->irq, mv_xor_interrupt_handler,
0, dev_name(&pdev->dev), mv_chan);
if (ret)
- goto err_free_dma;
+ goto err_unmap_dst;
mv_chan_unmask_interrupts(mv_chan);
@@ -1138,14 +1134,14 @@ mv_xor_channel_add(struct mv_xor_device *xordev,
ret = mv_chan_memcpy_self_test(mv_chan);
dev_dbg(&pdev->dev, "memcpy self test returned %d\n", ret);
if (ret)
- goto err_free_irq;
+ goto err_unmap_dst;
}
if (dma_has_cap(DMA_XOR, dma_dev->cap_mask)) {
ret = mv_chan_xor_self_test(mv_chan);
dev_dbg(&pdev->dev, "xor self test returned %d\n", ret);
if (ret)
- goto err_free_irq;
+ goto err_unmap_dst;
}
dev_info(&pdev->dev, "Marvell XOR (%s): ( %s%s%s)\n",
@@ -1156,15 +1152,10 @@ mv_xor_channel_add(struct mv_xor_device *xordev,
ret = dma_async_device_register(dma_dev);
if (ret)
- goto err_free_irq;
+ goto err_unmap_dst;
return mv_chan;
-err_free_irq:
- free_irq(mv_chan->irq, mv_chan);
-err_free_dma:
- dma_free_wc(&pdev->dev, MV_XOR_POOL_SIZE,
- mv_chan->dma_desc_pool_virt, mv_chan->dma_desc_pool);
err_unmap_dst:
dma_unmap_single(dma_dev->dev, mv_chan->dummy_dst_addr,
MV_XOR_MIN_BYTE_COUNT, DMA_TO_DEVICE);
--
2.54.0
next prev parent reply other threads:[~2026-06-10 6:58 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-10 6:57 [PATCH 0/3] dma: mv_xor: convert to devm resource management Rosen Penev
2026-06-10 6:57 ` [PATCH 1/3] dma: mv_xor: use devm_clk_get_optional_enabled Rosen Penev
2026-06-10 7:13 ` sashiko-bot
2026-06-10 6:57 ` [PATCH 2/3] dma: mv_xor: add missing platform remove function Rosen Penev
2026-06-10 9:10 ` sashiko-bot
2026-06-10 6:57 ` Rosen Penev [this message]
2026-06-10 7:12 ` [PATCH 3/3] dma: mv_xor: use devm for dma pool and irq sashiko-bot
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=20260610065737.118211-4-rosenp@gmail.com \
--to=rosenp@gmail.com \
--cc=Frank.Li@kernel.org \
--cc=dmaengine@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=vkoul@kernel.org \
/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: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox