Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3477508imu; Sun, 11 Nov 2018 16:01:15 -0800 (PST) X-Google-Smtp-Source: AJdET5dLD5ZnmORELmRRST34WsbsO36foa5OYp07GWtqAqTM0kVy1dVvGYnHGCM5V2eXNJVnS9eN X-Received: by 2002:a17:902:6a87:: with SMTP id n7-v6mr14774327plk.86.1541980875412; Sun, 11 Nov 2018 16:01:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541980875; cv=none; d=google.com; s=arc-20160816; b=qATRxTMNI8RLbDMNcf/jzXogPGmVRihVVxzINZWYLqCHb4Elnkq/L9srmRwgbTdJkH blgqjJAdpTwpU6Mez5Sbw8LurGoTjPMwSZRhmJtE6Y55LvytVi4/qQYlqj7snbG/V8Ns WwsU+SwTxMUQH6J0GWH5O0FL++51ZvB55x4DU7XZ8C5vQVClEo4xC//9/IGV6mhHl6nm zI6B1s5R3ziWQPrtvhXWF5ebxM/UcDDdlocA9QUABdM+PjRejXiu7wbx8yvJ85bmYZXD Hc2Ag0RbNued1hOChZizMKHg4jUQxTYYQ80Jp64Q5WJ5j82LsKbAEP70mUu3rzRYwHWD 8iRQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=pPm0kN2BQysj+iYHWaHvwYsovFbczboW2YpYOX/l28A=; b=ypi68rSZt44CvWfLbkxtSiEbmxS4dH4+8dwarnjpyfv1iP/ACaHfi41wfmj8ZMvdO2 jgWOLI6HTBBvj9gsvFSX8WkI3TN2AwYiiZHklR+m8duXlshU6NqljrID0Kmh2xFrXEbb 9J6ZAzmRQRPjqYYo7A53O2vwfTcWVC22sYfN0J/k8p+8tL3sdBxdqjrntA8MSKyxgyll Foxt6eEMbZWwyoasYBn5g+1oWExtp7zOYqQiZ3gTqSSruy8PR3kYn66EFXPSHhpwegiP PoD/JWDmOHg4MriSuQw6MJ9XsWw09p3dIMhGvzPoKr2D0v4JT1u2aso4oe6O+97SwW8w +sTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=tCTUq6x3; 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 r4si15040267pgi.387.2018.11.11.16.01.00; Sun, 11 Nov 2018 16:01:15 -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=@kernel.org header.s=default header.b=tCTUq6x3; 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 S1732308AbeKLISA (ORCPT + 99 others); Mon, 12 Nov 2018 03:18:00 -0500 Received: from mail.kernel.org ([198.145.29.99]:35400 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732294AbeKLIR7 (ORCPT ); Mon, 12 Nov 2018 03:17:59 -0500 Received: from localhost (unknown [206.108.79.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B0616223AE; Sun, 11 Nov 2018 22:28:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541975283; bh=ee2M+mpwY50XLQIDQpBzkGHZbftzzLCfOr3lPbFP+UI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tCTUq6x30cvnhOjrJRnzDlagVq4uVp0uKDF9CoAdL0f1MG7WQXmdY8tc0vdic+Jop EgcJ3pAI14ztm3ryhoDCayMnw7J5IG1XJSBaQlcpUUyO09ecVEK+T7xbPykRK91GBa y9JLp+o94K6bS05xu2nUUyXV7Va2aFqfziV1p7B8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Akshu Agrawal , Mark Brown , Sasha Levin Subject: [PATCH 4.19 176/361] ASoC: AMD: Fix capture unstable in beginning for some runs Date: Sun, 11 Nov 2018 14:18:43 -0800 Message-Id: <20181111221644.930639081@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181111221619.915519183@linuxfoundation.org> References: <20181111221619.915519183@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Akshu Agrawal [ Upstream commit c50535ed6a10fcae1b64ae83c0f6b1eeb5535afc ] alsa_conformance_test -C hw:0,4 -p 1024 --debug would sometime show: TIME_DIFF(s) HW_LEVEL READ RATE 0.000095970 1024 1024 10670001.041992 0.042609555 1024 2048 24032.168372 0.021330364 1024 3072 48006.681930 0.021339559 1024 4096 47985.996337 The issue is that in dma pointer function we can have stale value of the register for current descriptor of channel. The register retains the number of the last descriptor that was transferred. Fix ensures that we report position, 0, till the one period worth of data is transferred. After one period of data, in handler of period completion interrupt we update the config and correct value of descriptor starts reflecting. Signed-off-by: Akshu Agrawal Signed-off-by: Mark Brown Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- sound/soc/amd/acp-pcm-dma.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) --- a/sound/soc/amd/acp-pcm-dma.c +++ b/sound/soc/amd/acp-pcm-dma.c @@ -1036,16 +1036,22 @@ static snd_pcm_uframes_t acp_dma_pointer if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) { period_bytes = frames_to_bytes(runtime, runtime->period_size); - dscr = acp_reg_read(rtd->acp_mmio, rtd->dma_curr_dscr); - if (dscr == rtd->dma_dscr_idx_1) - pos = period_bytes; - else - pos = 0; bytescount = acp_get_byte_count(rtd); - if (bytescount > rtd->bytescount) + if (bytescount >= rtd->bytescount) bytescount -= rtd->bytescount; - delay = do_div(bytescount, period_bytes); - runtime->delay = bytes_to_frames(runtime, delay); + if (bytescount < period_bytes) { + pos = 0; + } else { + dscr = acp_reg_read(rtd->acp_mmio, rtd->dma_curr_dscr); + if (dscr == rtd->dma_dscr_idx_1) + pos = period_bytes; + else + pos = 0; + } + if (bytescount > 0) { + delay = do_div(bytescount, period_bytes); + runtime->delay = bytes_to_frames(runtime, delay); + } } else { buffersize = frames_to_bytes(runtime, runtime->buffer_size); bytescount = acp_get_byte_count(rtd);