FROMLIST: ALSA: hda/hdmi: fix race in handling acomp ELD notification at resume

When snd-hda-codec-hdmi is used with ASoC HDA controller like SOF (acomp
used for ELD notifications), display connection change done during suspend,
can be lost due to following sequence of events:

  1. system in S3 suspend
  2. DP/HDMI receiver connected
  3. system resumed
  4. HDA controller resumed, but card->deferred_resume_work not complete
  5. acomp eld_notify callback
  6. eld_notify ignored as power state is not CTL_POWER_D0
  7. HDA resume deferred work completed, power state set to CTL_POWER_D0

This results in losing the notification, and the jack state reported to
user-space is not correct.

The check on step 6 was added in commit 8ae743e ("ALSA: hda - Skip
ELD notification during system suspend"). It would seem with the deferred
resume logic in ASoC core, this check is not safe.

Fix the issue by modifying the check to only skip ELD notification
processing if power state is D3 or deeper. This helps in the ASoC
controller case as card power state is set to D2 at start of
soc_resume_deferred().

BugLink: https://github.com/thesofproject/linux/issues/2825
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
(am from https://patchwork.kernel.org/project/alsa-devel/patch/20210407154727.589017-1-kai.vehmanen@linux.intel.com)

BUG=b:180070914
TEST=Test HDMI on Boten

Signed-off-by: Yong Zhi <yong.zhi@intel.com>
Change-Id: I22a48cb4dcf7cde8d5cf9a3cb619f302efc3aa79
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/kernel/+/2821791
Reviewed-by: Henry Sun <henrysun@google.com>
Commit-Queue: Henry Sun <henrysun@google.com>
Tested-by: Henry Sun <henrysun@google.com>
1 file changed