From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 14437C352A3 for ; Mon, 10 Feb 2020 14:21:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DC44B2070A for ; Mon, 10 Feb 2020 14:21:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728085AbgBJOVX (ORCPT ); Mon, 10 Feb 2020 09:21:23 -0500 Received: from mx2.suse.de ([195.135.220.15]:43958 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727563AbgBJOVW (ORCPT ); Mon, 10 Feb 2020 09:21:22 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id D963FB1A6; Mon, 10 Feb 2020 14:21:20 +0000 (UTC) Date: Mon, 10 Feb 2020 15:21:20 +0100 Message-ID: From: Takashi Iwai To: Peter Ujfalusi Cc: , , , , , , , Subject: Re: [PATCH] ASoC: dmaengine_pcm: Consider DMA cache caused delay in pointer callback In-Reply-To: <20200210140423.10232-1-peter.ujfalusi@ti.com> References: <20200210140423.10232-1-peter.ujfalusi@ti.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.8 Emacs/25.3 (x86_64-suse-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 10 Feb 2020 15:04:23 +0100, Peter Ujfalusi wrote: > > Some DMA engines can have big FIFOs which adds to the latency. > The DMAengine framework can report the FIFO utilization in bytes. Use this > information for the delay reporting. > > Signed-off-by: Peter Ujfalusi > --- > Hi, > > 5.6-rc1 now have support for reporting the DMA cached data. > With this patch we can include it to the delay calculation. > The first DMA driver which reports this is the TI K3 UDMA driver. > > Regards, > Peter > > sound/core/pcm_dmaengine.c | 6 ++++++ > sound/soc/soc-pcm.c | 2 +- > 2 files changed, 7 insertions(+), 1 deletion(-) > > diff --git a/sound/core/pcm_dmaengine.c b/sound/core/pcm_dmaengine.c > index 5749a8a49784..4f1395fd0160 100644 > --- a/sound/core/pcm_dmaengine.c > +++ b/sound/core/pcm_dmaengine.c > @@ -247,9 +247,15 @@ snd_pcm_uframes_t snd_dmaengine_pcm_pointer(struct snd_pcm_substream *substream) > > status = dmaengine_tx_status(prtd->dma_chan, prtd->cookie, &state); > if (status == DMA_IN_PROGRESS || status == DMA_PAUSED) { > + struct snd_pcm_runtime *runtime = substream->runtime; > + int sample_bits = snd_pcm_format_physical_width(runtime->format); > + > buf_size = snd_pcm_lib_buffer_bytes(substream); > if (state.residue > 0 && state.residue <= buf_size) > pos = buf_size - state.residue; > + > + sample_bits *= runtime->channels; > + runtime->delay = state.in_flight_bytes / (sample_bits / 8); Can this be simply bytes_to_frames()? runtime->delay = bytes_to_frames(runtime, state.in_flight_bytes); > } > > return bytes_to_frames(substream->runtime, pos); > diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c > index ff1b7c7078e5..58ef508d70a3 100644 > --- a/sound/soc/soc-pcm.c > +++ b/sound/soc/soc-pcm.c > @@ -1151,7 +1151,7 @@ static snd_pcm_uframes_t soc_pcm_pointer(struct snd_pcm_substream *substream) > } > delay += codec_delay; > > - runtime->delay = delay; > + runtime->delay += delay; Is it correct? delay already takes runtime->delay as its basis, so it'll result in a double. thanks, Takashi