From: Marco Felsch <m.felsch@pengutronix.de>
To: Vinod Koul <vkoul@kernel.org>, Shawn Guo <shawnguo@kernel.org>,
Sascha Hauer <s.hauer@pengutronix.de>,
Pengutronix Kernel Team <kernel@pengutronix.de>,
Fabio Estevam <festevam@gmail.com>,
Jiada Wang <jiada_wang@mentor.com>, Frank Li <Frank.Li@nxp.com>
Cc: dmaengine@vger.kernel.org, imx@lists.linux.dev,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org,
Marco Felsch <m.felsch@pengutronix.de>
Subject: [PATCH 2/2] dmaengine: imx-sdma: fix supplier/consumer dependency handling
Date: Fri, 12 Sep 2025 00:00:42 +0200 [thread overview]
Message-ID: <20250912-v6-16-topic-dma-devlink-v1-2-4debc2fbf901@pengutronix.de> (raw)
In-Reply-To: <20250912-v6-16-topic-dma-devlink-v1-0-4debc2fbf901@pengutronix.de>
The whole driver was converted to the devm APIs except for this last
for-loop. This loop is buggy due to three reasons:
1) It removes the channels without removing the users first. This can
lead to very bad situations.
2) The loop starts at 0 and which is channel0 which is a special
control channel not registered via vchan_init(). Therefore the
remove() always Oops because of NULL pointer exception.
3) sdma_free_chan_resources() disable the clks unconditional without
checking if the clks are enabled. This is done for all
MAX_DMA_CHANNELS which hang the system if there is at least one unused
channel.
The first issue is fixed by making use of the dmaengine devlink support.
The second issue is fixed by not doing anything on channel0.
The last issue is also fixed by the devlink support because during the
consumer teardown phase each requested channel is dropped accordingly so
the dmaengine driver doesn't need to this.
To sum-up, all issues are fixed by dropping the .remove() callback and
let the frameworks do their job.
Reviewed-by: Frank Li <Frank.Li@nxp.com>
Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
---
drivers/dma/imx-sdma.c | 15 +--------------
1 file changed, 1 insertion(+), 14 deletions(-)
diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c
index d4430e6e56deda7de3538e42af7987a456957b43..a11317c8827297d1d6b8ddc0254ecf549e486001 100644
--- a/drivers/dma/imx-sdma.c
+++ b/drivers/dma/imx-sdma.c
@@ -2393,6 +2393,7 @@ static int sdma_probe(struct platform_device *pdev)
sdma->dma_device.device_prep_dma_memcpy = sdma_prep_memcpy;
sdma->dma_device.device_issue_pending = sdma_issue_pending;
sdma->dma_device.copy_align = 2;
+ sdma->dma_device.create_devlink = true;
dma_set_max_seg_size(sdma->dma_device.dev, SDMA_BD_MAX_CNT);
platform_set_drvdata(pdev, sdma);
@@ -2432,25 +2433,11 @@ static int sdma_probe(struct platform_device *pdev)
return 0;
}
-static void sdma_remove(struct platform_device *pdev)
-{
- struct sdma_engine *sdma = platform_get_drvdata(pdev);
- int i;
-
- /* Kill the tasklet */
- for (i = 0; i < MAX_DMA_CHANNELS; i++) {
- struct sdma_channel *sdmac = &sdma->channel[i];
-
- sdma_free_chan_resources(&sdmac->vc.chan);
- }
-}
-
static struct platform_driver sdma_driver = {
.driver = {
.name = "imx-sdma",
.of_match_table = sdma_dt_ids,
},
- .remove = sdma_remove,
.probe = sdma_probe,
};
--
2.47.3
prev parent reply other threads:[~2025-09-11 22:02 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-11 22:00 [PATCH 0/2] Add DMA devlink support Marco Felsch
2025-09-11 22:00 ` [PATCH 1/2] dmaengine: add device_link support Marco Felsch
2025-09-25 16:31 ` Frank Li
2025-10-27 1:11 ` Laurent Pinchart
2025-10-27 18:59 ` Frank Li
2025-09-11 22:00 ` Marco Felsch [this message]
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=20250912-v6-16-topic-dma-devlink-v1-2-4debc2fbf901@pengutronix.de \
--to=m.felsch@pengutronix.de \
--cc=Frank.Li@nxp.com \
--cc=dmaengine@vger.kernel.org \
--cc=festevam@gmail.com \
--cc=imx@lists.linux.dev \
--cc=jiada_wang@mentor.com \
--cc=kernel@pengutronix.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=s.hauer@pengutronix.de \
--cc=shawnguo@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