From 82ee7cf40530b95534db6b6f3db0cdf7d287bf18 Mon Sep 17 00:00:00 2001 From: Cal Archer Date: Mon, 18 Jul 2016 23:01:19 +0200 Subject: [PATCH] ASoC: ES705: fix mediaserver hang on restart If mediaserver crashes it might hang in es705_wakeup() on restart, leading to watchdog killing systemserver and endless wait for service media.audio_policy. [10750.498808] kworker/0:3 D c0a354b4 0 19414 2 0x00000200 [10750.498840] [] (__schedule+0x590/0x7bc) from [] (schedule_preempt_disabled+0x24/0x34) [10750.498862] [] (schedule_preempt_disabled+0x24/0x34) from [] (__mutex_lock_slowpath+0x170/0x1c8) [10750.498884] [] (__mutex_lock_slowpath+0x170/0x1c8) from [] (mutex_lock+0x20/0x40) [10750.498908] [] (mutex_lock+0x20/0x40) from [] (es705_bootup+0x2c/0xa4) [10750.498927] [] (es705_bootup+0x2c/0xa4) from [] (restore_std_fw+0x34/0x60) [10750.498946] [] (restore_std_fw+0x34/0x60) from [] (es705_sleep+0x84/0x1f4) [10750.498966] [] (es705_sleep+0x84/0x1f4) from [] (process_one_work+0x270/0x434) [10750.498987] [] (process_one_work+0x270/0x434) from [] (worker_thread+0x198/0x2d8) [10750.499007] [] (worker_thread+0x198/0x2d8) from [] (kthread+0x84/0x90) [10750.499026] [] (kthread+0x84/0x90) from [] (kernel_thread_exit+0x0/0x8) [10750.499038] mediaserver D c0a354b4 0 21682 1 0x00000201 [10750.499068] [] (__schedule+0x590/0x7bc) from [] (schedule_timeout+0x28/0x32c) [10750.499088] [] (schedule_timeout+0x28/0x32c) from [] (wait_for_common+0x11c/0x15c) [10750.499108] [] (wait_for_common+0x11c/0x15c) from [] (wait_on_work+0xbc/0x108) [10750.499129] [] (wait_on_work+0xbc/0x108) from [] (__cancel_work_timer+0x78/0xec) [10750.499149] [] (__cancel_work_timer+0x78/0xec) from [] (es705_wakeup+0x64/0x270) [10750.499169] [] (es705_wakeup+0x64/0x270) from [] (es705_power_control+0x154/0x4d8) [10750.499188] [] (es705_power_control+0x154/0x4d8) from [] (es705_read_write_power_control+0x58/0x60) [10750.499209] [] (es705_read_write_power_control+0x58/0x60) from [] (es705_get_control_enum+0x18/0x64) [10750.499233] [] (es705_get_control_enum+0x18/0x64) from [] (snd_ctl_ioctl+0x588/0xb1c) [10750.499258] [] (snd_ctl_ioctl+0x588/0xb1c) from [] (vfs_ioctl+0x28/0x3c) [10750.499279] [] (vfs_ioctl+0x28/0x3c) from [] (do_vfs_ioctl+0x488/0x578) [10750.499297] [] (do_vfs_ioctl+0x488/0x578) from [] (sys_ioctl+0x48/0x74) [10750.499317] [] (sys_ioctl+0x48/0x74) from [] (__sys_trace_return+0x0/0x24) Change-Id: Ibe0750413b59301d0249c2c1a357880fc4dbde0f Signed-off-by: Kevin F. Haggerty --- sound/soc/codecs/audience/es705.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/sound/soc/codecs/audience/es705.c b/sound/soc/codecs/audience/es705.c index 86dc4c7f02e..937035e7e3c 100644 --- a/sound/soc/codecs/audience/es705.c +++ b/sound/soc/codecs/audience/es705.c @@ -1889,9 +1889,13 @@ static int es705_wakeup(struct es705_priv *es705) if (delayed_work_pending(&es705->sleep_work) || (es705->pm_state == ES705_POWER_SLEEP_PENDING)) { + mutex_unlock(&es705->pm_mutex); cancel_delayed_work_sync(&es705->sleep_work); - es705->pm_state = ES705_POWER_AWAKE; - goto es705_wakeup_exit; + mutex_lock(&es705->pm_mutex); + if (es705->pm_state == ES705_POWER_SLEEP_PENDING) { + es705->pm_state = ES705_POWER_AWAKE; + goto es705_wakeup_exit; + } } /* Check if previous power state is not sleep then return */