linux-stable/sound
Joao Paulo Goncalves ed47e8e096 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 12:15:04 +02:00
..
ac97 ALSA: ac97: fix build regression 2024-01-03 11:47:04 +01:00
aoa ALSA: aoa: Replace with __packed attribute 2023-10-26 09:43:11 +02:00
arm ASoC: arm: convert not to use asoc_xxx() 2023-09-25 14:16:16 +02:00
atmel
core ALSA: seq: ump: Fix conversion from MIDI2 to MIDI1 UMP messages 2024-04-27 17:12:57 +02:00
drivers sound fixes for 6.8-rc1 2024-01-19 12:30:29 -08:00
firewire ALSA: firewire-lib: handle quirk to calculate payload quadlets as data block counter 2024-04-13 13:10:05 +02:00
hda ALSA: hda: intel-sdw-acpi: fix usage of device_get_named_child_node() 2024-05-17 12:14:32 +02:00
i2c
isa ALSA: wavefront: copy userspace array safely 2023-11-20 12:38:31 +01:00
mips
oss OSS: dmasound/paula: Mark driver struct with __refdata to prevent section mismatch 2024-05-17 12:14:40 +02:00
parisc
pci ALSA: hda/realtek: Fix conflicting PCI SSID 17aa:386f for Lenovo Legion models 2024-05-17 12:15:00 +02:00
pcmcia
ppc
sh ALSA: sh: aica: reorder cleanup operations to avoid UAF bugs 2024-04-03 15:32:44 +02:00
soc ASoC: ti: davinci-mcasp: Fix race condition during probe 2024-05-17 12:15:04 +02:00
sparc
spi
synth
usb ALSA: line6: Zero-initialize message buffers 2024-05-17 12:14:40 +02:00
virtio ALSA: virtio: remove duplicate check if queue is broken 2024-01-24 14:41:37 +01:00
x86 drm/edid: include drm_eld.h only where required 2023-11-09 16:47:31 +02:00
xen ALSA: xen: Fix -Wformat-truncation warning 2023-09-15 13:21:35 +02:00
Kconfig
Makefile
ac97_bus.c ALSA: mark all struct bus_type as const 2023-12-30 10:10:41 +01:00
last.c
sound_core.c