linux-stable/sound
Joao Paulo Goncalves 0b47bbc91f ASoC: ti: davinci-mcasp: Fix race condition during probe
commit d18ca8635d upstream.

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: stable@vger.kernel.org
Fixes: 9fbd58cf4a ("ASoC: davinci-mcasp: Choose PCM driver based on configured DMA controller")
Signed-off-by: Joao Paulo Goncalves <joao.goncalves@toradex.com>
Acked-by: Peter Ujfalusi <peter.ujfalusi@gmail.com>
Reviewed-by: Jai Luthra <j-luthra@ti.com>
Link: https://lore.kernel.org/r/20240417184138.1104774-1-jpaulo.silvagoncalves@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-05-17 11:56:20 +02:00
..
ac97
aoa ALSA: aoa: Fix I2S device accounting 2022-10-27 08:53:08 +02:00
arm ALSA: arm: pxa: pxa2xx-ac97-lib: fix return value check of platform_get_irq() 2022-10-29 10:45:27 +02:00
atmel
core ALSA: seq: fix function cast warnings 2024-03-26 18:20:48 -04:00
drivers ALSA: mts64: fix possible null-ptr-defer in snd_mts64_interrupt 2022-12-31 13:32:22 +01:00
firewire ALSA: firewire-lib: handle quirk to calculate payload quadlets as data block counter 2024-04-13 13:05:09 +02:00
hda ALSA: hda: intel-sdw-acpi: fix usage of device_get_named_child_node() 2024-05-17 11:56:00 +02:00
i2c ALSA: i2c/cs8427: fix iec958 mixer control deactivation 2023-04-20 12:35:05 +02:00
isa ALSA: gus: Fix kctl->id initialization 2023-06-14 11:15:24 +02:00
mips
oss sound: oss: dmasound: remove software_input_volume declaration 2022-09-09 09:11:06 +02:00
parisc
pci ALSA: hda/realtek: Fix mute led of HP Laptop 15-da3001TU 2024-05-17 11:56:19 +02:00
pcmcia
ppc sound updates for 6.1-rc1 2022-10-05 12:02:07 -07:00
sh ALSA: sh: aica: reorder cleanup operations to avoid UAF bugs 2024-04-03 15:19:50 +02:00
soc ASoC: ti: davinci-mcasp: Fix race condition during probe 2024-05-17 11:56:20 +02:00
sparc
spi
synth ALSA: emux: Avoid potential array out-of-bound in snd_emux_xg_control() 2023-02-14 19:11:41 +01:00
usb ALSA: line6: Zero-initialize message buffers 2024-05-17 11:56:05 +02:00
virtio
x86
xen
Kconfig um: Fix hostaudio build errors 2023-09-13 09:42:58 +02:00
Makefile
ac97_bus.c
last.c
sound_core.c