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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 0F6CCC76196 for ; Thu, 6 Apr 2023 15:02:42 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 7C80CEDB; Thu, 6 Apr 2023 17:01:50 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 7C80CEDB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1680793360; bh=P43ElmAsX93VFPSHv4IXSYsDYMMMl79AyWqnX6zZydU=; h=Date:From:To:Subject:In-Reply-To:References:CC:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=s6gHW0ZY4jv7V4O7UXa+pjcRGU1YcPvpglSaJfz4veZLN0vRBlqaljPkj0tW9aq1F 4k2PDhvesb+T3XZLcUg2eytip/R9H0/5y6JsQndy8AGLN+TZtcgmFPvrMGLw0NB8M+ V8M69FbpVvft/mkk/hBeGlc3CAM6/6LSE1AmEALE= Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 40403F80149; Thu, 6 Apr 2023 17:01:28 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id E0082F80246; Thu, 6 Apr 2023 17:01:24 +0200 (CEST) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 5FF70F8015B for ; Thu, 6 Apr 2023 17:01:21 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 5FF70F8015B Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key, unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=bulNN/ha; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=p2/HfqPT Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id BBF3E2277D; Thu, 6 Apr 2023 15:01:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1680793280; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=rkFAOuoZZGRLa/Itf5pOxP/nosmjxLeOoQzFJQ+UWgc=; b=bulNN/hag/ltlA2zb+NGJM5m5WzFOVD+1L6iG5P3arrUWRAVL/cW822WWa1rozEhARcuTA cnmWbHee6ZdMgdnchGNBUw70ZIkhIH6OtTAdz6y7SZOvz/5xOyeU01Eo6RenXhONa7Qly8 WkKSRALTVpsFy1sS6c8HjctS4R2xFIs= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1680793280; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=rkFAOuoZZGRLa/Itf5pOxP/nosmjxLeOoQzFJQ+UWgc=; b=p2/HfqPTenjBmqOX8gUzXKCGL2YoiJGA3nz6vqJxBsEFFMpB+SaqCFlBpU6zvoIRTzcznU 8uyWFfc8/kgDVtCQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id A4807133E5; Thu, 6 Apr 2023 15:01:20 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id ruNrJ8DeLmSuPwAAMHmgww (envelope-from ); Thu, 06 Apr 2023 15:01:20 +0000 Date: Thu, 06 Apr 2023 17:01:20 +0200 Message-ID: <877cupt5q7.wl-tiwai@suse.de> From: Takashi Iwai To: Oswald Buddenhagen Subject: Re: [PATCH] ALSA: pcm: fix wait_time calculations In-Reply-To: <20230405201219.2197774-1-oswald.buddenhagen@gmx.de> References: <20230405201219.2197774-1-oswald.buddenhagen@gmx.de> User-Agent: Wanderlust/2.15.9 (Almost Unreal) Emacs/27.2 Mule/6.0 MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII Message-ID-Hash: EGVG6QJRRLVRPLNUKZ6GDGFXJHGFQSPE X-Message-ID-Hash: EGVG6QJRRLVRPLNUKZ6GDGFXJHGFQSPE X-MailFrom: tiwai@suse.de X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: alsa-devel@alsa-project.org X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: On Wed, 05 Apr 2023 22:12:19 +0200, Oswald Buddenhagen wrote: > > ... in wait_for_avail() and snd_pcm_drain(). > > t was calculated in seconds, so it would be pretty much always zero, to > be subsequently de-facto ignored due to being max(t, 10)'d. And then it > (i.e., 10) would be treated as secs, which doesn't seem right. > > However, fixing it to properly calculate msecs would potentially cause > timeouts when using twice the period size for the default timeout (which > seems reasonable to me), so instead use the buffer size plus 10 percent > to be on the safe side ... but that still seems insufficient, presumably > because the hardware typically needs a moment to fire up. To compensate > for this, we up the minimal timeout to 100ms, which is still two orders > of magnitude less than the bogus minimum. > > substream->wait_time was also misinterpreted as jiffies, despite being > documented as being in msecs. Only the soc/sof driver sets it - to 500, > which looks very much like msecs were intended. > > Speaking of which, shouldn't snd_pcm_drain() also use substream-> > wait_time? Yes, and unifying the code might make more sense. > As a drive-by, make the debug messages on timeout less confusing. > > Signed-off-by: Oswald Buddenhagen I applied this patch as is now to for-next branch. thanks, Takashi