]> git.baikalelectronics.ru Git - kernel.git/commit
ASoC: rt5682s: do not block workqueue if card is unbound
authorKai Vehmanen <kai.vehmanen@linux.intel.com>
Mon, 7 Feb 2022 15:29:58 +0000 (17:29 +0200)
committerMark Brown <broonie@kernel.org>
Tue, 8 Feb 2022 13:37:43 +0000 (13:37 +0000)
commitd3619f37649860e6d2d262b63921bca5ca25fb6a
tree94d09347c8b8721e0b52be5cdfcd681d5b3e9588
parente30c275be685d51882eb42db933fbca38e6457c1
ASoC: rt5682s: do not block workqueue if card is unbound

The current rt5682s_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: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: Shuming Fan <shumingf@realtek.com>
Link: https://lore.kernel.org/r/20220207153000.3452802-1-kai.vehmanen@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/codecs/rt5682s.c