From: Takashi Iwai <tiwai@suse.de>
To: Jaroslav Kysela <perex@perex.cz>
Cc: "Lu, Brent" <brent.lu@intel.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
"alsa-devel@alsa-project.org" <alsa-devel@alsa-project.org>,
Takashi Iwai <tiwai@suse.com>,
Baolin Wang <baolin.wang@linaro.org>,
Arnd Bergmann <arnd@arndb.de>,
Richard Fontana <rfontana@redhat.com>,
Thomas Gleixner <tglx@linutronix.de>,
paulhsia <paulhsia@chromium.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] ALSA: pcm: fix incorrect hw_base increase
Date: Fri, 15 May 2020 12:39:32 +0200 [thread overview]
Message-ID: <s5hk11dmqhn.wl-tiwai@suse.de> (raw)
In-Reply-To: <ce215f76-89c3-3543-c6ed-bc9b81af50a0@perex.cz>
On Fri, 15 May 2020 11:30:54 +0200,
Jaroslav Kysela wrote:
>
> Dne 15. 05. 20 v 11:04 Lu, Brent napsal(a):
> >>
> >> Is this a bugfix needed for older kernels as well? When did this issue show
> >> up?
> >>
> >> thanks,
> >>
> >> greg k-h
> >
> > It happens when DMA stop moving data from host to DSP/DAI for a long time
> > (> half of buffer time). I know host driver should do something about it. But if
> > not, the HWSYNC will keep increasing the hw_base and hw_ptr and confuses
> > user space program.
>
> I'm afraid, but with this code, you turn off the hw_ptr jiffies
> code. It would be better to fix the driver in this case (return the
> updated / estimated DMA pointer, increase DMA buffer size etc.). This
> "lag" is unacceptable.
The problem is obviously in the driver's side and it's best to be
addressed there. But, I think it's still worth to apply this change.
The hw_ptr jiffies check is performed basically in two places: one is
snd_pcm_period_elapsed() call from ISR, and another is with the
no_period_wakeup flag. In both cases, it calculates the diff of
jiffies from the previous update, and corrects the hw_ptr_base if that
exceeds the threshold.
And the bug here is that the "previous" jiffies is kept as long as the
hwptr itself is updated. What we need is the correction of the base
when it really has processed the period size; i.e. hwptr got the same
value (with no_period_wakeup) and yet the jiffies diff is big. For
this check, it's correct to update hw_ptr_jiffies at each call no
matter whether hwptr moved or not; we need to evaluate from the
previous update, after all.
But I might overlook something. Jaroslav, could you check it again?
The jiffies check code is your black magic :)
thanks,
Takashi
next prev parent reply other threads:[~2020-05-15 10:39 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-15 4:09 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 [this message]
2020-05-15 12:01 ` Jaroslav Kysela
2020-05-18 4:38 ` Lu, Brent
2020-05-15 7:21 ` Takashi Iwai
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=s5hk11dmqhn.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
all inboxes | Powered by JetHome®