Skip to content

Commit 989c318

Browse files
committed
ALSA: hda - Fix recursive suspend/resume call
When the bus reset is performed during the suspend/resume (including the power-saving too), it calls snd_hda_suspend() and snd_hda_resume() again, and deadlocks eventually. For avoiding the recursive call, add a new flag indicating that the PM is being performed, and don't go to the bus reset mode when it's on. Reported-and-tested-by: Julian Wollrath <jwollrath@web.de> Signed-off-by: Takashi Iwai <tiwai@suse.de>
1 parent 0ced14f commit 989c318

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

sound/pci/hda/hda_codec.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ static int codec_exec_verb(struct hda_codec *codec, unsigned int cmd,
228228
}
229229
mutex_unlock(&bus->cmd_mutex);
230230
snd_hda_power_down(codec);
231-
if (res && *res == -1 && bus->rirb_error) {
231+
if (!codec->in_pm && res && *res == -1 && bus->rirb_error) {
232232
if (bus->response_reset) {
233233
snd_printd("hda_codec: resetting BUS due to "
234234
"fatal communication error\n");
@@ -238,7 +238,7 @@ static int codec_exec_verb(struct hda_codec *codec, unsigned int cmd,
238238
goto again;
239239
}
240240
/* clear reset-flag when the communication gets recovered */
241-
if (!err)
241+
if (!err || codec->in_pm)
242242
bus->response_reset = 0;
243243
return err;
244244
}
@@ -3616,6 +3616,8 @@ static unsigned int hda_call_codec_suspend(struct hda_codec *codec, bool in_wq)
36163616
{
36173617
unsigned int state;
36183618

3619+
codec->in_pm = 1;
3620+
36193621
if (codec->patch_ops.suspend)
36203622
codec->patch_ops.suspend(codec);
36213623
hda_cleanup_all_streams(codec);
@@ -3630,6 +3632,7 @@ static unsigned int hda_call_codec_suspend(struct hda_codec *codec, bool in_wq)
36303632
codec->power_transition = 0;
36313633
codec->power_jiffies = jiffies;
36323634
spin_unlock(&codec->power_lock);
3635+
codec->in_pm = 0;
36333636
return state;
36343637
}
36353638

@@ -3638,6 +3641,8 @@ static unsigned int hda_call_codec_suspend(struct hda_codec *codec, bool in_wq)
36383641
*/
36393642
static void hda_call_codec_resume(struct hda_codec *codec)
36403643
{
3644+
codec->in_pm = 1;
3645+
36413646
/* set as if powered on for avoiding re-entering the resume
36423647
* in the resume / power-save sequence
36433648
*/
@@ -3656,6 +3661,8 @@ static void hda_call_codec_resume(struct hda_codec *codec)
36563661
snd_hda_codec_resume_cache(codec);
36573662
}
36583663
snd_hda_jack_report_sync(codec);
3664+
3665+
codec->in_pm = 0;
36593666
snd_hda_power_down(codec); /* flag down before returning */
36603667
}
36613668
#endif /* CONFIG_PM */

sound/pci/hda/hda_codec.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -869,6 +869,7 @@ struct hda_codec {
869869
unsigned int power_on :1; /* current (global) power-state */
870870
unsigned int d3_stop_clk:1; /* support D3 operation without BCLK */
871871
unsigned int pm_down_notified:1; /* PM notified to controller */
872+
unsigned int in_pm:1; /* suspend/resume being performed */
872873
int power_transition; /* power-state in transition */
873874
int power_count; /* current (global) power refcount */
874875
struct delayed_work power_work; /* delayed task for powerdown */

0 commit comments

Comments
 (0)