Skip to content

Commit 770f3d9

Browse files
plbossartbroonie
authored andcommitted
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: thesofproject#3459 Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Reviewed-by: Rander Wang <rander.wang@intel.com> Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com> Link: https://lore.kernel.org/r/20220406192005.262996-1-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent fcd1e39 commit 770f3d9

2 files changed

Lines changed: 16 additions & 0 deletions

File tree

sound/soc/codecs/rt5682.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1100,6 +1100,15 @@ void rt5682_jack_detect_handler(struct work_struct *work)
11001100
return;
11011101
}
11021102

1103+
if (rt5682->is_sdw) {
1104+
if (pm_runtime_status_suspended(rt5682->slave->dev.parent)) {
1105+
dev_dbg(&rt5682->slave->dev,
1106+
"%s: parent device is pm_runtime_status_suspended, skipping jack detection\n",
1107+
__func__);
1108+
return;
1109+
}
1110+
}
1111+
11031112
dapm = snd_soc_component_get_dapm(rt5682->component);
11041113

11051114
snd_soc_dapm_mutex_lock(dapm);

sound/soc/codecs/rt711.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,13 @@ static void rt711_jack_detect_handler(struct work_struct *work)
245245
if (!rt711->component->card->instantiated)
246246
return;
247247

248+
if (pm_runtime_status_suspended(rt711->slave->dev.parent)) {
249+
dev_dbg(&rt711->slave->dev,
250+
"%s: parent device is pm_runtime_status_suspended, skipping jack detection\n",
251+
__func__);
252+
return;
253+
}
254+
248255
reg = RT711_VERB_GET_PIN_SENSE | RT711_HP_OUT;
249256
ret = regmap_read(rt711->regmap, reg, &jack_status);
250257
if (ret < 0)

0 commit comments

Comments
 (0)