ALSA: hda/hdmi: fix race in monitor detection during probe
PATCH 1/1 ALSA: hda/hdmi: fix race in monitor detection during probe
A race exists between build_pcms() and build_controls() phases of codec setup. Build_pcms() sets up notifier for jack events. If a monitor event is received before build_controls() is run, the initial jack state is lost and never reported via mixer controls.
The problem can be hit at least with SOF as the controller driver. SOF calls snd_hda_codec_build_controls() in its workqueue-based probe and this can be delayed enough to hit the race condition.
Fix the issue by invalidating the per-pin ELD information when build_controls() is called. The existing call to hdmi_present_sense() will update the ELD contents. This ensures initial monitor state is correctly reflected via mixer controls.
--- sound/pci/hda/patch_hdmi.c | 2 ++ 1 file changed, 2 insertions(+)
sound/pci/hda/patch_hdmi.c +2 -0
@@ -2194,7 +2194,9 @@ static int generic_hdmi_build_controls(struct hda_codec *codec)for (pin_idx =0 ; pin_idx < spec->num_pins; pin_idx++) {struct hdmi_spec_per_pin *per_pin =get_pin (spec, pin_idx); +struct hdmi_eld *pin_eld = &per_pin->sink_eld; + pin_eld->eld_valid = false;hdmi_present_sense (per_pin,0 ); }
Signature · 1 line
2.26.0
Takashi Iwai
AppliedQuoted 10 lines · Kai Vehmanen
A race exists between
build_pcms()andbuild_controls()phases of codec setup.Build_pcms()sets up notifier for jack events. If a monitor event is received beforebuild_controls()is run, the initial jack state is lost and never reported via mixer controls.The problem can be hit at least with SOF as the controller driver. SOF calls
snd_hda_codec_build_controls()in its workqueue-based probe and this can be delayed enough to hit the race condition.
Quoted 7 lines
Fix the issue by invalidating the per-pin ELD information when
build_controls()is called. The existing call tohdmi_present_sense()will update the ELD contents. This ensures initial monitor state is correctly reflected via mixer controls.Signed-off-by Kai Vehmanen <[email protected]>
Applied, thanks.
Takashi