Commit 770f3d99 authored by Pierre-Louis Bossart's avatar Pierre-Louis Bossart Committed by Mark Brown

ASoC: rt711/5682: check if bus is active before deferred jack detection

This patch takes a defensive programming and paranoid approach in case
the parent device (SoundWire) is pm_runtime resumed but the rt711
device is not. In that case, during the attachment and initialization,
a jack detection workqueue can be scheduled. Since the pm_runtime
suspend routines will not be invoked, the sequence to cancel all
deferred work is not executed, and the jack detection could happen
after the bus stops operating, leading to a timeout.

This patch applies the same solution to rt5682, based on the
similarities between codec drivers. The race condition with rt5682 was
not detected experimentally though.

BugLink: https://github.com/thesofproject/linux/issues/3459Signed-off-by: default avatarPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: default avatarRander Wang <rander.wang@intel.com>
Reviewed-by: default avatarBard Liao <yung-chuan.liao@linux.intel.com>
Link: https://lore.kernel.org/r/20220406192005.262996-1-pierre-louis.bossart@linux.intel.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent fcd1e39c
...@@ -1100,6 +1100,15 @@ void rt5682_jack_detect_handler(struct work_struct *work) ...@@ -1100,6 +1100,15 @@ void rt5682_jack_detect_handler(struct work_struct *work)
return; return;
} }
if (rt5682->is_sdw) {
if (pm_runtime_status_suspended(rt5682->slave->dev.parent)) {
dev_dbg(&rt5682->slave->dev,
"%s: parent device is pm_runtime_status_suspended, skipping jack detection\n",
__func__);
return;
}
}
dapm = snd_soc_component_get_dapm(rt5682->component); dapm = snd_soc_component_get_dapm(rt5682->component);
snd_soc_dapm_mutex_lock(dapm); snd_soc_dapm_mutex_lock(dapm);
......
...@@ -245,6 +245,13 @@ static void rt711_jack_detect_handler(struct work_struct *work) ...@@ -245,6 +245,13 @@ static void rt711_jack_detect_handler(struct work_struct *work)
if (!rt711->component->card->instantiated) if (!rt711->component->card->instantiated)
return; return;
if (pm_runtime_status_suspended(rt711->slave->dev.parent)) {
dev_dbg(&rt711->slave->dev,
"%s: parent device is pm_runtime_status_suspended, skipping jack detection\n",
__func__);
return;
}
reg = RT711_VERB_GET_PIN_SENSE | RT711_HP_OUT; reg = RT711_VERB_GET_PIN_SENSE | RT711_HP_OUT;
ret = regmap_read(rt711->regmap, reg, &jack_status); ret = regmap_read(rt711->regmap, reg, &jack_status);
if (ret < 0) if (ret < 0)
......
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