From: Stefan Binding <sbinding@opensource.cirrus.com>
To: Mark Brown <broonie@kernel.org>, Jaroslav Kysela <perex@perex.cz>,
Takashi Iwai <tiwai@suse.com>
Cc: linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org,
patches@opensource.cirrus.com,
Stefan Binding <sbinding@opensource.cirrus.com>
Subject: [PATCH v1 4/7] ALSA: hda/cs35l41: Split System Suspend/Resume callbacks
Date: Fri, 20 Nov 2026 16:10:50 +0000 [thread overview]
Message-ID: <20261120161136.157593-5-sbinding@opensource.cirrus.com> (raw)
In-Reply-To: <20261120161136.157593-1-sbinding@opensource.cirrus.com>
Currently, the CS35L41 driver does most of its system suspend and
resume functions inside single suspend and resume callbacks.
Ensure IRQs are correctly disabled and enabled at the right times
during the System Suspend and Resume process, to ensure we don't get
spurious interrupts which cause issues.
Signed-off-by: Stefan Binding <sbinding@opensource.cirrus.com>
---
sound/hda/codecs/side-codecs/cs35l41_hda.c | 91 ++++++++++++++++++----
1 file changed, 78 insertions(+), 13 deletions(-)
diff --git a/sound/hda/codecs/side-codecs/cs35l41_hda.c b/sound/hda/codecs/side-codecs/cs35l41_hda.c
index 2e2bf231d3fc..1a192749c7b0 100644
--- a/sound/hda/codecs/side-codecs/cs35l41_hda.c
+++ b/sound/hda/codecs/side-codecs/cs35l41_hda.c
@@ -942,10 +942,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_once(cs35l41->dev, "System Suspend not supported\n");
+ if (cs35l41->hw_cfg.bst_type == CS35L41_EXT_BOOST_NO_VSPK_SWITCH)
return 0; /* don't block the whole system suspend */
- }
scoped_guard(mutex, &cs35l41->fw_mutex) {
if (cs35l41->playback_started)
@@ -963,15 +961,75 @@ static int cs35l41_system_suspend(struct device *dev)
if (ret)
dev_err(dev, "System Suspend Failed, not ready for Reset: %d\n", ret);
+
+ /*
+ * The interrupt line is normally shared, but after we start suspending
+ * we can't check if our device is the source of an interrupt, and can't
+ * clear it. Prevent this race by temporarily disabling the parent irq
+ * until we reach _noirq.
+ */
+ if (cs35l41->irq)
+ disable_irq(cs35l41->irq);
+
+ dev_dbg(cs35l41->dev, "System Suspended\n");
+
+ return ret;
+}
+
+static int cs35l41_system_suspend_late(struct device *dev)
+{
+ struct cs35l41_hda *cs35l41 = dev_get_drvdata(dev);
+
+ if (cs35l41->hw_cfg.bst_type == CS35L41_EXT_BOOST_NO_VSPK_SWITCH)
+ return 0; /* don't block the whole system suspend */
+
+ /*
+ * RESET is usually shared by all amps so it must not be asserted until
+ * all driver instances have done their suspend() stage.
+ */
if (cs35l41->reset_gpio) {
dev_info(cs35l41->dev, "Asserting Reset\n");
gpiod_set_value_cansleep(cs35l41->reset_gpio, 0);
usleep_range(2000, 2100);
}
- dev_dbg(cs35l41->dev, "System Suspended\n");
+ return 0;
+}
- return ret;
+static int cs35l41_system_suspend_noirq(struct device *dev)
+{
+ struct cs35l41_hda *cs35l41 = dev_get_drvdata(dev);
+
+ if (cs35l41->hw_cfg.bst_type == CS35L41_EXT_BOOST_NO_VSPK_SWITCH)
+ return 0; /* don't block the whole system suspend */
+
+ /* Handlers are now disabled so the parent IRQ can safely be re-enabled. */
+ if (cs35l41->irq)
+ enable_irq(cs35l41->irq);
+
+ return 0;
+}
+
+static int cs35l41_system_resume_noirq(struct device *dev)
+{
+ struct cs35l41_hda *cs35l41 = dev_get_drvdata(dev);
+
+ if (cs35l41->hw_cfg.bst_type == CS35L41_EXT_BOOST_NO_VSPK_SWITCH) {
+ dev_err_once(cs35l41->dev, "System Resume not supported\n");
+ return 0; /* don't block the whole system resume */
+ }
+
+ /*
+ * WAKE interrupts unmask if the CS35L41 resets, which can cause
+ * spurious interrupts, and the interrupt line is normally shared.
+ * We can't check if our device is the source of an interrupt, and can't
+ * clear it, until it has fully resumed. Prevent this race by temporarily
+ * disabling the parent irq until we complete resume().
+ */
+ if (cs35l41->irq)
+ disable_irq(cs35l41->irq);
+
+ return 0;
}
static int cs35l41_system_resume(struct device *dev)
@@ -981,28 +1039,32 @@ 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_once(cs35l41->dev, "System Resume not supported\n");
+ if (cs35l41->hw_cfg.bst_type == CS35L41_EXT_BOOST_NO_VSPK_SWITCH)
return 0; /* don't block the whole system resume */
- }
if (cs35l41->reset_gpio) {
+ dev_info(cs35l41->dev, "Deasserting Reset\n");
gpiod_set_value_cansleep(cs35l41->reset_gpio, 0);
usleep_range(2000, 2100);
gpiod_set_value_cansleep(cs35l41->reset_gpio, 1);
+ usleep_range(2000, 2100);
}
- usleep_range(2000, 2100);
-
regcache_cache_only(cs35l41->regmap, false);
ret = cs35l41_reset_and_boot(cs35l41->dev, cs35l41->regmap);
- if (ret)
- return ret;
regcache_cache_only(cs35l41->regmap, true);
+ if (ret) {
+ dev_err(cs35l41->dev, "System Resume Failed: Boot Failed: %d\n", ret);
+ if (cs35l41->irq)
+ enable_irq(cs35l41->irq);
+ return ret;
+ }
ret = pm_runtime_force_resume(dev);
+ if (cs35l41->irq)
+ enable_irq(cs35l41->irq);
if (ret) {
dev_err(dev, "System Resume Failed: Unable to runtime resume: %d\n", ret);
return ret;
@@ -1015,7 +1077,7 @@ static int cs35l41_system_resume(struct device *dev)
schedule_work(&cs35l41->fw_load_work);
}
- return ret;
+ return 0;
}
static int cs35l41_runtime_idle(struct device *dev)
@@ -2083,6 +2145,9 @@ const struct dev_pm_ops cs35l41_hda_pm_ops = {
cs35l41_runtime_idle)
.prepare = cs35l41_system_suspend_prep,
SYSTEM_SLEEP_PM_OPS(cs35l41_system_suspend, cs35l41_system_resume)
+ LATE_SYSTEM_SLEEP_PM_OPS(cs35l41_system_suspend_late, NULL)
+ NOIRQ_SYSTEM_SLEEP_PM_OPS(cs35l41_system_suspend_noirq,
+ cs35l41_system_resume_noirq)
};
EXPORT_SYMBOL_NS_GPL(cs35l41_hda_pm_ops, "SND_HDA_SCODEC_CS35L41");
--
2.43.0
next prev parent reply other threads:[~2026-11-20 16:12 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-20 16:10 [PATCH v1 0/7] Fixes and improvements in CS35L41 HDA driver for System Suspend/Resume Stefan Binding
2026-11-20 16:10 ` [PATCH v1 1/7] ALSA: hda: cs35l41: Remove redundant lock_system_sleep() calls Stefan Binding
2026-11-20 16:10 ` [PATCH v1 2/7] ASoC: cs35l41: Prevent software reset when using SPI Stefan Binding
2026-11-20 16:10 ` [PATCH v1 3/7] ALSA: hda: cs35l41: Unset irq if not used or configured Stefan Binding
2026-11-20 16:10 ` Stefan Binding [this message]
2026-11-20 16:10 ` [PATCH v1 5/7] ALSA: hda/cs35l41: Remove support for alternative firmware types Stefan Binding
2026-11-20 16:10 ` [PATCH v1 6/7] ALSA: hda/cs35l41: Store filenames of successfully loaded firmware and tunings Stefan Binding
2026-11-20 16:10 ` [PATCH v1 7/7] ALSA: hda/cs35l41: rework how firmware requests are queued and flushed to prevent races Stefan Binding
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261120161136.157593-5-sbinding@opensource.cirrus.com \
--to=sbinding@opensource.cirrus.com \
--cc=broonie@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=patches@opensource.cirrus.com \
--cc=perex@perex.cz \
--cc=tiwai@suse.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox