Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp203858ybk; Thu, 14 May 2020 21:17:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy44Nw+Prn23O757Uiux3YIUc9gFdm03JQZ//euVPnD3ajKedjUCSuBystImxD27Qh6c3H7 X-Received: by 2002:a17:906:4d4a:: with SMTP id b10mr1039531ejv.262.1589516272634; Thu, 14 May 2020 21:17:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589516272; cv=none; d=google.com; s=arc-20160816; b=GWtPQaYHnugirp8IsIBKSTAnDkmlbT7DxLIv1uYm7tZEMmA3vBzJpiXHpSrPiB8z/A yh42Z9qEN3AeD+x59sAXaRiDNj8COvTj64IkBK0d1u8foaXEzK+4SiG7h1QmZGKP1PdP DhKuhuiuYWWBvZrIjVTe03/dnJfBipsFzxPiptKh0Zfp7XjFGEsRyUkc6FWLzM0iY1b6 ZNr1bA97Ex8aDnrKtH+5kq58oFiLeKVtQFbIlOQn0xCt2s76H/KJ3EIps2B9aKI4JGpH QtMBKDPv7wDmaRh/A7qYyxlYTHQd4RmxEmSkT8dlS/4s97wG7TGLs/4DGvvNPY1vsDPi HXGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :ironport-sdr:ironport-sdr; bh=E738n1ysAKl1vHFp6LpVBpUO73Qf0bv+mEpCkCL4ahc=; b=LLJ5Uv5WuMx2T+G0CX1AO4Pg3Vl3hg358RpQGlqxwN5c06NG94c6LQv4IQl3s1iAzC VCJiSDEE6bCMq2LDXyC/ZY0VUehBoTJR2yy2Fc86fD8j3S/XzJDQM6XP/POcn8ZTrgsq bIxtQgwzYkRZggQm/sC+gU7ECsb1ZxerjPGo5zW0nVY+9zbocwTGXNIi+Yj315qBl9rJ 8TkuO54c0SxSdLHZ8XEN/2LO8kRtuw6+8UK710P7CaCz3F8Pmu/hzTRuiOZrEdnSURy9 BdUZyQ7T9C2Uc3m026qB1bpzYmsiAYkGeHE0nXSTpYzWuojdXdaVwuihteTvq+1C6REh b3iw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w26si434432edq.38.2020.05.14.21.17.29; Thu, 14 May 2020 21:17:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726231AbgEOEPs (ORCPT + 99 others); Fri, 15 May 2020 00:15:48 -0400 Received: from mga09.intel.com ([134.134.136.24]:13161 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725616AbgEOEPs (ORCPT ); Fri, 15 May 2020 00:15:48 -0400 IronPort-SDR: yvDlW/4+FWbM5MqhgKyFCSgUJDIXvDmyoCRPYkLVEyhwT5jypkSrYlKX5TiUEZhwDwxcHrSotw sjfTa+wGgcSQ== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 May 2020 21:15:47 -0700 IronPort-SDR: h21gBEuc1WSXsq8NSuif0vOqjl206dBqGYH1UlpT5XC4yIptNdSmDunNfMV8M5pQJWRmKg1I1p 4q4+5QVdf89A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,393,1583222400"; d="scan'208";a="253683839" Received: from brentlu-desk0.itwn.intel.com ([10.5.253.11]) by fmsmga008.fm.intel.com with ESMTP; 14 May 2020 21:15:42 -0700 From: Brent Lu To: alsa-devel@alsa-project.org Cc: Jaroslav Kysela , Takashi Iwai , Baolin Wang , Arnd Bergmann , Greg Kroah-Hartman , Richard Fontana , Thomas Gleixner , Brent Lu , paulhsia , linux-kernel@vger.kernel.org Subject: [PATCH] ALSA: pcm: fix incorrect hw_base increase Date: Fri, 15 May 2020 12:09:39 +0800 Message-Id: <1589515779-20987-1-git-send-email-brent.lu@intel.com> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The hw_base will be increased by runtime->buffer_size frames unconditionally if the runtime->status->hw_ptr is not updated for over half of buffer time. As the hw_base increases, so does the runtime->status->hw_ptr which could lead to invalid return value when user space program calls snd_pcm_avail() function. By updating runtime->hw_ptr_jiffies each time the HWSYNC is called, the hw_base will keep the same when buffer stall happens, so does the hw_ptr. Signed-off-by: Brent Lu --- sound/core/pcm_lib.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sound/core/pcm_lib.c b/sound/core/pcm_lib.c index 872a852..d531e1b 100644 --- a/sound/core/pcm_lib.c +++ b/sound/core/pcm_lib.c @@ -433,6 +433,7 @@ static int snd_pcm_update_hw_ptr0(struct snd_pcm_substream *substream, no_delta_check: if (runtime->status->hw_ptr == new_hw_ptr) { + runtime->hw_ptr_jiffies = curr_jiffies; update_audio_tstamp(substream, &curr_tstamp, &audio_tstamp); return 0; } -- 2.7.4