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 93262C3DA7A for ; Thu, 5 Jan 2023 08:56:02 +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 BEFE010099; Thu, 5 Jan 2023 09:55:08 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz BEFE010099 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1672908958; bh=sJOKWRxD/w9OFW5rHNCIzFI0oe4k9NP7xI+yFJkqbVY=; h=Date:From:To:Subject:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=m/fgAHL+9m/fFD3elum3jUlDxYalCsUYY4G2mUj1QDfUNQ9bNPgeK43VXT4yAp4dL Bf46SabemzbxMEeahwqMFltayMGmK6XHjk7ce0sk8Tg0+UtIjzXzrGm/LkQaeFHv7n /CObOqVTflITR1nvbwStLhMeB9+LBYUJ2Qr2/094= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 71F5FF8047B; Thu, 5 Jan 2023 09:55:08 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 1393CF804AA; Thu, 5 Jan 2023 09:55:07 +0100 (CET) Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) (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 73CBEF804AD for ; Thu, 5 Jan 2023 09:55:04 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 73CBEF804AD 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=uCiWNYqL; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=6/bNP8g/ 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-out2.suse.de (Postfix) with ESMTPS id 3888623071; Thu, 5 Jan 2023 08:55:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1672908904; 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=IHOYC6vfUa6VVFgCcPoqOyMNWdBh/humVgArq1I7u+A=; b=uCiWNYqLGWlCrP4+sxvzylCpKldvKj02X/dPIZ/LiBQgA1w6rsuZxTcNAgN0A39Zxrd1O/ WqEbr3aDmlfn+lcVFWWwmw1Nq0n6RFGVKJer+nMv5+eWW/8u1/ORb7zrh90efyz9k/IcJe EHtvWcyApVkMjJAA3WkvNhRIzvcqIbs= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1672908904; 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=IHOYC6vfUa6VVFgCcPoqOyMNWdBh/humVgArq1I7u+A=; b=6/bNP8g/DknzW+F86MsMEJ9LltOtvCIBf93a68f0ZF8SqXHxKk8kRGQot8mDBhlERErfwB kFnjvLITCP8cXvCA== 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 0C8A613273; Thu, 5 Jan 2023 08:55:04 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id NgZ3AmiQtmNpKAAAMHmgww (envelope-from ); Thu, 05 Jan 2023 08:55:04 +0000 Date: Thu, 05 Jan 2023 09:55:03 +0100 Message-ID: <877cy1mkd4.wl-tiwai@suse.de> From: Takashi Iwai To: Ben Carter Subject: Re: [PATCH] sound: hda: increase timeouts to stop crash on resume with ALC3204 and others In-Reply-To: <20230104221024.23524-1-craterrender@gmail.com> References: <20230104221024.23524-1-craterrender@gmail.com> 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 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.29 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: , Cc: Cezary Rojewski , alsa-devel@alsa-project.org, Divya Prakash , Takashi Iwai , Mark Brown , Amadeusz =?ISO-8859-2?Q?S=B3awi=F1s?= =?ISO-8859-2?Q?ki?= , linux-kernel@vger.kernel.org Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" On Wed, 04 Jan 2023 23:10:24 +0100, Ben Carter wrote: > > Upon waking after system suspend, ALSA often crashed with: > snd_hda_intel 0000:00:1f.3: CORB reset timeout#2, CORBRP = 65535 > snd_hda_codec_hdmi hdaudioC1D2: Unable to sync register 0x2f8100. -5 > snd_hda_codec_realtek hdaudioC1D0: Unable to sync register 0x2b8000. -5 > A temporary fix was established by reloading snd_hda_intel, but increasing > the rather strict timeout of 1ms to 100ms has remedied the issue on my > device. Although this is a much larger delay, most hardware took less than > 1ms anyway and it's preferable to the whole audio system crashing. 100ms is way too long for an atomic context. How long it took in reality? If we extend to 100ms, the loop should be outside the spinlock. Maybe it's worth to rewrite with the standard iopoll helper, too. thanks, Takashi > > Signed-off-by: Ben Carter > --- > sound/hda/hdac_controller.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/sound/hda/hdac_controller.c b/sound/hda/hdac_controller.c > index 3c7af6558249..1ab573248452 100644 > --- a/sound/hda/hdac_controller.c > +++ b/sound/hda/hdac_controller.c > @@ -16,7 +16,7 @@ static void azx_clear_corbrp(struct hdac_bus *bus) > { > int timeout; > > - for (timeout = 1000; timeout > 0; timeout--) { > + for (timeout = 100000; timeout > 0; timeout--) { > if (snd_hdac_chip_readw(bus, CORBRP) & AZX_CORBRP_RST) > break; > udelay(1); > @@ -26,7 +26,7 @@ static void azx_clear_corbrp(struct hdac_bus *bus) > snd_hdac_chip_readw(bus, CORBRP)); > > snd_hdac_chip_writew(bus, CORBRP, 0); > - for (timeout = 1000; timeout > 0; timeout--) { > + for (timeout = 100000; timeout > 0; timeout--) { > if (snd_hdac_chip_readw(bus, CORBRP) == 0) > break; > udelay(1); > -- > 2.39.0 > 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5B96CC3DA7D for ; Thu, 5 Jan 2023 08:55:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231347AbjAEIzK (ORCPT ); Thu, 5 Jan 2023 03:55:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49180 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230292AbjAEIzH (ORCPT ); Thu, 5 Jan 2023 03:55:07 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5628837274 for ; Thu, 5 Jan 2023 00:55:06 -0800 (PST) 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-out2.suse.de (Postfix) with ESMTPS id 3888623071; Thu, 5 Jan 2023 08:55:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1672908904; 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=IHOYC6vfUa6VVFgCcPoqOyMNWdBh/humVgArq1I7u+A=; b=uCiWNYqLGWlCrP4+sxvzylCpKldvKj02X/dPIZ/LiBQgA1w6rsuZxTcNAgN0A39Zxrd1O/ WqEbr3aDmlfn+lcVFWWwmw1Nq0n6RFGVKJer+nMv5+eWW/8u1/ORb7zrh90efyz9k/IcJe EHtvWcyApVkMjJAA3WkvNhRIzvcqIbs= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1672908904; 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=IHOYC6vfUa6VVFgCcPoqOyMNWdBh/humVgArq1I7u+A=; b=6/bNP8g/DknzW+F86MsMEJ9LltOtvCIBf93a68f0ZF8SqXHxKk8kRGQot8mDBhlERErfwB kFnjvLITCP8cXvCA== 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 0C8A613273; Thu, 5 Jan 2023 08:55:04 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id NgZ3AmiQtmNpKAAAMHmgww (envelope-from ); Thu, 05 Jan 2023 08:55:04 +0000 Date: Thu, 05 Jan 2023 09:55:03 +0100 Message-ID: <877cy1mkd4.wl-tiwai@suse.de> From: Takashi Iwai To: Ben Carter Cc: Jaroslav Kysela , Takashi Iwai , Cezary Rojewski , Amadeusz =?ISO-8859-2?Q?S=B3awi=F1s?= =?ISO-8859-2?Q?ki?= , Mark Brown , Divya Prakash , alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] sound: hda: increase timeouts to stop crash on resume with ALC3204 and others In-Reply-To: <20230104221024.23524-1-craterrender@gmail.com> References: <20230104221024.23524-1-craterrender@gmail.com> 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 04 Jan 2023 23:10:24 +0100, Ben Carter wrote: > > Upon waking after system suspend, ALSA often crashed with: > snd_hda_intel 0000:00:1f.3: CORB reset timeout#2, CORBRP = 65535 > snd_hda_codec_hdmi hdaudioC1D2: Unable to sync register 0x2f8100. -5 > snd_hda_codec_realtek hdaudioC1D0: Unable to sync register 0x2b8000. -5 > A temporary fix was established by reloading snd_hda_intel, but increasing > the rather strict timeout of 1ms to 100ms has remedied the issue on my > device. Although this is a much larger delay, most hardware took less than > 1ms anyway and it's preferable to the whole audio system crashing. 100ms is way too long for an atomic context. How long it took in reality? If we extend to 100ms, the loop should be outside the spinlock. Maybe it's worth to rewrite with the standard iopoll helper, too. thanks, Takashi > > Signed-off-by: Ben Carter > --- > sound/hda/hdac_controller.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/sound/hda/hdac_controller.c b/sound/hda/hdac_controller.c > index 3c7af6558249..1ab573248452 100644 > --- a/sound/hda/hdac_controller.c > +++ b/sound/hda/hdac_controller.c > @@ -16,7 +16,7 @@ static void azx_clear_corbrp(struct hdac_bus *bus) > { > int timeout; > > - for (timeout = 1000; timeout > 0; timeout--) { > + for (timeout = 100000; timeout > 0; timeout--) { > if (snd_hdac_chip_readw(bus, CORBRP) & AZX_CORBRP_RST) > break; > udelay(1); > @@ -26,7 +26,7 @@ static void azx_clear_corbrp(struct hdac_bus *bus) > snd_hdac_chip_readw(bus, CORBRP)); > > snd_hdac_chip_writew(bus, CORBRP, 0); > - for (timeout = 1000; timeout > 0; timeout--) { > + for (timeout = 100000; timeout > 0; timeout--) { > if (snd_hdac_chip_readw(bus, CORBRP) == 0) > break; > udelay(1); > -- > 2.39.0 >