Skip to contentSkip to conversation

PM_QOS-to-use-handle-based-requests-pcm-update 5/5

PATCH In review mark gross 2 participants 5 messages Dec 1, 2009 – Dec 2, 2009 Sound

lore
Share & tools
lore

mark gross

author
#0 lore raw

PATCH 1/1 PM_QOS-to-use-handle-based-requests-pcm-update 5/5

This is the patch to update sound pcm's dependencies on the pmqos api that was changed in the first patch in this series.

Updated per input from RFC.

--mgross

Quoted 1 line

From 7a0daea4708a2fca0e615ba36daeac60efea3cd6 Mon Sep 17 00:00:00 2001

From: mark gross <mgross@mgross-hp8510w.(none)>
Date: Tue, 1 Dec 2009 13:01:04 -0800
Subject: [PATCH 5/5] PM_QOS to use handle based requests pcm update

---
 include/sound/pcm.h     |    3 ++-
 sound/core/pcm.c        |    3 ---
 sound/core/pcm_native.c |   14 ++++++++------
 3 files changed, 10 insertions(+), 10 deletions(-)
include/sound/pcm.h +2 -1
index de6d981..91daac3 100644
@@ -29,6 +29,7 @@
 #include <linux/poll.h>
 #include <linux/mm.h>
 #include <linux/bitops.h>
+#include <linux/pm_qos_params.h>
 
 #define snd_pcm_substream_chip(substream) ((substream)->private_data)
 #define snd_pcm_chip(pcm) ((pcm)->private_data)
