lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <f0dcab9a-1f9d-4db5-b886-0d2174070f37@gmail.com>
Date: Thu, 18 Apr 2024 20:49:09 +0300
From: Péter Ujfalusi <peter.ujfalusi@...il.com>
To: Joao Paulo Goncalves <jpaulo.silvagoncalves@...il.com>,
 Liam Girdwood <lgirdwood@...il.com>, Mark Brown <broonie@...nel.org>,
 Jaroslav Kysela <perex@...ex.cz>, Takashi Iwai <tiwai@...e.com>
Cc: Joao Paulo Goncalves <joao.goncalves@...adex.com>,
 Jai Luthra <j-luthra@...com>, alsa-devel@...a-project.org,
 linux-sound@...r.kernel.org, linux-kernel@...r.kernel.org,
 stable@...r.kernel.org
Subject: Re: [PATCH] ASoC: ti: davinci-mcasp: Fix race condition during probe



On 17/04/2024 21:41, Joao Paulo Goncalves wrote:
> From: Joao Paulo Goncalves <joao.goncalves@...adex.com>
> 
> 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

Interesting... Thanks for the details.
Acked-by: Peter Ujfalusi <peter.ujfalusi@...il.com>

> 
> Cc: stable@...r.kernel.org
> Fixes: 9fbd58cf4ab0 ("ASoC: davinci-mcasp: Choose PCM driver based on configured DMA controller")

Just to note that the DAI registration was always before the platform
registration (ever since the DAI driver started to register the
platform) and I think most TI (and probably other vendor's) driver does
things this way. McASP does a bit of lifting by requesting a DMA channel
to figure out the type of DMA...

> Signed-off-by: Joao Paulo Goncalves <joao.goncalves@...adex.com>
> ---
>  sound/soc/ti/davinci-mcasp.c | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/sound/soc/ti/davinci-mcasp.c b/sound/soc/ti/davinci-mcasp.c
> index b892d66f78470..1e760c3155213 100644
> --- a/sound/soc/ti/davinci-mcasp.c
> +++ b/sound/soc/ti/davinci-mcasp.c
> @@ -2417,12 +2417,6 @@ static int davinci_mcasp_probe(struct platform_device *pdev)
>  
>  	mcasp_reparent_fck(pdev);
>  
> -	ret = devm_snd_soc_register_component(&pdev->dev, &davinci_mcasp_component,
> -					      &davinci_mcasp_dai[mcasp->op_mode], 1);
> -
> -	if (ret != 0)
> -		goto err;
> -
>  	ret = davinci_mcasp_get_dma_type(mcasp);
>  	switch (ret) {
>  	case PCM_EDMA:
> @@ -2449,6 +2443,12 @@ static int davinci_mcasp_probe(struct platform_device *pdev)
>  		goto err;
>  	}
>  
> +	ret = devm_snd_soc_register_component(&pdev->dev, &davinci_mcasp_component,
> +					      &davinci_mcasp_dai[mcasp->op_mode], 1);
> +
> +	if (ret != 0)
> +		goto err;
> +
>  no_audio:
>  	ret = davinci_mcasp_init_gpiochip(mcasp);
>  	if (ret) {

-- 
Péter

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