Linux Sound subsystem development
 help / color / mirror / Atom feed
* [PATCH 1/2] ALSA: hda/hdmi: intelhdmi: Skip ELD notification during hibernation freeze
@ 2026-12-04 12:13 Yogesh Gaur
  2026-12-04 12:13 ` [PATCH 2/2] ALSA: hda/hdmi: intelhdmi: Request resume when skipping ELD notification Yogesh Gaur
  2026-12-04 12:19 ` [PATCH 1/2] ALSA: hda/hdmi: intelhdmi: Skip ELD notification during hibernation freeze Kai Vehmanen
  0 siblings, 2 replies; 5+ messages in thread
From: Yogesh Gaur @ 2026-12-04 12:13 UTC (permalink / raw)
  To: Takashi Iwai, linux-sound; +Cc: Jaroslav Kysela, Kai Vehmanen, stable

intel_pin_eld_notify() skips ELD notifications in PM_EVENT_SUSPEND but
not in PM_EVENT_FREEZE. On hibernation restore, i915 resumes before the
codec, so the notification enables the silent stream on a codec whose
controller is not restored yet. The verbs time out and resume takes
about 35 seconds longer on Meteor Lake.

Skip the notification in FREEZE too, as is done for SUSPEND.

Fixes: 0c37e2eb6b83 ("ALSA: hda/hdmi: fix race in handling acomp ELD notification at resume")
Cc: stable@vger.kernel.org
Closes: https://bugzilla.kernel.org/show_bug.cgi?id=222335
Assisted-by: LLM
Signed-off-by: Yogesh Gaur <yogesh.gaur@intel.com>
---
 sound/hda/codecs/hdmi/intelhdmi.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/sound/hda/codecs/hdmi/intelhdmi.c b/sound/hda/codecs/hdmi/intelhdmi.c
index 73141046d502..46dcc3e50fb3 100644
--- a/sound/hda/codecs/hdmi/intelhdmi.c
+++ b/sound/hda/codecs/hdmi/intelhdmi.c
@@ -166,7 +166,8 @@ static void intel_pin_eld_notify(void *audio_ptr, int port, int pipe)
 	/* skip notification during system suspend (but not in runtime PM);
 	 * the state will be updated at resume
 	 */
-	if (codec->core.dev.power.power_state.event == PM_EVENT_SUSPEND)
+	if (codec->core.dev.power.power_state.event == PM_EVENT_SUSPEND ||
+	    codec->core.dev.power.power_state.event == PM_EVENT_FREEZE)
 		return;
 
 	snd_hdac_i915_set_bclk(&codec->bus->core);

base-commit: fe6ff8d5d675c01793b9f051d16055dd4aa75244
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/2] ALSA: hda/hdmi: intelhdmi: Request resume when skipping ELD notification
  2026-12-04 12:13 [PATCH 1/2] ALSA: hda/hdmi: intelhdmi: Skip ELD notification during hibernation freeze Yogesh Gaur
@ 2026-12-04 12:13 ` Yogesh Gaur
  2026-12-04 14:03   ` sashiko-bot
  2026-12-04 17:27   ` Kai Vehmanen
  2026-12-04 12:19 ` [PATCH 1/2] ALSA: hda/hdmi: intelhdmi: Skip ELD notification during hibernation freeze Kai Vehmanen
  1 sibling, 2 replies; 5+ messages in thread
From: Yogesh Gaur @ 2026-12-04 12:13 UTC (permalink / raw)
  To: Takashi Iwai, linux-sound; +Cc: Jaroslav Kysela, Kai Vehmanen

When intel_pin_eld_notify() skips a notification during system suspend
or hibernation, the jack state is not synced after resume unless silent
stream is enabled, because relaxed_resume is set. A monitor plugged in
while the system sleeps is then not reported.

Set acomp_requested_resume, as commit c0933934d5d9 ("ALSA: hda: Force
resume if acomp notified during system suspend") does for the generic
path.

Assisted-by: LLM
Signed-off-by: Yogesh Gaur <yogesh.gaur@intel.com>
---
 sound/hda/codecs/hdmi/intelhdmi.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/sound/hda/codecs/hdmi/intelhdmi.c b/sound/hda/codecs/hdmi/intelhdmi.c
index 46dcc3e50fb3..e3c69675902e 100644
--- a/sound/hda/codecs/hdmi/intelhdmi.c
+++ b/sound/hda/codecs/hdmi/intelhdmi.c
@@ -163,12 +163,14 @@ static void intel_pin_eld_notify(void *audio_ptr, int port, int pipe)
 	pin_nid = intel_port2pin(codec, port);
 	if (!pin_nid)
 		return;
-	/* skip notification during system suspend (but not in runtime PM);
-	 * the state will be updated at resume
+	/* skip notification during system suspend and hibernation (but not
+	 * in runtime PM); states would be updated at resume request
 	 */
 	if (codec->core.dev.power.power_state.event == PM_EVENT_SUSPEND ||
-	    codec->core.dev.power.power_state.event == PM_EVENT_FREEZE)
+	    codec->core.dev.power.power_state.event == PM_EVENT_FREEZE) {
+		codec->acomp_requested_resume = 1;
 		return;
+	}
 
 	snd_hdac_i915_set_bclk(&codec->bus->core);
 	snd_hda_hdmi_check_presence_and_report(codec, pin_nid, dev_id);
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] ALSA: hda/hdmi: intelhdmi: Skip ELD notification during hibernation freeze
  2026-12-04 12:13 [PATCH 1/2] ALSA: hda/hdmi: intelhdmi: Skip ELD notification during hibernation freeze Yogesh Gaur
  2026-12-04 12:13 ` [PATCH 2/2] ALSA: hda/hdmi: intelhdmi: Request resume when skipping ELD notification Yogesh Gaur
@ 2026-12-04 12:19 ` Kai Vehmanen
  1 sibling, 0 replies; 5+ messages in thread
