During dsp init failure, the ref count is not incremented and dsp is
powered down. But as the skl driver calls put_core for the init failure it
decrements the dsp core ref count and ref count becomes unbalanced.
This results in dsp core powered up in further runtime suspend/resume
cycles and never powered down.
So increment the ref count before dsp core powerup and for any failure,
decrement in put_core will be balanced.
Signed-off-by: Subhransu S. Prusty <subhransu.s.prusty@intel.com>
Acked-By: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
                return -EINVAL;
        }
 
+       skl->cores.usage_count[core_id]++;
+
        if (skl->cores.state[core_id] == SKL_DSP_RESET) {
                ret = ctx->fw_ops.set_state_D0(ctx, core_id);
                if (ret < 0) {
                }
        }
 
-       skl->cores.usage_count[core_id]++;
-
 out:
        dev_dbg(ctx->dev, "core id %d state %d usage_count %d\n",
                        core_id, skl->cores.state[core_id],