Skip to content

Commit d18ca86

Browse files
JPSGoncalvesbroonie
authored andcommitted
ASoC: ti: davinci-mcasp: Fix race condition during probe
When using davinci-mcasp as CPU DAI with simple-card, there are some conditions that cause simple-card to finish registering a sound card before davinci-mcasp finishes registering all sound components. This creates a non-working sound card from userspace with no problem indication apart from not being able to play/record audio on a PCM stream. The issue arises during simultaneous probe execution of both drivers. Specifically, the simple-card driver, awaiting a CPU DAI, proceeds as soon as davinci-mcasp registers its DAI. However, this process can lead to the client mutex lock (client_mutex in soc-core.c) being held or davinci-mcasp being preempted before PCM DMA registration on davinci-mcasp finishes. This situation occurs when the probes of both drivers run concurrently. Below is the code path for this condition. To solve the issue, defer davinci-mcasp CPU DAI registration to the last step in the audio part of it. This way, simple-card CPU DAI parsing will be deferred until all audio components are registered. Fail Code Path: simple-card.c: probe starts simple-card.c: simple_dai_link_of: simple_parse_node(..,cpu,..) returns EPROBE_DEFER, no CPU DAI yet davinci-mcasp.c: probe starts davinci-mcasp.c: devm_snd_soc_register_component() register CPU DAI simple-card.c: probes again, finish CPU DAI parsing and call devm_snd_soc_register_card() simple-card.c: finish probe davinci-mcasp.c: *dma_pcm_platform_register() register PCM DMA davinci-mcasp.c: probe finish Cc: [email protected] Fixes: 9fbd58c ("ASoC: davinci-mcasp: Choose PCM driver based on configured DMA controller") Signed-off-by: Joao Paulo Goncalves <[email protected]> Acked-by: Peter Ujfalusi <[email protected]> Reviewed-by: Jai Luthra <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 4cbb505 commit d18ca86

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

sound/soc/ti/davinci-mcasp.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2417,12 +2417,6 @@ static int davinci_mcasp_probe(struct platform_device *pdev)
24172417

24182418
mcasp_reparent_fck(pdev);
24192419

2420-
ret = devm_snd_soc_register_component(&pdev->dev, &davinci_mcasp_component,
2421-
&davinci_mcasp_dai[mcasp->op_mode], 1);
2422-
2423-
if (ret != 0)
2424-
goto err;
2425-
24262420
ret = davinci_mcasp_get_dma_type(mcasp);
24272421
switch (ret) {
24282422
case PCM_EDMA:
@@ -2449,6 +2443,12 @@ static int davinci_mcasp_probe(struct platform_device *pdev)
24492443
goto err;
24502444
}
24512445

2446+
ret = devm_snd_soc_register_component(&pdev->dev, &davinci_mcasp_component,
2447+
&davinci_mcasp_dai[mcasp->op_mode], 1);
2448+
2449+
if (ret != 0)
2450+
goto err;
2451+
24522452
no_audio:
24532453
ret = davinci_mcasp_init_gpiochip(mcasp);
24542454
if (ret) {

0 commit comments

Comments
 (0)