Skip to content

Commit 2b73649

Browse files
khfengtiwai
authored andcommitted
ALSA: hda: Balance runtime/system PM if direct-complete is disabled
After hibernation, HDA controller can't be runtime-suspended after commit 215a22e ("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 <[email protected]> Fixes: 215a22e ("ALSA: hda: Refactor codec PM to use direct-complete optimization") Signed-off-by: Kai-Heng Feng <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Takashi Iwai <[email protected]>
1 parent c23010f commit 2b73649

File tree

1 file changed

+7
-17
lines changed

1 file changed

+7
-17
lines changed

sound/pci/hda/hda_codec.c

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2934,7 +2934,7 @@ static void hda_call_codec_resume(struct hda_codec *codec)
29342934
snd_hdac_leave_pm(&codec->core);
29352935
}
29362936

2937-
static int hda_codec_suspend(struct device *dev)
2937+
static int hda_codec_runtime_suspend(struct device *dev)
29382938
{
29392939
struct hda_codec *codec = dev_to_hda_codec(dev);
29402940
unsigned int state;
@@ -2953,7 +2953,7 @@ static int hda_codec_suspend(struct device *dev)
29532953
return 0;
29542954
}
29552955

2956-
static int hda_codec_resume(struct device *dev)
2956+
static int hda_codec_runtime_resume(struct device *dev)
29572957
{
29582958
struct hda_codec *codec = dev_to_hda_codec(dev);
29592959

@@ -2968,16 +2968,6 @@ static int hda_codec_resume(struct device *dev)
29682968
return 0;
29692969
}
29702970

2971-
static int hda_codec_runtime_suspend(struct device *dev)
2972-
{
2973-
return hda_codec_suspend(dev);
2974-
}
2975-
2976-
static int hda_codec_runtime_resume(struct device *dev)
2977-
{
2978-
return hda_codec_resume(dev);
2979-
}
2980-
29812971
#endif /* CONFIG_PM */
29822972

29832973
#ifdef CONFIG_PM_SLEEP
@@ -2998,31 +2988,31 @@ static void hda_codec_pm_complete(struct device *dev)
29982988
static int hda_codec_pm_suspend(struct device *dev)
29992989
{
30002990
dev->power.power_state = PMSG_SUSPEND;
3001-
return hda_codec_suspend(dev);
2991+
return pm_runtime_force_suspend(dev);
30022992
}
30032993

30042994
static int hda_codec_pm_resume(struct device *dev)
30052995
{
30062996
dev->power.power_state = PMSG_RESUME;
3007-
return hda_codec_resume(dev);
2997+
return pm_runtime_force_resume(dev);
30082998
}
30092999

30103000
static int hda_codec_pm_freeze(struct device *dev)
30113001
{
30123002
dev->power.power_state = PMSG_FREEZE;
3013-
return hda_codec_suspend(dev);
3003+
return pm_runtime_force_suspend(dev);
30143004
}
30153005

30163006
static int hda_codec_pm_thaw(struct device *dev)
30173007
{
30183008
dev->power.power_state = PMSG_THAW;
3019-
return hda_codec_resume(dev);
3009+
return pm_runtime_force_resume(dev);
30203010
}
30213011

30223012
static int hda_codec_pm_restore(struct device *dev)
30233013
{
30243014
dev->power.power_state = PMSG_RESTORE;
3025-
return hda_codec_resume(dev);
3015+
return pm_runtime_force_resume(dev);
30263016
}
30273017
#endif /* CONFIG_PM_SLEEP */
30283018

0 commit comments

Comments
 (0)