Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp3800540ybv; Mon, 10 Feb 2020 06:39:16 -0800 (PST) X-Google-Smtp-Source: APXvYqy8hEZvYeWvJ7ER5ldj5oskW3HzA9BkdVkB2RQ5p11rZgpz2ovIDLdoUgZrUkLrKk1RJSkM X-Received: by 2002:a9d:6a85:: with SMTP id l5mr1357184otq.231.1581345556085; Mon, 10 Feb 2020 06:39:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581345556; cv=none; d=google.com; s=arc-20160816; b=UAya4NRIl/doN4XnpftnxdfKCUJdXqWe/ttjRE6gnUiAUziEHgRyOF6VDOQTZHfo9k BjQmW4OTMD0zzYsGtK6wO00M7MgdhgjjBzx2Xn1R+foUU/OilTKFbBQbZlGK9CPM0AF/ Bnh8eU6rKQVkM1ufq53QXqv8vFPz01Oa38X6ynzM7gp5EuNWCPbVepunD+Vk0mmojPhY /clpmeW/mpwezXFIqo9LhX89hoYYV0Nq1fGUiNFXOn0ICqkXJ+MftOmWeO2CeYuG/4Q+ aXoXBG8Cv56bThDcgdH6EaER1WxlldaMkx2KlubkhXavcxBKyhG4qXriwBFOtV+DhCzt Wdtw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:subject:cc:to:from:message-id:date; bh=M8cY1UV6+nHjLVwLODrKHdZfW0WZgyXRp3BPorbPGcM=; b=HmF3iyfrId3JHYvyOwsIJ67mLGqBIo863rFYfGCDoHo/rNiTcbMp9atY51IEGPGsRw x2g8WNg2xX+Slsonle9M/7RYMtweCMlG/p6oDPR8sO1zIhwWVkVHsxK+MdGFsr4wQ6th Ey51E4kiaIV+VMqXFl2W3zeUx2QvM69lG1/klP9myIrCx8knXE9DLWsp4swx8HWXCVRZ ecuHo7wt0YOzWfjKoMDd0l6glQlTfv144d7wmUqY2jtB9pqQIwBFYvxowbygf9feO1qg HwiJqyOuEaC3sGL8s2l8ZwS5I77hFdRtDwOYNLskwwjYbnaPtGBzfCcX3+Lq6DAGi4m0 /opA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i78si272649oib.1.2020.02.10.06.39.03; Mon, 10 Feb 2020 06:39:16 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727727AbgBJOip (ORCPT + 99 others); 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