ASoC: SOF: fix runtime pm usage mismatch after probe errors
authorKai Vehmanen <kai.vehmanen@linux.intel.com>
Wed, 10 Feb 2021 10:52:37 +0000 (12:52 +0200)
committerMark Brown <broonie@kernel.org>
Wed, 10 Feb 2021 17:22:57 +0000 (17:22 +0000)
commit271d9373db1c76f239fe3124e552b6b58b2af984
tree451261a1f8cc5e4161cd9417bbf2ae4a35e65e69
parentb6eabd247db8bb2d013fb9a9451ecb04a44ee58f
ASoC: SOF: fix runtime pm usage mismatch after probe errors

With current delayed probe implementation, sof_probe_complete is not
called in case of errors. And as this function is responsible for
decrementing runtime pm usage counter, this will result in following
problem:

 - probe driver in conditions where probe will fail (to force
   the condition on Intel SOF systems, set
   "snd_sof_intel_hda_common.codec_mask=0")
 - unload driver (runtime-pm usage_count is leaked)
 - fix the issue by installing missing fw, modifying module parameters,
   etc actions
 - try to load driver again -> success, probe ok
 -> device never enters runtime suspend

Fix the issue by storing result of delayed probe to a state variable and
providing new snd_sof_device_probe_completed() to be queried from SOF
PCI/ACPI/OF drivers.

If probe never completed successfully, runtime PM was not set up and
thus at remove(), we should not increment usage count anymore.

Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@intel.com>
Reviewed-by: Guennadi Liakhovetski <guennadi.liakhovetski@intel.com>
Link: https://lore.kernel.org/r/20210210105237.2179273-1-kai.vehmanen@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/sof/core.c
sound/soc/sof/sof-pci-dev.c
sound/soc/sof/sof-priv.h