mbox series

[0/8] ASoC/soundwire/qdsp6/wcd: fix leaks and probe deferral

Message ID 20230705123018.30903-1-johan+linaro@kernel.org
Headers show
Series ASoC/soundwire/qdsp6/wcd: fix leaks and probe deferral | expand

Message

Johan Hovold July 5, 2023, 12:30 p.m. UTC
I've been hitting a race during boot which breaks probe of the sound
card on the Lenovo ThinkPad X13s as I've previously reported here:

	https://lore.kernel.org/all/ZIHMMFtuDtvdpFAZ@hovoldconsulting.com/

The immediate issue appeared to be a probe deferral that was turned into
a hard failure, but addressing that in itself only made things worse as
it exposed further bugs.

I was hoping someone more familiar with the code in question would look
into this, but as this affects users of the X13s and breaks audio on my
machine every fifth boot or so, I decided to investigate it myself.

As expected, the Qualcomm codec drivers are broken and specifically leak
resources on component remove, which in turn breaks sound card probe
deferrals.

The source of the deferral itself appears to be legitimate and was
simply due to some audio component not yet having been registered due to
random changes in timing during boot.

These issues can most easily be reproduced by simply blacklisting the
q6apm_dai module and loading it manually after boot.

The sound card probe deferral also exposes a bug in the soundwire
subsystem, which uses completion structures for signalling that a device
has been enumerated on the bus and initialised. The way this is
implemented prevents reprobed codec drivers from learning that the
soundwire devices are still attached, which causes probe to fail.

Included are also two patches that suppresses error messages on
component probe deferral to avoid spamming the logs during boot.

These patches should preferably all go through the ASoC tree even if
merging the soundwire fix separately also works.

Note the ASoC tree already has the following related fixes:

	https://lore.kernel.org/lkml/20230630120318.6571-1-johan+linaro@kernel.org/
	https://lore.kernel.org/lkml/20230630142717.5314-1-johan+linaro@kernel.org/
	https://lore.kernel.org/lkml/20230701094723.29379-1-johan+linaro@kernel.org/
	https://lore.kernel.org/lkml/20230703124701.11734-1-johan+linaro@kernel.org/

Johan


Johan Hovold (8):
  soundwire: fix enumeration completion
  ASoC: qdsp6: audioreach: fix topology probe deferral
  ASoC: codecs: wcd938x: fix missing clsh ctrl error handling
  ASoC: codecs: wcd938x: fix resource leaks on component remove
  ASoC: codecs: wcd934x: fix resource leaks on component remove
  ASoC: codecs: wcd-mbhc-v2: fix resource leaks on component remove
  ASoC: topology: suppress probe deferral errors
  ASoC: core: suppress probe deferral errors

 drivers/soundwire/bus.c         |  8 ++---
 sound/soc/codecs/wcd-mbhc-v2.c  | 57 ++++++++++++++++++++++---------
 sound/soc/codecs/wcd934x.c      | 12 +++++++
 sound/soc/codecs/wcd938x.c      | 59 +++++++++++++++++++++++++++++----
 sound/soc/qcom/qdsp6/topology.c |  4 +--
 sound/soc/soc-core.c            |  6 ++--
 sound/soc/soc-topology.c        | 10 ++++--
 7 files changed, 122 insertions(+), 34 deletions(-)

Comments

Vinod Koul July 10, 2023, 8:53 a.m. UTC | #1
On Wed, 05 Jul 2023 14:30:10 +0200, Johan Hovold wrote:
> I've been hitting a race during boot which breaks probe of the sound
> card on the Lenovo ThinkPad X13s as I've previously reported here:
> 
> 	https://lore.kernel.org/all/ZIHMMFtuDtvdpFAZ@hovoldconsulting.com/
> 
> The immediate issue appeared to be a probe deferral that was turned into
> a hard failure, but addressing that in itself only made things worse as
> it exposed further bugs.
> 
> [...]

Applied, thanks!

[1/8] soundwire: fix enumeration completion
      commit: 27e0c9f08ac622db7b907c126249dd23367867ab

Best regards,
Mark Brown July 11, 2023, 8:44 p.m. UTC | #2
On Wed, 05 Jul 2023 14:30:10 +0200, Johan Hovold wrote:
> I've been hitting a race during boot which breaks probe of the sound
> card on the Lenovo ThinkPad X13s as I've previously reported here:
> 
> 	https://lore.kernel.org/all/ZIHMMFtuDtvdpFAZ@hovoldconsulting.com/
> 
> The immediate issue appeared to be a probe deferral that was turned into
> a hard failure, but addressing that in itself only made things worse as
> it exposed further bugs.
> 
> [...]

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

Thanks!

[2/8] ASoC: qdsp6: audioreach: fix topology probe deferral
      commit: 46ec420573cefa1fc98025e7e6841bdafd6f1e20
[3/8] ASoC: codecs: wcd938x: fix missing clsh ctrl error handling
      commit: ed0dd9205bf69593edb495cb4b086dbae96a3f05
[4/8] ASoC: codecs: wcd938x: fix resource leaks on component remove
      commit: a3406f87775fee986876e03f93a84385f54d5999
[5/8] ASoC: codecs: wcd934x: fix resource leaks on component remove
      commit: 798590cc7d3c2b5f3a7548d96dd4d8a081c1bc39
[6/8] ASoC: codecs: wcd-mbhc-v2: fix resource leaks on component remove
      commit: a5475829adcc600bc69ee9ff7c9e3e43fb4f8d30
[7/8] ASoC: topology: suppress probe deferral errors
      commit: b6c3bdda3a7e43acfcec711ce20e7cfe44744740
[8/8] ASoC: core: suppress probe deferral errors
      commit: f09b6e96796056633453cb0d07b720d09f1efc68

All 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