Skip to contentSkip to conversation

ata: pata_pxa: use devres for DMA channel management

PATCH Superseded Rosen Penev 3 participants 3 messages Jul 20 libata

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ata: pata_pxa: use devres for DMA channel management

Convert the DMA channel request to devm_dma_request_chan() so the channel is released automatically on device teardown. This removes the explicit dma_release_channel() calls in the probe error paths and in pxa_ata_remove(), simplifying the driver.

Devres releases in LIFO order, so the managed host detach registered by ata_host_activate() runs before the DMA channel is released, which preserves the previous teardown ordering.

Built as a module for arm/pxa_defconfig (CONFIG_PATA_PXA=m) with LLVM=1 W=1; no new warnings.

Assisted-by opencode:hy3-free
---
 drivers/ata/pata_pxa.c | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)
drivers/ata/pata_pxa.c +3 -10
index c816997dc0a9..a08b852dd9f9 100644
@@ -262,33 +262,26 @@ static int pxa_ata_probe(struct platform_device *pdev)
 	/*
 	 * Request the DMA channel
 	 */
-	data->dma_chan = dma_request_chan(&pdev->dev, "data");
+	data->dma_chan = devm_dma_request_chan(&pdev->dev, "data");
 	if (IS_ERR(data->dma_chan))
 		return PTR_ERR(data->dma_chan);
+
 	ret = dmaengine_slave_config(data->dma_chan, &config);
 	if (ret < 0) {
 		dev_err(&pdev->dev, "dma configuration failed: %d\n", ret);
-		dma_release_channel(data->dma_chan);
 		return ret;
 	}
 
 	/*
 	 * Activate the ATA host
 	 */
-	ret = ata_host_activate(host, irq, ata_sff_interrupt,
+	return ata_host_activate(host, irq, ata_sff_interrupt,
 				pdata->irq_flags, &pxa_ata_sht);
-	if (ret)
-		dma_release_channel(data->dma_chan);
-
-	return ret;
 }
 
 static void pxa_ata_remove(struct platform_device *pdev)
 {
 	struct ata_host *host = platform_get_drvdata(pdev);
-	struct pata_pxa_data *data = host->ports[0]->private_data;
-
-	dma_release_channel(data->dma_chan);
 
 	ata_host_detach(host);
 }
Signature · 1 line
2.55.0
#1 lore raw
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] The commit message falsely claims that `ata_host_activate()` registers a managed host detach and…

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] The commit message falsely claims that ata_host_activate() registers a managed host detach and that the patch preserves the previous teardown ordering. --

--- Patch [1]: [PATCH] ata: pata_pxa: use devres for DMA channel management --- commit d581effc5d41a82779ae2b411de235a8efbfb017
Author: Rosen Penev <[email protected]>

ata: pata_pxa: use devres for DMA channel management

Convert the DMA channel request to devm_dma_request_chan() so the channel is released automatically on device teardown. This removes the explicit dma_release_channel() calls in the probe error paths and in pxa_ata_remove().

Quoted 3 lines

Devres releases in LIFO order, so the managed host detach registered by ata_host_activate() runs before the DMA channel is released, which preserves the previous teardown ordering.

[Severity: Medium]
Is this description accurate regarding the managed host detach and teardown ordering?

Looking at ata_host_activate(), it does not appear to register a managed host detach.

Additionally, pxa_ata_remove() retains the explicit call to ata_host_detach():

Quoted 3 lines
drivers/ata/pata_pxa.c +0 -0

[ ... ]

Quoted 1 line
drivers/ata/pata_pxa.c +0 -0
@@ -280,33 +280,26 @@ static int pxa_ata_probe(struct platform_device *pdev)

[ ... ]

drivers/ata/pata_pxa.c static int pxa_ata_probe(struct platform_device *pdev) · line 287

Quoted 9 lines

static void pxa_ata_remove(struct platform_device *pdev) {

drivers/ata/pata_pxa.c +0 -3
 	struct ata_host *host = platform_get_drvdata(pdev);
-	struct pata_pxa_data *data = host->ports[0]->private_data;
-
-	dma_release_channel(data->dma_chan);
 
 	ata_host_detach(host);
 }

Because devres cleanup executes after pxa_ata_remove() returns, the DMA channel is now released after the host is explicitly detached. This reverses the previous teardown ordering, which released the DMA channel before the host detach. Could the commit message be more precise about the actual teardown sequence?

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
maintainer
#2 lore raw
Quoted 15 lines · On 7/20/26 11:01, [email protected] wrote:

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] The commit message falsely claims that ata_host_activate() registers a managed host detach and that the patch preserves the previous teardown ordering. --

--- Patch [1]: [PATCH] ata: pata_pxa: use devres for DMA channel management --- commit d581effc5d41a82779ae2b411de235a8efbfb017
Author: Rosen Penev <[email protected]>

ata: pata_pxa: use devres for DMA channel management

Convert the DMA channel request to devm_dma_request_chan() so the channel is released automatically on device teardown. This removes the explicit dma_release_channel() calls in the probe error paths and in pxa_ata_remove().

Quoted 7 lines
Quoted 3 lines

Devres releases in LIFO order, so the managed host detach registered by ata_host_activate() runs before the DMA channel is released, which preserves the previous teardown ordering.

[Severity: Medium]
Is this description accurate regarding the managed host detach and teardown ordering?

Rosen,

Can you resend with a fixed up commit message?
Thanks.

Signature · 2 lines
Damien Le Moal
Western Digital Research