diff options
author | David Henningsson <david.henningsson@canonical.com> | 2013-02-19 16:11:25 +0100 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2013-02-19 18:28:30 +0100 |
commit | 4bd038f9d80216a6e95c5c36fae5054a83ea75d7 (patch) | |
tree | a2347fc3bb5bdbb84527858956667b9d9882ba0c /sound/pci/hda/hda_eld.c | |
parent | 1613d6b46b433f07f1d2703e4bd102802dcd75a4 (diff) |
ALSA: hda - hdmi: Protect ELD buffer
Because the eld buffer can be simultaneously accessed from both
workqueue context (updating) and process context (kcontrol read),
we need to protect it with a mutex to guarantee consistency.
To avoid holding the mutex while reading the ELD info from the
codec, we introduce a temporary eld buffer.
Signed-off-by: David Henningsson <david.henningsson@canonical.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci/hda/hda_eld.c')
-rw-r--r-- | sound/pci/hda/hda_eld.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/sound/pci/hda/hda_eld.c b/sound/pci/hda/hda_eld.c index 16066d7763ec..7dd846380a50 100644 --- a/sound/pci/hda/hda_eld.c +++ b/sound/pci/hda/hda_eld.c @@ -500,10 +500,13 @@ static void hdmi_print_eld_info(struct snd_info_entry *entry, [4 ... 7] = "reserved" }; + mutex_lock(&eld->lock); snd_iprintf(buffer, "monitor_present\t\t%d\n", eld->monitor_present); snd_iprintf(buffer, "eld_valid\t\t%d\n", eld->eld_valid); - if (!eld->eld_valid) + if (!eld->eld_valid) { + mutex_unlock(&eld->lock); return; + } snd_iprintf(buffer, "monitor_name\t\t%s\n", e->monitor_name); snd_iprintf(buffer, "connection_type\t\t%s\n", eld_connection_type_names[e->conn_type]); @@ -525,6 +528,7 @@ static void hdmi_print_eld_info(struct snd_info_entry *entry, for (i = 0; i < e->sad_count; i++) hdmi_print_sad_info(i, e->sad + i, buffer); + mutex_unlock(&eld->lock); } static void hdmi_write_eld_info(struct snd_info_entry *entry, @@ -538,6 +542,7 @@ static void hdmi_write_eld_info(struct snd_info_entry *entry, long long val; unsigned int n; + mutex_lock(&eld->lock); while (!snd_info_get_line(buffer, line, sizeof(line))) { if (sscanf(line, "%s %llx", name, &val) != 2) continue; @@ -589,6 +594,7 @@ static void hdmi_write_eld_info(struct snd_info_entry *entry, e->sad_count = n + 1; } } + mutex_unlock(&eld->lock); } |