Skip to content

Commit 0d6defc

Browse files
Olivier Moysanbroonie
authored andcommitted
ASoC: stm32: sai: manage rebind issue
The commit e894efe ("ASoC: core: add support to card rebind") allows to rebind the sound card after a rebind of one of its component. With this commit, the sound card is actually rebound, but may be no more functional. The following problems have been seen with STM32 SAI driver. 1) DMA channel is not requested: With the sound card rebind the simplified call sequence is: stm32_sai_sub_probe snd_soc_register_component snd_soc_try_rebind_card snd_soc_instantiate_card devm_snd_dmaengine_pcm_register The problem occurs because the pcm must be registered, before snd_soc_instantiate_card() is called. Modify SAI driver, to change the call sequence as follows: stm32_sai_sub_probe devm_snd_dmaengine_pcm_register snd_soc_register_component snd_soc_try_rebind_card 2) DMA channel is not released: dma_release_channel() is not called when devm_dmaengine_pcm_release() is executed. This occurs because SND_DMAENGINE_PCM_DRV_NAME component, has already been released through devm_component_release(). devm_dmaengine_pcm_release() should be called before devm_component_release() to avoid this problem. Call snd_dmaengine_pcm_unregister() and snd_soc_unregister_component() explicitly from SAI driver, to have the right sequence. Signed-off-by: Olivier Moysan <[email protected]> Message-Id: <[email protected]> Signed-off-by: Mark Brown <[email protected]>
1 parent 613cea5 commit 0d6defc

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

sound/soc/stm/stm32_sai_sub.c

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1543,20 +1543,20 @@ static int stm32_sai_sub_probe(struct platform_device *pdev)
15431543
return ret;
15441544
}
15451545

1546-
ret = devm_snd_soc_register_component(&pdev->dev, &stm32_component,
1547-
&sai->cpu_dai_drv, 1);
1546+
ret = snd_dmaengine_pcm_register(&pdev->dev, conf, 0);
1547+
if (ret) {
1548+
dev_err(&pdev->dev, "Could not register pcm dma\n");
1549+
return ret;
1550+
}
1551+
1552+
ret = snd_soc_register_component(&pdev->dev, &stm32_component,
1553+
&sai->cpu_dai_drv, 1);
15481554
if (ret)
15491555
return ret;
15501556

15511557
if (STM_SAI_PROTOCOL_IS_SPDIF(sai))
15521558
conf = &stm32_sai_pcm_config_spdif;
15531559

1554-
ret = devm_snd_dmaengine_pcm_register(&pdev->dev, conf, 0);
1555-
if (ret) {
1556-
dev_err(&pdev->dev, "Could not register pcm dma\n");
1557-
return ret;
1558-
}
1559-
15601560
return 0;
15611561
}
15621562

@@ -1565,6 +1565,8 @@ static int stm32_sai_sub_remove(struct platform_device *pdev)
15651565
struct stm32_sai_sub_data *sai = dev_get_drvdata(&pdev->dev);
15661566

15671567
clk_unprepare(sai->pdata->pclk);
1568+
snd_dmaengine_pcm_unregister(&pdev->dev);
1569+
snd_soc_unregister_component(&pdev->dev);
15681570

15691571
return 0;
15701572
}

0 commit comments

Comments
 (0)