Commit 412efa73 authored by Shilpa Sreeramalu's avatar Shilpa Sreeramalu Committed by Mark Brown

ASoC: Intel: Get correct usage_count value to load firmware

The usage_count variable was read before it was set to the correct
value, due to which the firmware load was failing. Because of this
IPC messages sent to the firmware were timing out causing a delay
of about 1 second while playing audio from the internal speakers.

With this patch the usage_count is read after the function call
pm_runtime_get_sync which will increment the usage_count variable
and the firmware load is successful and all the IPC messages are
processed correctly.
Signed-off-by: default avatarShilpa Sreeramalu <shilpa.sreeramalu@intel.com>
Signed-off-by: default avatarFang, Yang A <yang.a.fang@intel.com>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
Cc: stable@vger.kernel.org
parent 8bc76c8b
...@@ -42,6 +42,11 @@ ...@@ -42,6 +42,11 @@
#define MIN_FRAGMENT_SIZE (50 * 1024) #define MIN_FRAGMENT_SIZE (50 * 1024)
#define MAX_FRAGMENT_SIZE (1024 * 1024) #define MAX_FRAGMENT_SIZE (1024 * 1024)
#define SST_GET_BYTES_PER_SAMPLE(pcm_wd_sz) (((pcm_wd_sz + 15) >> 4) << 1) #define SST_GET_BYTES_PER_SAMPLE(pcm_wd_sz) (((pcm_wd_sz + 15) >> 4) << 1)
#ifdef CONFIG_PM
#define GET_USAGE_COUNT(dev) (atomic_read(&dev->power.usage_count))
#else
#define GET_USAGE_COUNT(dev) 1
#endif
int free_stream_context(struct intel_sst_drv *ctx, unsigned int str_id) int free_stream_context(struct intel_sst_drv *ctx, unsigned int str_id)
{ {
...@@ -141,15 +146,9 @@ static int sst_power_control(struct device *dev, bool state) ...@@ -141,15 +146,9 @@ static int sst_power_control(struct device *dev, bool state)
int ret = 0; int ret = 0;
int usage_count = 0; int usage_count = 0;
#ifdef CONFIG_PM
usage_count = atomic_read(&dev->power.usage_count);
#else
usage_count = 1;
#endif
if (state == true) { if (state == true) {
ret = pm_runtime_get_sync(dev); ret = pm_runtime_get_sync(dev);
usage_count = GET_USAGE_COUNT(dev);
dev_dbg(ctx->dev, "Enable: pm usage count: %d\n", usage_count); dev_dbg(ctx->dev, "Enable: pm usage count: %d\n", usage_count);
if (ret < 0) { if (ret < 0) {
dev_err(ctx->dev, "Runtime get failed with err: %d\n", ret); dev_err(ctx->dev, "Runtime get failed with err: %d\n", ret);
...@@ -164,6 +163,7 @@ static int sst_power_control(struct device *dev, bool state) ...@@ -164,6 +163,7 @@ static int sst_power_control(struct device *dev, bool state)
} }
} }
} else { } else {
usage_count = GET_USAGE_COUNT(dev);
dev_dbg(ctx->dev, "Disable: pm usage count: %d\n", usage_count); dev_dbg(ctx->dev, "Disable: pm usage count: %d\n", usage_count);
return sst_pm_runtime_put(ctx); return sst_pm_runtime_put(ctx);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment