ALSA: hda/hdmi: fix race in monitor detection during probe
authorKai Vehmanen <kai.vehmanen@linux.intel.com>
Tue, 28 Apr 2020 12:38:36 +0000 (15:38 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 20 May 2020 06:15:35 +0000 (08:15 +0200)
commitbb577c20b991c2c16c6172d82f0e12d2e4658eef
tree1b0f4a687e29dc9bb4767d31f1bb199c133c98d1
parent6f53659a06780eec15454798ed20571f0ec23fe0
ALSA: hda/hdmi: fix race in monitor detection during probe

[ Upstream commit ca76282b6faffc83601c25bd2a95f635c03503ef ]

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.

BugLink: https://github.com/thesofproject/linux/issues/1687
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Link: https://lore.kernel.org/r/20200428123836.24512-1-kai.vehmanen@linux.intel.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
sound/pci/hda/patch_hdmi.c