Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp3969443img; Mon, 25 Mar 2019 23:47:41 -0700 (PDT) X-Google-Smtp-Source: APXvYqyTjACHUbpDj5w2+fMDzefLop58aDOUp/yRe6jiC3W4enCvMPiCj5Yi8luMv+FTANc4g9/P X-Received: by 2002:a63:c61:: with SMTP id 33mr20634354pgm.293.1553582861617; Mon, 25 Mar 2019 23:47:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553582861; cv=none; d=google.com; s=arc-20160816; b=Z3+sjB9yeX8zTrPS22m+dxUEAZ1Pf7j3vaskWQrHHmD55lxBM03+5TAuVG4wiZiW/+ x3HF0BtPclsdLEN53vAQkV77MXgZyCICtLjiGye8/r3ktXV0mtXddyFSzqG3WobaSyv7 /FnniXX9eB5gLexknAnl7p5BiQ7xOqfsS6EefLujRb+vK3aXNpdTFmFihjqrRNL68Jnm 1ctVcpVNvDsEQ1yfsHVr1WgJypPnyVP3zIfegecHUCqc7LCr1vnHAdd9kKm9kTKnQpFy nhXlMSKTTsYFyUKauAOSJ2yWr7S6uUXVLE17SL+e9PxlT0Wcsl/38gkpHLroTtJZGMUE EFDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=bnjvfu8xdSpY3En+kXbLFoMzg4N54VBqx40JTEdjEgI=; b=JUm0SOidWAxH64zB/rXCeE4wr+iZfY7XhQKs6UAXG6LV6M6hGudv5m1FwufIx/InML 3G2/ztofs/os1I4TG5iBRtt1XHoDHqGG7QVgg84E7AWqcC7pO2j4NDt76GQGSc2I4C7B AVFQFxJU23+FzEgbqcpf/rr2c8nwqBhih/dO83H4rsGjTnuqgY27xZkzhTak24TyxGIs 82uLvWKj3ck/t86FhfQTKGbwr9qoXYVb5IVOAxgBtfN1V7MXqhJnvTYSxk958C6NID8v rKbYIaZHm5EWwTXZdlbTKKkZ6ObfP0CoEhG40Hbk29fiw5Cc4UaUjcglwKbHQngvwvP2 S2iQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=NBHCHCdd; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a21si15238829pgg.330.2019.03.25.23.47.26; Mon, 25 Mar 2019 23:47:41 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=NBHCHCdd; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731480AbfCZGcl (ORCPT + 99 others); Tue, 26 Mar 2019 02:32:41 -0400 Received: from mail.kernel.org ([198.145.29.99]:42048 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731467AbfCZGcj (ORCPT ); Tue, 26 Mar 2019 02:32:39 -0400 Received: from localhost (unknown [104.132.152.111]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 33AEA20857; Tue, 26 Mar 2019 06:32:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553581957; bh=Nt2YkjMrtUZ7eZwlX7JONgUPwP/zg5iNfWt8hrRX3ss=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NBHCHCddV7hCL3Yoz/PUOrKgIQ6MAwyzNx+bQjW1G4RqOM5Jcn2eUZ0eXDV68dGd+ kXBds+X36t44pm+pBrjSw4baA9lJk1s1wzX7IINiOIT7JrwD/Nc4NM9vvdWDosiPzO qkuJU030hY03tEs6uuqY4KQyDMJHYeRgKNDwP7Mk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hui Wang , Takashi Iwai Subject: [PATCH 4.9 18/30] ALSA: hda - Enforces runtime_resume after S3 and S4 for each codec Date: Tue, 26 Mar 2019 15:29:57 +0900 Message-Id: <20190326042608.185910736@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190326042607.558087893@linuxfoundation.org> References: <20190326042607.558087893@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Hui Wang commit b5a236c175b0d984552a5f7c9d35141024c2b261 upstream. Recently we found the audio jack detection stop working after suspend on many machines with Realtek codec. Sometimes the audio selection dialogue didn't show up after users plugged headhphone/headset into the headset jack, sometimes after uses plugged headphone/headset, then click the sound icon on the upper-right corner of gnome-desktop, it also showed the speaker rather than the headphone. The root cause is that before suspend, the codec already call the runtime_suspend since this codec is not used by any apps, then in resume, it will not call runtime_resume for this codec. But for some realtek codec (so far, alc236, alc255 and alc891) with the specific BIOS, if it doesn't run runtime_resume after suspend, all codec functions including jack detection stop working anymore. This problem existed for a long time, but it was not exposed, that is because when problem happens, if users play sound or open sound-setting to check audio device, this will trigger calling to runtime_resume (via snd_hda_power_up), then the codec starts working again before users notice this problem. Since we don't know how many codec and BIOS combinations have this problem, to fix it, let the driver call runtime_resume for all codecs in pm_resume, maybe for some codecs, this is not needed, but it is harmless. After a codec is runtime resumed, if it is not used by any apps, it will be runtime suspended soon and furthermore we don't run suspend frequently, this change will not add much power consumption. Fixes: cc72da7d4d06 ("ALSA: hda - Use standard runtime PM for codec power-save control") Signed-off-by: Hui Wang Signed-off-by: Takashi Iwai Signed-off-by: Greg Kroah-Hartman --- sound/pci/hda/hda_codec.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) --- a/sound/pci/hda/hda_codec.c +++ b/sound/pci/hda/hda_codec.c @@ -3038,6 +3038,20 @@ static int hda_codec_runtime_resume(stru #endif /* CONFIG_PM */ #ifdef CONFIG_PM_SLEEP +static int hda_codec_force_resume(struct device *dev) +{ + int ret; + + /* The get/put pair below enforces the runtime resume even if the + * device hasn't been used at suspend time. This trick is needed to + * update the jack state change during the sleep. + */ + pm_runtime_get_noresume(dev); + ret = pm_runtime_force_resume(dev); + pm_runtime_put(dev); + return ret; +} + static int hda_codec_pm_suspend(struct device *dev) { dev->power.power_state = PMSG_SUSPEND; @@ -3047,7 +3061,7 @@ static int hda_codec_pm_suspend(struct d static int hda_codec_pm_resume(struct device *dev) { dev->power.power_state = PMSG_RESUME; - return pm_runtime_force_resume(dev); + return hda_codec_force_resume(dev); } static int hda_codec_pm_freeze(struct device *dev) @@ -3059,13 +3073,13 @@ static int hda_codec_pm_freeze(struct de static int hda_codec_pm_thaw(struct device *dev) { dev->power.power_state = PMSG_THAW; - return pm_runtime_force_resume(dev); + return hda_codec_force_resume(dev); } static int hda_codec_pm_restore(struct device *dev) { dev->power.power_state = PMSG_RESTORE; - return pm_runtime_force_resume(dev); + return hda_codec_force_resume(dev); } #endif /* CONFIG_PM_SLEEP */