* [PATCH v2] ALSA: hda: Balance runtime/system PM if direct-complete is disabled
@ 2021-01-19 15:21 Kai-Heng Feng
2021-01-19 15:48 ` Takashi Iwai
0 siblings, 1 reply; 2+ messages in thread
From: Kai-Heng Feng @ 2021-01-19 15:21 UTC (permalink / raw)
To: tiwai
Cc: Kai-Heng Feng, Kenneth R . Crudup, Jaroslav Kysela,
Ranjani Sridharan, Kai Vehmanen, Pierre-Louis Bossart,
Mark Brown, Harsha Priya, Randy Dunlap, moderated list:SOUND,
open list
After hibernation, 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 the codec is prepared for direct-complete but PM core still calls
codec's suspend or freeze callback, partially revert the commit and take
the original approach, which uses pm_runtime_force_*() helpers to
ensure PM refcount are balanced. Meanwhile, still keep prepare() and
complete() callbacks to enable direct-complete and request a resume for
jack detection, respectively.
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>
---
v2:
- Use pm_runtime_force_*() helpers to avoid suspend/resume ping pong.
sound/pci/hda/hda_codec.c | 24 +++++++-----------------
1 file changed, 7 insertions(+), 17 deletions(-)
diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
index 687216e74526..eec1775dfffe 100644
--- a/sound/pci/hda/hda_codec.c
+++ b/sound/pci/hda/hda_codec.c
@@ -2934,7 +2934,7 @@ static void hda_call_codec_resume(struct hda_codec *codec)
snd_hdac_leave_pm(&codec->core);
}
-static int hda_codec_suspend(struct device *dev)
+static int hda_codec_runtime_suspend(struct device *dev)
{
struct hda_codec *codec = dev_to_hda_codec(dev);
unsigned int state;
@@ -2953,7 +2953,7 @@ static int hda_codec_suspend(struct device *dev)
return 0;
}
-static int hda_codec_resume(struct device *dev)
+static int hda_codec_runtime_resume(struct device *dev)
{
struct hda_codec *codec = dev_to_hda_codec(dev);
@@ -2968,16 +2968,6 @@ static int hda_codec_resume(struct device *dev)
return 0;
}
-static int hda_codec_runtime_suspend(struct device *dev)
-{
- return hda_codec_suspend(dev);
-}
-
-static int hda_codec_runtime_resume(struct device *dev)
-{
- return hda_codec_resume(dev);
-}
-
#endif /* CONFIG_PM */
#ifdef CONFIG_PM_SLEEP
@@ -2998,31 +2988,31 @@ static void hda_codec_pm_complete(struct device *dev)
static int hda_codec_pm_suspend(struct device *dev)
{
dev->power.power_state = PMSG_SUSPEND;
- return hda_codec_suspend(dev);
+ return pm_runtime_force_suspend(dev);
}
static int hda_codec_pm_resume(struct device *dev)
{
dev->power.power_state = PMSG_RESUME;
- return hda_codec_resume(dev);
+ return pm_runtime_force_resume(dev);
}
static int hda_codec_pm_freeze(struct device *dev)
{
dev->power.power_state = PMSG_FREEZE;
- return hda_codec_suspend(dev);
+ return pm_runtime_force_suspend(dev);
}
static int hda_codec_pm_thaw(struct device *dev)
{
dev->power.power_state = PMSG_THAW;
- return hda_codec_resume(dev);
+ return pm_runtime_force_resume(dev);
}
static int hda_codec_pm_restore(struct device *dev)
{
dev->power.power_state = PMSG_RESTORE;
- return hda_codec_resume(dev);
+ return pm_runtime_force_resume(dev);
}
#endif /* CONFIG_PM_SLEEP */
--
2.29.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] ALSA: hda: Balance runtime/system PM if direct-complete is disabled
2021-01-19 15:21 [PATCH v2] ALSA: hda: Balance runtime/system PM if direct-complete is disabled Kai-Heng Feng
@ 2021-01-19 15:48 ` Takashi Iwai
0 siblings, 0 replies; 2+ messages in thread
From: Takashi Iwai @ 2021-01-19 15:48 UTC (permalink / raw)
To: Kai-Heng Feng
Cc: tiwai, Kenneth R . Crudup, Jaroslav Kysela, Ranjani Sridharan,
Kai Vehmanen, Pierre-Louis Bossart, Mark Brown, Harsha Priya,
Randy Dunlap, moderated list:SOUND, open list
On Tue, 19 Jan 2021 16:21:43 +0100,
Kai-Heng Feng wrote:
>
> After hibernation, 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 the codec is prepared for direct-complete but PM core still calls
> codec's suspend or freeze callback, partially revert the commit and take
> the original approach, which uses pm_runtime_force_*() helpers to
> ensure PM refcount are balanced. Meanwhile, still keep prepare() and
> complete() callbacks to enable direct-complete and request a resume for
> jack detection, respectively.
>
> 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>
> ---
> v2:
> - Use pm_runtime_force_*() helpers to avoid suspend/resume ping pong.
Thanks, applied now.
Takashi
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-01-19 15:49 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-19 15:21 [PATCH v2] ALSA: hda: Balance runtime/system PM if direct-complete is disabled Kai-Heng Feng
2021-01-19 15:48 ` Takashi Iwai
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).