ALSA: hda: Refactor codec PM to use direct-complete optimization
authorKai-Heng Feng <kai.heng.feng@canonical.com>
Tue, 27 Oct 2020 13:00:36 +0000 (21:00 +0800)
committerTakashi Iwai <tiwai@suse.de>
Wed, 28 Oct 2020 08:42:46 +0000 (09:42 +0100)
commit215a22ed31a1332075866eca07744d442367c04b
tree840352c767f3b4487d2da81458f6e0f979f60272
parent8a8de09cb2adc119104f35044d1a840dd47aa9d8
ALSA: hda: Refactor codec PM to use direct-complete optimization

Upon system resume, hda_codec_pm_resume() uses hda_codec_force_resume()
to resume the codec. However, pm_runtime_force_resume() won't really
resume the codec because of pm_runtime_need_not_resume() check.

Hence, hda_codec_force_resume() schedules a jackpoll work, which is to
really power up the codec.

Instead of doing that, we can use direct-complete to make the PM flow
more straightforward, and keep codec always suspended through system PM
flow if conditions are met.

On system suspend, PM core will decide what to do based on
hda_codec_pm_prepare():
- If codec is not runtime-suspended, PM core will suspend and resume the
device as normal.
- If codec is runtime-suspended, PM core will try to keep it suspended.
If it's still suspended after system resume, we use
hda_codec_pm_complete() to resume codec if it's needed.

Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
Link: https://lore.kernel.org/r/20201027130038.16463-2-kai.heng.feng@canonical.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/pci/hda/hda_codec.c