From: Takashi Iwai <tiwai@suse.de>
To: Mark Hills <mark@xwax.org>
Cc: alsa-devel@alsa-project.org
Subject: Re: [PATCH 5/5] echoaudio: Address bugs in the interrupt handling
Date: Thu, 09 Jul 2020 13:01:07 +0200 [thread overview]
Message-ID: <s5hblkp7y18.wl-tiwai@suse.de> (raw)
In-Reply-To: <20200708101848.3457-5-mark@xwax.org>
On Wed, 08 Jul 2020 12:18:48 +0200,
Mark Hills wrote:
>
> 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>
Applied now. Thanks.
Takashi
next prev parent reply other threads:[~2020-07-09 11:03 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-16 13:13 echoaudio: Fix some long standing bugs Mark Hills
2020-06-16 13:17 ` [PATCH 1/3] echoaudio: Race conditions around "opencount" Mark Hills
2020-06-16 13:17 ` [PATCH 2/3] echoaudio: Prevent races in calls to set_audio_format() Mark Hills
2020-06-16 13:24 ` Takashi Iwai
2020-06-16 13:17 ` [PATCH 3/3] echoaudio: Address bugs in the interrupt handling Mark Hills
2020-06-16 13:35 ` Takashi Iwai
2020-06-16 14:01 ` Mark Hills
2020-06-16 14:18 ` Takashi Iwai
2020-06-17 10:51 ` Mark Hills
2020-06-18 8:17 ` Takashi Iwai
2020-06-18 11:07 ` Mark Hills
2020-06-18 11:21 ` Takashi Iwai
2020-06-18 12:29 ` Mark Hills
2020-06-18 13:22 ` Mark Hills
2020-06-16 19:46 ` Giuliano Pochini
2020-06-17 10:57 ` Mark Hills
2020-06-16 22:01 ` Giuliano Pochini
2020-06-17 11:14 ` Mark Hills
2020-06-19 19:56 ` Giuliano Pochini
2020-06-19 21:21 ` Mark Hills
2020-06-28 22:02 ` Giuliano Pochini
2020-07-01 12:25 ` Mark Hills
2020-07-01 14:51 ` Giuliano Pochini
2020-07-01 12:25 ` echoaudio: Fix some long standing bugs Mark Hills
2020-07-01 12:27 ` [PATCH 1/4] echoaudio: Race conditions around "opencount" Mark Hills
2020-07-01 16:37 ` kernel test robot
2020-07-01 17:32 ` kernel test robot
2020-07-02 9:53 ` Mark Hills
2020-07-07 8:28 ` Takashi Iwai
2020-07-08 10:16 ` Mark Hills
2020-07-08 10:18 ` [PATCH 1/5] echoaudio: Remove redundant check Mark Hills
2020-07-09 11:00 ` Takashi Iwai
2020-07-08 10:18 ` [PATCH 2/5] echoaudio: Race conditions around "opencount" Mark Hills
2020-07-09 11:00 ` Takashi Iwai
2020-07-08 10:18 ` [PATCH 3/5] echoaudio: Prevent races in calls to set_audio_format() Mark Hills
2020-07-09 11:00 ` Takashi Iwai
2020-07-08 10:18 ` [PATCH 4/5] echoaudio: Prevent some noise on unloading the module Mark Hills
2020-07-09 11:00 ` Takashi Iwai
2020-07-08 10:18 ` [PATCH 5/5] echoaudio: Address bugs in the interrupt handling Mark Hills
2020-07-09 11:01 ` Takashi Iwai [this message]
2020-07-01 12:27 ` [PATCH 2/4] echoaudio: Prevent races in calls to set_audio_format() Mark Hills
2020-07-01 12:27 ` [PATCH 3/4] echoaudio: Prevent some noise on unloading the module Mark Hills
2020-07-01 12:27 ` [PATCH 4/4] echoaudio: Address bugs in the interrupt handling Mark Hills
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=s5hblkp7y18.wl-tiwai@suse.de \
--to=tiwai@suse.de \
--cc=alsa-devel@alsa-project.org \
--cc=mark@xwax.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).