WSL2-Linux-Kernel/sound
Mark Hills a0b224b90b ALSA: echoaudio: Address bugs in the interrupt handling
Distorted audio appears occasionally, affecting either playback or
capture and requiring the affected substream to be closed by all
applications and re-opened.

The best way I have found to reproduce the bug is to use dmix in
combination with Chromium, which opens the audio device multiple times
in threads. Anecdotally, the problems appear to have increased with
faster CPUs. I ruled out 32-bit counter wrapping; it often happens
much earlier.

Since applying this patch I have not had problems, where previously
they would occur several times a day.

The patch targets the following issues:

* Check for progress using the counter from the hardware, not after it
  has been truncated to the buffer.

  This is a clean way to address a possible bug where if a whole
  ringbuffer advances between interrupts, it goes unnoticed.

* Move last_period state from chip to pipe

  This more logically belongs as part of pipe, and code is reasier to
  read if it is "counter position last time a period elapsed".

  Now the code has no references to period count. A period is just
  when the regular counter crosses a threshold. This increases
  readability and reduces scope for bugs.

* Treat period notification and buffer advance independently:

  This helps to clarify what is the responsibility of the interrupt
  handler, and what is pcm_pointer().

  Removing shared state between these operations means race conditions
  are fixed without introducing locks. Synchronisation is only around
  the read of pipe->dma_counter. There may be cache line contention
  around "struct audiopipe" but I did not have cause to profile this.

Pay attention to be robust where dma_counter wrapping is not a
multiple of period_size or buffer_size.

This is a revised patch based on feedback from Takashi and Giuliano.

Signed-off-by: Mark Hills <mark@xwax.org>
Link: https://lore.kernel.org/r/20200708101848.3457-5-mark@xwax.org
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2020-07-09 12:59:24 +02:00
..
ac97
aoa treewide: replace '---help---' in Kconfig files with 'help' 2020-06-14 01:57:21 +09:00
arm
atmel
core ALSA: pcm: Fix build error on m68k and others 2020-07-07 13:13:12 +02:00
drivers ALSA: vx_core: remove warning for empty loop body 2020-07-07 12:13:16 +02:00
firewire ALSA: firewire: fix kernel-doc 2020-07-07 12:09:32 +02:00
hda ASoC: Updates for v5.8 2020-06-01 20:26:07 +02:00
i2c
isa ALSA: isa/gus: remove 'set but not used' warning 2020-07-07 12:02:24 +02:00
mips
oss
parisc
pci ALSA: echoaudio: Address bugs in the interrupt handling 2020-07-09 12:59:24 +02:00
pcmcia ALSA: pcmcia/pdaudiocf: fix kernel-doc 2020-07-07 12:12:55 +02:00
ppc powerpc updates for 5.8 2020-06-05 12:39:30 -07:00
sh
soc Kbuild updates for v5.8 (2nd) 2020-06-13 13:29:16 -07:00
sparc
spi
synth
usb ALSA: usb/line6: remove 'defined but not used' warning 2020-07-08 09:13:40 +02:00
x86 treewide: replace '---help---' in Kconfig files with 'help' 2020-06-14 01:57:21 +09:00
xen ALSA: xen: remove 'set but not used' warning 2020-07-07 12:11:39 +02:00
Kconfig
Makefile
ac97_bus.c
last.c
sound_core.c