linux-stable/sound
Joao Paulo Goncalves 866d844564 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:51:04 +02:00
..
ac97
aoa ALSA: aoa: Fix I2S device accounting 2022-11-03 23:59:18 +09:00
arm
atmel
core ALSA: seq: fix function cast warnings 2024-03-26 18:21:27 -04:00
drivers ALSA: mts64: fix possible null-ptr-defer in snd_mts64_interrupt 2022-12-31 13:14:16 +01:00
firewire ALSA: firewire-lib: handle quirk to calculate payload quadlets as data block counter 2024-04-13 13:01:45 +02:00
hda ALSA: hda: intel-sdw-acpi: fix usage of device_get_named_child_node() 2024-05-17 11:50:49 +02:00
i2c ALSA: i2c/cs8427: fix iec958 mixer control deactivation 2023-04-20 12:13:51 +02:00
isa
mips
oss sound/oss/dmasound: fix 'dmasound_setup' defined but not used 2023-05-11 23:00:40 +09:00
parisc
pci ALSA: hda/realtek: Fix mute led of HP Laptop 15-da3001TU 2024-05-17 11:51:03 +02:00
pcmcia
ppc
sh ALSA: sh: aica: reorder cleanup operations to avoid UAF bugs 2024-04-10 16:19:32 +02:00
soc ASoC: ti: davinci-mcasp: Fix race condition during probe 2024-05-17 11:51:04 +02:00
sparc
spi
synth ALSA: emux: Avoid potential array out-of-bound in snd_emux_xg_control() 2023-02-14 19:17:56 +01:00
usb ALSA: line6: Zero-initialize message buffers 2024-05-17 11:50:53 +02:00
virtio
x86
xen
Kconfig um: Fix hostaudio build errors 2023-09-19 12:22:49 +02:00
Makefile
ac97_bus.c
last.c
sound_core.c