ALSA: HDA - Check return value to reduce useless delay
PATCH 1/1 ALSA: HDA - Check return value to reduce useless delay
For verb 705h, it's useless to read response, so use *write api would be better. If there's error after sending cmd, just try again without continue after wrong operation.Otherwise there's long time delay.
--- sound/pci/hda/hda_codec.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
sound/pci/hda/hda_codec.c +4 -1
@@ -3569,6 +3569,7 @@ static unsigned int hda_set_power_state(struct hda_codec *codec,hda_nid_t fg = codec->afg ? codec->afg : codec->mfg;int count;unsigned int state; +int err;/* this delay seems necessary to avoid click noise at power-down */ if (power_state ==AC_PWRST_D3 ) {
@@ -3582,9 +3583,11 @@ static unsigned int hda_set_power_state(struct hda_codec *codec, codec->patch_ops.set_power_state (codec, fg, power_state); else { -snd_hda_codec_read (codec, fg,0 , + err =snd_hda_codec_write (codec, fg,0 ,AC_VERB_SET_POWER_STATE , power_state); +if (err <0 ) +continue ;snd_hda_codec_set_power_to_all (codec, fg, power_state, true); }
Signature · 1 line
1.7.9.5
At Wed, 24 Oct 2012 14:53:23 +0800,
Quoted 4 lines · Wang Xingchao
For verb 705h, it's useless to read response, so use *write api would be better. If there's error after sending cmd, just try again without continue after wrong operation.Otherwise there's long time delay.
Well, this is a bit sensitive part. Did you do the good test coverage for different hardware controllers and codecs, including the non-Intel ones?
Takashi
Quoted 33 lines
Signed-off-by Wang Xingchao <[email protected]>--- sound/pci/hda/hda_codec.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)sound/pci/hda/hda_codec.c +4
-1@@ -3569,6 +3569,7 @@ static unsigned int hda_set_power_state(struct hda_codec *codec,hda_nid_t fg = codec->afg ? codec->afg : codec->mfg;int count;unsigned int state; +int err;/* this delay seems necessary to avoid click noise at power-down */ if (power_state ==AC_PWRST_D3 ) {@@ -3582,9 +3583,11 @@ static unsigned int hda_set_power_state(struct hda_codec *codec, codec->patch_ops.set_power_state (codec, fg, power_state); else { -snd_hda_codec_read (codec, fg,0 , + err =snd_hda_codec_write (codec, fg,0 ,AC_VERB_SET_POWER_STATE , power_state); +if (err <0 ) +continue ;snd_hda_codec_set_power_to_all (codec, fg, power_state, true); }Signature · 1 line
1.7.9.5
Quoted 12 lines
-----Original Message-----
From: Takashi Iwai [mailto:[email protected]]
Sent: Thursday, October 25, 2012 6:01 AM
To: Wang, Xingchao
Cc: [email protected]
Subject: Re: [PATCH] ALSA: HDA - Check return value to reduce useless delayAt Wed, 24 Oct 2012 14:53:23 +0800,
Quoted 1 line · Wang Xingchao
Quoted 7 lines
Quoted 3 lines
For verb 705h, it's useless to read response, so use *write api would be better. If there's error after sending cmd, just try again without continue after wrong operation.Otherwise there's long time delay.
Well, this is a bit sensitive part. Did you do the good test coverage for different hardware controllers and codecs, including the non-Intel ones?
Well I only tested the patch on Haswell/Ivybridge platform. For Haswell I meet an issue about codec suspend/resume. There's no response from codec when there's power state transition from D3 to D0, and the patch could reduced delay time. For ivybridge the codec works well, so this patch has no active behavior.
I assume the verb 705h will not work for subnodes if it failed at first for "function group".
Is there such case when set power state for the "Audio Function Group" fail but the sub-nodes could keep on setting power?
Thanks
--xingchao
Quoted 38 lines
Takashi
sound/pci/hda/hda_codec.c static unsigned int hda_set_power_state(struct
Quoted 10 lines
Signed-off-by Wang Xingchao <[email protected]>--- sound/pci/hda/hda_codec.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)sound/pci/hda/hda_codec.c +0
-0@@ -3569,6 +3569,7 @@ static unsigned int hda_set_power_state(struct
hda_codec*codec,sound/pci/hda/hda_codec.c static unsigned int hda_set_power_state(struct
Quoted 8 lines
sound/pci/hda/hda_codec.c +1
-0hda_nid_t fg = codec->afg ? codec->afg : codec->mfg;int count;unsigned int state; +int err;/* this delay seems necessary to avoid click noise at power-down */ if (power_state ==AC_PWRST_D3 ) {@@ -3582,9 +3583,11 @@ static unsigned int hda_set_power_state(struct
hda_codec*codec,Quoted 15 lines
sound/pci/hda/hda_codec.c +3
-2codec->patch_ops.set_power_state (codec, fg, power_state); else { -snd_hda_codec_read (codec, fg,0 , + err =snd_hda_codec_write (codec, fg,0 ,AC_VERB_SET_POWER_STATE , power_state); +if (err <0 ) +continue ;snd_hda_codec_set_power_to_all (codec, fg, power_state, true); } --1.7.9.5
At Thu, 25 Oct 2012 10:30:35 +0000,
Quoted 17 lines · Xingchao
Quoted 17 lines
-----Original Message-----
From: Takashi Iwai [mailto:[email protected]]
Sent: Thursday, October 25, 2012 6:01 AM
To: Wang, Xingchao
Cc: [email protected]
Subject: Re: [PATCH] ALSA: HDA - Check return value to reduce useless delayAt Wed, 24 Oct 2012 14:53:23 +0800,
Quoted 4 lines · Wang Xingchao
For verb 705h, it's useless to read response, so use *write api would be better. If there's error after sending cmd, just try again without continue after wrong operation.Otherwise there's long time delay.
Quoted 5 lines
Quoted 3 lines
Well, this is a bit sensitive part. Did you do the good test coverage for different hardware controllers and codecs, including the non-Intel ones?
Well I only tested the patch on Haswell/Ivybridge platform.
Both are too new :)
Quoted 2 lines
For Haswell I meet an issue about codec suspend/resume.
There's no response from codec when there's power state transition from D3 to D0, and the patch could reduced delay time.
But does it fix the issue itself?
Quoted 3 lines
For ivybridge the codec works well, so this patch has no active behavior.
I assume the verb 705h will not work for subnodes if it failed at first for "function group".
Is there such case when set power state for the "Audio Function Group" fail but the sub-nodes could keep on setting power?
Not sure. But we need more testing obviously before breaking anything.
thanks,
Takashi
Quoted 43 lines
Thanks
--xingchaoQuoted 38 lines
Takashi
sound/pci/hda/hda_codec.c static unsigned int hda_set_power_state(struct
Quoted 10 lines
Signed-off-by Wang Xingchao <[email protected]>--- sound/pci/hda/hda_codec.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)sound/pci/hda/hda_codec.c +0
-0@@ -3569,6 +3569,7 @@ static unsigned int hda_set_power_state(struct
hda_codec*codec,sound/pci/hda/hda_codec.c static unsigned int hda_set_power_state(struct
Quoted 8 lines
sound/pci/hda/hda_codec.c +1
-0hda_nid_t fg = codec->afg ? codec->afg : codec->mfg;int count;unsigned int state; +int err;/* this delay seems necessary to avoid click noise at power-down */ if (power_state ==AC_PWRST_D3 ) {@@ -3582,9 +3583,11 @@ static unsigned int hda_set_power_state(struct
hda_codec*codec,Quoted 15 lines
sound/pci/hda/hda_codec.c +3
-2codec->patch_ops.set_power_state (codec, fg, power_state); else { -snd_hda_codec_read (codec, fg,0 , + err =snd_hda_codec_write (codec, fg,0 ,AC_VERB_SET_POWER_STATE , power_state); +if (err <0 ) +continue ;snd_hda_codec_set_power_to_all (codec, fg, power_state, true); } --1.7.9.5
Quoted 37 lines
-----Original Message-----
From: Takashi Iwai [mailto:[email protected]]
Sent: Thursday, October 25, 2012 7:08 PM
To: Wang, Xingchao
Cc: [email protected]
Subject: Re: [PATCH] ALSA: HDA - Check return value to reduce useless delayAt Thu, 25 Oct 2012 10:30:35 +0000,
Quoted 11 lines · Xingchao
Quoted 11 lines
-----Original Message-----
From: Takashi Iwai [mailto:[email protected]]
Sent: Thursday, October 25, 2012 6:01 AM
To: Wang, Xingchao
Cc: [email protected]
Subject: Re: [PATCH] ALSA: HDA - Check return value to reduce useless delayQuoted 6 lines
Quoted 6 lines
At Wed, 24 Oct 2012 14:53:23 +0800,
Quoted 4 lines · Wang Xingchao
For verb 705h, it's useless to read response, so use *write api would be better. If there's error after sending cmd, just try again without continue after wrong operation.Otherwise there's long
time delay.
Quoted 3 lines
Quoted 3 lines
Well, this is a bit sensitive part. Did you do the good test coverage for different hardware controllers and codecs, including the
non-Intel ones?
Quoted 3 lines
Quoted 1 line
Well I only tested the patch on Haswell/Ivybridge platform.
Quoted 7 lines
Both are too new :)
Quoted 2 lines
For Haswell I meet an issue about codec suspend/resume. There's no response from codec when there's power state transition from D3
to D0, and the patch could reduced delay time.
But does it fix the issue itself?
Actually not. :)
Quoted 8 lines
Quoted 3 lines
For ivybridge the codec works well, so this patch has no active behavior. I assume the verb 705h will not work for subnodes if it failed at first for
"function group".
Quoted 1 line
Is there such case when set power state for the "Audio Function Group" fail
but the sub-nodes could keep on setting power?
Not sure. But we need more testing obviously before breaking anything.
Okay, I will try to test it on other platforms. :)
--xingchao
Quoted 52 lines
thanks,
Takashi
Quoted 19 lines
Thanks
--xingchaoQuoted 15 lines
Takashi
Quoted 11 lines
Signed-off-by Wang Xingchao <[email protected]>--- sound/pci/hda/hda_codec.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)sound/pci/hda/hda_codec.c +0
-0@@ -3569,6 +3569,7 @@ static unsigned inthda_set_power_state(struct
hda_codec*codec,Quoted 7 lines
Quoted 7 lines
sound/pci/hda/hda_codec.c static unsigned int hda_set_power_state(struct hda_codec *codec,
Quoted 7 lines
sound/pci/hda/hda_codec.c +1
-0hda_nid_t fg = codec->afg ? codec->afg : codec->mfg;int count;unsigned int state; +int err;/* this delay seems necessary to avoid click noise at power-down */ if (power_state == AC_PWRST_D3) { @@ -3582,9 +3583,11 @@static
Quoted 18 lines
Quoted 17 lines
Quoted 1 line
unsigned int hda_set_power_state(struct
hda_codec*codec,Quoted 15 lines
sound/pci/hda/hda_codec.c +3
-2codec->patch_ops.set_power_state (codec, fg, power_state); else { -snd_hda_codec_read (codec, fg,0 , + err =snd_hda_codec_write (codec, fg,0 ,AC_VERB_SET_POWER_STATE , power_state); +if (err <0 ) +continue ;snd_hda_codec_set_power_to_all (codec, fg, power_state, true); } --1.7.9.5
At Fri, 26 Oct 2012 10:45:33 +0000,
Quoted 50 lines · Xingchao
Quoted 38 lines
-----Original Message-----
From: Takashi Iwai [mailto:[email protected]]
Sent: Thursday, October 25, 2012 7:08 PM
To: Wang, Xingchao
Cc: [email protected]
Subject: Re: [PATCH] ALSA: HDA - Check return value to reduce useless delayAt Thu, 25 Oct 2012 10:30:35 +0000,
Quoted 11 lines · Xingchao
Quoted 11 lines
-----Original Message-----
From: Takashi Iwai [mailto:[email protected]]
Sent: Thursday, October 25, 2012 6:01 AM
To: Wang, Xingchao
Cc: [email protected]
Subject: Re: [PATCH] ALSA: HDA - Check return value to reduce useless delayQuoted 6 lines
Quoted 6 lines
At Wed, 24 Oct 2012 14:53:23 +0800,
Quoted 4 lines · Wang Xingchao
For verb 705h, it's useless to read response, so use *write api would be better. If there's error after sending cmd, just try again without continue after wrong operation.Otherwise there's long
time delay.
Quoted 3 lines
Quoted 3 lines
Well, this is a bit sensitive part. Did you do the good test coverage for different hardware controllers and codecs, including the
non-Intel ones?
Quoted 3 lines
Quoted 1 line
Well I only tested the patch on Haswell/Ivybridge platform.
Quoted 7 lines
Both are too new :)
Quoted 2 lines
For Haswell I meet an issue about codec suspend/resume. There's no response from codec when there's power state transition from D3
to D0, and the patch could reduced delay time.
But does it fix the issue itself?
Actually not. :)
Quoted 3 lines
Quoted 3 lines
For ivybridge the codec works well, so this patch has no active behavior. I assume the verb 705h will not work for subnodes if it failed at first for
Quoted 7 lines
Quoted 5 lines
"function group".
Quoted 1 line
Is there such case when set power state for the "Audio Function Group" fail
but the sub-nodes could keep on setting power?
Not sure. But we need more testing obviously before breaking anything.
Okay, I will try to test it on other platforms. :)
Thanks.
But thinking this twice, I think the only case it matters is that when the codec returns a bogus error at the power up. As the original code, it continues to power up all sub nodes. But with your patch, the sub node power-up will be skipped completely.
So, a compromise option would be:
- Keep using snd_hda_codec_read() to sync with the power up of FG node; snd_hda_codec_write() is asynchronous, so this can be too fast for power up of sub nodes, and...
- Check the return value from the fg node, skip the rest and continue, except for the last try. (Maybe we should add some delay for the repeated try here, though.) And in the last loop count, forcibly continue to the power up of the rest.
In this way, most of time consumed for the broken power up case you faced should be avoided.
Takashi
Quoted 54 lines
--xingchao
Quoted 52 lines
thanks,
Takashi
Quoted 19 lines
Thanks
--xingchaoQuoted 15 lines
Takashi
Quoted 11 lines
Signed-off-by Wang Xingchao <[email protected]>--- sound/pci/hda/hda_codec.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)sound/pci/hda/hda_codec.c +0
-0@@ -3569,6 +3569,7 @@ static unsigned inthda_set_power_state(struct
hda_codec*codec,Quoted 7 lines
Quoted 7 lines
sound/pci/hda/hda_codec.c static unsigned int hda_set_power_state(struct hda_codec *codec,
Quoted 7 lines
sound/pci/hda/hda_codec.c +1
-0hda_nid_t fg = codec->afg ? codec->afg : codec->mfg;int count;unsigned int state; +int err;/* this delay seems necessary to avoid click noise at power-down */ if (power_state == AC_PWRST_D3) { @@ -3582,9 +3583,11 @@static
Quoted 18 lines
Quoted 17 lines
Quoted 1 line
unsigned int hda_set_power_state(struct
hda_codec*codec,Quoted 15 lines
sound/pci/hda/hda_codec.c +3
-2codec->patch_ops.set_power_state (codec, fg, power_state); else { -snd_hda_codec_read (codec, fg,0 , + err =snd_hda_codec_write (codec, fg,0 ,AC_VERB_SET_POWER_STATE , power_state); +if (err <0 ) +continue ;snd_hda_codec_set_power_to_all (codec, fg, power_state, true); } --1.7.9.5