alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] ALSA: hda: cs35l41: Don't return -EINVAL from system suspend/resume
@ 2023-01-05  9:35 Takashi Iwai
  2023-01-05  9:35 ` [PATCH 2/2] ALSA: hda: cs35l41: Check runtime suspend capability at runtime_idle Takashi Iwai
  2023-01-05 10:14 ` [PATCH 1/2] ALSA: hda: cs35l41: Don't return -EINVAL from system suspend/resume Thorsten Leemhuis
  0 siblings, 2 replies; 4+ messages in thread
From: Takashi Iwai @ 2023-01-05  9:35 UTC (permalink / raw)
  To: alsa-devel; +Cc: Stefan Binding, Richard Fitzgerald, Lucas Tanure

The recent commit to support the system suspend for CS35L41 caused a
regression on the models with CS35L41_EXT_BOOST_NO_VSPK_SWITC boost
type, as the suspend/resume callbacks just return -EINVAL.  This is
eventually handled as a fatal error and blocks the whole system
suspend/resume.

For avoiding the problem, this patch corrects the return code from
cs35l41_system_suspend() and _resume() to 0, and replace dev_err()
with dev_err_once() for stop spamming too much.

Fixes: 88672826e2a4 ("ALSA: hda: cs35l41: Support System Suspend")
Cc: <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/4262e3c4-6169-bbd2-e918-16b06f6994bc@protonmail.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 sound/pci/hda/cs35l41_hda.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/sound/pci/hda/cs35l41_hda.c b/sound/pci/hda/cs35l41_hda.c
index 91842c0c8c74..0a5cee730268 100644
--- a/sound/pci/hda/cs35l41_hda.c
+++ b/sound/pci/hda/cs35l41_hda.c
@@ -598,8 +598,8 @@ static int cs35l41_system_suspend(struct device *dev)
 	dev_dbg(cs35l41->dev, "System Suspend\n");
 
 	if (cs35l41->hw_cfg.bst_type == CS35L41_EXT_BOOST_NO_VSPK_SWITCH) {
-		dev_err(cs35l41->dev, "System Suspend not supported\n");
-		return -EINVAL;
+		dev_err_once(cs35l41->dev, "System Suspend not supported\n");
+		return 0; /* don't block the whole system suspend */
 	}
 
 	ret = pm_runtime_force_suspend(dev);
@@ -624,8 +624,8 @@ static int cs35l41_system_resume(struct device *dev)
 	dev_dbg(cs35l41->dev, "System Resume\n");
 
 	if (cs35l41->hw_cfg.bst_type == CS35L41_EXT_BOOST_NO_VSPK_SWITCH) {
-		dev_err(cs35l41->dev, "System Resume not supported\n");
-		return -EINVAL;
+		dev_err_once(cs35l41->dev, "System Resume not supported\n");
+		return 0; /* don't block the whole system resume */
 	}
 
 	if (cs35l41->reset_gpio) {
-- 
2.35.3


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] ALSA: hda: cs35l41: Check runtime suspend capability at runtime_idle
  2023-01-05  9:35 [PATCH 1/2] ALSA: hda: cs35l41: Don't return -EINVAL from system suspend/resume Takashi Iwai
@ 2023-01-05  9:35 ` Takashi Iwai
  2023-01-05 10:14 ` [PATCH 1/2] ALSA: hda: cs35l41: Don't return -EINVAL from system suspend/resume Thorsten Leemhuis
  1 sibling, 0 replies; 4+ messages in thread
From: Takashi Iwai @ 2023-01-05  9:35 UTC (permalink / raw)
  To: alsa-devel; +Cc: Stefan Binding, Richard Fitzgerald, Lucas Tanure

The runtime PM core checks with runtime_idle callback whether it can
goes to the runtime suspend or not, and we can put the boost type
check there instead of runtime_suspend and _resume calls.  This will
reduce the unnecessary runtime_suspend() calls.

Fixes: 1873ebd30cc8 ("ALSA: hda: cs35l41: Support Hibernation during Suspend")
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 sound/pci/hda/cs35l41_hda.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/sound/pci/hda/cs35l41_hda.c b/sound/pci/hda/cs35l41_hda.c
index 0a5cee730268..f7815ee24f83 100644
--- a/sound/pci/hda/cs35l41_hda.c
+++ b/sound/pci/hda/cs35l41_hda.c
@@ -647,6 +647,15 @@ static int cs35l41_system_resume(struct device *dev)
 	return ret;
 }
 
