Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp290260ybk; Fri, 15 May 2020 00:23:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx92C8awVL54ohYkDj6qs2nggFGFoDNFcBGdlO7K+GtfXyIg5+qa00txsDbedpfycykNUEp X-Received: by 2002:a17:906:46d3:: with SMTP id k19mr1468791ejs.349.1589527390394; Fri, 15 May 2020 00:23:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589527390; cv=none; d=google.com; s=arc-20160816; b=zKNjeJs+ZH6oqQwlSEgNPH3p9qrWcGYm14VjLMy4EltkHCMWeO+OT+4N47AwtgEJ5R sX2y3SF2z6fR0GNIOmHyKpVrLszhIMcLY4ECU4o/87XkLpdXPyXfwZ62giCD47MPoGeF dFOWfoUf2j7nIEFUtJLsnTFwcWKeypcZzaeOPAp/x2sJ4QjNY8bbXgTBw/so4WcSfJVF 0wj3xnbHxMjxzlWbXKCNDYn0AuFaz0Gg30UdF3fEQ1YLng/ws9a4OLY4zujLGmKCPfUN rHcaqm9SB4OlNdkBGEIYbJEVDT1ZQ2agiXCiWnoydQPa1SMuqffHf/dMY24Boi/ju8qH /kvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:subject:cc:to:from:message-id:date; bh=DozHvpUtFyAP/V2iMIU624L2b1sNJ9yi+ncJ4f0Utmc=; b=F2yZBFaopDgEtVBUyt7h+8u7jDUNz0GlMH2s0svBBkSufO/wJFAzNYUqs+u/Rr4/nt tNBaXBZ9ZSGN6XaIiRvGb0ROC5tLCWxUvox4S5I0bUTdkPC/txvpEWVSsBA7tm7nR1M1 n6tRZiVHzo8z/p5GRVMTP4q/mtOKaUa/4USP1W9u0+P2/N5gAoluoUq4HKABS/4xOcHm zP1a8gCFRybBVxCg0KCzkUj8Lvq+LKzTBy7a7QZBjwNJ/S0t/UYY+Tw27D5folyGh+Nj lpmvMLWTSh+2LMLKRGagKYOUdV03ohmumf1Mr8BhLdaKxW4yqELTCcENjPsOOxewnBCo AV5g== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d60si659467edc.337.2020.05.15.00.22.45; Fri, 15 May 2020 00:23:10 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726622AbgEOHVN (ORCPT + 99 others); Fri, 15 May 2020 03:21:13 -0400 Received: from mx2.suse.de ([195.135.220.15]:49682 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726496AbgEOHVM (ORCPT ); Fri, 15 May 2020 03:21:12 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 3553AACC5; Fri, 15 May 2020 07:21:14 +0000 (UTC) Date: Fri, 15 May 2020 09:21:10 +0200 Message-ID: From: Takashi Iwai To: Brent Lu Cc: , Jaroslav Kysela , Takashi Iwai , Baolin Wang , Arnd Bergmann , Greg Kroah-Hartman , Richard Fontana , Thomas Gleixner , paulhsia , Subject: Re: [PATCH] ALSA: pcm: fix incorrect hw_base increase In-Reply-To: <1589515779-20987-1-git-send-email-brent.lu@intel.com> References: <1589515779-20987-1-git-send-email-brent.lu@intel.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.8 Emacs/25.3 (x86_64-suse-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 15 May 2020 06:09:39 +0200, Brent Lu wrote: > > 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. Updating hw_ptr_jiffies at that code path looks correct, but it still leaves the question why this condition happens. It means that the actual hwptr isn't changed and yet only jiffies increase significantly; it means that the hardware can't report proper pointer, and it should have set SNDRV_PCM_INFO_BATCH flag, then the jiffies check is skipped. With which hardware and under which situation did it happen (and the patch fixed)? thanks, Takashi > > 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 >