linux-stable/sound/pci
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 ALSA: Fix misspellings of "Analog Devices" 2020-04-17 11:38:03 +02:00
ali5451 ALSA: ali5451: remove redundant variable capture_flag 2020-02-10 08:29:54 +01:00
asihpi ALSA: pci/asihpi: remove 'set but not used' warning 2020-07-07 12:03:54 +02:00
au88x0 ALSA: pci/au88x0: remove "defined but not used" warnings 2020-07-07 12:13:39 +02:00
aw2 ALSA: pci/aw2-saa7146: remove 'set but not used' warning 2020-07-07 12:05:14 +02:00
ca0106 ALSA: ca0106: More constifications 2020-01-05 16:14:52 +01:00
cs46xx sound updates for 5.6-rc1 2020-01-28 16:26:57 -08:00
cs5535audio ALSA: pci: Constify snd_kcontrol_new items 2020-01-03 09:24:28 +01:00
ctxfi ALSA: pci/ctxfi: fix kernel-doc warnings 2020-07-07 12:05:56 +02:00
echoaudio ALSA: echoaudio: Address bugs in the interrupt handling 2020-07-09 12:59:24 +02:00
emu10k1 ALSA: pci/emu10k1: remove 'set but not used' warning 2020-07-07 12:09:45 +02:00
hda ALSA: hda/hdmi: Add Intel silent stream support 2020-07-07 12:42:35 +02:00
ice1712 ALSA: iec1712: Initialize STDSP24 properly when using the model=staudio option 2020-05-18 19:58:07 +02:00
korg1212 ALSA: pci/korg1212: remove 'set but not used' warnings 2020-07-07 12:10:21 +02:00
lola ALSA: pci: Constify snd_device_ops definitions 2020-01-03 09:23:56 +01:00
lx6464es ALSA: lx6464es: More constifications 2020-01-05 16:15:07 +01:00
mixart ALSA: mixart: More constifications 2020-01-05 16:14:48 +01:00
nm256 sound updates for 5.6-rc1 2020-01-28 16:26:57 -08:00
oxygen ALSA: pci/oxygen/xonar_wm87x6: remove always true condition 2020-07-07 12:11:18 +02:00
pcxhr ALSA: pcxhr: More constifications 2020-01-05 16:14:47 +01:00
riptide ALSA: riptide: More constifications 2020-01-05 16:14:40 +01:00
rme9652 ALSA: pci/rme9652/hdspm: remove always true condition 2020-07-07 12:10:50 +02:00
trident ALSA: pci: Constify snd_ac97_bus_ops definitions 2020-01-03 09:24:13 +01:00
vx222 ALSA: vx: More constifications 2020-01-05 16:14:30 +01:00
ymfpci sound updates for 5.6-rc1 2020-01-28 16:26:57 -08:00
ad1889.c ALSA: pci: Constify snd_ac97_bus_ops definitions 2020-01-03 09:24:13 +01:00
ad1889.h
ak4531_codec.c ALSA: ak4531: More constification 2020-01-05 16:15:09 +01:00
als300.c ALSA: pci: Constify snd_ac97_bus_ops definitions 2020-01-03 09:24:13 +01:00
als4000.c ALSA: pci: Drop superfluous ioctl PCM ops 2019-12-11 07:25:31 +01:00
atiixp.c ALSA: atiixp: More constifications 2020-01-05 16:14:54 +01:00
atiixp_modem.c ALSA: atiixp: More constifications 2020-01-05 16:14:54 +01:00
azt3328.c ALSA: azt3328: More constification 2020-01-05 16:15:09 +01:00
azt3328.h
bt87x.c sound: bt87x: use pci_status_get_and_clear_errors 2020-03-04 14:21:00 -08:00
cmipci.c ALSA: cmipci: More constifications 2020-01-05 16:14:55 +01:00
cs4281.c ALSA: cs4281: More constification 2020-01-05 16:15:10 +01:00
cs5530.c ALSA: pci: Constify snd_device_ops definitions 2020-01-03 09:23:56 +01:00
ens1370.c ALSA: ens137x: More constification 2020-01-05 16:15:11 +01:00
ens1371.c
es1938.c ALSA: pci/es1938: remove 'set but not used' warning 2020-07-07 12:11:59 +02:00
es1968.c ALSA: es1968: More constifications 2020-01-05 16:14:55 +01:00
fm801.c ALSA: pci/fm801: fix kernel-doc 2020-07-07 12:12:21 +02:00
intel8x0.c ALSA: intel8x0: More constifications 2020-01-05 16:14:31 +01:00
intel8x0m.c ALSA: intel8x0: More constifications 2020-01-05 16:14:31 +01:00
Kconfig sound: Fix Kconfig indentation 2019-10-07 03:53:03 +02:00
maestro3.c ALSA: pci: Constify snd_pci_quirk tables 2020-01-03 09:24:45 +01:00
Makefile
rme32.c sound updates for 5.6-rc1 2020-01-28 16:26:57 -08:00
rme96.c sound updates for 5.6-rc1 2020-01-28 16:26:57 -08:00
sis7019.c sound updates for 5.6-rc1 2020-01-28 16:26:57 -08:00
sis7019.h
sonicvibes.c ALSA: pci: Constify snd_kcontrol_new items 2020-01-03 09:24:28 +01:00
via82xx.c ALSA: pci/via82xx: remove 'set but not used' warnings 2020-07-07 12:12:38 +02:00
via82xx_modem.c ALSA: pci/via82xx: remove 'set but not used' warnings 2020-07-07 12:12:38 +02:00