Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp3961100img; Mon, 25 Mar 2019 23:35:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqwQazxRBEp1k0YerwIxKW5eNs8mrYb/Cyotn9gzisEdusBArWgKnYNZKW273VcJDbWn8bbx X-Received: by 2002:a62:388d:: with SMTP id f135mr13779819pfa.103.1553582105997; Mon, 25 Mar 2019 23:35:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553582105; cv=none; d=google.com; s=arc-20160816; b=uEQwtHou5bm+F8kJ1vWS3JWGKuoT9QwKX+ZmaF5K2hYBuT8qvNbP1lYcvD52q9h6fD fTNKVcIAduY966b35a5oYuJ31+rJcO9gMki88Ei/FN5SRUgZ/e3wQzQMIyQgRK0ALQMg pVeoN/TG9ZJF7Hqi3sAGHZS/9bT3/CFBUWusetEbo9wP4fUbaL3UAqbAYPyQo7sTU7iv 3aVp2UeE3d5NP+nuVJ4lScn1MyszFrz/CAi5gnN5AUIun+ksuN7+86fJ3Z6BjCfjNWkd 3wbVrzoBSi4cC5DTGWWqYoloE0c70ynQDgf61WB4pPEunKFAS/fbWtbblcfYJYhfbGCX 73sQ== 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=vu0LaczyKxb6xU7JD6atpUZBXt1WoX+TDL/k6GyXi8E=; b=jM3AQaT1NH4LTCQKM/LFbXW8UDBDHfzmTPRRKwAm+5Zt6fBrebTbvLgvLfV0qVkrVw kIVx8wl6rExx5zKmWqvUwn2g4mqU/tFDxLncvf+hnblw9esJoFjZ3AWMAqztcPs6xj5+ U65aZl+2J5JQnEaC5F5/ApWXTF1cdfaB1nNANA5ff0HCjV4AGPQUbK2cY2rfWAJHb/us PnxPVwt7bdoHxNcwvx0YimaCQieYY2EJ3dnEw9FUb1tnlY8/JkMPtZukgHsckMK6Zp0h BpVFdb9tm7wU3MxZ5iF/NphWcjz9kw2zd7+fNGhBuBK0ExqNXnVYF4UfF/XZNdb1wtXk WDYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=RK7oXxkv; 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 j17si15819682pfn.210.2019.03.25.23.34.51; Mon, 25 Mar 2019 23:35:05 -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=RK7oXxkv; 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 S1730587AbfCZGci (ORCPT + 99 others); Tue, 26 Mar 2019 02:32:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:41988 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726279AbfCZGcf (ORCPT ); Tue, 26 Mar 2019 02:32:35 -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 B777B20856; Tue, 26 Mar 2019 06:32:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553581954; bh=KNOAQobM1jkRGX2beULoZOkwZDkI3G34G9hmhFknmeE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RK7oXxkvppWhNHt1+9h8/OfNjAzjPI2X1WV9r3ySbuMtaEQSMVG9QOnB0yfyOHBCB QZfOzev2EJqIQi1zUSAkgBkVYHBM3UaGrtDH9gDpXSGNrhCd25EIVKmoQm9TzxXeA7 zA1h4YWNjFD45EnMj1Ju4XUYbYqfCJRtIZfJGaGU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Takashi Iwai Subject: [PATCH 4.9 17/30] ALSA: hda - Record the current power state before suspend/resume calls Date: Tue, 26 Mar 2019 15:29:56 +0900 Message-Id: <20190326042608.153473318@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: Takashi Iwai commit 98081ca62cbac31fb0f7efaf90b2e7384ce22257 upstream. Currently we deal with single codec and suspend codec callbacks for all S3, S4 and runtime PM handling. But it turned out that we want distinguish the call patterns sometimes, e.g. for applying some init sequence only at probing and restoring from hibernate. This patch slightly modifies the common PM callbacks for HD-audio codec and stores the currently processed PM event in power_state of the codec's device.power field, which is currently unused. The codec callback can take a look at this event value and judges which purpose it's being called. Signed-off-by: Takashi Iwai Signed-off-by: Greg Kroah-Hartman --- sound/pci/hda/hda_codec.c | 43 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) --- a/sound/pci/hda/hda_codec.c +++ b/sound/pci/hda/hda_codec.c @@ -3004,6 +3004,7 @@ static void hda_call_codec_resume(struct hda_jackpoll_work(&codec->jackpoll_work.work); else snd_hda_jack_report_sync(codec); + codec->core.dev.power.power_state = PMSG_ON; atomic_dec(&codec->core.in_pm); } @@ -3036,10 +3037,48 @@ static int hda_codec_runtime_resume(stru } #endif /* CONFIG_PM */ +#ifdef CONFIG_PM_SLEEP +static int hda_codec_pm_suspend(struct device *dev) +{ + dev->power.power_state = PMSG_SUSPEND; + return pm_runtime_force_suspend(dev); +} + +static int hda_codec_pm_resume(struct device *dev) +{ + dev->power.power_state = PMSG_RESUME; + return pm_runtime_force_resume(dev); +} + +static int hda_codec_pm_freeze(struct device *dev) +{ + dev->power.power_state = PMSG_FREEZE; + return pm_runtime_force_suspend(dev); +} + +static int hda_codec_pm_thaw(struct device *dev) +{ + dev->power.power_state = PMSG_THAW; + return pm_runtime_force_resume(dev); +} + +static int hda_codec_pm_restore(struct device *dev) +{ + dev->power.power_state = PMSG_RESTORE; + return pm_runtime_force_resume(dev); +} +#endif /* CONFIG_PM_SLEEP */ + /* referred in hda_bind.c */ const struct dev_pm_ops hda_codec_driver_pm = { - SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, - pm_runtime_force_resume) +#ifdef CONFIG_PM_SLEEP + .suspend = hda_codec_pm_suspend, + .resume = hda_codec_pm_resume, + .freeze = hda_codec_pm_freeze, + .thaw = hda_codec_pm_thaw, + .poweroff = hda_codec_pm_suspend, + .restore = hda_codec_pm_restore, +#endif /* CONFIG_PM_SLEEP */ SET_RUNTIME_PM_OPS(hda_codec_runtime_suspend, hda_codec_runtime_resume, NULL) };