Patch "ASoC: rt5682: do not block workqueue if card is unbound" has been added to the 5.15-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

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

to the 5.15-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     asoc-rt5682-do-not-block-workqueue-if-card-is-unboun.patch
and it can be found in the queue-5.15 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit d4b6e8050b47580fbbc80a544c3cdf3267cf4c37
Author: Kai Vehmanen <kai.vehmanen@xxxxxxxxxxxxxxx>
Date:   Mon Feb 7 17:30:00 2022 +0200

    ASoC: rt5682: do not block workqueue if card is unbound
    
    [ Upstream commit 4c33de0673ced9c7c37b3bbd9bfe0fda72340b2a ]
    
    The 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.
    
    Signed-off-by: Kai Vehmanen <kai.vehmanen@xxxxxxxxxxxxxxx>
    Reviewed-by: Bard Liao <yung-chuan.liao@xxxxxxxxxxxxxxx>
    Reviewed-by: Ranjani Sridharan <ranjani.sridharan@xxxxxxxxxxxxxxx>
    Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@xxxxxxxxxxxxxxx>
    Reviewed-by: Péter Ujfalusi <peter.ujfalusi@xxxxxxxxxxxxxxx>
    Reviewed-by: Shuming Fan <shumingf@xxxxxxxxxxx>
    Link: https://lore.kernel.org/r/20220207153000.3452802-3-kai.vehmanen@xxxxxxxxxxxxxxx
    Signed-off-by: Mark Brown <broonie@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/sound/soc/codecs/rt5682.c b/sound/soc/codecs/rt5682.c
index 757d1362b5f48..6ad3159eceb98 100644
--- a/sound/soc/codecs/rt5682.c
+++ b/sound/soc/codecs/rt5682.c
@@ -1090,11 +1090,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->calibrate_mutex);
 



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux