ASoC: rt5682s: do not block workqueue if card is unbound
Subsystems (3)
PATCH 2/3 ASoC: rt5668: do not block workqueue if card is unbound
In reply to Kai VehmanenThe 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.
--- sound/soc/codecs/rt5668.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
sound/soc/codecs/rt5668.c +7 -5
@@ -1022,11 +1022,13 @@ static void rt5668_jack_detect_handler(struct work_struct *work) container_of(work, struct rt5668_priv, jack_detect_work.work);int val, btn_type; -while (!rt5668->component) -usleep_range (10000 ,15000 ); - -while (!rt5668->component->card->instantiated) -usleep_range (10000 ,15000 ); +if (!rt5668->component || !rt5668->component->card || + !rt5668->component->card->instantiated) { +/* card not yet ready, try later */ +mod_delayed_work (system_power_efficient_wq, + &rt5668->jack_detect_work,msecs_to_jiffies (15 )); +return ; + }mutex_lock (&rt5668->calibrate_mutex);
Signature · 1 line
2.35.1
PATCH 3/3 ASoC: rt5682: do not block workqueue if card is unbound
In reply to Kai VehmanenThe current rt5682_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.
--- sound/soc/codecs/rt5682.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
sound/soc/codecs/rt5682.c +7 -5
@@ -1096,11 +1096,13 @@ void rt5682_jack_detect_handler(struct work_struct *work) container_of(work, struct rt5682_priv, jack_detect_work.work);int val, btn_type; -while (!rt5682->component) -usleep_range (10000 ,15000 ); - -while (!rt5682->component->card->instantiated) -usleep_range (10000 ,15000 ); +if (!rt5682->component || !rt5682->component->card || + !rt5682->component->card->instantiated) { +/* card not yet ready, try later */ +mod_delayed_work (system_power_efficient_wq, + &rt5682->jack_detect_work,msecs_to_jiffies (15 )); +return ; + }mutex_lock (&rt5682->jdet_mutex);mutex_lock (&rt5682->calibrate_mutex);
Signature · 1 line
2.35.1
PATCH 1/3 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.
--- sound/soc/codecs/rt5682s.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
sound/soc/codecs/rt5682s.c +7 -5
@@ -824,11 +824,13 @@ static void rt5682s_jack_detect_handler(struct work_struct *work) container_of(work, struct rt5682s_priv, jack_detect_work.work);int val, btn_type; -while (!rt5682s->component) -usleep_range (10000 ,15000 ); - -while (!rt5682s->component->card->instantiated) -usleep_range (10000 ,15000 ); +if (!rt5682s->component || !rt5682s->component->card || + !rt5682s->component->card->instantiated) { +/* card not yet ready, try later */ +mod_delayed_work (system_power_efficient_wq, + &rt5682s->jack_detect_work,msecs_to_jiffies (15 )); +return ; + }mutex_lock (&rt5682s->jdet_mutex);mutex_lock (&rt5682s->calibrate_mutex);
base-commit: d466706b9d0dae4754a47c34fd5f4654ee54f609
Signature · 1 line
2.35.1
Mark Brown
maintainerQuoted 11 lines · Kai Vehmanen
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.
[...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-linus
Thanks!
[1/3] ASoC: rt5682s: do not block workqueue if card is unbound
commit: d7b530fdc45e75a54914a194c4becd9672a4e24f
[2/3] ASoC: rt5668: do not block workqueue if card is unbound
commit: a6d78661dc903d90a327892bbc34268f3a5f4b9c
[3/3] ASoC: rt5682: do not block workqueue if card is unbound
commit: 4c33de0673ced9c7c37b3bbd9bfe0fda72340b2aAll being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark