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 9CEA5C352A1 for ; Wed, 7 Dec 2022 10:32:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229609AbiLGKcy (ORCPT ); Wed, 7 Dec 2022 05:32:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59418 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229522AbiLGKcu (ORCPT ); Wed, 7 Dec 2022 05:32:50 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 400151F2C7 for ; Wed, 7 Dec 2022 02:32:49 -0800 (PST) Received: from imap1.suse-dmz.suse.de (imap1.suse-dmz.suse.de [192.168.254.73]) (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 012B921C1A; Wed, 7 Dec 2022 10:32:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1670409168; 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=eKVlMJ51CppPCOSDHD95loKLQZYt0ubpr1b9urDAxbc=; b=qniScK7JS4/6eNrlHzwYLy2i40lYaEeGCAlKNaXk8XE7C1GauzX6qI80P7TCl0GlMyBOCM w57c2BsHTrAPZONn7x8T8JeDCXA8y9ZjZpQQCpmLe/bctxnOcWl2ntvPNywYQ8UxJ4zAyA Jv0EkFAiwCqjGiPHD/OL8eNE6Am7CEc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1670409168; 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=eKVlMJ51CppPCOSDHD95loKLQZYt0ubpr1b9urDAxbc=; b=e3NyDxwCsdQfKjAillCtcjTuiHRUYN5WvlNunUMQdSzBe5N60E6d8J3vrhArHLr6RnrUy7 +o+8hzq+rE6MbdAQ== Received: from imap1.suse-dmz.suse.de (imap1.suse-dmz.suse.de [192.168.254.73]) (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 imap1.suse-dmz.suse.de (Postfix) with ESMTPS id B3DA3134CD; Wed, 7 Dec 2022 10:32:47 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap1.suse-dmz.suse.de with ESMTPSA id 3k0jK89rkGNHDwAAGKfGzw (envelope-from ); Wed, 07 Dec 2022 10:32:47 +0000 Date: Wed, 07 Dec 2022 11:32:47 +0100 Message-ID: <87cz8va4hc.wl-tiwai@suse.de> From: Takashi Iwai To: Zhen Ni Cc: perex@perex.cz, tiwai@suse.com, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Pierre-Louis Bossart , Kai Vehmanen , Ricardo Ribalda Subject: Re: [PATCH] ASoc: SOF: Fix sof-audio-pci-intel-tgl shutdown timeout during hibernation In-Reply-To: <20221207102229.25962-1-nizhen@uniontech.com> References: <20221207102229.25962-1-nizhen@uniontech.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, 07 Dec 2022 11:22:29 +0100, Zhen Ni wrote: > > On Dell Latitude 3420 Notebook, sof-audio-pci-intel-tgl may fail to shutdown > sporadically during hibernation as following log: > > [ 43.281110] PM: Image saving done > [ 43.281699] PM: hibernation: Wrote 2828852 kbytes in 2.78 seconds(1017.57 MB/s) > [ 43.282359] PM: SI > [ 43.345156] kvm: exiting hardware virtualization > [ 43.345865] auxiliary snd_sof.hda-probes.0: shutdown > [ 43.346359] skl_hda_dsp_generic skl_hda_dsp_generic: shutdown > [ 43.346849] skl_hda_codec hdmi ehdaudio0D2: shutdown > [ 43.398204] snd_hda_codec_realtek ehdaudio0DO: shutdown > [ 43.419621] dmic-codec dmic-codec: shutdown > [ 43.420194] sof-audio-pci-intel-tgl 0000:00:1f.3: shutdown > > Call wait_xxx_timeout() to process the timeout. > > Signed-off-by: Zhen Ni It's a known problem and being discussed (although it's a slightly different code path): https://lore.kernel.org/r/20221127-snd-freeze-v4-0-51ca64b7f2ab@chromium.org We need the proper fix for ASoC shutdown. Adding relevant people to Cc. And, the unconditional exit from the sync is dangerous. It may lead to use-after-free or such. thanks, Takashi > --- > sound/core/init.c | 7 ++++--- > 1 file changed, 4 insertions(+), 3 deletions(-) > > diff --git a/sound/core/init.c b/sound/core/init.c > index 5377f94eb211..9bd674d7a0fd 100644 > --- a/sound/core/init.c > +++ b/sound/core/init.c > @@ -574,9 +574,10 @@ void snd_card_disconnect_sync(struct snd_card *card) > } > > spin_lock_irq(&card->files_lock); > - wait_event_lock_irq(card->remove_sleep, > + wait_event_lock_irq_timeout(card->remove_sleep, > list_empty(&card->files_list), > - card->files_lock); > + card->files_lock, > + msecs_to_jiffies(2000)); > spin_unlock_irq(&card->files_lock); > } > EXPORT_SYMBOL_GPL(snd_card_disconnect_sync); > @@ -659,7 +660,7 @@ int snd_card_free(struct snd_card *card) > if (ret) > return ret; > /* wait, until all devices are ready for the free operation */ > - wait_for_completion(&released); > + wait_for_completion_timeout(&released, msecs_to_jiffies(2000)) > > return 0; > } > -- > 2.20.1 > >