ALSA: hda: update the power_state during the direct-complete
PATCH 1/1 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.
--- sound/pci/hda/hda_codec.c | 5 +++++ 1 file changed, 5 insertions(+)
sound/pci/hda/hda_codec.c +5 -0
@@ -2917,6 +2917,7 @@ static int hda_codec_runtime_resume(struct device *dev)#ifdef CONFIG_PM_SLEEP static int hda_codec_pm_prepare (struct device *dev) { + dev->power.power_state =PMSG_SUSPEND ;return pm_runtime_suspended (dev); }
@@ -2924,6 +2925,10 @@ static void hda_codec_pm_complete(struct device *dev) {struct hda_codec *codec =dev_to_hda_codec (dev); +/* If no other pm-functions are called between prepare() and complete() */ +if (dev->power.power_state.event ==PM_EVENT_SUSPEND ) + dev->power.power_state =PMSG_RESUME ; +if (pm_runtime_suspended (dev) && (codec->jackpoll_interval ||hda_codec_need_resume (codec) || codec->forced_resume))pm_request_resume (dev);
Signature · 1 line
2.25.1
Takashi Iwai
AppliedQuoted 16 lines · Hui Wang
The
patch_realtek.cneeds to check if the power_state.event equalsPM_EVENT_SUSPEND, after using the direct-complete, thesuspend()andresume()will be skipped if the codec is alreadyrt_suspended, in this case, thepatch_realtek.cwill always getPM_EVENT_ONeven the system is really resumed from S3.We could set
power_statetoPMSG_SUSPENDin theprepare(), if other PM functions are called beforecomplete(), those functions will overridepower_state; if no other PM functions are called beforecomplete(), we could know thesuspend()andresume()are skipped since only S3 pm functions could be skipped by direct-complete, in this case setpower_statetoPMSG_RESUMEin thecomplete(). This could guarantee the first time of callinghda_codec_runtime_resume()aftercomplete()has the correctpower_state.
Quoted 2 lines
Fixes 215a22ed31a1 ("ALSA: hda: Refactor codec PM to use direct-complete optimization")Signed-off-by Hui Wang <[email protected]>
Thanks, applied.
Takashi