soundwire: qcom: fix unbalanced pm_runtime_put()
authorKrzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Wed, 17 May 2023 16:37:49 +0000 (18:37 +0200)
committerVinod Koul <vkoul@kernel.org>
Mon, 29 May 2023 05:19:46 +0000 (10:49 +0530)
commit9f9914b178a7935d2d94ee3e1bf55f2b42b18528
treef9c285af9f0ce49f36122cf89b1a0d293a68bbb9
parent4830bfa2c812689e6007f42536eeb86df08f9d29
soundwire: qcom: fix unbalanced pm_runtime_put()

This reverts commit 57ed510b0547 ("soundwire: qcom: use
pm_runtime_resume_and_get()") which introduced unbalanced
pm_runtime_put(), when device did not have runtime PM enabled.

If pm_runtime_resume_and_get() failed with -EACCES, the driver continued
execution and finally called pm_runtime_put_autosuspend().  Since
pm_runtime_resume_and_get() drops the usage counter on every error, this
lead to double decrement of that counter visible in certain debugfs
actions on unattached devices (still in reset state):

  $ cat /sys/kernel/debug/soundwire/master-0-0/sdw:0:0217:f001:00:0/registers
  qcom-soundwire 3210000.soundwire-controller: swrm_wait_for_wr_fifo_avail err write overflow
  soundwire sdw-master-0: trf on Slave 1 failed:-5 read addr e36 count 1
  soundwire sdw:0:0217:f001:00:0: Runtime PM usage count underflow!

Fixes: 57ed510b0547 ("soundwire: qcom: use pm_runtime_resume_and_get()")
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20230517163750.997629-1-krzysztof.kozlowski@linaro.org
Signed-off-by: Vinod Koul <vkoul@kernel.org>
drivers/soundwire/qcom.c