Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp3821925ybv; Mon, 10 Feb 2020 07:03:17 -0800 (PST) X-Google-Smtp-Source: APXvYqxbG9cLJfWo8Wq87PGQCU/8NNSc5gK0m0Iv4NN7EIUvzBuM8J4It/c4tfXPnxeDyPUJobAn X-Received: by 2002:a9d:7607:: with SMTP id k7mr1363682otl.205.1581346997752; Mon, 10 Feb 2020 07:03:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581346997; cv=none; d=google.com; s=arc-20160816; b=NEtOfEQ/JcIz86VdycetCRhHL1nqYcM6iBL0Iz4sUcqjXkT6H/O0LIjbF8Rqb89BzN Aouj99+6jWU6crG3m7Qt93yrX1LSWpUSjzDXr0PnFR3p83xvvq+w0iZGVio/JdoFKypK 3IEex5p3tRtr1cRduQoSpYyy/17DIuDssR0BiJr6AostRTleusXiwJUZIIBWSosnaPXW q3GpGle/BNPdqhag6G5pgZxly2CCEyVW2XgJ5UwUBakqSbk6UYSr6CkypRHrTtvIhlfM ZCnZJG4lnnxoeU0wO3xtwLTgMvsL6zF9wnmXeiEr2e2ULUuiKgHkk/tsRYRDMzXkhaUZ Wo0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=B/nOBT8Nq5yZ+RzogfXRvk5kf/L+erqu046VxjWWtjE=; b=smY+nLNxH7J//jXbM959puMAzHx/ZD8wYf/jxZuYkk6EN1rwAXb9wlVn7FJAp8ZlKD gyZaXl2A1teFxEewVMLmsfoSBG/Ip8t/qMtf899Ksz3QQSTJdm/t3rdmVOJFBeT3eC/u 0qO6O69vwRO1NhRn0PdMOx3+iCVgxbThh93PwnMoS/JIJ7riV6ffcP5iH3U8Dg0R/qki BCTBgf25Yd9d8r/JIab0MatHUtt2dcN1xwv653zCOtKE22iBCW/iuBJXVKsytLZPVvU9 0H76hxlj0ry5aAq//ujEfxQoQvLxgoqZqQEchsCoqRTrhYIPed9kjAiStEpzN76iDSPN hHuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=nnYvyvNu; 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; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l204si303790oig.31.2020.02.10.07.03.04; Mon, 10 Feb 2020 07:03:17 -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; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=nnYvyvNu; 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; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728485AbgBJPC0 (ORCPT + 99 others); Mon, 10 Feb 2020 10:02:26 -0500 Received: from lelv0142.ext.ti.com ([198.47.23.249]:60672 "EHLO lelv0142.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726809AbgBJPCZ (ORCPT ); Mon, 10 Feb 2020 10:02:25 -0500 Received: from lelv0265.itg.ti.com ([10.180.67.224]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id 01AF1JlZ009377; Mon, 10 Feb 2020 09:01:19 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1581346879; bh=B/nOBT8Nq5yZ+RzogfXRvk5kf/L+erqu046VxjWWtjE=; h=Subject:To:CC:References:From:Date:In-Reply-To; b=nnYvyvNudOMx7abul3CF1ecAWg13wKMSvZna3blAdDgGRYcgXYaFd/cQBMkkN7RBT ewfZjHv4+pP0P6CurzatKtza+2oFLxNVkK1gCJN+X2HqnLDEKdYCF4+IDgU1tyPJVF C31O1HpGm8HX2yXsmO2fYvaGEb+0RHvtxDrlRujA= Received: from DFLE115.ent.ti.com (dfle115.ent.ti.com [10.64.6.36]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 01AF1JBU048306 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 10 Feb 2020 09:01:19 -0600 Received: from DFLE113.ent.ti.com (10.64.6.34) by DFLE115.ent.ti.com (10.64.6.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1847.3; Mon, 10 Feb 2020 09:01:18 -0600 Received: from fllv0039.itg.ti.com (10.64.41.19) by DFLE113.ent.ti.com (10.64.6.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1847.3 via Frontend Transport; Mon, 10 Feb 2020 09:01:19 -0600 Received: from [192.168.2.6] (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0039.itg.ti.com (8.15.2/8.15.2) with ESMTP id 01AF1G2T128816; Mon, 10 Feb 2020 09:01:17 -0600 Subject: Re: [PATCH] ASoC: dmaengine_pcm: Consider DMA cache caused delay in pointer callback To: Takashi Iwai CC: , , , , , , , References: <20200210140423.10232-1-peter.ujfalusi@ti.com> <15c7df10-cf9f-109c-3cbf-e73af7f4f66a@ti.com> From: Peter Ujfalusi Message-ID: <084c2d48-96dd-4d57-84f9-f02204cfbece@ti.com> Date: Mon, 10 Feb 2020 17:01:19 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 8bit X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/02/2020 16.38, Takashi Iwai wrote: > 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. Yes, you are right. The change is added by 9fb4c2bf130b ASoC: soc-pcm: Use delay set in component pointer function which I have missed, apparently. > That said, judging from the code, I believe the current soc-pcm.c code > needs no change. Yes, there is no need to change soc-pcm. > > > thanks, > > Takashi > - Péter Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki