All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ALSA: hda: Balance runtime/system PM if direct-complete is disabled
@ 2021-01-18 13:09 ` Kai-Heng Feng
  0 siblings, 0 replies; 6+ messages in thread
From: Kai-Heng Feng @ 2021-01-18 13:09 UTC (permalink / raw)
  To: tiwai
  Cc: moderated list:SOUND, Kai Vehmanen, Harsha Priya, open list,
	Mark Brown, Pierre-Louis Bossart, Ranjani Sridharan,
	Kai-Heng Feng, Kenneth R . Crudup

HDA controller can't be runtime-suspended after commit 215a22ed31a1
("ALSA: hda: Refactor codjc PM to use direct-complete optimization"),
which enables direct-complete for HDA codec.

The HDA codec driver didn't expect direct-complete will be disabled
after it returns a positive value from prepare() callback. However,
there are some places that PM core can disable direct-complete. For
instance, system hibernation or when codec has subordinates like LEDs.

So if a device is prepared for direct-complete but PM core still calls
codec's suspend or freeze callback, resume the device to keep PM
operations balanced.

Reported-by: Kenneth R. Crudup <kenny@panix.com>
Fixes: 215a22ed31a1 ("ALSA: hda: Refactor codec PM to use direct-complete optimization")
Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
---
 sound/pci/hda/hda_codec.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
index 687216e74526..0afbced979df 100644
--- a/sound/pci/hda/hda_codec.c
+++ b/sound/pci/hda/hda_codec.c
@@ -2997,6 +2997,9 @@ static void hda_codec_pm_complete(struct device *dev)
 
 static int hda_codec_pm_suspend(struct device *dev)
 {
+	if (pm_runtime_status_suspended(dev))
+		pm_runtime_resume(dev);
+
 	dev->power.power_state = PMSG_SUSPEND;
 	return hda_codec_suspend(dev);
 }
@@ -3009,6 +3012,9 @@ static int hda_codec_pm_resume(struct device *dev)
 
 static int hda_codec_pm_freeze(struct device *dev)
 {
+	if (pm_runtime_status_suspended(dev))
+		pm_runtime_resume(dev);
+
 	dev->power.power_state = PMSG_FREEZE;
 	return hda_codec_suspend(dev);
 }
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-01-18 17:33 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-01-18 13:09 [PATCH] ALSA: hda: Balance runtime/system PM if direct-complete is disabled Kai-Heng Feng
2021-01-18 13:09 ` Kai-Heng Feng
2021-01-18 13:21 ` Takashi Iwai
2021-01-18 13:21   ` Takashi Iwai
2021-01-18 17:27   ` Kai-Heng Feng
2021-01-18 17:27     ` Kai-Heng Feng

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.