public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: Brent Lu <brent.lu@intel.com>
Cc: <alsa-devel@alsa-project.org>, Jaroslav Kysela <perex@perex.cz>,
	Takashi Iwai <tiwai@suse.com>,
	Baolin Wang <baolin.wang@linaro.org>,
	Arnd Bergmann <arnd@arndb.de>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Richard Fontana <rfontana@redhat.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	paulhsia <paulhsia@chromium.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] ALSA: pcm: fix incorrect hw_base increase
Date: Fri, 15 May 2020 09:21:10 +0200	[thread overview]
Message-ID: <s5htv0hoe8p.wl-tiwai@suse.de> (raw)
In-Reply-To: <1589515779-20987-1-git-send-email-brent.lu@intel.com>

On Fri, 15 May 2020 06:09:39 +0200,
Brent Lu wrote:
> 
> The hw_base will be increased by runtime->buffer_size frames
> unconditionally if the runtime->status->hw_ptr is not updated for over
> half of buffer time. As the hw_base increases, so does the
> runtime->status->hw_ptr which could lead to invalid return value when
> user space program calls snd_pcm_avail() function.
> 
> By updating runtime->hw_ptr_jiffies each time the HWSYNC is called,
> the hw_base will keep the same when buffer stall happens, so does the
> hw_ptr.

Updating hw_ptr_jiffies at that code path looks correct, but it still
leaves the question why this condition happens.  It means that the
actual hwptr isn't changed and yet only jiffies increase
significantly; it means that the hardware can't report proper pointer,
and it should have set SNDRV_PCM_INFO_BATCH flag, then the jiffies
check is skipped.

With which hardware and under which situation did it happen (and the
patch fixed)?


thanks,

Takashi

> 
> Signed-off-by: Brent Lu <brent.lu@intel.com>
> ---
>  sound/core/pcm_lib.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/sound/core/pcm_lib.c b/sound/core/pcm_lib.c
> index 872a852..d531e1b 100644
> --- a/sound/core/pcm_lib.c
> +++ b/sound/core/pcm_lib.c
> @@ -433,6 +433,7 @@ static int snd_pcm_update_hw_ptr0(struct snd_pcm_substream *substream,
>  
>   no_delta_check:
>  	if (runtime->status->hw_ptr == new_hw_ptr) {
> +		runtime->hw_ptr_jiffies = curr_jiffies;
>  		update_audio_tstamp(substream, &curr_tstamp, &audio_tstamp);
>  		return 0;
>  	}
> -- 
> 2.7.4
> 

  parent reply	other threads:[~2020-05-15  7:21 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-15  4:09 [PATCH] ALSA: pcm: fix incorrect hw_base increase Brent Lu
2020-05-15  7:04 ` Greg Kroah-Hartman
2020-05-15  9:04   ` Lu, Brent
2020-05-15  9:30     ` Jaroslav Kysela
2020-05-15 10:39       ` Takashi Iwai
2020-05-15 12:01         ` Jaroslav Kysela
2020-05-18  4:38           ` Lu, Brent
2020-05-15  7:21 ` Takashi Iwai [this message]
2020-05-15  9:36   ` Lu, Brent
2020-05-15 10:40     ` Takashi Iwai

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=s5htv0hoe8p.wl-tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=alsa-devel@alsa-project.org \
    --cc=arnd@arndb.de \
    --cc=baolin.wang@linaro.org \
    --cc=brent.lu@intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=paulhsia@chromium.org \
    --cc=perex@perex.cz \
    --cc=rfontana@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=tiwai@suse.com \
    /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