Skip to content

Commit b8b90c1

Browse files
jason77-wangtiwai
authored andcommitted
ALSA: hda: update the power_state during the direct-complete
The patch_realtek.c needs to check if the power_state.event equals PM_EVENT_SUSPEND, after using the direct-complete, the suspend() and resume() will be skipped if the codec is already rt_suspended, in this case, the patch_realtek.c will always get PM_EVENT_ON even the system is really resumed from S3. We could set power_state to PMSG_SUSPEND in the prepare(), if other PM functions are called before complete(), those functions will override power_state; if no other PM functions are called before complete(), we could know the suspend() and resume() are skipped since only S3 pm functions could be skipped by direct-complete, in this case set power_state to PMSG_RESUME in the complete(). This could guarantee the first time of calling hda_codec_runtime_resume() after complete() has the correct power_state. Fixes: 215a22e ("ALSA: hda: Refactor codec PM to use direct-complete optimization") Cc: <[email protected]> Signed-off-by: Hui Wang <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Takashi Iwai <[email protected]>
1 parent 9c1fe96 commit b8b90c1

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

sound/pci/hda/hda_codec.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2917,13 +2917,18 @@ static int hda_codec_runtime_resume(struct device *dev)
29172917
#ifdef CONFIG_PM_SLEEP
29182918
static int hda_codec_pm_prepare(struct device *dev)
29192919
{
2920+
dev->power.power_state = PMSG_SUSPEND;
29202921
return pm_runtime_suspended(dev);
29212922
}
29222923

29232924
static void hda_codec_pm_complete(struct device *dev)
29242925
{
29252926
struct hda_codec *codec = dev_to_hda_codec(dev);
29262927

2928+
/* If no other pm-functions are called between prepare() and complete() */
2929+
if (dev->power.power_state.event == PM_EVENT_SUSPEND)
2930+
dev->power.power_state = PMSG_RESUME;
2931+
29272932
if (pm_runtime_suspended(dev) && (codec->jackpoll_interval ||
29282933
hda_codec_need_resume(codec) || codec->forced_resume))
29292934
pm_request_resume(dev);

0 commit comments

Comments
 (0)