summaryrefslogtreecommitdiff
path: root/sound/pci/hda/patch_ca0132.c
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2015-04-08 11:43:14 +0200
committerTakashi Iwai <tiwai@suse.de>2015-04-08 13:50:42 +0200
commit664c715573c2c116c2d8f5de7d59ce85a98a1751 (patch)
tree78629587a6d0ddfc478fa59d0248baa815f7132f /sound/pci/hda/patch_ca0132.c
parent142267c9e026827ca5fa622f1f13780b6db26cf8 (diff)
ALSA: hda - Work around races of power up/down with runtime PM
Currently, snd_hdac_power_up()/down() helpers checks whether the codec is being in pm (suspend/resume), and skips the call of runtime get/put during it. This is needed as there are lots of power up/down sequences called in the paths that are also used in the PM itself. An example is found in hda_codec.c::codec_exec_verb(), where this can power up the codec while it may be called again in its power up sequence, too. The above works in most cases, but sometimes we really want to wait for the real power up. For example, the control element get/put may want explicit power up so that the value change is assured to reach to the hardware. Using the current snd_hdac_power_up(), however, results in a race, e.g. when it's called during the runtime suspend is being performed. In the worst case, as found in patch_ca0132.c, it can even lead to the deadlock because the code assumes the power up while it was skipped due to the check above. For dealing with such cases, this patch makes snd_hdac_power_up() and _down() to two variants: with and without in_pm flag check. The version with pm flag check is named as snd_hdac_power_up_pm() while the version without pm flag check is still kept as snd_hdac_power_up(). (Just because the usage of the former is fewer.) Then finally, the patch replaces each call potentially done in PM with the new _pm() variant. In theory, we can implement a unified version -- if we can distinguish the current context whether it's in the pm path. But such an implementation is cumbersome, so leave the code like this a bit messy way for now... Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=96271 Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci/hda/patch_ca0132.c')
-rw-r--r--sound/pci/hda/patch_ca0132.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/sound/pci/hda/patch_ca0132.c b/sound/pci/hda/patch_ca0132.c
index 5aff35a09fd4..4a4e7b282e4f 100644
--- a/sound/pci/hda/patch_ca0132.c
+++ b/sound/pci/hda/patch_ca0132.c
@@ -3131,7 +3131,7 @@ static int ca0132_select_out(struct hda_codec *codec)
codec_dbg(codec, "ca0132_select_out\n");
- snd_hda_power_up(codec);
+ snd_hda_power_up_pm(codec);
auto_jack = spec->vnode_lswitch[VNID_HP_ASEL - VNODE_START_NID];
@@ -3215,7 +3215,7 @@ static int ca0132_select_out(struct hda_codec *codec)
}
exit:
- snd_hda_power_down(codec);
+ snd_hda_power_down_pm(codec);
return err < 0 ? err : 0;
}
@@ -3293,7 +3293,7 @@ static int ca0132_select_mic(struct hda_codec *codec)
codec_dbg(codec, "ca0132_select_mic\n");
- snd_hda_power_up(codec);
+ snd_hda_power_up_pm(codec);
auto_jack = spec->vnode_lswitch[VNID_AMIC1_ASEL - VNODE_START_NID];
@@ -3326,7 +3326,7 @@ static int ca0132_select_mic(struct hda_codec *codec)
ca0132_effects_set(codec, VOICE_FOCUS, 0);
}
- snd_hda_power_down(codec);
+ snd_hda_power_down_pm(codec);
return 0;
}
@@ -4546,7 +4546,7 @@ static int ca0132_init(struct hda_codec *codec)
spec->dsp_state = DSP_DOWNLOAD_INIT;
spec->curr_chip_addx = INVALID_CHIP_ADDRESS;
- snd_hda_power_up(codec);
+ snd_hda_power_up_pm(codec);
ca0132_init_unsol(codec);
@@ -4577,7 +4577,7 @@ static int ca0132_init(struct hda_codec *codec)
snd_hda_jack_report_sync(codec);
- snd_hda_power_down(codec);
+ snd_hda_power_down_pm(codec);
return 0;
}