@@ -355,7 +356,7 @@ struct snd_pcm_substream {
 	int number;
 	char name[32];			/* substream name */
 	int stream;			/* stream (direction) */
-	char latency_id[20];		/* latency identifier */
+	struct pm_qos_request_list *latency_pm_qos_req; /* pm_qos latency request */
 	size_t buffer_bytes_max;	/* limit ring buffer size */
 	struct snd_dma_buffer dma_buffer;
 	unsigned int dma_buf_id;
sound/core/pcm.c +0 -3
index c69c60b..6faf4b5 100644
@@ -647,9 +647,6 @@ int snd_pcm_new_stream(struct snd_pcm *pcm, int stream, int substream_count)
 		substream->number = idx;
 		substream->stream = stream;
 		sprintf(substream->name, "subdevice #%i", idx);
-		snprintf(substream->latency_id, sizeof(substream->latency_id),
-			 "ALSA-PCM%d-%d%c%d", pcm->card->number, pcm->device,
-			 (stream ? 'c' : 'p'), idx);
 		substream->buffer_bytes_max = UINT_MAX;
 		if (prev == NULL)
 			pstr->substream = substream;
sound/core/pcm_native.c +8 -6
index ab73edf..2aab6cf 100644
@@ -447,11 +447,13 @@ static int snd_pcm_hw_params(struct snd_pcm_substream *substream,
 	snd_pcm_timer_resolution_change(substream);
 	runtime->status->state = SNDRV_PCM_STATE_SETUP;
 
-	pm_qos_remove_requirement(PM_QOS_CPU_DMA_LATENCY,
-				substream->latency_id);
+	if (substream->latency_pm_qos_req) {
+		pm_qos_remove_request(substream->latency_pm_qos_req);
+		substream->latency_pm_qos_req = NULL;
+	}
 	if ((usecs = period_to_usecs(runtime)) >= 0)
-		pm_qos_add_requirement(PM_QOS_CPU_DMA_LATENCY,
-					substream->latency_id, usecs);
+		substream->latency_pm_qos_req = pm_qos_add_request(
+					PM_QOS_CPU_DMA_LATENCY, usecs);
 	return 0;
  _error:
 	/* hardware might be unuseable from this time,
@@ -506,8 +508,8 @@ static int snd_pcm_hw_free(struct snd_pcm_substream *substream)
 	if (substream->ops->hw_free)
 		result = substream->ops->hw_free(substream);
 	runtime->status->state = SNDRV_PCM_STATE_OPEN;
-	pm_qos_remove_requirement(PM_QOS_CPU_DMA_LATENCY,
-		substream->latency_id);
+	pm_qos_remove_request(substream->latency_pm_qos_req);
+	substream->latency_pm_qos_req = NULL;
 	return result;
 }
 
Signature · 1 line
1.6.3.3
#1 lore raw

At Tue, 1 Dec 2009 13:38:40 -0800,

Quoted 3 lines · mark gross
sound/core/pcm_native.c +0 -0

(snip)

sound/core/pcm_native.c static int snd_pcm_hw_free(struct snd_pcm_substream *substream) · line 511

Quoted 7 lines
sound/core/pcm_native.c +1 -2
@@ -506,8 +508,8 @@ static int snd_pcm_hw_free(struct snd_pcm_substream *substream)
 	if (substream->ops->hw_free)
 		result = substream->ops->hw_free(substream);
 	runtime->status->state = SNDRV_PCM_STATE_OPEN;
-	pm_qos_remove_requirement(PM_QOS_CPU_DMA_LATENCY,
-		substream->latency_id);
+	pm_qos_remove_request(substream->latency_pm_qos_req);

The NULL check seems needed in the caller side because pm_qos_remove_request() doesn't do it.

Or, would you add a NULL check in pm_qos_remove_request()? It'd be more handy.

thanks,

Takashi

author
#2 lore raw
Quoted 6 lines · Takashi Iwai

At Tue, 1 Dec 2009 13:38:40 -0800,

Quoted 3 lines · mark gross
sound/core/pcm_native.c +0 -0

(snip)

Quoted 10 lines

sound/core/pcm_native.c static int snd_pcm_hw_free(struct snd_pcm_substream *substream) · line 511

Quoted 7 lines
sound/core/pcm_native.c +1 -2
@@ -506,8 +508,8 @@ static int snd_pcm_hw_free(struct snd_pcm_substream *substream)
 	if (substream->ops->hw_free)
 		result = substream->ops->hw_free(substream);
 	runtime->status->state = SNDRV_PCM_STATE_OPEN;
-	pm_qos_remove_requirement(PM_QOS_CPU_DMA_LATENCY,
-		substream->latency_id);
+	pm_qos_remove_request(substream->latency_pm_qos_req);

The NULL check seems needed in the caller side because pm_qos_remove_request() doesn't do it.

ouch. Thanks for noticing this.

Quoted 3 lines

Or, would you add a NULL check in pm_qos_remove_request()? It'd be more handy.

I can make the pm_qos_remove_request null pointer safe, its assumed to be a slow path so it would be a good thing to do.

I'll add this to the next patch set that the e1000e guys are making me do against linux-next.

Thanks!

--mgross

Quoted 5 lines

thanks,

Takashi

author
#3 lore raw
In reply to Takashi Iwai
Quoted 6 lines · Takashi Iwai

At Tue, 1 Dec 2009 13:38:40 -0800,

Quoted 3 lines · mark gross
sound/core/pcm_native.c +0 -0

(snip)

Quoted 10 lines

sound/core/pcm_native.c static int snd_pcm_hw_free(struct snd_pcm_substream *substream) · line 511

Quoted 7 lines
sound/core/pcm_native.c +1 -2
@@ -506,8 +508,8 @@ static int snd_pcm_hw_free(struct snd_pcm_substream *substream)
 	if (substream->ops->hw_free)
 		result = substream->ops->hw_free(substream);
 	runtime->status->state = SNDRV_PCM_STATE_OPEN;
-	pm_qos_remove_requirement(PM_QOS_CPU_DMA_LATENCY,
-		substream->latency_id);
+	pm_qos_remove_request(substream->latency_pm_qos_req);

The NULL check seems needed in the caller side because pm_qos_remove_request() doesn't do it.

ouch. Thanks for noticing this.

Quoted 3 lines

Or, would you add a NULL check in pm_qos_remove_request()? It'd be more handy.

I can make the pm_qos_remove_request null pointer safe, its assumed to be a slow path so it would be a good thing to do.

I'll add this to the next patch set that the e1000e guys are making me do against linux-next.

Thanks!

--mgross

Quoted 5 lines

thanks,

Takashi

#4 lore raw
In reply to mark gross

At Tue, 1 Dec 2009 13:38:40 -0800,

Quoted 3 lines · mark gross
sound/core/pcm_native.c +0 -0

(snip)

sound/core/pcm_native.c static int snd_pcm_hw_free(struct snd_pcm_substream *substream) · line 511

Quoted 7 lines
sound/core/pcm_native.c +1 -2
@@ -506,8 +508,8 @@ static int snd_pcm_hw_free(struct snd_pcm_substream *substream)
 	if (substream->ops->hw_free)
 		result = substream->ops->hw_free(substream);
 	runtime->status->state = SNDRV_PCM_STATE_OPEN;
-	pm_qos_remove_requirement(PM_QOS_CPU_DMA_LATENCY,
-		substream->latency_id);
+	pm_qos_remove_request(substream->latency_pm_qos_req);

The NULL check seems needed in the caller side because pm_qos_remove_request() doesn't do it.

Or, would you add a NULL check in pm_qos_remove_request()? It'd be more handy.

thanks,

Takashi