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=-0.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no 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 6D26EC352A3 for ; Mon, 10 Feb 2020 14:38:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4D6A72082F for ; Mon, 10 Feb 2020 14:38:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727830AbgBJOip (ORCPT ); Mon, 10 Feb 2020 09:38:45 -0500 Received: from mx2.suse.de ([195.135.220.15]:49652 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727429AbgBJOip (ORCPT ); Mon, 10 Feb 2020 09:38:45 -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 7BC54AE41; Mon, 10 Feb 2020 14:38:43 +0000 (UTC) Date: Mon, 10 Feb 2020 15:38:42 +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: <15c7df10-cf9f-109c-3cbf-e73af7f4f66a@ti.com> References: <20200210140423.10232-1-peter.ujfalusi@ti.com> <15c7df10-cf9f-109c-3cbf-e73af7f4f66a@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:28:44 +0100, Peter Ujfalusi wrote: > > Hi Takashi, > > >> --- 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. > > The delay here is coming from the DAI and the codec. > The runtime->delay hold the PCM (DMA) caused delay. Well, let's take a look at soc_pcm_pointer(): /* clearing the previous total delay */ runtime->delay = 0; offset = snd_soc_pcm_component_pointer(substream); /* base delay if assigned in pointer callback */ delay = runtime->delay; delay += snd_soc_dai_delay(cpu_dai, substream); for_each_rtd_codec_dai(rtd, i, codec_dai) { codec_delay = max(codec_delay, snd_soc_dai_delay(codec_dai, substream)); } delay += codec_delay; runtime->delay = delay; So, the code reads the current runtime->delay and saves it as delay variable. Then it adds the max delay from codec DAIs, and stores back to runtime->delay. If we change the last line to runtime->delay += delay; it'll add to the already existing value again, so it'll be doubly if runtime->delay was non-zero beforehand. That said, judging from the code, I believe the current soc-pcm.c code needs no change. thanks, Takashi