public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH V3] dmaengine: imx-sdma: Fix SPBA bus detection on multi-SPBA platforms
@ 2026-04-20 10:08 Shengjiu Wang
  2026-04-21  2:37 ` Frank Li
  2026-04-21  8:53 ` Marco Felsch
  0 siblings, 2 replies; 6+ messages in thread
From: Shengjiu Wang @ 2026-04-20 10:08 UTC (permalink / raw)
  To: vkoul, Frank.Li, s.hauer, kernel, festevam, dmaengine, imx,
	linux-arm-kernel, linux-kernel

i.MX8M platforms have multiple SPBA buses under different AIPS buses.
The current code searches the entire device tree and returns the first
SPBA bus found, which may not be under the same AIPS bus as the SDMA
controller.

This breaks SDMA P2P transfers because the SDMA script needs to know
if peripherals are on SPBA or AIPS to configure watermark levels
correctly. Using the wrong SPBA bus causes DMA timeouts and transfer
failures.

Fix by searching for the SPBA bus under the SDMA's parent node (AIPS)
first, then falling back to a global search for backward compatibility.

Example device tree showing the issue:
  aips1 {
    spba1 { sai@...; };      /* Correct SPBA for sdma1 */
    sdma1@...;
  };
  aips2 {
    spba2 { uart@...; };     /* Wrong SPBA - found first by old code */
  };

Fixes: 8391ecf465ec ("dmaengine: imx-sdma: Add device to device support")
Cc: stable@vger.kernel.org
Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
---
changs in v3:
- add fallback to a global search for backward compatibility, which is
  to address comments from sashiko.dev
- update commit subject and commit message
- add comments in code.
- add Cc stable tag
- Don't add Frank's RB on v2 as there are several other changes.

changes in v2:
- add fixes tag
- use __free(device_node) for auto release. 

 drivers/dma/imx-sdma.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c
index 3d527883776b..592705af2319 100644
--- a/drivers/dma/imx-sdma.c
+++ b/drivers/dma/imx-sdma.c
@@ -2364,7 +2364,18 @@ static int sdma_probe(struct platform_device *pdev)
 			return dev_err_probe(&pdev->dev, ret,
 					     "failed to register controller\n");
 
-		spba_bus = of_find_compatible_node(NULL, NULL, "fsl,spba-bus");
+		/*
+		 * On i.MX8M platforms with multiple SPBA buses, we need to find
+		 * the SPBA bus that's under the same AIPS bus as this SDMA controller.
+		 * First check the SDMA's parent (AIPS bus) for a child SPBA bus.
+		 * If not found, fall back to searching the entire device tree for
+		 * backward compatibility with older platforms.
+		 */
+		struct device_node *sdma_parent_np __free(device_node) = of_get_parent(np);
+
+		spba_bus = of_get_compatible_child(sdma_parent_np, "fsl,spba-bus");
+		if (!spba_bus)
+			spba_bus = of_find_compatible_node(NULL, NULL, "fsl,spba-bus");
 		ret = of_address_to_resource(spba_bus, 0, &spba_res);
 		if (!ret) {
 			sdma->spba_start_addr = spba_res.start;
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-04-21 10:26 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-20 10:08 [PATCH V3] dmaengine: imx-sdma: Fix SPBA bus detection on multi-SPBA platforms Shengjiu Wang
2026-04-21  2:37 ` Frank Li
2026-04-21  8:53 ` Marco Felsch
2026-04-21  9:13   ` Shengjiu Wang
2026-04-21  9:44     ` Marco Felsch
2026-04-21 10:25       ` Shengjiu Wang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox