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=-13.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 C2097C433E0 for ; Sat, 26 Dec 2020 07:47:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 82850221E7 for ; Sat, 26 Dec 2020 07:47:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728542AbgLZHrY (ORCPT ); Sat, 26 Dec 2020 02:47:24 -0500 Received: from mx2.suse.de ([195.135.220.15]:58050 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725979AbgLZHrX (ORCPT ); Sat, 26 Dec 2020 02:47:23 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 6FEEBAD29; Sat, 26 Dec 2020 07:46:41 +0000 (UTC) Date: Sat, 26 Dec 2020 08:46:41 +0100 Message-ID: From: Takashi Iwai To: Kai-Heng Feng Cc: tiwai@suse.com, Jaroslav Kysela , Pierre-Louis Bossart , Kai Vehmanen , Ranjani Sridharan , Mark Brown , Randy Dunlap , =?UTF-8?B?TWljaGHFgiBNaXJvc8WCYXc=?= , alsa-devel@alsa-project.org (moderated list:SOUND), linux-kernel@vger.kernel.org (open list) Subject: Re: [PATCH] ALSA: hda: Resume codec for system suspend if LED is controlled by codec In-Reply-To: <20201225164727.103280-1-kai.heng.feng@canonical.com> References: <20201225164727.103280-1-kai.heng.feng@canonical.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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 25 Dec 2020 17:47:23 +0100, Kai-Heng Feng wrote: > > Laptop with codec controlled LEDs takes a very long time to suspend > after commit 215a22ed31a1 ("ALSA: hda: Refactor codec PM to use > direct-complete optimization"): > [ 90.065964] PM: suspend entry (s2idle) > [ 90.067337] Filesystems sync: 0.001 seconds > [ 90.185758] Freezing user space processes ... (elapsed 0.002 seconds) done. > [ 90.188713] OOM killer disabled. > [ 90.188714] Freezing remaining freezable tasks ... (elapsed 0.001 seconds) done. > [ 90.190024] printk: Suspending console(s) (use no_console_suspend to debug) > [ 90.904912] intel_pch_thermal 0000:00:12.0: CPU-PCH is cool [49C], continue to suspend > [ 321.262505] snd_hda_codec_realtek ehdaudio0D0: Unable to sync register 0x2b8000. -5 > [ 328.426919] snd_hda_codec_realtek ehdaudio0D0: Unable to sync register 0x2b8000. -5 > [ 329.490933] ACPI: EC: interrupt blocked > > That commit keeps codec suspended during the system suspend. This > doesn't play well with codec controlled mute and micmute LEDs, because > LED core will use codec registers to turn off those LEDs. > > Currently, all users of create_mute_led_cdev() use codec to control > LED, so unconditionally runtime resume those codecs before system > suspend to solve the problem. > > Fixes: 215a22ed31a1 ("ALSA: hda: Refactor codec PM to use direct-complete optimization") > Signed-off-by: Kai-Heng Feng A puzzling point is that it's applied only to the cases with the led cdev. Or does it basically apply for the ASoC controller? That is, if you run with legacy HDA (snd-intel-dspcfg.dsp_driver=1), does the issue appear as well on those machines? thanks, Takashi > --- > include/sound/hda_codec.h | 1 + > sound/pci/hda/hda_codec.c | 7 +++++++ > sound/pci/hda/hda_generic.c | 1 + > 3 files changed, 9 insertions(+) > > diff --git a/include/sound/hda_codec.h b/include/sound/hda_codec.h > index 2e8d51937acd..b01d76abe008 100644 > --- a/include/sound/hda_codec.h > +++ b/include/sound/hda_codec.h > @@ -255,6 +255,7 @@ struct hda_codec { > unsigned int relaxed_resume:1; /* don't resume forcibly for jack */ > unsigned int forced_resume:1; /* forced resume for jack */ > unsigned int mst_no_extra_pcms:1; /* no backup PCMs for DP-MST */ > + unsigned int resume_for_sleep:1; /* runtime resume for system sleep */ > > #ifdef CONFIG_PM > unsigned long power_on_acct; > diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c > index 687216e74526..b890d9b4339e 100644 > --- a/sound/pci/hda/hda_codec.c > +++ b/sound/pci/hda/hda_codec.c > @@ -2983,6 +2983,13 @@ static int hda_codec_runtime_resume(struct device *dev) > #ifdef CONFIG_PM_SLEEP > static int hda_codec_pm_prepare(struct device *dev) > { > + struct hda_codec *codec = dev_to_hda_codec(dev); > + > + if (codec->resume_for_sleep) { > + pm_runtime_resume(dev); > + return 0; > + } > + > return pm_runtime_suspended(dev); > } > > diff --git a/sound/pci/hda/hda_generic.c b/sound/pci/hda/hda_generic.c > index 8060cc86dfea..6d259d5bb5bb 100644 > --- a/sound/pci/hda/hda_generic.c > +++ b/sound/pci/hda/hda_generic.c > @@ -3913,6 +3913,7 @@ static int create_mute_led_cdev(struct hda_codec *codec, > cdev->brightness_set_blocking = callback; > cdev->brightness = ledtrig_audio_get(micmute ? LED_AUDIO_MICMUTE : LED_AUDIO_MUTE); > cdev->flags = LED_CORE_SUSPENDRESUME; > + codec->resume_for_sleep = 1; > > return devm_led_classdev_register(&codec->core.dev, cdev); > } > -- > 2.29.2 >