Skip to content

Commit 9f9914b

Browse files
krzkvinodkoul
authored andcommitted
soundwire: qcom: fix unbalanced pm_runtime_put()
This reverts commit 57ed510 ("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: 57ed510 ("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>
1 parent 4830bfa commit 9f9914b

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

drivers/soundwire/qcom.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -642,11 +642,12 @@ static irqreturn_t qcom_swrm_wake_irq_handler(int irq, void *dev_id)
642642
struct qcom_swrm_ctrl *ctrl = dev_id;
643643
int ret;
644644

645-
ret = pm_runtime_resume_and_get(ctrl->dev);
645+
ret = pm_runtime_get_sync(ctrl->dev);
646646
if (ret < 0 && ret != -EACCES) {
647647
dev_err_ratelimited(ctrl->dev,
648-
"pm_runtime_resume_and_get failed in %s, ret %d\n",
648+
"pm_runtime_get_sync failed in %s, ret %d\n",
649649
__func__, ret);
650+
pm_runtime_put_noidle(ctrl->dev);
650651
return ret;
651652
}
652653

@@ -1257,11 +1258,12 @@ static int qcom_swrm_startup(struct snd_pcm_substream *substream,
12571258
struct snd_soc_dai *codec_dai;
12581259
int ret, i;
12591260

1260-
ret = pm_runtime_resume_and_get(ctrl->dev);
1261+
ret = pm_runtime_get_sync(ctrl->dev);
12611262
if (ret < 0 && ret != -EACCES) {
12621263
dev_err_ratelimited(ctrl->dev,
1263-
"pm_runtime_resume_and_get failed in %s, ret %d\n",
1264+
"pm_runtime_get_sync failed in %s, ret %d\n",
12641265
__func__, ret);
1266+
pm_runtime_put_noidle(ctrl->dev);
12651267
return ret;
12661268
}
12671269

@@ -1463,11 +1465,12 @@ static int swrm_reg_show(struct seq_file *s_file, void *data)
14631465
struct qcom_swrm_ctrl *ctrl = s_file->private;
14641466
int reg, reg_val, ret;
14651467

1466-
ret = pm_runtime_resume_and_get(ctrl->dev);
1468+
ret = pm_runtime_get_sync(ctrl->dev);
14671469
if (ret < 0 && ret != -EACCES) {
14681470
dev_err_ratelimited(ctrl->dev,
1469-
"pm_runtime_resume_and_get failed in %s, ret %d\n",
1471+
"pm_runtime_get_sync failed in %s, ret %d\n",
14701472
__func__, ret);
1473+
pm_runtime_put_noidle(ctrl->dev);
14711474
return ret;
14721475
}
14731476

0 commit comments

Comments
 (0)