1 From 16037643969e095509cd8446a3f8e406a6dc3a2c Mon Sep 17 00:00:00 2001
2 From: Takashi Iwai <tiwai@suse.de>
3 Date: Thu, 30 Aug 2018 15:13:16 +0200
4 Subject: ALSA: hda - Fix cancel_work_sync() stall from jackpoll work
6 From: Takashi Iwai <tiwai@suse.de>
8 commit 16037643969e095509cd8446a3f8e406a6dc3a2c upstream.
10 On AMD/ATI controllers, the HD-audio controller driver allows a bus
11 reset upon the error recovery, and its procedure includes the
12 cancellation of pending jack polling work as found in
13 snd_hda_bus_codec_reset(). This works usually fine, but it becomes a
14 problem when the reset happens from the jack poll work itself; then
15 calling cancel_work_sync() from the work being processed tries to wait
18 As a workaround, this patch adds the check of current_work() and
19 applies the cancel_work_sync() only when it's not from the
22 This doesn't fix the root cause of the reported error below, but at
23 least, it eases the unexpected stall of the whole system.
25 Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=200937
26 Cc: <stable@vger.kernel.org>
27 Cc: Lukas Wunner <lukas@wunner.de>
28 Signed-off-by: Takashi Iwai <tiwai@suse.de>
29 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
32 sound/pci/hda/hda_codec.c | 3 ++-
33 1 file changed, 2 insertions(+), 1 deletion(-)
35 --- a/sound/pci/hda/hda_codec.c
36 +++ b/sound/pci/hda/hda_codec.c
37 @@ -4019,7 +4019,8 @@ void snd_hda_bus_reset_codecs(struct hda
39 list_for_each_codec(codec, bus) {
40 /* FIXME: maybe a better way needed for forced reset */
41 - cancel_delayed_work_sync(&codec->jackpoll_work);
42 + if (current_work() != &codec->jackpoll_work.work)
43 + cancel_delayed_work_sync(&codec->jackpoll_work);
45 if (hda_codec_is_power_on(codec)) {
46 hda_call_codec_suspend(codec);