Commit a6d78661 authored by Kai Vehmanen's avatar Kai Vehmanen Committed by Mark Brown

ASoC: rt5668: do not block workqueue if card is unbound

The current rt5668_jack_detect_handler() assumes the component
and card will always show up and implements an infinite usleep
loop waiting for them to show up.

This does not hold true if a codec interrupt (or other
event) occurs when the card is unbound. The codec driver's
remove  or shutdown functions cannot cancel the workqueue due
to the wait loop. As a result, code can either end up blocking
the workqueue, or hit a kernel oops when the card is freed.

Fix the issue by rescheduling the jack detect handler in
case the card is not ready. In case card never shows up,
the shutdown/remove/suspend calls can now cancel the detect
task.
Signed-off-by: default avatarKai Vehmanen <kai.vehmanen@linux.intel.com>
Reviewed-by: default avatarBard Liao <yung-chuan.liao@linux.intel.com>
Reviewed-by: default avatarRanjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: default avatarPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: default avatarPéter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: default avatarShuming Fan <shumingf@realtek.com>
Link: https://lore.kernel.org/r/20220207153000.3452802-2-kai.vehmanen@linux.intel.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent d7b530fd
...@@ -1022,11 +1022,13 @@ static void rt5668_jack_detect_handler(struct work_struct *work) ...@@ -1022,11 +1022,13 @@ static void rt5668_jack_detect_handler(struct work_struct *work)
container_of(work, struct rt5668_priv, jack_detect_work.work); container_of(work, struct rt5668_priv, jack_detect_work.work);
int val, btn_type; int val, btn_type;
while (!rt5668->component) if (!rt5668->component || !rt5668->component->card ||
usleep_range(10000, 15000); !rt5668->component->card->instantiated) {
/* card not yet ready, try later */
while (!rt5668->component->card->instantiated) mod_delayed_work(system_power_efficient_wq,
usleep_range(10000, 15000); &rt5668->jack_detect_work, msecs_to_jiffies(15));
return;
}
mutex_lock(&rt5668->calibrate_mutex); mutex_lock(&rt5668->calibrate_mutex);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment