ASoC: Intel: sst: Fix runtime PM imbalance in sst_power_control
diff mbox series

Message ID 20200525070701.3888-1-dinghao.liu@zju.edu.cn
State New
Headers show
Series
  • ASoC: Intel: sst: Fix runtime PM imbalance in sst_power_control
Related show

Commit Message

Dinghao Liu May 25, 2020, 7:06 a.m. UTC
When sst_load_fw() returns an error code, a pairing runtime
PM usage counter decrement is needed to keep the counter
balanced.

Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
---
 sound/soc/intel/atom/sst/sst_drv_interface.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Pierre-Louis Bossart May 26, 2020, 1:25 p.m. UTC | #1
On 5/25/20 2:06 AM, Dinghao Liu wrote:
> When sst_load_fw() returns an error code, a pairing runtime
> PM usage counter decrement is needed to keep the counter
> balanced.
> 
> Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
> ---
>   sound/soc/intel/atom/sst/sst_drv_interface.c | 1 +
>   1 file changed, 1 insertion(+)
> 
> diff --git a/sound/soc/intel/atom/sst/sst_drv_interface.c b/sound/soc/intel/atom/sst/sst_drv_interface.c
> index 762495385d5c..3897985b254f 100644
> --- a/sound/soc/intel/atom/sst/sst_drv_interface.c
> +++ b/sound/soc/intel/atom/sst/sst_drv_interface.c
> @@ -150,6 +150,7 @@ static int sst_power_control(struct device *dev, bool state)
>   		if ((ctx->sst_state == SST_RESET) && (usage_count == 1)) {
>   			ret = sst_load_fw(ctx);
>   			if (ret) {
> +				pm_runtime_put_sync(dev);
>   				dev_err(dev, "FW download fail %d\n", ret);
>   				sst_set_fw_state_locked(ctx, SST_RESET);
>   				ret = sst_pm_runtime_put(ctx);

this change doesn't seem quite right, if you look the code below there 
is no PM imbalance, is there?

int sst_pm_runtime_put(struct intel_sst_drv *sst_drv)
{
	int ret;

	pm_runtime_mark_last_busy(sst_drv->dev);
	ret = pm_runtime_put_autosuspend(sst_drv->dev);
	if (ret < 0)
		return ret;
	return 0;
}
Dinghao Liu May 27, 2020, 1:07 a.m. UTC | #2
> 
> this change doesn't seem quite right, if you look the code below there 
> is no PM imbalance, is there?
> 
> int sst_pm_runtime_put(struct intel_sst_drv *sst_drv)
> {
> 	int ret;
> 
> 	pm_runtime_mark_last_busy(sst_drv->dev);
> 	ret = pm_runtime_put_autosuspend(sst_drv->dev);
> 	if (ret < 0)
> 		return ret;
> 	return 0;
> }

You are right. Thank you for your correction!

Regards,
Dinghao

Patch
diff mbox series

diff --git a/sound/soc/intel/atom/sst/sst_drv_interface.c b/sound/soc/intel/atom/sst/sst_drv_interface.c
index 762495385d5c..3897985b254f 100644
--- a/sound/soc/intel/atom/sst/sst_drv_interface.c
+++ b/sound/soc/intel/atom/sst/sst_drv_interface.c
@@ -150,6 +150,7 @@  static int sst_power_control(struct device *dev, bool state)
 		if ((ctx->sst_state == SST_RESET) && (usage_count == 1)) {
 			ret = sst_load_fw(ctx);
 			if (ret) {
+				pm_runtime_put_sync(dev);
 				dev_err(dev, "FW download fail %d\n", ret);
 				sst_set_fw_state_locked(ctx, SST_RESET);
 				ret = sst_pm_runtime_put(ctx);