From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.7 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 99A9BCA9EB6 for ; Wed, 23 Oct 2019 13:30:28 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 98B8221906 for ; Wed, 23 Oct 2019 13:30:27 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="S7Ao0d8s" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 98B8221906 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 5DE3084C; Wed, 23 Oct 2019 15:29:35 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 5DE3084C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1571837425; bh=9aG8UQi5fC3gbx8CKYInWngBURglCGHX07pFcUMdx2Y=; h=Date:From:To:In-Reply-To:References:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=S7Ao0d8sbYMesgmFM1SK54Q9i00B3K9inti2CJCi9khZWfIYx5Mz3ns/HD8a6T5RA 6vqY+nCHfp6VlFdGdZDcgSh+7gstQ74l+NXofQ2XPhK5wjtSI7DozFvl3NFSSstgZh iSv5i1znuTTBuaySyev9SkmEAD3LQ16bB0AkHZHc= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id CC745F80321; Wed, 23 Oct 2019 15:29:34 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 546FDF80368; Wed, 23 Oct 2019 15:29:31 +0200 (CEST) Received: from mx1.suse.de (mx2.suse.de [195.135.220.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 7EE36F80112 for ; Wed, 23 Oct 2019 15:29:28 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 7EE36F80112 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 66EDCB8BE; Wed, 23 Oct 2019 13:29:27 +0000 (UTC) Date: Wed, 23 Oct 2019 15:29:27 +0200 Message-ID: From: Takashi Iwai To: Srinivas Kandagatla In-Reply-To: <20191023120114.17445-1-srinivas.kandagatla@linaro.org> References: <20191023120114.17445-1-srinivas.kandagatla@linaro.org> 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") Cc: alsa-devel@alsa-project.org, bgoswami@codeaurora.org, spapothi@codeaurora.org, tiwai@suse.com, Preetam Singh Ranawat , vkoul@kernel.org, broonie@kernel.org Subject: Re: [alsa-devel] [RFC PATCH] ALSA: pcm: fix blocking while loop in snd_pcm_update_hw_ptr0() X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" On Wed, 23 Oct 2019 14:01:14 +0200, Srinivas Kandagatla wrote: > > From: Preetam Singh Ranawat > > When period interrupts are disabled, while loop in snd_pcm_update_hw_ptr0() > results in the machine locking up if runtime->hw_ptr_buffer_jiffies is 0. > > Validate runtime->hw_ptr_buffer_jiffies value before while loop to avoid > delta check. Although the fix itself is fine, I still wonder how this is triggered. Could you check in what kind of PCM state is it? Basically snd_pcm_update_hw_ptr*() is called only in the running PCM state, and for that, we should have set hw_ptr_buffer_jiffies at snd_pcm_post_start(). It's runtime->hw_ptr_buffer_jiffies = (runtime->buffer_size * HZ) / runtime->rate; So maybe the given buffer size is so small and hw_ptr_buffer_jiffies is really 0? thanks, Takashi > > Signed-off-by: Preetam Singh Ranawat > Signed-off-by: Srinivas Kandagatla > --- > > This issue was noticed in Android setup from fastcapture path. > > sound/core/pcm_lib.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/sound/core/pcm_lib.c b/sound/core/pcm_lib.c > index d80041ea4e01..f407f6895f8a 100644 > --- a/sound/core/pcm_lib.c > +++ b/sound/core/pcm_lib.c > @@ -341,7 +341,8 @@ static int snd_pcm_update_hw_ptr0(struct snd_pcm_substream *substream, > * the elapsed time to detect xruns. > */ > jdelta = curr_jiffies - runtime->hw_ptr_jiffies; > - if (jdelta < runtime->hw_ptr_buffer_jiffies / 2) > + if ((jdelta < runtime->hw_ptr_buffer_jiffies / 2) || > + !runtime->hw_ptr_buffer_jiffies) > goto no_delta_check; > hdelta = jdelta - delta * HZ / runtime->rate; > xrun_threshold = runtime->hw_ptr_buffer_jiffies / 2 + 1; > -- > 2.21.0 > _______________________________________________ Alsa-devel mailing list Alsa-devel@alsa-project.org https://mailman.alsa-project.org/mailman/listinfo/alsa-devel