Skip to contentSkip to conversation

ASoC: Intel: Get correct usage_count value to load firmware

PATCH Superseded [email protected] 3 participants 7 messages Jul 14, 2015 – Jul 15, 2015

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ASoC: Intel: Get correct usage_count value to load firmware

From: Shilpa Sreeramalu <[email protected]>

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.

---
 sound/soc/intel/atom/sst/sst_drv_interface.c |   14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
sound/soc/intel/atom/sst/sst_drv_interface.c +7 -7
index 620da1d..440b953 100644
@@ -42,6 +42,11 @@
 #define MIN_FRAGMENT_SIZE (50 * 1024)
 #define MAX_FRAGMENT_SIZE (1024 * 1024)
 #define SST_GET_BYTES_PER_SAMPLE(pcm_wd_sz)  (((pcm_wd_sz + 15) >> 4) << 1)
+#ifdef PM_CONFIG
+#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)
 {
@@ -141,15 +146,9 @@ static int sst_power_control(struct device *dev, bool state)
 	int ret = 0;
 	int usage_count = 0;
 
-#ifdef CONFIG_PM
-	usage_count = atomic_read(&dev->power.usage_count);
-#else
-	usage_count = 1;
-#endif
-
 	if (state == true) {
 		ret = pm_runtime_get_sync(dev);
-
+		usage_count = GET_USAGE_COUNT(dev);
 		dev_dbg(ctx->dev, "Enable: pm usage count: %d\n", usage_count);
 		if (ret < 0) {
 			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)
 			}
 		}
 	} else {
+		usage_count = GET_USAGE_COUNT(dev);
 		dev_dbg(ctx->dev, "Disable: pm usage count: %d\n", usage_count);
 		return sst_pm_runtime_put(ctx);
 	}
Signature · 1 line
1.7.9.5
maintainer
#1 lore raw

sound/soc/intel/atom/sst/sst_drv_interface.c line 49

Quoted 5 lines · On Tue, Jul 14, 2015 at 11:13:46AM -0700, [email protected] wrote:
sound/soc/intel/atom/sst/sst_drv_interface.c +5 -0
+#ifdef PM_CONFIG
+#define GET_USAGE_COUNT(dev) (atomic_read(&dev->power.usage_count))
+#else
+#define GET_USAGE_COUNT(dev) 1
+#endif

PM_CONFIG?

#2 lore raw
Quoted 14 lines

-----Original Message-----
From: Mark Brown [mailto:[email protected]]
Sent: Tuesday, July 14, 2015 11:16 AM
To: Fang, Yang A
Cc: [email protected]; [email protected]; Koul, Vinod; Nujella, Sathyanarayana; [email protected]; Sripathi, Srinivas; Sreeramalu, Shilpa; Mirche, Dinesh; [email protected]
Subject: Re: [PATCH] ASoC: Intel: Get correct usage_count value to load firmware

On Tue, Jul 14, 2015 at 11:13:46AM -0700, [email protected] wrote:

Quoted 8 lines

sound/soc/intel/atom/sst/sst_drv_interface.c line 49

Quoted 6 lines
(quoted diff) +2 -0
+#ifdef PM_CONFIG
+#define GET_USAGE_COUNT(dev) (atomic_read(&dev-

power.usage_count))

sound/soc/intel/atom/sst/sst_drv_interface.c +3 -0
+#else
+#define GET_USAGE_COUNT(dev) 1
+#endif

PM_CONFIG?

Sorry for the typo. Will fix that.

#3 lore raw

PATCH v2 1/1 ASoC: Intel: Get correct usage_count value to load firmware

In reply to [email protected]

From: Shilpa Sreeramalu <[email protected]>

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.

---
 sound/soc/intel/atom/sst/sst_drv_interface.c |   14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
sound/soc/intel/atom/sst/sst_drv_interface.c +7 -7
index 620da1d..0e0e4d9 100644
@@ -42,6 +42,11 @@
 #define MIN_FRAGMENT_SIZE (50 * 1024)
 #define MAX_FRAGMENT_SIZE (1024 * 1024)
 #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)
 {
@@ -141,15 +146,9 @@ static int sst_power_control(struct device *dev, bool state)
 	int ret = 0;
 	int usage_count = 0;
 
-#ifdef CONFIG_PM
-	usage_count = atomic_read(&dev->power.usage_count);
-#else
-	usage_count = 1;
-#endif
-
 	if (state == true) {
 		ret = pm_runtime_get_sync(dev);
-
+		usage_count = GET_USAGE_COUNT(dev);
 		dev_dbg(ctx->dev, "Enable: pm usage count: %d\n", usage_count);
 		if (ret < 0) {
 			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)
 			}
 		}
 	} else {
+		usage_count = GET_USAGE_COUNT(dev);
 		dev_dbg(ctx->dev, "Disable: pm usage count: %d\n", usage_count);
 		return sst_pm_runtime_put(ctx);
 	}
Signature · 1 line
1.7.9.5
#5 lore raw

PATCH v3 1/1 ASoC: Intel: Get correct usage_count value to load firmware

In reply to [email protected]

From: Shilpa Sreeramalu <[email protected]>

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.

---
 sound/soc/intel/atom/sst/sst_drv_interface.c |   14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
sound/soc/intel/atom/sst/sst_drv_interface.c +7 -7
index 620da1d..0e0e4d9 100644
@@ -42,6 +42,11 @@
 #define MIN_FRAGMENT_SIZE (50 * 1024)
 #define MAX_FRAGMENT_SIZE (1024 * 1024)
 #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)
 {
@@ -141,15 +146,9 @@ static int sst_power_control(struct device *dev, bool state)
 	int ret = 0;
 	int usage_count = 0;
 
-#ifdef CONFIG_PM
-	usage_count = atomic_read(&dev->power.usage_count);
-#else
-	usage_count = 1;
-#endif
-
 	if (state == true) {
 		ret = pm_runtime_get_sync(dev);
-
+		usage_count = GET_USAGE_COUNT(dev);
 		dev_dbg(ctx->dev, "Enable: pm usage count: %d\n", usage_count);
 		if (ret < 0) {
 			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)
 			}
 		}
 	} else {
+		usage_count = GET_USAGE_COUNT(dev);
 		dev_dbg(ctx->dev, "Disable: pm usage count: %d\n", usage_count);
 		return sst_pm_runtime_put(ctx);
 	}
Signature · 1 line
1.7.9.5
Acked-by on v3 1/1
#6 lore raw
Quoted 11 lines · On Wed, Jul 15, 2015 at 07:58:09AM -0700, [email protected] wrote:

From: Shilpa Sreeramalu <[email protected]>

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.

Signature · 1 line
~Vinod