+static int cs35l41_runtime_idle(struct device *dev)
+{
+	struct cs35l41_hda *cs35l41 = dev_get_drvdata(dev);
+
+	if (cs35l41->hw_cfg.bst_type == CS35L41_EXT_BOOST_NO_VSPK_SWITCH)
+		return -EBUSY; /* suspend not supported yet on this model */
+	return 0;
+}
+
 static int cs35l41_runtime_suspend(struct device *dev)
 {
 	struct cs35l41_hda *cs35l41 = dev_get_drvdata(dev);
@@ -1536,7 +1545,8 @@ void cs35l41_hda_remove(struct device *dev)
 EXPORT_SYMBOL_NS_GPL(cs35l41_hda_remove, SND_HDA_SCODEC_CS35L41);
 
 const struct dev_pm_ops cs35l41_hda_pm_ops = {
-	RUNTIME_PM_OPS(cs35l41_runtime_suspend, cs35l41_runtime_resume, NULL)
+	RUNTIME_PM_OPS(cs35l41_runtime_suspend, cs35l41_runtime_resume,
+		       cs35l41_runtime_idle)
 	SYSTEM_SLEEP_PM_OPS(cs35l41_system_suspend, cs35l41_system_resume)
 };
 EXPORT_SYMBOL_NS_GPL(cs35l41_hda_pm_ops, SND_HDA_SCODEC_CS35L41);
-- 
2.35.3


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] ALSA: hda: cs35l41: Don't return -EINVAL from system suspend/resume
  2023-01-05  9:35 [PATCH 1/2] ALSA: hda: cs35l41: Don't return -EINVAL from system suspend/resume Takashi Iwai
  2023-01-05  9:35 ` [PATCH 2/2] ALSA: hda: cs35l41: Check runtime suspend capability at runtime_idle Takashi Iwai
@ 2023-01-05 10:14 ` Thorsten Leemhuis
  2023-01-05 13:33   ` Takashi Iwai
  1 sibling, 1 reply; 4+ messages in thread
From: Thorsten Leemhuis @ 2023-01-05 10:14 UTC (permalink / raw)
  To: Takashi Iwai, alsa-devel; +Cc: Stefan Binding, Richard Fitzgerald, Lucas Tanure

On 05.01.23 10:35, Takashi Iwai wrote:
> The recent commit to support the system suspend for CS35L41 caused a
> regression on the models with CS35L41_EXT_BOOST_NO_VSPK_SWITC boost
> type, as the suspend/resume callbacks just return -EINVAL.  This is
> eventually handled as a fatal error and blocks the whole system
> suspend/resume.
> 
> For avoiding the problem, this patch corrects the return code from
> cs35l41_system_suspend() and _resume() to 0, and replace dev_err()
> with dev_err_once() for stop spamming too much.
> 
> Fixes: 88672826e2a4 ("ALSA: hda: cs35l41: Support System Suspend")
> Cc: <stable@vger.kernel.org>

Thx for taking care of that.

> Link: https://lore.kernel.org/r/4262e3c4-6169-bbd2-e918-16b06f6994bc@protonmail.com

Lore says "Not found". I wonder if it was a private mail later send
again here:

https://lore.kernel.org/all/e6751ac2-34f3-d13f-13db-8174fade8308@pm.me/

Ciao, Thorsten

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] ALSA: hda: cs35l41: Don't return -EINVAL from system suspend/resume
  2023-01-05 10:14 ` [PATCH 1/2] ALSA: hda: cs35l41: Don't return -EINVAL from system suspend/resume Thorsten Leemhuis
@ 2023-01-05 13:33   ` Takashi Iwai
  0 siblings, 0 replies; 4+ messages in thread
From: Takashi Iwai @ 2023-01-05 13:33 UTC (permalink / raw)
  To: Thorsten Leemhuis
  Cc: alsa-devel, Richard Fitzgerald, Stefan Binding, Lucas Tanure

On Thu, 05 Jan 2023 11:14:13 +0100,
Thorsten Leemhuis wrote:
> 
> On 05.01.23 10:35, Takashi Iwai wrote:
> > The recent commit to support the system suspend for CS35L41 caused a
> > regression on the models with CS35L41_EXT_BOOST_NO_VSPK_SWITC boost
> > type, as the suspend/resume callbacks just return -EINVAL.  This is
> > eventually handled as a fatal error and blocks the whole system
> > suspend/resume.
> > 
> > For avoiding the problem, this patch corrects the return code from
> > cs35l41_system_suspend() and _resume() to 0, and replace dev_err()
> > with dev_err_once() for stop spamming too much.
> > 
> > Fixes: 88672826e2a4 ("ALSA: hda: cs35l41: Support System Suspend")
> > Cc: <stable@vger.kernel.org>
> 
> Thx for taking care of that.
> 
> > Link: https://lore.kernel.org/r/4262e3c4-6169-bbd2-e918-16b06f6994bc@protonmail.com
> 
> Lore says "Not found". I wonder if it was a private mail later send
> again here:
> 
> https://lore.kernel.org/all/e6751ac2-34f3-d13f-13db-8174fade8308@pm.me/

Yeah, it looks so.  I'll correct the URL at applying the patches.


thanks,

Takashi

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-01-05 13:34 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-05  9:35 [PATCH 1/2] ALSA: hda: cs35l41: Don't return -EINVAL from system suspend/resume Takashi Iwai
2023-01-05  9:35 ` [PATCH 2/2] ALSA: hda: cs35l41: Check runtime suspend capability at runtime_idle Takashi Iwai
2023-01-05 10:14 ` [PATCH 1/2] ALSA: hda: cs35l41: Don't return -EINVAL from system suspend/resume Thorsten Leemhuis
2023-01-05 13:33   ` Takashi Iwai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).