summaryrefslogtreecommitdiffstats
path: root/sound/hda/hdac_component.c
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2019-04-10 12:49:55 +0200
committerTakashi Iwai <tiwai@suse.de>2019-04-10 15:23:36 +0200
commitd7a181da2dfa3190487c446042ba01e07d851c74 (patch)
treec2c281018d0a0dd56e792e0fca49af8313d5a30b /sound/hda/hdac_component.c
parentALSA: hda - Add two more machines to the power_save_blacklist (diff)
downloadlinux-d7a181da2dfa3190487c446042ba01e07d851c74.tar.xz
linux-d7a181da2dfa3190487c446042ba01e07d851c74.zip
ALSA: hda: Fix racy display power access
snd_hdac_display_power() doesn't handle the concurrent calls carefully enough, and it may lead to the doubly get_power or put_power calls, when a runtime PM and an async work get called in racy way. This patch addresses it by reusing the bus->lock mutex that has been used for protecting the link state change in ext bus code, so that it can protect against racy display state changes. The initialization of bus->lock was moved from snd_hdac_ext_bus_init() to snd_hdac_bus_init() as well accordingly. Testcase: igt/i915_pm_rpm/module-reload #glk-dsi Reported-by: Chris Wilson <chris@chris-wilson.co.uk> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk> Cc: Imre Deak <imre.deak@intel.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/hda/hdac_component.c')
-rw-r--r--sound/hda/hdac_component.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/sound/hda/hdac_component.c b/sound/hda/hdac_component.c
index a6d37b9d6413..6b5caee61c6e 100644
--- a/sound/hda/hdac_component.c
+++ b/sound/hda/hdac_component.c
@@ -69,13 +69,15 @@ void snd_hdac_display_power(struct hdac_bus *bus, unsigned int idx, bool enable)
dev_dbg(bus->dev, "display power %s\n",
enable ? "enable" : "disable");
+
+ mutex_lock(&bus->lock);
if (enable)
set_bit(idx, &bus->display_power_status);
else
clear_bit(idx, &bus->display_power_status);
if (!acomp || !acomp->ops)
- return;
+ goto unlock;
if (bus->display_power_status) {
if (!bus->display_power_active) {
@@ -92,6 +94,8 @@ void snd_hdac_display_power(struct hdac_bus *bus, unsigned int idx, bool enable)
bus->display_power_active = false;
}
}
+ unlock:
+ mutex_unlock(&bus->lock);
}
EXPORT_SYMBOL_GPL(snd_hdac_display_power);