Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp3962359img; Mon, 25 Mar 2019 23:37:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqwrgqcLv2VQ+guyjj6un/RORXaG3UpQ9NXKWsZevX+i8uuyslQEe65ZsWXseQR3yOVCW7au X-Received: by 2002:a63:6903:: with SMTP id e3mr27397598pgc.147.1553582220930; Mon, 25 Mar 2019 23:37:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553582220; cv=none; d=google.com; s=arc-20160816; b=RtPz0lSyoeRBi78XWdDK4iUj9+fNKszSpmeQZtFSHAEhub6NSGpxYEgHuop6PMAnmx YX7FovQ1DkDOT1UJjHJyNMt2TrusUX9kTPzVzpBuQ9cKiVU6FAmDpwGzYhF4JX931KJk nURoC2xfQkC/7pPZY/yXTEDWytTIYa9NmCxuVIcNpZ966UnjhIJ17alZZ06suiBlgo9T nfeydnFSN5dHyHgQelpKBYcir9yZOOacnml00sTbep7SAz0X8NvCW+JF84FB1ZQxw/da hfhMvvPUhdcJGFz6+hT/b4UfGVlTdu3qLkRP3UkyXVyEgYQaNNga9PwMQTqtKBk2Z/2W w75A== 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=cL57rXFr4MGNDNFGbus8smZaByuhd4kjM7I3mBEVfX8=; b=mu4sIBhgqZQbKLTleOSXiBhULOQr/KpKl6T7JdW/1FKecm2+VWtKCuBfHWbw2n9Gig UJ3U1VpbrZAQAcgggNcjKcTloms6sgjQi65F4zLjghbsMYeE7+gdOjxLFE8VTTXvstTq bdwuoswwkhgYLaOJi5ASOeMi0T6EsvQWYeW7eGPbs/fOMpos3N5UaC6moi/op0t6XdQi fxCXzMMe3Xj+N28DBltL8m75t9DrkYO9NbHC40Rt4w7ecWtTohsjIJgkxR7KVDCSep27 TA0BFWUnlPQxvyAXBxtXi4nkJTHSQEM2bsSS10R9Kz92hN0pBCRhna9pj7YuGAovRe39 p50A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="ev/UptV/"; 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 f69si3979014pgc.103.2019.03.25.23.36.45; Mon, 25 Mar 2019 23:37:00 -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="ev/UptV/"; 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 S1731821AbfCZGeM (ORCPT + 99 others); Tue, 26 Mar 2019 02:34:12 -0400 Received: from mail.kernel.org ([198.145.29.99]:44458 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731403AbfCZGeK (ORCPT ); Tue, 26 Mar 2019 02:34:10 -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 870CD20823; Tue, 26 Mar 2019 06:34:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553582049; bh=w4rBr4hUC85N8My419lAaiBGuc/JLpx9Ct60cz7XXDI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ev/UptV/rIYsUVp/r3XoNnymEmDPEx3tztS71SqgHGM/7y00gRHSOyb6ipozzZaF8 iv7lVp8AOdzaaSHqIiVFL+2JUR+Hbu+pIOwzp3oXCjJ4H40G/BTESRZrNeheLFhoJw JnuCyJOdMFOGBTEbMJ4nH1oPi8mJXnITvtiDQiw8= 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.14 30/41] ALSA: hda - Enforces runtime_resume after S3 and S4 for each codec Date: Tue, 26 Mar 2019 15:30:07 +0900 Message-Id: <20190326042651.549722608@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190326042649.889479098@linuxfoundation.org> References: <20190326042649.889479098@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.14-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 @@ -2934,6 +2934,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; @@ -2943,7 +2957,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) @@ -2955,13 +2969,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 */