Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp3834776ybv; Mon, 10 Feb 2020 07:15:37 -0800 (PST) X-Google-Smtp-Source: APXvYqyv5qSH6S0IuJ4e7NT2Jmcv5gfOxvwa3hYPVTi1TRuJUT8SGDXnpDs0I2k525/FK80xaCIv X-Received: by 2002:a9d:5885:: with SMTP id x5mr1399704otg.132.1581347737652; Mon, 10 Feb 2020 07:15:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581347737; cv=none; d=google.com; s=arc-20160816; b=PxhHtkJCkizUc+mb2MIqCaP8V9dwZeXrBZiahmHLUWr8s9rx7M9hUlfczY4tU9guHj r4b2aDkFSYysv8XgDNwSXLoDoBeAeMp5QrOAJ7GjXruLC2B7SnT3FoqBk9vmn1xrcaDu asFNPUXZlwmF2aU0kKuDTFlqjfStcoSk/l1CS6iKvbdqTC9SIOO7kKPH78GdCxKJclmi VUgdWwmtBWdeVwO+ZxhKfwD8PBlTSLgJ1JrJ8qk18Wf5t/pIYgJjek/hZOqjg4/FLdnc X73HgB1Ka0pmewe+ZRTd9XU+KXNx9aW8iOYdS0WZlSzOCacHmVTDSbaScwADWBepUv0f 8nJg== 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:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=CTOwkFUbIy08mEjbwj0bYGRUO57VUe1/SfMIuhw6a7o=; b=mda8dfbGfjNdjoeyRna6uY6OQ6r01t3Ens1Gl9+JPlukWcQmN/tjW7Q9FMKE87/s4C kajRabNmTnkbqjEuYTjHUEqb9sChk1BqyzdiLJdNVxCXNLnOVDDayvbH9H/mrF9+gn9f ceWPKzZn4QE3uH3WBzVCvRiBd62tHJx9Hhq5ihw/Qn4z7DGRRpZUzF21HRA3/uw2857b h15nKT2jRfSqnVSUN2KGV0xPwhtN6AEd9F+1cwBcDjuQ0iFTnGLn2pO28qT8Mm4P1cOK w1FFCH+/qH29rMsVM52RUr/8CjgxzU3gOqkLWQVjt7Wa1kB9KtM7cyesS0zXlKZCOPTz kWnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=YJdAgluG; 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 i23si308638oto.206.2020.02.10.07.15.26; Mon, 10 Feb 2020 07:15:37 -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=YJdAgluG; 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 S1729272AbgBJPO4 (ORCPT + 99 others); Mon, 10 Feb 2020 10:14:56 -0500 Received: from lelv0142.ext.ti.com ([198.47.23.249]:34450 "EHLO lelv0142.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727008AbgBJPO4 (ORCPT ); Mon, 10 Feb 2020 10:14:56 -0500 Received: from lelv0266.itg.ti.com ([10.180.67.225]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id 01AFE2sT013007; Mon, 10 Feb 2020 09:14:02 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1581347642; bh=CTOwkFUbIy08mEjbwj0bYGRUO57VUe1/SfMIuhw6a7o=; h=From:To:CC:Subject:Date; b=YJdAgluGxWR+XkmDaVObE+r3ioGNcRp/i1zcMmlGJqDdCzJLM5m68BQC4HYKktbTX YX4ybkkc9sOkJd1j5EEv87GfRzZz+oeOnSFoD0+hZlQpyrIUoGHCQEHN5V24YxwXJN Z26+N3TYLUZPNUzlfJ8GQ6Obx3XyETlDjIoXftlI= Received: from DLEE105.ent.ti.com (dlee105.ent.ti.com [157.170.170.35]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 01AFE2f3064432 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 10 Feb 2020 09:14:02 -0600 Received: from DLEE111.ent.ti.com (157.170.170.22) by DLEE105.ent.ti.com (157.170.170.35) 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:14:02 -0600 Received: from fllv0039.itg.ti.com (10.64.41.19) by DLEE111.ent.ti.com (157.170.170.22) 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:14:02 -0600 Received: from feketebors.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0039.itg.ti.com (8.15.2/8.15.2) with ESMTP id 01AFDxp6020133; Mon, 10 Feb 2020 09:14:00 -0600 From: Peter Ujfalusi To: , , , CC: , , , Subject: [PATCH v2] ALSA: dmaengine_pcm: Consider DMA cache caused delay in pointer callback Date: Mon, 10 Feb 2020 17:14:02 +0200 Message-ID: <20200210151402.29634-1-peter.ujfalusi@ti.com> X-Mailer: git-send-email 2.25.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain 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 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); } return bytes_to_frames(substream->runtime, pos); -- Peter Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki