public inbox for dmaengine@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] dmaengine: imx-sdma: Setting DMA_PRIVATE capability during the probe
@ 2022-05-24  7:49 Hui Wang
  2022-06-17  2:48 ` Hui Wang
  2022-06-20  8:33 ` Sascha Hauer
  0 siblings, 2 replies; 4+ messages in thread
From: Hui Wang @ 2022-05-24  7:49 UTC (permalink / raw)
  To: dmaengine, vkoul; +Cc: s.hauer, shawnguo, yibin.gong, hui.wang

We have an imx6sx EVB, the audio driver fails to get a valid dma chan
and the audio can't work at all on this board, below is the error log:
 fsl-ssi-dai 202c000.ssi: Missing dma channel for stream: 0
 202c000.ssi-nau8822-hifi: ASoC: pcm constructor failed: -22
 asoc-simple-card sound: ASoC: can't create pcm 202c000.ssi-nau8822-hifi :-22

Then I checked the usage_count of each dma chan through sysfs, all
channels are occupied as below:
ubuntu@ubuntu:cd /sys/devices/platform/soc/2000000.bus/20ec000.sdma/dma
ubuntu@ubuntu:find . -iname in_use | xargs cat
2
2
2
...

Through debugging, we found the root cause, the
crypo/async_tx/async_tx.c calls the dmaengine_get() ahead of
registration of dma_device from imx-sdma.c. In the dmaengine_get(), the
dmaengine_ref_count will be increased, then in the
dma_async_device_register(), the client_count of each chan will be
increased.

To fix this issue, we could set DMA_PRIVATE to the dma_deivce before
registration.

Signed-off-by: Hui Wang <hui.wang@canonical.com>
---
 drivers/dma/imx-sdma.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c
index 95367a8a81a5..aabe8a8069fb 100644
--- a/drivers/dma/imx-sdma.c
+++ b/drivers/dma/imx-sdma.c
@@ -2201,6 +2201,7 @@ static int sdma_probe(struct platform_device *pdev)
 	for (i = 0; i < sizeof(*sdma->script_addrs) / sizeof(s32); i++)
 		saddr_arr[i] = -EINVAL;
 
+	dma_cap_set(DMA_PRIVATE, sdma->dma_device.cap_mask);
 	dma_cap_set(DMA_SLAVE, sdma->dma_device.cap_mask);
 	dma_cap_set(DMA_CYCLIC, sdma->dma_device.cap_mask);
 	dma_cap_set(DMA_MEMCPY, sdma->dma_device.cap_mask);
-- 
2.25.1


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

end of thread, other threads:[~2022-07-01 16:35 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-05-24  7:49 [PATCH] dmaengine: imx-sdma: Setting DMA_PRIVATE capability during the probe Hui Wang
2022-06-17  2:48 ` Hui Wang
2022-06-20  8:33 ` Sascha Hauer
2022-07-01 16:34   ` Vinod Koul

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