From: Kai Vehmanen @ 2026-12-04 12:19 UTC (permalink / raw)
  To: Yogesh Gaur
  Cc: Takashi Iwai, linux-sound, Jaroslav Kysela, Kai Vehmanen, stable

Hey,

On Fri, 4 Dec 2026, Yogesh Gaur wrote:

> intel_pin_eld_notify() skips ELD notifications in PM_EVENT_SUSPEND but
> not in PM_EVENT_FREEZE. On hibernation restore, i915 resumes before the
> codec, so the notification enables the silent stream on a codec whose
> controller is not restored yet. The verbs time out and resume takes
> about 35 seconds longer on Meteor Lake.
> 
> Skip the notification in FREEZE too, as is done for SUSPEND.
[...]
> --- a/sound/hda/codecs/hdmi/intelhdmi.c
> +++ b/sound/hda/codecs/hdmi/intelhdmi.c
> @@ -166,7 +166,8 @@ static void intel_pin_eld_notify(void *audio_ptr, int port, int pipe)
>  	/* skip notification during system suspend (but not in runtime PM);
>  	 * the state will be updated at resume
>  	 */
> -	if (codec->core.dev.power.power_state.event == PM_EVENT_SUSPEND)
> +	if (codec->core.dev.power.power_state.event == PM_EVENT_SUSPEND ||
> +	    codec->core.dev.power.power_state.event == PM_EVENT_FREEZE)
>  		return;

thanks, looks good:
Reviewed-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>

Br, Kai

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] ALSA: hda/hdmi: intelhdmi: Request resume when skipping ELD notification
  2026-12-04 12:13 ` [PATCH 2/2] ALSA: hda/hdmi: intelhdmi: Request resume when skipping ELD notification Yogesh Gaur
@ 2026-12-04 14:03   ` sashiko-bot
  2026-12-04 17:27   ` Kai Vehmanen
  1 sibling, 0 replies; 5+ messages in thread
From: sashiko-bot @ 2026-12-04 14:03 UTC (permalink / raw)
  To: Yogesh Gaur, linux-sound

Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [Medium] ALSA: hda/hdmi: bitfield data race in intel_pin_eld_notify()
- [Medium] ALSA: hda/hdmi: TOCTOU race drops ELD notify in
  intel_pin_eld_notify()
- [Low] ALSA: hda/hdmi: commit message overstates silent stream resume
  sync
--

commit e7a308e01d9fac7611a59d7f65d7969384c790b7
Author: Yogesh Gaur <yogesh.gaur@intel.com>

ALSA: hda/hdmi: intelhdmi: Request resume when skipping ELD notification

This commit sets codec->acomp_requested_resume when intel_pin_eld_notify()
skips a notification during system suspend or hibernation, so the codec is
resumed to sync jack state after sleep.

> When intel_pin_eld_notify() skips a notification during system suspend
> or hibernation, the jack state is not synced after resume unless silent
> stream is enabled, because relaxed_resume is set. A monitor plugged in
> while the system sleeps is then not reported.

[Severity: Low]
Is "unless silent stream is enabled" accurate here?

In i915_hdmi_suspend(), codec->forced_resume is only set when a pin already
has per_pin->silent_stream active at suspend.  Even with silent stream
enabled, a monitor plugged during sleep when none was connected before still
leaves forced_resume clear.

> diff --git a/sound/hda/codecs/hdmi/intelhdmi.c b/sound/hda/codecs/hdmi/intelhdmi.c
> index 46dcc3e50fb31..e3c69675902e9 100644
> --- a/sound/hda/codecs/hdmi/intelhdmi.c
> +++ b/sound/hda/codecs/hdmi/intelhdmi.c
> @@ -163,12 +163,14 @@ static void intel_pin_eld_notify(void *audio_ptr, int port, int pipe)
>  	pin_nid = intel_port2pin(codec, port);
>  	if (!pin_nid)
>  		return;
> -	/* skip notification during system suspend (but not in runtime PM);
> -	 * the state will be updated at resume
> +	/* skip notification during system suspend and hibernation (but not
> +	 * in runtime PM); states would be updated at resume request
>  	 */
>  	if (codec->core.dev.power.power_state.event == PM_EVENT_SUSPEND ||
> -	    codec->core.dev.power.power_state.event == PM_EVENT_FREEZE)
> +	    codec->core.dev.power.power_state.event == PM_EVENT_FREEZE) {
> +		codec->acomp_requested_resume = 1;
>  		return;
> +	}

[Severity: Medium]
Can this unlocked write to codec->acomp_requested_resume race with sibling
bitfields in struct hda_codec?

acomp_requested_resume shares a 32-bit bitfield word with forced_resume and
no_stream_clean_at_suspend, so writing it compiles to a non-atomic
read-modify-write.  intel_audio_codec_enable() calls pin_eld_notify() after
dropping display->audio.mutex and without any HDA lock.

Because the HDA codec is a PM consumer of the display device,
i915_hdmi_suspend() runs before i915_drm_suspend() stops display HPD and
modeset work, and updates forced_resume and no_stream_clean_at_suspend in
the same word.  A concurrent write here can clobber those flags and break
KAE silent-stream retention across suspend, or race with
hda_codec_pm_complete() clearing acomp_requested_resume.

Using an atomic flag or a separate field outside the bitfield word (or
synchronizing with a lock) would avoid clobbering adjacent bits.

[Severity: Medium]
Can an ELD notification arriving during system resume still be dropped by a
TOCTOU race between intel_pin_eld_notify() and hda_codec_pm_complete()?

When the codec uses direct_complete, power_state stays PMSG_SUSPEND until
hda_codec_pm_complete() runs.  During resume, i915 re-enables HPD, MST, and
output polling in intel_display_driver_pm_resume() before dpm_complete()
calls hda_codec_pm_complete():

CPU0                               CPU1
hda_codec_pm_complete()            intel_pin_eld_notify()
                                     power_state.event == PM_EVENT_SUSPEND
  power_state = PMSG_RESUME
  if (... || acomp_requested_resume)
    /* sees 0, skips resume */
                                     acomp_requested_resume = 1
                                     return  <-- notification dropped

There is no shared lock or memory barrier ordering the power_state update
against acomp_requested_resume (and store-load reordering allows the same
outcome even without preemption).  The hotplug event is missed and jack
state stays stale until a later wake.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261204121330.785676-1-yogesh.gaur@intel.com?part=2

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] ALSA: hda/hdmi: intelhdmi: Request resume when skipping ELD notification
  2026-12-04 12:13 ` [PATCH 2/2] ALSA: hda/hdmi: intelhdmi: Request resume when skipping ELD notification Yogesh Gaur
  2026-12-04 14:03   ` sashiko-bot
@ 2026-12-04 17:27   ` Kai Vehmanen
  1 sibling, 0 replies; 5+ messages in thread
