Skip to contentSkip to conversation

hda - remove unnecessary msleep on power state transitions

PATCH In review Wu Fengguang 2 participants 3 messages Feb 24, 2010 – Feb 25, 2010 Sound

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hda - remove unnecessary msleep on power state transitions

From: "Zhang, Rui" <[email protected]>

This will save ~15ms boot time.

The first 10ms sleep was introduced in commit d2595d86e5 for (buggy) Cxt codecs, so better to limit the sleep to the problem hardware.

For the second 10ms sleep, the HDA spec says:

Power State[1:0]:
00: Node Power state (D0) is fully on.
01: Node Power state (D1) allows for (does not require) the lowest possible power consuming state from which it can return to the "fully on" state (D0) within 10 ms, excepting analog pass through circuits (e.g., CD analog playback) which must remain fully on.
10: Node Power state (D2) allows for (does not require) the lowest possible power consuming state from which it can return to the "fully on" state (D0) within 10 ms. For modems, this is the "wake on ring" power state. 11: Node Power state (D3) allows for (does not require) lowest possible power consuming state under software control. Note that any low power state set by software must retain sufficient operational capability to properly respond to subsequent software Power State command.

So 10ms is actually the max wait time. It should be safe to remove/reduce it and rely on the loop of 1ms-sleeps.

CC Marc Boucher <[email protected]>
CC Arjan van de Ven <[email protected]>
---
 sound/pci/hda/hda_codec.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
sound/pci/hda/hda_codec.c +2 -2
@@ -2767,7 +2767,8 @@ static void hda_set_power_state(struct h
 	snd_hda_codec_read(codec, fg, 0, AC_VERB_SET_POWER_STATE,
 			    power_state);
 	/* partial workaround for "azx_get_response timeout" */
-	if (power_state == AC_PWRST_D0)
+	if (power_state == AC_PWRST_D0 &&
+	    codec->vendor_id & 0xffff0000 == 0x14f10000)
 		msleep(10);
 
 	nid = codec->start_nid;
@@ -2801,7 +2802,6 @@ static void hda_set_power_state(struct h
 	if (power_state == AC_PWRST_D0) {
 		unsigned long end_time;
 		int state;
-		msleep(10);
 		/* wait until the codec reachs to D0 */
 		end_time = jiffies + msecs_to_jiffies(500);
 		do {
#1 lore raw

At Wed, 24 Feb 2010 09:38:49 +0800,

Quoted 21 lines · Wu Fengguang

From: "Zhang, Rui" <[email protected]>

This will save ~15ms boot time.

The first 10ms sleep was introduced in commit d2595d86e5 for (buggy) Cxt codecs, so better to limit the sleep to the problem hardware.

For the second 10ms sleep, the HDA spec says:

Power State[1:0]:
00: Node Power state (D0) is fully on.
01: Node Power state (D1) allows for (does not require) the lowest possible power consuming state from which it can return to the "fully on" state (D0) within 10 ms, excepting analog pass through circuits (e.g., CD analog playback) which must remain fully on.
10: Node Power state (D2) allows for (does not require) the lowest possible power consuming state from which it can return to the "fully on" state (D0) within 10 ms. For modems, this is the "wake on ring" power state. 11: Node Power state (D3) allows for (does not require) lowest possible power consuming state under software control. Note that any low power state set by software must retain sufficient operational capability to properly respond to subsequent software Power State command.

Quoted 7 lines

So 10ms is actually the max wait time. It should be safe to remove/reduce it and rely on the loop of 1ms-sleeps.

CC Marc Boucher <[email protected]>
CC Arjan van de Ven <[email protected]>

This delay might be needed for codecs of other vendors, but let's see... If more codecs need this, we may put a flag into hda_codec struct.

Anyway, I applied the patch with a minor compile warning fix now.

thanks,

Takashi

Quoted 25 lines
---
 sound/pci/hda/hda_codec.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
sound/pci/hda/hda_codec.c +2 -2
@@ -2767,7 +2767,8 @@ static void hda_set_power_state(struct h
 	snd_hda_codec_read(codec, fg, 0, AC_VERB_SET_POWER_STATE,
 			    power_state);
 	/* partial workaround for "azx_get_response timeout" */
-	if (power_state == AC_PWRST_D0)
+	if (power_state == AC_PWRST_D0 &&
+	    codec->vendor_id & 0xffff0000 == 0x14f10000)
 		msleep(10);
 
 	nid = codec->start_nid;
@@ -2801,7 +2802,6 @@ static void hda_set_power_state(struct h
 	if (power_state == AC_PWRST_D0) {
 		unsigned long end_time;
 		int state;
-		msleep(10);
 		/* wait until the codec reachs to D0 */
 		end_time = jiffies + msecs_to_jiffies(500);
 		do {
#2 lore raw
Quoted 26 lines · Takashi Iwai

At Wed, 24 Feb 2010 09:38:49 +0800,

Quoted 24 lines · Wu Fengguang

From: "Zhang, Rui" <[email protected]>

This will save ~15ms boot time.

The first 10ms sleep was introduced in commit d2595d86e5 for (buggy) Cxt codecs, so better to limit the sleep to the problem hardware.

For the second 10ms sleep, the HDA spec says:

Power State[1:0]:
00: Node Power state (D0) is fully on.
01: Node Power state (D1) allows for (does not require) the lowest possible power consuming state from which it can return to the "fully on" state (D0) within 10 ms, excepting analog pass through circuits (e.g., CD analog playback) which must remain fully on.
10: Node Power state (D2) allows for (does not require) the lowest possible power consuming state from which it can return to the "fully on" state (D0) within 10 ms. For modems, this is the "wake on ring" power state. 11: Node Power state (D3) allows for (does not require) lowest possible power consuming state under software control. Note that any low power state set by software must retain sufficient operational capability to properly respond to subsequent software Power State command.

So 10ms is actually the max wait time. It should be safe to remove/reduce it and rely on the loop of 1ms-sleeps.

Quoted 7 lines
Quoted 4 lines
CC Marc Boucher <[email protected]>
CC Arjan van de Ven <[email protected]>

This delay might be needed for codecs of other vendors, but let's see... If more codecs need this, we may put a flag into hda_codec struct.

The first delay? OK let's see. Hopefully this won't break audio playback if there are similar broken hw..

Quoted 1 line

Anyway, I applied the patch with a minor compile warning fix now.

Thank you!

Regards,
Fengguang