Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp3847141ybv; Mon, 10 Feb 2020 07:28:29 -0800 (PST) X-Google-Smtp-Source: APXvYqwjzDxbKyVZf+DCUSfQTGTSwObWt0rgSXfKSQxbB/KyP/MNdjvstDgVBm4yoyWq2CFAwCxt X-Received: by 2002:a05:6830:1218:: with SMTP id r24mr1521752otp.144.1581348508903; Mon, 10 Feb 2020 07:28:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581348508; cv=none; d=google.com; s=arc-20160816; b=Yzh3MaSDY9n3VyiuIhUJfrWVZi6YJUaaTa9GQUDb78xfFA+zTDMT8vPHtqzgmbZVh0 L8HSQ+L5k3osyeeEWH16Up6HUaQu+6gO6y2N+QNpAuYSxPRgMqrX6vKkuToGTZv3OyJL HzlVeurA3XwNfCZduIHtt/yDtxJXe58iSLXxZAOFtdO9GqjGxM7Wmd9FlBdVKEiFfI8C 2PDyJW38wzX18TEQ4nWmkPxHh1h5HtEw5FQJRXKGd2p+s91YEjf0RNp97dSPJD2J9rkG 2MiQuE4wG5W9snM7d2H47EKbDTmDL0+RBbfjYOvu9crMfgpH/aCjEx1twJlh10CmMPRc 8bMg== 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=PE0/niZ0NJN+ktbHMsqTxiXJMvJZVgZpeLZrw49S0gA=; b=zwb52ZE5p5VXJCP8y87liD7x+yciR2tPHxUkWQ2nNQHJDmOG9v52inHQWqNMDpEl9y 7BBEZqHBcK/sukfX0JyzvThl7rIUcQdiLj2ZpIulJy7XjHWBz9v9eVd2T11DkVgp8B38 aIv4zbJpyPoF9w2RpADq4nzzvt8HR9m5KhpM3mDCKwiI/Cs5mV1W0N/oAnULHhziUGkq KekYXUhiQNffTfomCbyx0cBXvXJeKqIG5WE2amymdrRN444rc5wXq8vkck/YrreshJ7N MlnMmDZoWvkieVFU0BgOxRqmMX+C4lueaAcWvYjnyWtChDrTUEJVN1DjM6nn1GAzCy38 7muA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=If5zr7ng; 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 s21si319528otr.304.2020.02.10.07.28.16; Mon, 10 Feb 2020 07:28:28 -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=If5zr7ng; 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 S1727566AbgBJP1z (ORCPT + 99 others); Mon, 10 Feb 2020 10:27:55 -0500 Received: from lelv0143.ext.ti.com ([198.47.23.248]:39182 "EHLO lelv0143.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727431AbgBJP1z (ORCPT ); Mon, 10 Feb 2020 10:27:55 -0500 Received: from lelv0265.itg.ti.com ([10.180.67.224]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id 01AFQtd0029300; Mon, 10 Feb 2020 09:26:55 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1581348415; bh=PE0/niZ0NJN+ktbHMsqTxiXJMvJZVgZpeLZrw49S0gA=; h=Subject:To:CC:References:From:Date:In-Reply-To; b=If5zr7ng27VO4qW11rsYUoXwaWY8sxlS9ywIycau1SdqM86om6cEz+EukdwsCtBEW JPznHvE/BwJCWjPBMPaz77OLMoPqS3cQkXS+MQAKPOsqaUEMaXEp+Fc8dScKwMcfhZ lU0tH87xBxL5vB1pgV7r81ul5HVOl46lTQ9c8bYE= Received: from DLEE107.ent.ti.com (dlee107.ent.ti.com [157.170.170.37]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 01AFQtiG084574 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 10 Feb 2020 09:26:55 -0600 Received: from DLEE102.ent.ti.com (157.170.170.32) by DLEE107.ent.ti.com (157.170.170.37) 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:26:54 -0600 Received: from fllv0039.itg.ti.com (10.64.41.19) by DLEE102.ent.ti.com (157.170.170.32) 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:26:54 -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 01AFQqr0041110; Mon, 10 Feb 2020 09:26:52 -0600 Subject: Re: [PATCH v2] ALSA: dmaengine_pcm: Consider DMA cache caused delay in pointer callback To: Takashi Iwai CC: , , , , , , , References: <20200210151402.29634-1-peter.ujfalusi@ti.com> From: Peter Ujfalusi Message-ID: <7b2014d6-3c85-0f2b-c01f-3bfd8112dca1@ti.com> Date: Mon, 10 Feb 2020 17:26:55 +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 17.23, Takashi Iwai wrote: > On Mon, 10 Feb 2020 16:14:02 +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, >> >> Changes since v1: >> - use bytes_to_frames() for the DMA delay calculation >> - Drop changes to soc-pcm >> >> 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 | 5 +++++ >> 1 file changed, 5 insertions(+) >> >> diff --git a/sound/core/pcm_dmaengine.c b/sound/core/pcm_dmaengine.c >> index 5749a8a49784..d8be7b488162 100644 >> --- a/sound/core/pcm_dmaengine.c >> +++ b/sound/core/pcm_dmaengine.c >> @@ -247,9 +247,14 @@ 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; >> + >> buf_size = snd_pcm_lib_buffer_bytes(substream); >> if (state.residue > 0 && state.residue <= buf_size) >> pos = buf_size - state.residue; >> + >> + runtime->delay = bytes_to_frames(runtime, >> + state.in_flight_bytes); > > Another call of bytes_to_frames() below... > >> } >> >> return bytes_to_frames(substream->runtime, pos); > > ... refers to substream->runtime. > Better to align both places, either runtime or substream->runtime. Sure, I'll use the runtime as with substream->runtime the delay part is not nicely wrapping. > With that minor nitpick, the change looks good: > Reviewed-by: Takashi Iwai > > > thanks, > > Takashi > - Péter Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki