hdac-codec runtime suspended at PM:Suspend.
PATCH 1/1 hdac-codec runtime suspended at PM:Suspend.
Keep hdac-codec to be in runtime suspended while entering to suspend. If hdac-codec is already in runtime suspend state skip its power down sequence in prepare, power up sequence in complete phase.
Avoid resuming hdac controller PCI device 00:1f.3 from runtime suspend state in case hdac-codec already in runtime-suspend state, this is unnecessary and block the direct complete even for hdac controller PCI device 00:1f.3.
This enabled direct complete path for hdac-codec and PCI device 00:1f.3.
--- sound/soc/codecs/hdac_hdmi.c | 4 ++++ 1 file changed, 4 insertions(+)
sound/soc/codecs/hdac_hdmi.c +4 -0
@@ -1852,6 +1852,8 @@ static int hdmi_codec_prepare(struct device *dev)struct hdac_ext_device *edev =to_hda_ext_device (dev);struct hdac_device *hdac = &edev->hdac; +if (pm_runtime_status_suspended (dev)) +return 1 ;pm_runtime_get_sync (&edev->hdac.dev);/*
@@ -1873,6 +1875,8 @@ static void hdmi_codec_complete(struct device *dev)struct hdac_hdmi_priv *hdmi = edev->private_data;struct hdac_device *hdac = &edev->hdac; +if (pm_runtime_status_suspended (dev)) +return ;/* Power up afg */ snd_hdac_codec_read (hdac, hdac->afg,0 ,AC_VERB_SET_POWER_STATE ,AC_PWRST_D0 );
Signature · 1 line
2.7.4
Quoted 21 lines · Anshuman Gupta
Keep hdac-codec to be in runtime suspended while entering to suspend. If hdac-codec is already in runtime suspend state skip its power down sequence in prepare, power up sequence in complete phase.
Avoid resuming hdac controller PCI device 00:1f.3 from runtime suspend state in case hdac-codec already in runtime-suspend state, this is unnecessary and block the direct complete even for hdac controller PCI device 00:1f.3.
This enabled direct complete path for hdac-codec and PCI device 00:1f.3.
Signed-off-by Anshuman Gupta <[email protected]>--- sound/soc/codecs/hdac_hdmi.c | 4 ++++ 1 file changed, 4 insertions(+)sound/soc/codecs/hdac_hdmi.c +0
-0
sound/soc/codecs/hdac_hdmi.c static int hdmi_codec_prepare(struct device *dev) · line 1856
Quoted 5 lines
sound/soc/codecs/hdac_hdmi.c +2
-0@@ -1852,6 +1852,8 @@ static int hdmi_codec_prepare(struct device *dev)struct hdac_ext_device *edev =to_hda_ext_device (dev);struct hdac_device *hdac = &edev->hdac; +if (pm_runtime_status_suspended (dev)) +return 1 ;
This is racy in principle, because the runtime PM status can still change after you've checked here.
But even if it isn't racy in practice, the following pm_runtime_get_sync() becomes redundant after it, doesn't it?
sound/soc/codecs/hdac_hdmi.c static void hdmi_codec_complete(struct device *dev) · line 1879
Quoted 9 lines
sound/soc/codecs/hdac_hdmi.c +2
-0pm_runtime_get_sync (&edev->hdac.dev);/* @@ -1873,6 +1875,8 @@ static void hdmi_codec_complete(struct device *dev)struct hdac_hdmi_priv *hdmi = edev->private_data;struct hdac_device *hdac = &edev->hdac; +if (pm_runtime_status_suspended (dev)) +return ;
That, again, is somewhat fragile from the concurrency perspective.
Quoted 6 lines
sound/soc/codecs/hdac_hdmi.c +0
-1/* Power up afg */ snd_hdac_codec_read (hdac, hdac->afg,0 ,AC_VERB_SET_POWER_STATE ,AC_PWRST_D0 ); --2.7.4
Quoted 26 lines · Rafael J. Wysocki
Quoted 24 lines · Anshuman Gupta
Keep hdac-codec to be in runtime suspended while entering to suspend. If hdac-codec is already in runtime suspend state skip its power down sequence in prepare, power up sequence in complete phase.
Avoid resuming hdac controller PCI device 00:1f.3 from runtime suspend state in case hdac-codec already in runtime-suspend state, this is unnecessary and block the direct complete even for hdac controller PCI device 00:1f.3.
This enabled direct complete path for hdac-codec and PCI device 00:1f.3.
Signed-off-by Anshuman Gupta <[email protected]>--- sound/soc/codecs/hdac_hdmi.c | 4 ++++ 1 file changed, 4 insertions(+)sound/soc/codecs/hdac_hdmi.c +0
-0@@ -1852,6 +1852,8 @@ static int hdmi_codec_prepare(struct device *dev)struct hdac_ext_device *edev =to_hda_ext_device (dev);struct hdac_device *hdac = &edev->hdac;
Quoted 5 lines
sound/soc/codecs/hdac_hdmi.c static int hdmi_codec_prepare(struct device *dev) · line 1856
Quoted 2 lines
sound/soc/codecs/hdac_hdmi.c +2
-0+if (pm_runtime_status_suspended (dev)) +return 1 ;This is racy in principle, because the runtime PM status can still change after you've checked here.
Will using pm_runtime_disable/pm_runtime_enable for safe check of runtime status avoids this race?
Quoted 3 lines
But even if it isn't racy in practice, the following
pm_runtime_get_sync()becomes redundant after it, doesn't it?
I have no idea but if there can be a case that PCI 00:1f.3 (hdac controller) is runtime suspended and hdac hdmi codec is active, in that case it may be required to use pm_runtime_get_sync() for hdac controller as it is parent of hdac hdmi codec.
Quoted 19 lines
sound/soc/codecs/hdac_hdmi.c static void hdmi_codec_complete(struct device *dev) · line 1879
Quoted 10 lines
sound/soc/codecs/hdac_hdmi.c +2
-0pm_runtime_get_sync (&edev->hdac.dev);/* @@ -1873,6 +1875,8 @@ static void hdmi_codec_complete(struct device *dev)struct hdac_hdmi_priv *hdmi = edev->private_data;struct hdac_device *hdac = &edev->hdac; +if (pm_runtime_status_suspended (dev)) +return ;That, again, is somewhat fragile from the concurrency perspective.
Quoted 6 lines
sound/soc/codecs/hdac_hdmi.c +0
-1/* Power up afg */ snd_hdac_codec_read (hdac, hdac->afg,0 ,AC_VERB_SET_POWER_STATE ,AC_PWRST_D0 ); --2.7.4
Signature · 2 lines
Thanks, Anshuman
Quoted 26 lines · Rafael J. Wysocki
Quoted 24 lines · Anshuman Gupta
Keep hdac-codec to be in runtime suspended while entering to suspend. If hdac-codec is already in runtime suspend state skip its power down sequence in prepare, power up sequence in complete phase.
Avoid resuming hdac controller PCI device 00:1f.3 from runtime suspend state in case hdac-codec already in runtime-suspend state, this is unnecessary and block the direct complete even for hdac controller PCI device 00:1f.3.
This enabled direct complete path for hdac-codec and PCI device 00:1f.3.
Signed-off-by Anshuman Gupta <[email protected]>--- sound/soc/codecs/hdac_hdmi.c | 4 ++++ 1 file changed, 4 insertions(+)sound/soc/codecs/hdac_hdmi.c +0
-0@@ -1852,6 +1852,8 @@ static int hdmi_codec_prepare(struct device *dev)struct hdac_ext_device *edev =to_hda_ext_device (dev);struct hdac_device *hdac = &edev->hdac;
Quoted 5 lines
sound/soc/codecs/hdac_hdmi.c static int hdmi_codec_prepare(struct device *dev) · line 1856
Quoted 2 lines
sound/soc/codecs/hdac_hdmi.c +2
-0+if (pm_runtime_status_suspended (dev)) +return 1 ;This is racy in principle, because the runtime PM status can still change after you've checked here.
Will using pm_runtime_disable/pm_runtime_enable for safe check of runtime status avoids this race?
Quoted 3 lines
But even if it isn't racy in practice, the following
pm_runtime_get_sync()becomes redundant after it, doesn't it?
I have no idea but if there can be a case that PCI 00:1f.3 (hdac controller) is runtime suspended and hdac hdmi codec is active, in that case it may be required to use pm_runtime_get_sync() for hdac controller as it is parent of hdac hdmi codec.
Quoted 19 lines
sound/soc/codecs/hdac_hdmi.c static void hdmi_codec_complete(struct device *dev) · line 1879
Quoted 10 lines
sound/soc/codecs/hdac_hdmi.c +2
-0pm_runtime_get_sync (&edev->hdac.dev);/* @@ -1873,6 +1875,8 @@ static void hdmi_codec_complete(struct device *dev)struct hdac_hdmi_priv *hdmi = edev->private_data;struct hdac_device *hdac = &edev->hdac; +if (pm_runtime_status_suspended (dev)) +return ;That, again, is somewhat fragile from the concurrency perspective.
Quoted 6 lines
sound/soc/codecs/hdac_hdmi.c +0
-1/* Power up afg */ snd_hdac_codec_read (hdac, hdac->afg,0 ,AC_VERB_SET_POWER_STATE ,AC_PWRST_D0 ); --2.7.4
Signature · 6 lines
Thanks, Anshuman _______________________________________________ Alsa-devel mailing list [email protected] http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Quoted 27 lines · Anshuman Gupta
Quoted 26 lines · Rafael J. Wysocki
Quoted 24 lines · Anshuman Gupta
Keep hdac-codec to be in runtime suspended while entering to suspend. If hdac-codec is already in runtime suspend state skip its power down sequence in prepare, power up sequence in complete phase.
Avoid resuming hdac controller PCI device 00:1f.3 from runtime suspend state in case hdac-codec already in runtime-suspend state, this is unnecessary and block the direct complete even for hdac controller PCI device 00:1f.3.
This enabled direct complete path for hdac-codec and PCI device 00:1f.3.
Signed-off-by Anshuman Gupta <[email protected]>--- sound/soc/codecs/hdac_hdmi.c | 4 ++++ 1 file changed, 4 insertions(+)sound/soc/codecs/hdac_hdmi.c +0
-0@@ -1852,6 +1852,8 @@ static int hdmi_codec_prepare(struct device *dev)struct hdac_ext_device *edev =to_hda_ext_device (dev);struct hdac_device *hdac = &edev->hdac;
Quoted 7 lines
Quoted 5 lines
sound/soc/codecs/hdac_hdmi.c static int hdmi_codec_prepare(struct device *dev) · line 1856
Quoted 2 lines
sound/soc/codecs/hdac_hdmi.c +2
-0+if (pm_runtime_status_suspended (dev)) +return 1 ;This is racy in principle, because the runtime PM status can still change after you've checked here.
Will using pm_runtime_disable/pm_runtime_enable for safe check of runtime status avoids this race?
It might help, but is this a leaf device or does it have children?
Quoted 9 lines
Quoted 2 lines
But even if it isn't racy in practice, the following
pm_runtime_get_sync()becomes redundant after it, doesn't it?I have no idea but if there can be a case that PCI 00:1f.3 (hdac controller) is runtime suspended and hdac hdmi codec is active, in that case it may be required to use
pm_runtime_get_sync()for hdac controller as it is parent of hdac hdmi codec.Quoted 3 lines
Quoted 3 lines
sound/soc/codecs/hdac_hdmi.c +0
-0pm_runtime_get_sync (&edev->hdac.dev);
So it sounds like you need the "get" part, but you don't need the "sync" one, because you've just checked that the device is not suspended.
I guess the idea is to return 1 for the direct-complete mechanism to kick in if the device is already suspended, but otherwise bump up its reference counter to prevent it from suspending going forward, right?
Quoted 10 lines
Quoted 10 lines
sound/soc/codecs/hdac_hdmi.c static void hdmi_codec_complete(struct device *dev) · line 1879
Quoted 7 lines
sound/soc/codecs/hdac_hdmi.c +2
-0/* @@ -1873,6 +1875,8 @@ static void hdmi_codec_complete(struct device *dev)struct hdac_hdmi_priv *hdmi = edev->private_data;struct hdac_device *hdac = &edev->hdac; +if (pm_runtime_status_suspended (dev)) +return ;That, again, is somewhat fragile from the concurrency perspective.
And here you want to avoid the below if the device is still suspended.
Why is the below code located in the ->complete callback anyway? Shouldn't it be there in the ->resume one?
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
sound/soc/codecs/hdac_hdmi.c +0
-1/* Power up afg */ snd_hdac_codec_read (hdac, hdac->afg,0 ,AC_VERB_SET_POWER_STATE ,AC_PWRST_D0 ); --2.7.4
Quoted 34 lines · Rafael J. Wysocki
Quoted 32 lines · Anshuman Gupta
Quoted 31 lines · Rafael J. Wysocki
Quoted 21 lines · Anshuman Gupta
Keep hdac-codec to be in runtime suspended while entering to suspend. If hdac-codec is already in runtime suspend state skip its power down sequence in prepare, power up sequence in complete phase.
Avoid resuming hdac controller PCI device 00:1f.3 from runtime suspend state in case hdac-codec already in runtime-suspend state, this is unnecessary and block the direct complete even for hdac controller PCI device 00:1f.3.
This enabled direct complete path for hdac-codec and PCI device 00:1f.3.
Signed-off-by Anshuman Gupta <[email protected]>--- sound/soc/codecs/hdac_hdmi.c | 4 ++++ 1 file changed, 4 insertions(+)sound/soc/codecs/hdac_hdmi.c +0
-0sound/soc/codecs/hdac_hdmi.c static int hdmi_codec_prepare(struct device *dev) · line 1856
Quoted 5 lines
sound/soc/codecs/hdac_hdmi.c +2
-0@@ -1852,6 +1852,8 @@ static int hdmi_codec_prepare(struct device *dev)struct hdac_ext_device *edev =to_hda_ext_device (dev);struct hdac_device *hdac = &edev->hdac; +if (pm_runtime_status_suspended (dev)) +return 1 ;This is racy in principle, because the runtime PM status can still change after you've checked here.
Quoted 4 lines
Quoted 2 lines
Will using pm_runtime_disable/pm_runtime_enable for safe check of runtime status avoids this race?
It might help, but is this a leaf device or does it have children?
In kernel traces this hdac hdmi codec device appear with name "HDA Codec ehdaudio0D2", and it seems to be a leaf device do not have any child. So it would be ok to use pm_runtime_disable to avoid any race ?
Quoted 11 lines
Quoted 10 lines
Quoted 3 lines
But even if it isn't racy in practice, the following
pm_runtime_get_sync()becomes redundant after it, doesn't it?I have no idea but if there can be a case that PCI 00:1f.3 (hdac controller) is runtime suspended and hdac hdmi codec is active, in that case it may be required to use
pm_runtime_get_sync()for hdac controller as it is parent of hdac hdmi codec.Quoted 3 lines
Quoted 3 lines
sound/soc/codecs/hdac_hdmi.c +0
-0pm_runtime_get_sync (&edev->hdac.dev);
Quoted 8 lines
So it sounds like you need the "get" part, but you don't need the "sync" one, because you've just checked that the device is not suspended.
I guess the idea is to return 1 for the direct-complete mechanism to kick in if the device is already suspended, but otherwise bump up its reference counter to prevent it from suspending going forward, right?
Idea of this patch to remove the PCI 00:1f:3 (hdac controller) direct complete blocker, as hdac hdmi codec is resuming it from runtime suspend in its prepare callback to set the hdac hdmi codec in low power state.
(https://elixir.bootlin.com/linux/v4.16-rc5/source/sound/soc/codecs/hdac_hdmi.c#L1860)
So if hdac hdmi codec in active state it require to resume hdac controller from runtime suspend.
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
sound/soc/codecs/hdac_hdmi.c +0
-0/* @@ -1873,6 +1875,8 @@ static void hdmi_codec_complete(struct device *dev)struct hdac_hdmi_priv *hdmi = edev->private_data;struct hdac_device *hdac = &edev->hdac;
Quoted 7 lines
Quoted 5 lines
Quoted 5 lines
sound/soc/codecs/hdac_hdmi.c static void hdmi_codec_complete(struct device *dev) · line 1879
Quoted 2 lines
sound/soc/codecs/hdac_hdmi.c +2
-0+if (pm_runtime_status_suspended (dev)) +return ;That, again, is somewhat fragile from the concurrency perspective.
And here you want to avoid the below if the device is still suspended.
Yes, if we do not avoid the code below, complete callback takes about 3 seconds due to snd_hdac_codec_read timed out because hdac controller would be in runtime suspend state.
Quoted 4 lines
Why is the below code located in the ->complete callback anyway? Shouldn't it be there in the ->resume one?
Yes even i am also having same doubt, why these power down and power up sequences are part of prepare and complete callback.
Adding driver author "Subhransu S. Prusty" to provide more inputs on this.
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
sound/soc/codecs/hdac_hdmi.c +0
-1/* Power up afg */ snd_hdac_codec_read (hdac, hdac->afg,0 ,AC_VERB_SET_POWER_STATE ,AC_PWRST_D0 ); --2.7.4
Signature · 2 lines
Thanks, Anshuman
Quoted 34 lines · Rafael J. Wysocki
Quoted 32 lines · Anshuman Gupta
Quoted 31 lines · Rafael J. Wysocki
Quoted 21 lines · Anshuman Gupta
Keep hdac-codec to be in runtime suspended while entering to suspend. If hdac-codec is already in runtime suspend state skip its power down sequence in prepare, power up sequence in complete phase.
Avoid resuming hdac controller PCI device 00:1f.3 from runtime suspend state in case hdac-codec already in runtime-suspend state, this is unnecessary and block the direct complete even for hdac controller PCI device 00:1f.3.
This enabled direct complete path for hdac-codec and PCI device 00:1f.3.
Signed-off-by Anshuman Gupta <[email protected]>--- sound/soc/codecs/hdac_hdmi.c | 4 ++++ 1 file changed, 4 insertions(+)sound/soc/codecs/hdac_hdmi.c +0
-0sound/soc/codecs/hdac_hdmi.c static int hdmi_codec_prepare(struct device *dev) · line 1856
Quoted 5 lines
sound/soc/codecs/hdac_hdmi.c +2
-0@@ -1852,6 +1852,8 @@ static int hdmi_codec_prepare(struct device *dev)struct hdac_ext_device *edev =to_hda_ext_device (dev);struct hdac_device *hdac = &edev->hdac; +if (pm_runtime_status_suspended (dev)) +return 1 ;This is racy in principle, because the runtime PM status can still change after you've checked here.
Quoted 4 lines
Quoted 2 lines
Will using pm_runtime_disable/pm_runtime_enable for safe check of runtime status avoids this race?
It might help, but is this a leaf device or does it have children?
In kernel traces this hdac hdmi codec device appear with name "HDA Codec ehdaudio0D2", and it seems to be a leaf device do not have any child. So it would be ok to use pm_runtime_disable to avoid any race ?
Quoted 11 lines
Quoted 10 lines
Quoted 3 lines
But even if it isn't racy in practice, the following
pm_runtime_get_sync()becomes redundant after it, doesn't it?I have no idea but if there can be a case that PCI 00:1f.3 (hdac controller) is runtime suspended and hdac hdmi codec is active, in that case it may be required to use
pm_runtime_get_sync()for hdac controller as it is parent of hdac hdmi codec.Quoted 3 lines
Quoted 3 lines
sound/soc/codecs/hdac_hdmi.c +0
-0pm_runtime_get_sync (&edev->hdac.dev);
Quoted 8 lines
So it sounds like you need the "get" part, but you don't need the "sync" one, because you've just checked that the device is not suspended.
I guess the idea is to return 1 for the direct-complete mechanism to kick in if the device is already suspended, but otherwise bump up its reference counter to prevent it from suspending going forward, right?
Idea of this patch to remove the PCI 00:1f:3 (hdac controller) direct complete blocker, as hdac hdmi codec is resuming it from runtime suspend in its prepare callback to set the hdac hdmi codec in low power state.
(https://elixir.bootlin.com/linux/v4.16-rc5/source/sound/soc/codecs/hdac_hdmi.c#L1860)
So if hdac hdmi codec in active state it require to resume hdac controller from runtime suspend.
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
sound/soc/codecs/hdac_hdmi.c +0
-0/* @@ -1873,6 +1875,8 @@ static void hdmi_codec_complete(struct device *dev)struct hdac_hdmi_priv *hdmi = edev->private_data;struct hdac_device *hdac = &edev->hdac;
Quoted 7 lines
Quoted 5 lines
Quoted 5 lines
sound/soc/codecs/hdac_hdmi.c static void hdmi_codec_complete(struct device *dev) · line 1879
Quoted 2 lines
sound/soc/codecs/hdac_hdmi.c +2
-0+if (pm_runtime_status_suspended (dev)) +return ;That, again, is somewhat fragile from the concurrency perspective.
And here you want to avoid the below if the device is still suspended.
Yes, if we do not avoid the code below, complete callback takes about 3 seconds due to snd_hdac_codec_read timed out because hdac controller would be in runtime suspend state.
Quoted 4 lines
Why is the below code located in the ->complete callback anyway? Shouldn't it be there in the ->resume one?
Yes even i am also having same doubt, why these power down and power up sequences are part of prepare and complete callback.
Adding driver author "Subhransu S. Prusty" to provide more inputs on this.
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
sound/soc/codecs/hdac_hdmi.c +0
-1/* Power up afg */ snd_hdac_codec_read (hdac, hdac->afg,0 ,AC_VERB_SET_POWER_STATE ,AC_PWRST_D0 ); --2.7.4
Signature · 6 lines
Thanks, Anshuman _______________________________________________ Alsa-devel mailing list [email protected] http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Quoted 18 lines · Anshuman Gupta
Quoted 6 lines · Rafael J. Wysocki
Quoted 4 lines · Anshuman Gupta
Quoted 3 lines · Rafael J. Wysocki
Quoted 1 line · Anshuman Gupta
Quoted 7 lines
Quoted 5 lines
Quoted 5 lines
sound/soc/codecs/hdac_hdmi.c static void hdmi_codec_complete(struct device *dev) · line 1879
Quoted 2 lines
sound/soc/codecs/hdac_hdmi.c +2
-0+if (pm_runtime_status_suspended (dev)) +return ;That, again, is somewhat fragile from the concurrency perspective.
And here you want to avoid the below if the device is still suspended.
Yes, if we do not avoid the code below, complete callback takes about 3 seconds due to
snd_hdac_codec_readtimed out because hdac controller would be in runtime suspend state.Quoted 1 line
Quoted 6 lines
Quoted 3 lines
Why is the below code located in the ->complete callback anyway? Shouldn't it be there in the ->resume one?
Yes even i am also having same doubt, why these power down and power up sequences are part of prepare and complete callback.
Adding driver author "Subhransu S. Prusty" to provide more inputs on this.
This driver needs a late resume as it receives a jack notification from the i915 driver and the skl controller driver resume may not have happened and in turn hda controller may not ready. This ensures a synchronization for jack event during resume from S3.
I think this patch defeats the purpose.
Regards,
Subhransu
Quoted 9 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
/* Power up afg */ snd_hdac_codec_read(hdac, hdac->afg, 0, AC_VERB_SET_POWER_STATE, AC_PWRST_D0);--
2.7.4Signature · 2 lines
Thanks, Anshuman
Quoted 22 lines · Subhransu S. Prusty
Quoted 21 lines · Anshuman Gupta
Quoted 6 lines · Rafael J. Wysocki
Quoted 4 lines · Anshuman Gupta
Quoted 3 lines · Rafael J. Wysocki
Quoted 1 line · Anshuman Gupta
Quoted 7 lines
Quoted 5 lines
Quoted 5 lines
sound/soc/codecs/hdac_hdmi.c static void hdmi_codec_complete(struct device *dev) · line 1879
Quoted 2 lines
sound/soc/codecs/hdac_hdmi.c +2
-0+if (pm_runtime_status_suspended (dev)) +return ;That, again, is somewhat fragile from the concurrency perspective.
And here you want to avoid the below if the device is still suspended.
Yes, if we do not avoid the code below, complete callback takes about 3 seconds due to
snd_hdac_codec_readtimed out because hdac controller would be in runtime suspend state.Quoted 4 lines
Why is the below code located in the ->complete callback anyway? Shouldn't it be there in the ->resume one?
Quoted 8 lines
Quoted 3 lines
Yes even i am also having same doubt, why these power down and power up sequences are part of prepare and complete callback.
Adding driver author "Subhransu S. Prusty" to provide more inputs on this.This driver needs a late resume as it receives a jack notification from the i915 driver and the skl controller driver resume may not have happened and in turn hda controller may not ready. This ensures a synchronization for jack event during resume from S3.
Let me give you insight of the issue, this driver blocks the direct complete of hda controller PCI 00:1f.3, sometimes it takes 280ms to resume hda controller from S3 and s2idle. So it does not make sense to suspend/resume hda controller when it is already in runtime suspend.
Quoted 2 lines
I think this patch defeats the purpose.
Here in this case PCI driver may kick the direct complete for hda controller
https://elixir.bootlin.com/linux/latest/source/drivers/pci/pci-driver.c#L691
But hdac hdmi codec driver is blocking it.
So i think it will be ok to keep this codec and hda controller in runtime suspend while entering S3 or s2idle, both can resume by runtime PM as well, will it brake any audio functionality?
Quoted 15 lines
Regards,
SubhransuQuoted 9 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
/* Power up afg */ snd_hdac_codec_read(hdac, hdac->afg, 0, AC_VERB_SET_POWER_STATE, AC_PWRST_D0);--
2.7.4Signature · 2 lines
Thanks, Anshuman
Signature · 2 lines
Thanks, Anshuman
Quoted 22 lines · Subhransu S. Prusty
Quoted 21 lines · Anshuman Gupta
Quoted 6 lines · Rafael J. Wysocki
Quoted 4 lines · Anshuman Gupta
Quoted 3 lines · Rafael J. Wysocki
Quoted 1 line · Anshuman Gupta
Quoted 7 lines
Quoted 5 lines
Quoted 5 lines
sound/soc/codecs/hdac_hdmi.c static void hdmi_codec_complete(struct device *dev) · line 1879
Quoted 2 lines
sound/soc/codecs/hdac_hdmi.c +2
-0+if (pm_runtime_status_suspended (dev)) +return ;That, again, is somewhat fragile from the concurrency perspective.
And here you want to avoid the below if the device is still suspended.
Yes, if we do not avoid the code below, complete callback takes about 3 seconds due to
snd_hdac_codec_readtimed out because hdac controller would be in runtime suspend state.Quoted 4 lines
Why is the below code located in the ->complete callback anyway? Shouldn't it be there in the ->resume one?
Quoted 8 lines
Quoted 3 lines
Yes even i am also having same doubt, why these power down and power up sequences are part of prepare and complete callback.
Adding driver author "Subhransu S. Prusty" to provide more inputs on this.This driver needs a late resume as it receives a jack notification from the i915 driver and the skl controller driver resume may not have happened and in turn hda controller may not ready. This ensures a synchronization for jack event during resume from S3.
Let me give you insight of the issue, this driver blocks the direct complete of hda controller PCI 00:1f.3, sometimes it takes 280ms to resume hda controller from S3 and s2idle. So it does not make sense to suspend/resume hda controller when it is already in runtime suspend.
Quoted 2 lines
I think this patch defeats the purpose.
Here in this case PCI driver may kick the direct complete for hda controller
https://elixir.bootlin.com/linux/latest/source/drivers/pci/pci-driver.c#L691
But hdac hdmi codec driver is blocking it.
So i think it will be ok to keep this codec and hda controller in runtime suspend while entering S3 or s2idle, both can resume by runtime PM as well, will it brake any audio functionality?
Quoted 15 lines
Regards,
SubhransuQuoted 9 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
/* Power up afg */ snd_hdac_codec_read(hdac, hdac->afg, 0, AC_VERB_SET_POWER_STATE, AC_PWRST_D0);--
2.7.4Signature · 2 lines
Thanks, Anshuman
Signature · 6 lines
Thanks, Anshuman _______________________________________________ Alsa-devel mailing list [email protected] http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Quoted 27 lines · Anshuman Gupta
Quoted 26 lines · Subhransu S. Prusty
Quoted 24 lines · Anshuman Gupta
Quoted 6 lines · Rafael J. Wysocki
Quoted 4 lines · Anshuman Gupta
Quoted 3 lines · Rafael J. Wysocki
Quoted 1 line · Anshuman Gupta
Quoted 7 lines
Quoted 5 lines
Quoted 5 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ if (pm_runtime_status_suspended(dev)) + return;That, again, is somewhat fragile from the concurrency perspective.
And here you want to avoid the below if the device is still suspended.
Yes, if we do not avoid the code below, complete callback takes about 3 seconds due to
snd_hdac_codec_readtimed out because hdac controller would be in runtime suspend state.Quoted 4 lines
Why is the below code located in the ->complete callback anyway? Shouldn't it be there in the ->resume one?
Yes even i am also having same doubt, why these power down and power up sequences are part of prepare and complete callback.
Adding driver author "Subhransu S. Prusty" to provide more inputs on this.
Quoted 8 lines
Quoted 4 lines
This driver needs a late resume as it receives a jack notification from the i915 driver and the skl controller driver resume may not have happened and in turn hda controller may not ready. This ensures a synchronization for jack event during resume from S3.
Let me give you insight of the issue, this driver blocks the direct complete of hda controller PCI 00:1f.3, sometimes it takes 280ms to resume hda controller from S3 and s2idle. So it does not make sense to suspend/resume hda controller when it is already in runtime suspend.
I get it now. I think this patch needs rework to address both the issues.
Quoted 8 lines
Quoted 2 lines
I think this patch defeats the purpose.
Here in this case PCI driver may kick the direct complete for hda controller
https://elixir.bootlin.com/linux/latest/source/drivers/pci/pci-driver.c#L691
But hdac hdmi codec driver is blocking it.
So i think it will be ok to keep this codec and hda controller in runtime suspend while entering S3 or s2idle, both can resume by runtime PM as well, will it brake any audio functionality?
There was some PM and jack detection issues (I don't recollect now) because of which this was added. This was due to the gfx display power and hda controller synchronization. The rework may be required in both hdac_hdmi and skylake drivers.
Regards,
Subhransu
Quoted 19 lines
Quoted 15 lines
Regards,
SubhransuQuoted 9 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
/* Power up afg */ snd_hdac_codec_read(hdac, hdac->afg, 0, AC_VERB_SET_POWER_STATE, AC_PWRST_D0);--
2.7.4Signature · 2 lines
Thanks, AnshumanSignature · 2 lines
Thanks, Anshuman
Quoted 49 lines · Subhransu S. Prusty
Quoted 27 lines · Anshuman Gupta
Quoted 26 lines · Subhransu S. Prusty
Quoted 24 lines · Anshuman Gupta
Quoted 6 lines · Rafael J. Wysocki
Quoted 4 lines · Anshuman Gupta
Quoted 3 lines · Rafael J. Wysocki
Quoted 1 line · Anshuman Gupta
Quoted 7 lines
Quoted 5 lines
Quoted 5 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ if (pm_runtime_status_suspended(dev)) + return;That, again, is somewhat fragile from the concurrency perspective.
And here you want to avoid the below if the device is still suspended.
Yes, if we do not avoid the code below, complete callback takes about 3 seconds due to
snd_hdac_codec_readtimed out because hdac controller would be in runtime suspend state.Quoted 4 lines
Why is the below code located in the ->complete callback anyway? Shouldn't it be there in the ->resume one?
Yes even i am also having same doubt, why these power down and power up sequences are part of prepare and complete callback.
Adding driver author "Subhransu S. Prusty" to provide more inputs on this.Quoted 8 lines
Quoted 4 lines
This driver needs a late resume as it receives a jack notification from the i915 driver and the skl controller driver resume may not have happened and in turn hda controller may not ready. This ensures a synchronization for jack event during resume from S3.
Let me give you insight of the issue, this driver blocks the direct complete of hda controller PCI 00:1f.3, sometimes it takes 280ms to resume hda controller from S3 and s2idle. So it does not make sense to suspend/resume hda controller when it is already in runtime suspend.
I get it now. I think this patch needs rework to address both the issues.
Quoted 8 lines
Quoted 2 lines
I think this patch defeats the purpose.
Here in this case PCI driver may kick the direct complete for hda controller
https://elixir.bootlin.com/linux/latest/source/drivers/pci/pci-driver.c#L691
But hdac hdmi codec driver is blocking it.
So i think it will be ok to keep this codec and hda controller in runtime suspend while entering S3 or s2idle, both can resume by runtime PM as well, will it brake any audio functionality?
Quoted 4 lines
There was some PM and jack detection issues (I don't recollect now) because of which this was added. This was due to the gfx display power and hda controller synchronization. The rework may be required in both
hdac_hdmiand skylake drivers.
If it's about the power well issue, it had been fixed in multiple ways. In i915 side, every relevant component callback is wrapped with power domain get/put. And, at least HD-audio legacy side, such a spurious notification is filtered out in the eld notifier:
static void intel_pin_eld_notify(void *audio_ptr, int port, int pipe)
{
....
/* skip notification during system suspend (but not in runtime PM);
* the state will be updated at resume
*/
if (snd_power_get_state(codec->card) != SNDRV_CTL_POWER_D0)
return;
/* ditto during suspend/resume process itself */
if (atomic_read(&(codec)->core.in_pm))
return;
snd_hdac_i915_set_bclk(&codec->bus->core);
check_presence_and_report(codec, pin_nid, dev_id);
}Last but not least, the jack state is explicitly updated via reading the ELD at resume callback.
In that way, we can live with the standard suspend/resume procedure.
Takashi
Quoted 35 lines · Takashi Iwai
Quoted 7 lines · Subhransu S. Prusty
Quoted 6 lines · Anshuman Gupta
Quoted 4 lines · Subhransu S. Prusty
This driver needs a late resume as it receives a jack notification from the i915 driver and the skl controller driver resume may not have happened and in turn hda controller may not ready. This ensures a synchronization for jack event during resume from S3.
Quoted 5 lines
Quoted 5 lines
Let me give you insight of the issue, this driver blocks the direct complete of hda controller PCI 00:1f.3, sometimes it takes 280ms to resume hda controller from S3 and s2idle. So it does not make sense to suspend/resume hda controller when it is already in runtime suspend.
If it's about the power well issue, it had been fixed in multiple ways. In i915 side, every relevant component callback is wrapped with power domain get/put. And, at least HD-audio legacy side, such a spurious notification is filtered out in the eld notifier:
static void
intel_pin_eld_notify(void *audio_ptr, int port, int pipe){ .... /* skip notification during system suspend (but not in runtime PM); * the state will be updated at resume */ if (snd_power_get_state(codec->card) != SNDRV_CTL_POWER_D0) return; /* ditto during suspend/resume process itself */ if (atomic_read(&(codec)->core.in_pm)) return; snd_hdac_i915_set_bclk(&codec->bus->core); check_presence_and_report(codec, pin_nid, dev_id); }
Quoted 4 lines
Last but not least, the jack state is explicitly updated via reading the ELD at resume callback.
In that way, we can live with the standard suspend/resume procedure.
FWIW, the i915 folks have put on their todo list to migrate the i915/hda_intel interaction to device links:
https://git.kernel.org/next/linux-next/c/7b3b61b62a58
Something similar has already been done for HDA controllers integrated into AMD / Nvidia GPUs with:
https://git.kernel.org/next/linux-next/c/07f4f97d7b4b
With device links, direct_complete will be used naturally, so time is probably best spent working towards this approach.
Thanks,
Lukas
v2 cover cover-letter hdac-codec runtime suspended at PM:Suspend.
In reply to Rafael J. WysockiCurrent implementation of hdac hdmi codec driver uses its suspend/resume operation callback in its prepare/complete callback which has issues with hdac direct-complete, it has been reviewed earlier that hdac hdmi codec driver requires a rework
(https://patchwork.kernel.org/patch/10276021/),
but as there is no rework with driver, it require to fix hdac direct complete issue to leverage hdac direct complete in order to optimize its resume latency while resuming from system wide suspend.
Anshuman Gupta (1):
hdac-codec runtime suspended at PM:Suspend.
sound/soc/codecs/hdac_hdmi.c | 6 ++++++ 1 file changed, 6 insertions(+)
Signature · 1 line
2.7.4
PATCH v2 1/1 hdac-codec runtime suspended at PM:Suspend.
Keep hdac hdmi codec to be in runtime suspended while entering to system wide suspend. Currently hdac hdmi codec driver using its suspend and resume operation in prepare and complete PM callbacks, and it resumes the hd audio controller (parent of self) from runtime suspend and blocks the direct complete for hd audio controller.
If hdac-codec is already in runtime suspend state skip its power down sequence in prepare, power up sequence in complete phase. It enables direct complete path for hdac-codec and hd audio controller PCI device.
---
Changes in v2
- Changed the commit message.
- Using pm_runtime_suspended instead of pm_runtime_status_suspended in order to handle any race condition.
sound/soc/codecs/hdac_hdmi.c | 6 ++++++
1 file changed, 6 insertions(+)
sound/soc/codecs/hdac_hdmi.c +6 -0
@@ -1859,6 +1859,9 @@ static int hdmi_codec_prepare(struct device *dev)struct hdac_ext_device *edev =to_hda_ext_device (dev);struct hdac_device *hdev = &edev->hdev; +if (pm_runtime_suspended (dev)) +return 1 ; +pm_runtime_get_sync (&edev->hdev.dev);/*
@@ -1880,6 +1883,9 @@ static void hdmi_codec_complete(struct device *dev)struct hdac_hdmi_priv *hdmi =hdev_to_hdmi_priv (&edev->hdev);struct hdac_device *hdev = &edev->hdev; +if (pm_runtime_suspended (dev)) +return ; +/* Power up afg */ snd_hdac_codec_read (hdev, hdev->afg,0 ,AC_VERB_SET_POWER_STATE ,AC_PWRST_D0 );
Signature · 1 line
2.7.4
Is this patch not in consideration, there are no review comment for it. this patch fixes an issue with hdac hdmi codec driver.
On one of our platform HD audio controller takes arounf 300ms. Below are the snippet of dmesg log.
[ 3778.461888] calling 0000:00:0e.0+ @ 3667, parent: pci0000:00, cb: pci_pm_resume [ 3778.775273] call 0000:00:0e.0+ returned 0 after 306016 usecs
When HD audio controller is in runtime suspend state,
with direct complete, we can improve overall system wide resume latency.
Quoted 46 lines · Anshuman Gupta
Keep hdac hdmi codec to be in runtime suspended while entering to system wide suspend. Currently hdac hdmi codec driver using its suspend and resume operation in prepare and complete PM callbacks, and it resumes the hd audio controller (parent of self) from runtime suspend and blocks the direct complete for hd audio controller.
If hdac-codec is already in runtime suspend state skip its power down sequence in prepare, power up sequence in complete phase. It enables direct complete path for hdac-codec and hd audio controller PCI device.
Signed-off-by Anshuman Gupta <[email protected]>---
Changes in v2
- Changed the commit message.
- Usingpm_runtime_suspendedinstead ofpm_runtime_status_suspendedin order to handle any race condition.
sound/soc/codecs/hdac_hdmi.c| 6 ++++++1 file changed, 6 insertions(+)sound/soc/codecs/hdac_hdmi.c +6
-1@@ -1859,6 +1859,9 @@ static int hdmi_codec_prepare(struct device *dev)struct hdac_ext_device *edev =to_hda_ext_device (dev);struct hdac_device *hdev = &edev->hdev; +if (pm_runtime_suspended (dev)) +return 1 ; +pm_runtime_get_sync (&edev->hdev.dev);/* @@ -1880,6 +1883,9 @@ static void hdmi_codec_complete(struct device *dev)struct hdac_hdmi_priv *hdmi =hdev_to_hdmi_priv (&edev->hdev);struct hdac_device *hdev = &edev->hdev; +if (pm_runtime_suspended (dev)) +return ; +/* Power up afg */ snd_hdac_codec_read (hdev, hdev->afg,0 ,AC_VERB_SET_POWER_STATE ,AC_PWRST_D0 ); --
Quoted 2 lines
2.7.4
--
Thanks,
Anshuman.
Quoted 4 lines · Anshuman Gupta
Is this patch not in consideration, there are no review comment for it. this patch fixes an issue with hdac hdmi codec driver.
Quoted 8 lines
On one of our platform HD audio controller takes arounf 300ms. Below are the snippet of dmesg log.
[ 3778.461888] calling 0000:00:0e.0+ @ 3667, parent: pci0000:00, cb: pci_pm_resume [ 3778.775273] call 0000:00:0e.0+ returned 0 after 306016 usecsWhen HD audio controller is in runtime suspend state,
with direct complete, we can improve overall system wide resume latency.
Actually, *this* should have been mentioned in the changelog, and the subject would be better phrased to reflect it.
After all, you're trying to reduce / optimize the runtime PM latency.
thanks,
Takashi
Quoted 55 lines · Anshuman Gupta
Quoted 46 lines
Keep hdac hdmi codec to be in runtime suspended while entering to system wide suspend. Currently hdac hdmi codec driver using its suspend and resume operation in prepare and complete PM callbacks, and it resumes the hd audio controller (parent of self) from runtime suspend and blocks the direct complete for hd audio controller.
If hdac-codec is already in runtime suspend state skip its power down sequence in prepare, power up sequence in complete phase. It enables direct complete path for hdac-codec and hd audio controller PCI device.
Signed-off-by Anshuman Gupta <[email protected]>---
Changes in v2
- Changed the commit message.
- Usingpm_runtime_suspendedinstead ofpm_runtime_status_suspendedin order to handle any race condition.
sound/soc/codecs/hdac_hdmi.c| 6 ++++++1 file changed, 6 insertions(+)sound/soc/codecs/hdac_hdmi.c +6
-1@@ -1859,6 +1859,9 @@ static int hdmi_codec_prepare(struct device *dev)struct hdac_ext_device *edev =to_hda_ext_device (dev);struct hdac_device *hdev = &edev->hdev; +if (pm_runtime_suspended (dev)) +return 1 ; +pm_runtime_get_sync (&edev->hdev.dev);/* @@ -1880,6 +1883,9 @@ static void hdmi_codec_complete(struct device *dev)struct hdac_hdmi_priv *hdmi =hdev_to_hdmi_priv (&edev->hdev);struct hdac_device *hdev = &edev->hdev; +if (pm_runtime_suspended (dev)) +return ; +/* Power up afg */ snd_hdac_codec_read (hdev, hdev->afg,0 ,AC_VERB_SET_POWER_STATE ,AC_PWRST_D0 ); --Quoted 2 lines
2.7.4
--
Thanks,
Anshuman.