* [PATCHv3 0/3] dmaengine: mv_xor: some devm cleanups
@ 2025-08-27 22:00 Rosen Penev
2025-08-27 22:00 ` [PATCHv3 1/3] dmaengine: mv_xor: use devm_platform_ioremap_resource Rosen Penev
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Rosen Penev @ 2025-08-27 22:00 UTC (permalink / raw)
To: dmaengine; +Cc: Vinod Koul, open list
Some devm cleanups that are now possible.
It's interesting that this driver lacks a _remove function to free its
resources...
v2: resent with dmaengine prefix
v3: add error handling for devm_clk_get_optional_enabled to potentially
handle EPROBE_DEFER.
Rosen Penev (3):
dmaengine: mv_xor: use devm_platform_ioremap_resource
dmaengine: mv_xor: use devm_clk_get_optional_enabled
dmaengine: mv_xor: use devm for request_irq
drivers/dma/mv_xor.c | 55 +++++++++++++-------------------------------
1 file changed, 16 insertions(+), 39 deletions(-)
--
2.51.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCHv3 1/3] dmaengine: mv_xor: use devm_platform_ioremap_resource
2025-08-27 22:00 [PATCHv3 0/3] dmaengine: mv_xor: some devm cleanups Rosen Penev
@ 2025-08-27 22:00 ` Rosen Penev
2025-08-27 22:00 ` [PATCHv3 2/3] dmaengine: mv_xor: use devm_clk_get_optional_enabled Rosen Penev
2025-08-27 22:00 ` [PATCHv3 3/3] dmaengine: mv_xor: use devm for request_irq Rosen Penev
2 siblings, 0 replies; 5+ messages in thread
From: Rosen Penev @ 2025-08-27 22:00 UTC (permalink / raw)
To: dmaengine; +Cc: Vinod Koul, open list
Simplifies probe slightly by removing explicit struct resource pointers
and platform_get_resource calls.
Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
drivers/dma/mv_xor.c | 23 ++++++-----------------
1 file changed, 6 insertions(+), 17 deletions(-)
diff --git a/drivers/dma/mv_xor.c b/drivers/dma/mv_xor.c
index 5e8386296046..3597ad8d1220 100644
--- a/drivers/dma/mv_xor.c
+++ b/drivers/dma/mv_xor.c
@@ -1309,7 +1309,6 @@ static int mv_xor_probe(struct platform_device *pdev)
const struct mbus_dram_target_info *dram;
struct mv_xor_device *xordev;
struct mv_xor_platform_data *pdata = dev_get_platdata(&pdev->dev);
- struct resource *res;
unsigned int max_engines, max_channels;
int i, ret;
@@ -1319,23 +1318,13 @@ static int mv_xor_probe(struct platform_device *pdev)
if (!xordev)
return -ENOMEM;
- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- if (!res)
- return -ENODEV;
+ xordev->xor_base = devm_platform_ioremap_resource(pdev, 0);
+ if (IS_ERR(xordev->xor_base))
+ return PTR_ERR(xordev->xor_base);
- xordev->xor_base = devm_ioremap(&pdev->dev, res->start,
- resource_size(res));
- if (!xordev->xor_base)
- return -EBUSY;
-
- res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
- if (!res)
- return -ENODEV;
-
- xordev->xor_high_base = devm_ioremap(&pdev->dev, res->start,
- resource_size(res));
- if (!xordev->xor_high_base)
- return -EBUSY;
+ xordev->xor_high_base = devm_platform_ioremap_resource(pdev, 1);
+ if (IS_ERR(xordev->xor_high_base))
+ return PTR_ERR(xordev->xor_high_base);
platform_set_drvdata(pdev, xordev);
--
2.51.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCHv3 2/3] dmaengine: mv_xor: use devm_clk_get_optional_enabled
2025-08-27 22:00 [PATCHv3 0/3] dmaengine: mv_xor: some devm cleanups Rosen Penev
2025-08-27 22:00 ` [PATCHv3 1/3] dmaengine: mv_xor: use devm_platform_ioremap_resource Rosen Penev
@ 2025-08-27 22:00 ` Rosen Penev
2025-08-27 22:00 ` [PATCHv3 3/3] dmaengine: mv_xor: use devm for request_irq Rosen Penev
2 siblings, 0 replies; 5+ messages in thread
From: Rosen Penev @ 2025-08-27 22:00 UTC (permalink / raw)
To: dmaengine; +Cc: Vinod Koul, open list
Driver was written before this was available. Simplifies code slightly.
Actually also a bugfix. clk_disable_unprepare is missing in _remove,
which is also missing.
Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
drivers/dma/mv_xor.c | 11 +++--------
1 file changed, 3 insertions(+), 8 deletions(-)
diff --git a/drivers/dma/mv_xor.c b/drivers/dma/mv_xor.c
index 3597ad8d1220..d15a1990534b 100644
--- a/drivers/dma/mv_xor.c
+++ b/drivers/dma/mv_xor.c
@@ -1351,9 +1351,9 @@ static int mv_xor_probe(struct platform_device *pdev)
/* Not all platforms can gate the clock, so it is not
* an error if the clock does not exists.
*/
- xordev->clk = clk_get(&pdev->dev, NULL);
- if (!IS_ERR(xordev->clk))
- clk_prepare_enable(xordev->clk);
+ xordev->clk = devm_clk_get_optional_enabled(&pdev->dev, NULL);
+ if (IS_ERR(xordev->clk))
+ return PTR_ERR(xordev->clk);
/*
* We don't want to have more than one channel per CPU in
@@ -1441,11 +1441,6 @@ static int mv_xor_probe(struct platform_device *pdev)
irq_dispose_mapping(xordev->channels[i]->irq);
}
- if (!IS_ERR(xordev->clk)) {
- clk_disable_unprepare(xordev->clk);
- clk_put(xordev->clk);
- }
-
return ret;
}
--
2.51.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCHv3 3/3] dmaengine: mv_xor: use devm for request_irq
2025-08-27 22:00 [PATCHv3 0/3] dmaengine: mv_xor: some devm cleanups Rosen Penev
2025-08-27 22:00 ` [PATCHv3 1/3] dmaengine: mv_xor: use devm_platform_ioremap_resource Rosen Penev
2025-08-27 22:00 ` [PATCHv3 2/3] dmaengine: mv_xor: use devm_clk_get_optional_enabled Rosen Penev
@ 2025-08-27 22:00 ` Rosen Penev
2025-09-02 6:42 ` Vinod Koul
2 siblings, 1 reply; 5+ messages in thread
From: Rosen Penev @ 2025-08-27 22:00 UTC (permalink / raw)
To: dmaengine; +Cc: Vinod Koul, open list
This is only called in _probe. Removes the need to manually free_irq.
Same with irq_dispose_mapping.
Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
drivers/dma/mv_xor.c | 21 +++++++--------------
1 file changed, 7 insertions(+), 14 deletions(-)
diff --git a/drivers/dma/mv_xor.c b/drivers/dma/mv_xor.c
index d15a1990534b..81799ac2f48b 100644
--- a/drivers/dma/mv_xor.c
+++ b/drivers/dma/mv_xor.c
@@ -1025,8 +1025,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;
}
@@ -1112,8 +1110,9 @@ 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,
- 0, dev_name(&pdev->dev), mv_chan);
+ 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;
@@ -1138,14 +1137,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_free_dma;
}
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_free_dma;
}
dev_info(&pdev->dev, "Marvell XOR (%s): ( %s%s%s)\n",
@@ -1156,12 +1155,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_free_dma;
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);
@@ -1400,7 +1397,6 @@ static int mv_xor_probe(struct platform_device *pdev)
cap_mask, irq);
if (IS_ERR(chan)) {
ret = PTR_ERR(chan);
- irq_dispose_mapping(irq);
goto err_channel_add;
}
@@ -1435,11 +1431,8 @@ static int mv_xor_probe(struct platform_device *pdev)
err_channel_add:
for (i = 0; i < MV_XOR_MAX_CHANNELS; i++)
- if (xordev->channels[i]) {
+ if (xordev->channels[i])
mv_xor_channel_remove(xordev->channels[i]);
- if (pdev->dev.of_node)
- irq_dispose_mapping(xordev->channels[i]->irq);
- }
return ret;
}
--
2.51.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCHv3 3/3] dmaengine: mv_xor: use devm for request_irq
2025-08-27 22:00 ` [PATCHv3 3/3] dmaengine: mv_xor: use devm for request_irq Rosen Penev
@ 2025-09-02 6:42 ` Vinod Koul
0 siblings, 0 replies; 5+ messages in thread
From: Vinod Koul @ 2025-09-02 6:42 UTC (permalink / raw)
To: Rosen Penev; +Cc: dmaengine, open list
On 27-08-25, 15:00, Rosen Penev wrote:
> This is only called in _probe. Removes the need to manually free_irq.
That can be intentional! We need to ensure the device is quiesced before
teardown...
>
> Same with irq_dispose_mapping.
>
> Signed-off-by: Rosen Penev <rosenp@gmail.com>
> ---
> drivers/dma/mv_xor.c | 21 +++++++--------------
> 1 file changed, 7 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/dma/mv_xor.c b/drivers/dma/mv_xor.c
> index d15a1990534b..81799ac2f48b 100644
> --- a/drivers/dma/mv_xor.c
> +++ b/drivers/dma/mv_xor.c
> @@ -1025,8 +1025,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;
> }
>
> @@ -1112,8 +1110,9 @@ 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,
> - 0, dev_name(&pdev->dev), mv_chan);
> + 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;
>
> @@ -1138,14 +1137,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_free_dma;
> }
>
> 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_free_dma;
> }
>
> dev_info(&pdev->dev, "Marvell XOR (%s): ( %s%s%s)\n",
> @@ -1156,12 +1155,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_free_dma;
>
> 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);
> @@ -1400,7 +1397,6 @@ static int mv_xor_probe(struct platform_device *pdev)
> cap_mask, irq);
> if (IS_ERR(chan)) {
> ret = PTR_ERR(chan);
> - irq_dispose_mapping(irq);
> goto err_channel_add;
> }
>
> @@ -1435,11 +1431,8 @@ static int mv_xor_probe(struct platform_device *pdev)
>
> err_channel_add:
> for (i = 0; i < MV_XOR_MAX_CHANNELS; i++)
> - if (xordev->channels[i]) {
> + if (xordev->channels[i])
> mv_xor_channel_remove(xordev->channels[i]);
> - if (pdev->dev.of_node)
> - irq_dispose_mapping(xordev->channels[i]->irq);
> - }
>
> return ret;
> }
> --
> 2.51.0
--
~Vinod
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-09-02 6:42 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-27 22:00 [PATCHv3 0/3] dmaengine: mv_xor: some devm cleanups Rosen Penev
2025-08-27 22:00 ` [PATCHv3 1/3] dmaengine: mv_xor: use devm_platform_ioremap_resource Rosen Penev
2025-08-27 22:00 ` [PATCHv3 2/3] dmaengine: mv_xor: use devm_clk_get_optional_enabled Rosen Penev
2025-08-27 22:00 ` [PATCHv3 3/3] dmaengine: mv_xor: use devm for request_irq Rosen Penev
2025-09-02 6:42 ` 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).