From: Kai Vehmanen @ 2026-12-04 17:27 UTC (permalink / raw)
  To: Yogesh Gaur
  Cc: Takashi Iwai, linux-sound, Jaroslav Kysela, Kai Vehmanen,
	Andy Shevchenko

Hey,

On Fri, 4 Dec 2026, Yogesh Gaur wrote:

> When intel_pin_eld_notify() skips a notification during system suspend
> or hibernation, the jack state is not synced after resume unless silent
> stream is enabled, because relaxed_resume is set. A monitor plugged in
> while the system sleeps is then not reported.
[...]
> --- a/sound/hda/codecs/hdmi/intelhdmi.c
> +++ b/sound/hda/codecs/hdmi/intelhdmi.c
> @@ -163,12 +163,14 @@ static void intel_pin_eld_notify(void *audio_ptr, int port, int pipe)
>  	pin_nid = intel_port2pin(codec, port);
>  	if (!pin_nid)
>  		return;
> -	/* skip notification during system suspend (but not in runtime PM);
> -	 * the state will be updated at resume
> +	/* skip notification during system suspend and hibernation (but not
> +	 * in runtime PM); states would be updated at resume request
>  	 */
>  	if (codec->core.dev.power.power_state.event == PM_EVENT_SUSPEND ||
> -	    codec->core.dev.power.power_state.event == PM_EVENT_FREEZE)
> +	    codec->core.dev.power.power_state.event == PM_EVENT_FREEZE) {
> +		codec->acomp_requested_resume = 1;
>  		return;
> +	}

thanks, looks good. This aligns behaviour with other hdmi codec variant
(added in commit c0933934d5d9 ), so seems good:

Reviewed-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>

If you need to respin for any reason, you can additionally fix the code 
comment style (Andy Shevchenko noted this).

Br, Kai

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-12-04 17:27 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-04 12:13 [PATCH 1/2] ALSA: hda/hdmi: intelhdmi: Skip ELD notification during hibernation freeze Yogesh Gaur
2026-12-04 12:13 ` [PATCH 2/2] ALSA: hda/hdmi: intelhdmi: Request resume when skipping ELD notification Yogesh Gaur
2026-12-04 14:03   ` sashiko-bot
2026-12-04 17:27   ` Kai Vehmanen
2026-12-04 12:19 ` [PATCH 1/2] ALSA: hda/hdmi: intelhdmi: Skip ELD notification during hibernation freeze Kai Vehmanen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox