]> git.itanic.dy.fi Git - linux-stable/commit
ASoC: codecs: rt700/rt711/rt711-sdca: resume bus/codec in .set_jack_detect
authorPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Mon, 6 Jun 2022 20:37:52 +0000 (15:37 -0500)
committerMark Brown <broonie@kernel.org>
Fri, 24 Jun 2022 15:21:35 +0000 (16:21 +0100)
commit40737057b48f1b4db67b0d766b95c87ba8fc5e03
treeb06c9046b5411b85f730d9992737ef47e685d08b
parentba98d7d8b60ba410aa03834f6aa48fd3b2e68478
ASoC: codecs: rt700/rt711/rt711-sdca: resume bus/codec in .set_jack_detect

The .set_jack_detect() codec component callback is invoked during card
registration, which happens when the machine driver is probed.

The issue is that this callback can race with the bus suspend/resume,
and IO timeouts can happen. This can be reproduced very easily if the
machine driver is 'blacklisted' and manually probed after the bus
suspends. The bus and codec need to be re-initialized using pm_runtime
helpers.

Previous contributions tried to make sure accesses to the bus during
the .set_jack_detect() component callback only happen when the bus is
active. This was done by changing the regcache status on a component
remove. This is however a layering violation, the regcache status
should only be modified on device probe, suspend and resume. The
component probe/remove should not modify how the device regcache is
handled. This solution also didn't handle all the possible race
conditions, and the RT700 headset codec was not handled.

This patch tries to resume the codec device before handling the jack
initializations. In case the codec has not yet been initialized,
pm_runtime may not be enabled yet, so we don't squelch the -EACCES
error code and only stop the jack information. When the codec reports
as attached, the jack initialization will proceed as usual.

BugLink: https://github.com/thesofproject/linux/issues/3643
Fixes: 7ad4d237e7c4a ('ASoC: rt711-sdca: Add RT711 SDCA vendor-specific driver')
Fixes: 899b12542b089 ('ASoC: rt711: add snd_soc_component remove callback')
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/20220606203752.144159-8-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/codecs/rt700.c
sound/soc/codecs/rt711-sdca.c
sound/soc/codecs/rt711.c