* [PATCH 0/6] Improve cs42l43 suspend/IRQ interactions
@ 2025-09-03 9:45 Charles Keepax
2025-09-03 9:45 ` [PATCH 1/6] ASoC: cs42l43: Rename system suspend callback and fix debug print Charles Keepax
` (7 more replies)
0 siblings, 8 replies; 9+ messages in thread
From: Charles Keepax @ 2025-09-03 9:45 UTC (permalink / raw)
To: broonie, lee; +Cc: lgirdwood, linux-sound, linux-kernel, patches
cs42l43 uses pm_runtime_force_suspend() during system suspend, however
this means care must be taken that IRQ handler code isn't running when
entering system suspend as force suspend will ignore that the handler
is holding a pm reference. Typically the result of this is just a few
error messages, but better to improve the handling and ensure that all
IRQ processing is synchronised in before system suspend.
Note the ASoC and MFD bits of this series have no build dependencies,
so could go through their seperate trees, however, it would be nice if
all the patches could land in the same kernel version to avoid the IRQ
handling being in a transitional state.
Thanks,
Charles
Charles Keepax (6):
ASoC: cs42l43: Rename system suspend callback and fix debug print
ASoC: cs42l43: Store IRQ domain in codec private data
ASoC: cs42l43: Disable IRQs in system suspend
ASoC: cs42l43: Shutdown jack detection on suspend
mfd: cs42l43: Move IRQ enable/disable to encompass force suspend
mfd: cs42l43: Remove IRQ masking in suspend
drivers/mfd/cs42l43.c | 32 +---------
sound/soc/codecs/cs42l43-jack.c | 8 ++-
sound/soc/codecs/cs42l43.c | 109 +++++++++++++++++++++++---------
sound/soc/codecs/cs42l43.h | 3 +
4 files changed, 89 insertions(+), 63 deletions(-)
--
2.47.2
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 1/6] ASoC: cs42l43: Rename system suspend callback and fix debug print
2025-09-03 9:45 [PATCH 0/6] Improve cs42l43 suspend/IRQ interactions Charles Keepax
@ 2025-09-03 9:45 ` Charles Keepax
2025-09-03 9:45 ` [PATCH 2/6] ASoC: cs42l43: Store IRQ domain in codec private data Charles Keepax
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Charles Keepax @ 2025-09-03 9:45 UTC (permalink / raw)
To: broonie, lee; +Cc: lgirdwood, linux-sound, linux-kernel, patches
There is some confusion around cs42l43_codec_runtime_force_suspend().
This function is the system suspend callback, however the name and
the debug print both use the words runtime. Rename the function to
the simpler cs42l43_codec_suspend() and correct the debug print.
Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
---
sound/soc/codecs/cs42l43.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/sound/soc/codecs/cs42l43.c b/sound/soc/codecs/cs42l43.c
index b0c27d696c58a..4d17799415817 100644
--- a/sound/soc/codecs/cs42l43.c
+++ b/sound/soc/codecs/cs42l43.c
@@ -2386,11 +2386,11 @@ static int cs42l43_codec_runtime_resume(struct device *dev)
return 0;
}
-static int cs42l43_codec_runtime_force_suspend(struct device *dev)
+static int cs42l43_codec_suspend(struct device *dev)
{
struct cs42l43_codec *priv = dev_get_drvdata(dev);
- dev_dbg(priv->dev, "Runtime suspend\n");
+ dev_dbg(priv->dev, "System suspend\n");
priv->suspend_jack_debounce = true;
@@ -2401,7 +2401,7 @@ static int cs42l43_codec_runtime_force_suspend(struct device *dev)
static const struct dev_pm_ops cs42l43_codec_pm_ops = {
RUNTIME_PM_OPS(NULL, cs42l43_codec_runtime_resume, NULL)
- SYSTEM_SLEEP_PM_OPS(cs42l43_codec_runtime_force_suspend, pm_runtime_force_resume)
+ SYSTEM_SLEEP_PM_OPS(cs42l43_codec_suspend, pm_runtime_force_resume)
};
static const struct platform_device_id cs42l43_codec_id_table[] = {
--
2.47.2
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 2/6] ASoC: cs42l43: Store IRQ domain in codec private data
2025-09-03 9:45 [PATCH 0/6] Improve cs42l43 suspend/IRQ interactions Charles Keepax
2025-09-03 9:45 ` [PATCH 1/6] ASoC: cs42l43: Rename system suspend callback and fix debug print Charles Keepax
@ 2025-09-03 9:45 ` Charles Keepax
2025-09-03 9:45 ` [PATCH 3/6] ASoC: cs42l43: Disable IRQs in system suspend Charles Keepax
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Charles Keepax @ 2025-09-03 9:45 UTC (permalink / raw)
To: broonie, lee; +Cc: lgirdwood, linux-sound, linux-kernel, patches
To support future refactoring store a pointer to the IRQ domain in the
codec private data allowing easier access to it outside of probe.
Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
---
sound/soc/codecs/cs42l43.c | 29 +++++++++++++----------------
sound/soc/codecs/cs42l43.h | 1 +
2 files changed, 14 insertions(+), 16 deletions(-)
diff --git a/sound/soc/codecs/cs42l43.c b/sound/soc/codecs/cs42l43.c
index 4d17799415817..241f7d013189c 100644
--- a/sound/soc/codecs/cs42l43.c
+++ b/sound/soc/codecs/cs42l43.c
@@ -2210,13 +2210,12 @@ static const struct cs42l43_irq cs42l43_irqs[] = {
};
static int cs42l43_request_irq(struct cs42l43_codec *priv,
- struct irq_domain *dom, const char * const name,
- unsigned int irq, irq_handler_t handler,
- unsigned long flags)
+ const char * const name, unsigned int irq,
+ irq_handler_t handler, unsigned long flags)
{
int ret;
- ret = irq_create_mapping(dom, irq);
+ ret = irq_create_mapping(priv->dom, irq);
if (ret < 0)
return dev_err_probe(priv->dev, ret, "Failed to map IRQ %s\n", name);
@@ -2230,8 +2229,7 @@ static int cs42l43_request_irq(struct cs42l43_codec *priv,
return 0;
}
-static int cs42l43_shutter_irq(struct cs42l43_codec *priv,
- struct irq_domain *dom, unsigned int shutter,
+static int cs42l43_shutter_irq(struct cs42l43_codec *priv, unsigned int shutter,
const char * const open_name,
const char * const close_name,
irq_handler_t handler)
@@ -2259,25 +2257,20 @@ static int cs42l43_shutter_irq(struct cs42l43_codec *priv,
return 0;
}
- ret = cs42l43_request_irq(priv, dom, close_name, close_irq, handler, IRQF_SHARED);
+ ret = cs42l43_request_irq(priv, close_name, close_irq, handler, IRQF_SHARED);
if (ret)
return ret;
- return cs42l43_request_irq(priv, dom, open_name, open_irq, handler, IRQF_SHARED);
+ return cs42l43_request_irq(priv, open_name, open_irq, handler, IRQF_SHARED);
}
static int cs42l43_codec_probe(struct platform_device *pdev)
{
struct cs42l43 *cs42l43 = dev_get_drvdata(pdev->dev.parent);
struct cs42l43_codec *priv;
- struct irq_domain *dom;
unsigned int val;
int i, ret;
- dom = irq_find_matching_fwnode(dev_fwnode(cs42l43->dev), DOMAIN_BUS_ANY);
- if (!dom)
- return -EPROBE_DEFER;
-
priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
if (!priv)
return -ENOMEM;
@@ -2285,6 +2278,10 @@ static int cs42l43_codec_probe(struct platform_device *pdev)
priv->dev = &pdev->dev;
priv->core = cs42l43;
+ priv->dom = irq_find_matching_fwnode(dev_fwnode(cs42l43->dev), DOMAIN_BUS_ANY);
+ if (!priv->dom)
+ return -EPROBE_DEFER;
+
platform_set_drvdata(pdev, priv);
mutex_init(&priv->jack_lock);
@@ -2314,7 +2311,7 @@ static int cs42l43_codec_probe(struct platform_device *pdev)
goto err_pm;
for (i = 0; i < ARRAY_SIZE(cs42l43_irqs); i++) {
- ret = cs42l43_request_irq(priv, dom, cs42l43_irqs[i].name,
+ ret = cs42l43_request_irq(priv, cs42l43_irqs[i].name,
cs42l43_irqs[i].irq,
cs42l43_irqs[i].handler, 0);
if (ret)
@@ -2327,13 +2324,13 @@ static int cs42l43_codec_probe(struct platform_device *pdev)
goto err_pm;
}
- ret = cs42l43_shutter_irq(priv, dom, val & CS42L43_MIC_SHUTTER_CFG_MASK,
+ ret = cs42l43_shutter_irq(priv, val & CS42L43_MIC_SHUTTER_CFG_MASK,
"mic shutter open", "mic shutter close",
cs42l43_mic_shutter);
if (ret)
goto err_pm;
- ret = cs42l43_shutter_irq(priv, dom, (val & CS42L43_SPK_SHUTTER_CFG_MASK) >>
+ ret = cs42l43_shutter_irq(priv, (val & CS42L43_SPK_SHUTTER_CFG_MASK) >>
CS42L43_SPK_SHUTTER_CFG_SHIFT,
"spk shutter open", "spk shutter close",
cs42l43_spk_shutter);
diff --git a/sound/soc/codecs/cs42l43.h b/sound/soc/codecs/cs42l43.h
index 3ea36362b11a4..f4ef93d1fc2a4 100644
--- a/sound/soc/codecs/cs42l43.h
+++ b/sound/soc/codecs/cs42l43.h
@@ -44,6 +44,7 @@ struct cs42l43_codec {
struct device *dev;
struct cs42l43 *core;
struct snd_soc_component *component;
+ struct irq_domain *dom;
struct clk *mclk;
--
2.47.2
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 3/6] ASoC: cs42l43: Disable IRQs in system suspend
2025-09-03 9:45 [PATCH 0/6] Improve cs42l43 suspend/IRQ interactions Charles Keepax
2025-09-03 9:45 ` [PATCH 1/6] ASoC: cs42l43: Rename system suspend callback and fix debug print Charles Keepax
2025-09-03 9:45 ` [PATCH 2/6] ASoC: cs42l43: Store IRQ domain in codec private data Charles Keepax
@ 2025-09-03 9:45 ` Charles Keepax
2025-09-03 9:45 ` [PATCH 4/6] ASoC: cs42l43: Shutdown jack detection on suspend Charles Keepax
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Charles Keepax @ 2025-09-03 9:45 UTC (permalink / raw)
To: broonie, lee; +Cc: lgirdwood, linux-sound, linux-kernel, patches
Currently the MFD driver disables all the IRQs upon entering system
suspend, however there are some issues with this approach. As this
device uses runtime force suspend.
The regmap IRQ handler can run, claim a PM runtime reference and get
scheduled, the MFD can then force suspend. When the IRQ thread gets
rescheduled it will try to access volatile registers on the
suspended device. Furthermore, this race also applies to work queue
items scheduled by the IRQ handlers.
As the MFD code doesn't know about the individual work queue items, the
end drivers must mask their own IRQs and sync in any work queues as part
of entering system suspend. Update the code here to do so.
Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
---
sound/soc/codecs/cs42l43.c | 78 ++++++++++++++++++++++++++++++--------
sound/soc/codecs/cs42l43.h | 1 +
2 files changed, 64 insertions(+), 15 deletions(-)
diff --git a/sound/soc/codecs/cs42l43.c b/sound/soc/codecs/cs42l43.c
index 241f7d013189c..405926149a137 100644
--- a/sound/soc/codecs/cs42l43.c
+++ b/sound/soc/codecs/cs42l43.c
@@ -2229,12 +2229,29 @@ static int cs42l43_request_irq(struct cs42l43_codec *priv,
return 0;
}
+static void cs42l43_disable_irq(struct cs42l43_codec *priv, unsigned int irq)
+{
+ int ret;
+
+ ret = irq_find_mapping(priv->dom, irq);
+ if (ret > 0)
+ disable_irq(ret);
+}
+
+static void cs42l43_enable_irq(struct cs42l43_codec *priv, unsigned int irq)
+{
+ int ret;
+
+ ret = irq_find_mapping(priv->dom, irq);
+ if (ret > 0)
+ enable_irq(ret);
+}
+
static int cs42l43_shutter_irq(struct cs42l43_codec *priv, unsigned int shutter,
- const char * const open_name,
- const char * const close_name,
+ const char * const open_name, unsigned int *open_irq,
+ const char * const close_name, unsigned int *close_irq,
irq_handler_t handler)
{
- unsigned int open_irq, close_irq;
int ret;
switch (shutter) {
@@ -2242,26 +2259,26 @@ static int cs42l43_shutter_irq(struct cs42l43_codec *priv, unsigned int shutter,
dev_warn(priv->dev, "Manual shutters, notifications not available\n");
return 0;
case 0x2:
- open_irq = CS42L43_GPIO1_RISE;
- close_irq = CS42L43_GPIO1_FALL;
+ *open_irq = CS42L43_GPIO1_RISE;
+ *close_irq = CS42L43_GPIO1_FALL;
break;
case 0x4:
- open_irq = CS42L43_GPIO2_RISE;
- close_irq = CS42L43_GPIO2_FALL;
+ *open_irq = CS42L43_GPIO2_RISE;
+ *close_irq = CS42L43_GPIO2_FALL;
break;
case 0x8:
- open_irq = CS42L43_GPIO3_RISE;
- close_irq = CS42L43_GPIO3_FALL;
+ *open_irq = CS42L43_GPIO3_RISE;
+ *close_irq = CS42L43_GPIO3_FALL;
break;
default:
return 0;
}
- ret = cs42l43_request_irq(priv, close_name, close_irq, handler, IRQF_SHARED);
+ ret = cs42l43_request_irq(priv, close_name, *close_irq, handler, IRQF_SHARED);
if (ret)
return ret;
- return cs42l43_request_irq(priv, open_name, open_irq, handler, IRQF_SHARED);
+ return cs42l43_request_irq(priv, open_name, *open_irq, handler, IRQF_SHARED);
}
static int cs42l43_codec_probe(struct platform_device *pdev)
@@ -2325,14 +2342,16 @@ static int cs42l43_codec_probe(struct platform_device *pdev)
}
ret = cs42l43_shutter_irq(priv, val & CS42L43_MIC_SHUTTER_CFG_MASK,
- "mic shutter open", "mic shutter close",
+ "mic shutter open", &priv->shutter_irqs[0],
+ "mic shutter close", &priv->shutter_irqs[1],
cs42l43_mic_shutter);
if (ret)
goto err_pm;
ret = cs42l43_shutter_irq(priv, (val & CS42L43_SPK_SHUTTER_CFG_MASK) >>
CS42L43_SPK_SHUTTER_CFG_SHIFT,
- "spk shutter open", "spk shutter close",
+ "spk shutter open", &priv->shutter_irqs[2],
+ "spk shutter close", &priv->shutter_irqs[3],
cs42l43_spk_shutter);
if (ret)
goto err_pm;
@@ -2386,19 +2405,48 @@ static int cs42l43_codec_runtime_resume(struct device *dev)
static int cs42l43_codec_suspend(struct device *dev)
{
struct cs42l43_codec *priv = dev_get_drvdata(dev);
+ int i;
dev_dbg(priv->dev, "System suspend\n");
priv->suspend_jack_debounce = true;
- pm_runtime_force_suspend(dev);
+ for (i = 0; i < ARRAY_SIZE(cs42l43_irqs); i++)
+ cs42l43_disable_irq(priv, cs42l43_irqs[i].irq);
+
+ for (i = 0; i < ARRAY_SIZE(priv->shutter_irqs); i++)
+ if (priv->shutter_irqs[i])
+ cs42l43_disable_irq(priv, priv->shutter_irqs[i]);
+
+ cancel_delayed_work_sync(&priv->bias_sense_timeout);
+ cancel_delayed_work_sync(&priv->tip_sense_work);
+ cancel_delayed_work_sync(&priv->hp_ilimit_clear_work);
+
+ return pm_runtime_force_suspend(dev);
+}
+
+static int cs42l43_codec_resume(struct device *dev)
+{
+ struct cs42l43_codec *priv = dev_get_drvdata(dev);
+ int ret, i;
+
+ ret = pm_runtime_force_resume(dev);
+ if (ret)
+ return ret;
+
+ for (i = 0; i < ARRAY_SIZE(cs42l43_irqs); i++)
+ cs42l43_enable_irq(priv, cs42l43_irqs[i].irq);
+
+ for (i = 0; i < ARRAY_SIZE(priv->shutter_irqs); i++)
+ if (priv->shutter_irqs[i])
+ cs42l43_enable_irq(priv, priv->shutter_irqs[i]);
return 0;
}
static const struct dev_pm_ops cs42l43_codec_pm_ops = {
RUNTIME_PM_OPS(NULL, cs42l43_codec_runtime_resume, NULL)
- SYSTEM_SLEEP_PM_OPS(cs42l43_codec_suspend, pm_runtime_force_resume)
+ SYSTEM_SLEEP_PM_OPS(cs42l43_codec_suspend, cs42l43_codec_resume)
};
static const struct platform_device_id cs42l43_codec_id_table[] = {
diff --git a/sound/soc/codecs/cs42l43.h b/sound/soc/codecs/cs42l43.h
index f4ef93d1fc2a4..0951ad3525efe 100644
--- a/sound/soc/codecs/cs42l43.h
+++ b/sound/soc/codecs/cs42l43.h
@@ -45,6 +45,7 @@ struct cs42l43_codec {
struct cs42l43 *core;
struct snd_soc_component *component;
struct irq_domain *dom;
+ unsigned int shutter_irqs[4];
struct clk *mclk;
--
2.47.2
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 4/6] ASoC: cs42l43: Shutdown jack detection on suspend
2025-09-03 9:45 [PATCH 0/6] Improve cs42l43 suspend/IRQ interactions Charles Keepax
` (2 preceding siblings ...)
2025-09-03 9:45 ` [PATCH 3/6] ASoC: cs42l43: Disable IRQs in system suspend Charles Keepax
@ 2025-09-03 9:45 ` Charles Keepax
2025-09-03 9:45 ` [PATCH 5/6] mfd: cs42l43: Move IRQ enable/disable to encompass force suspend Charles Keepax
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Charles Keepax @ 2025-09-03 9:45 UTC (permalink / raw)
To: broonie, lee; +Cc: lgirdwood, linux-sound, linux-kernel, patches
Fully power down the jack detection on system suspend since the device
will not be powered up during.
Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
---
sound/soc/codecs/cs42l43-jack.c | 8 +++++---
sound/soc/codecs/cs42l43.c | 2 ++
sound/soc/codecs/cs42l43.h | 1 +
3 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/sound/soc/codecs/cs42l43-jack.c b/sound/soc/codecs/cs42l43-jack.c
index 2a0a4986a9ce8..867e23d4fb8d8 100644
--- a/sound/soc/codecs/cs42l43-jack.c
+++ b/sound/soc/codecs/cs42l43-jack.c
@@ -684,7 +684,7 @@ static int cs42l43_run_type_detect(struct cs42l43_codec *priv)
}
}
-static void cs42l43_clear_jack(struct cs42l43_codec *priv)
+void cs42l43_clear_jack(struct cs42l43_codec *priv)
{
struct cs42l43 *cs42l43 = priv->core;
@@ -703,8 +703,6 @@ static void cs42l43_clear_jack(struct cs42l43_codec *priv)
regmap_update_bits(cs42l43->regmap, CS42L43_HS2,
CS42L43_HSDET_MODE_MASK | CS42L43_HSDET_MANUAL_MODE_MASK,
0x2 << CS42L43_HSDET_MODE_SHIFT);
-
- snd_soc_jack_report(priv->jack_hp, 0, 0xFFFF);
}
void cs42l43_tip_sense_work(struct work_struct *work)
@@ -753,6 +751,8 @@ void cs42l43_tip_sense_work(struct work_struct *work)
cs42l43_clear_jack(priv);
+ snd_soc_jack_report(priv->jack_hp, 0, 0xFFFF);
+
if (cs42l43->sdw && priv->jack_present) {
pm_runtime_put(priv->dev);
priv->jack_present = false;
@@ -903,6 +903,8 @@ int cs42l43_jack_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *u
cs42l43_clear_jack(priv);
+ snd_soc_jack_report(priv->jack_hp, 0, 0xFFFF);
+
if (!override) {
queue_delayed_work(system_long_wq, &priv->tip_sense_work, 0);
} else {
diff --git a/sound/soc/codecs/cs42l43.c b/sound/soc/codecs/cs42l43.c
index 405926149a137..b61df09f20cf4 100644
--- a/sound/soc/codecs/cs42l43.c
+++ b/sound/soc/codecs/cs42l43.c
@@ -2422,6 +2422,8 @@ static int cs42l43_codec_suspend(struct device *dev)
cancel_delayed_work_sync(&priv->tip_sense_work);
cancel_delayed_work_sync(&priv->hp_ilimit_clear_work);
+ cs42l43_clear_jack(priv);
+
return pm_runtime_force_suspend(dev);
}
diff --git a/sound/soc/codecs/cs42l43.h b/sound/soc/codecs/cs42l43.h
index 0951ad3525efe..b2fa2cd1d99f8 100644
--- a/sound/soc/codecs/cs42l43.h
+++ b/sound/soc/codecs/cs42l43.h
@@ -132,6 +132,7 @@ static inline int cs42l43_sdw_add_peripheral(struct snd_pcm_substream *substream
int cs42l43_set_jack(struct snd_soc_component *component,
struct snd_soc_jack *jack, void *d);
void cs42l43_bias_sense_timeout(struct work_struct *work);
+void cs42l43_clear_jack(struct cs42l43_codec *priv);
void cs42l43_tip_sense_work(struct work_struct *work);
irqreturn_t cs42l43_bias_detect_clamp(int irq, void *data);
irqreturn_t cs42l43_button_press(int irq, void *data);
--
2.47.2
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 5/6] mfd: cs42l43: Move IRQ enable/disable to encompass force suspend
2025-09-03 9:45 [PATCH 0/6] Improve cs42l43 suspend/IRQ interactions Charles Keepax
` (3 preceding siblings ...)
2025-09-03 9:45 ` [PATCH 4/6] ASoC: cs42l43: Shutdown jack detection on suspend Charles Keepax
@ 2025-09-03 9:45 ` Charles Keepax
2025-09-03 9:45 ` [PATCH 6/6] mfd: cs42l43: Remove IRQ masking in suspend Charles Keepax
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Charles Keepax @ 2025-09-03 9:45 UTC (permalink / raw)
To: broonie, lee; +Cc: lgirdwood, linux-sound, linux-kernel, patches
As pm_runtime_force_suspend() will force the device state to suspend,
the driver needs to ensure no IRQ handlers are currently running. If not
those handlers may find they are now running on suspended hardware
despite holding a PM runtime reference. disable_irq() will sync any
currently running handlers, so move the IRQ disabling to cover the whole
of the forced suspend state to avoid such race conditions.
Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
---
drivers/mfd/cs42l43.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/mfd/cs42l43.c b/drivers/mfd/cs42l43.c
index 07c8f1b8183ee..959298c8232f4 100644
--- a/drivers/mfd/cs42l43.c
+++ b/drivers/mfd/cs42l43.c
@@ -1151,6 +1151,8 @@ static int cs42l43_suspend(struct device *dev)
return ret;
}
+ disable_irq(cs42l43->irq);
+
ret = pm_runtime_force_suspend(dev);
if (ret) {
dev_err(cs42l43->dev, "Failed to force suspend: %d\n", ret);
@@ -1164,8 +1166,6 @@ static int cs42l43_suspend(struct device *dev)
if (ret)
return ret;
- disable_irq(cs42l43->irq);
-
return 0;
}
@@ -1196,14 +1196,14 @@ static int cs42l43_resume(struct device *dev)
if (ret)
return ret;
- enable_irq(cs42l43->irq);
-
ret = pm_runtime_force_resume(dev);
if (ret) {
dev_err(cs42l43->dev, "Failed to force resume: %d\n", ret);
return ret;
}
+ enable_irq(cs42l43->irq);
+
return 0;
}
--
2.47.2
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 6/6] mfd: cs42l43: Remove IRQ masking in suspend
2025-09-03 9:45 [PATCH 0/6] Improve cs42l43 suspend/IRQ interactions Charles Keepax
` (4 preceding siblings ...)
2025-09-03 9:45 ` [PATCH 5/6] mfd: cs42l43: Move IRQ enable/disable to encompass force suspend Charles Keepax
@ 2025-09-03 9:45 ` Charles Keepax
2025-09-04 18:09 ` (subset) [PATCH 0/6] Improve cs42l43 suspend/IRQ interactions Mark Brown
2025-09-11 15:02 ` Lee Jones
7 siblings, 0 replies; 9+ messages in thread
From: Charles Keepax @ 2025-09-03 9:45 UTC (permalink / raw)
To: broonie, lee; +Cc: lgirdwood, linux-sound, linux-kernel, patches
Now the individual child drivers mask their own IRQs there is no need
for the MFD code to do so anymore.
Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
---
drivers/mfd/cs42l43.c | 26 --------------------------
1 file changed, 26 deletions(-)
diff --git a/drivers/mfd/cs42l43.c b/drivers/mfd/cs42l43.c
index 959298c8232f4..107cfb983fec4 100644
--- a/drivers/mfd/cs42l43.c
+++ b/drivers/mfd/cs42l43.c
@@ -1117,24 +1117,6 @@ EXPORT_SYMBOL_NS_GPL(cs42l43_dev_probe, "MFD_CS42L43");
static int cs42l43_suspend(struct device *dev)
{
struct cs42l43 *cs42l43 = dev_get_drvdata(dev);
- static const struct reg_sequence mask_all[] = {
- { CS42L43_DECIM_MASK, 0xFFFFFFFF, },
- { CS42L43_EQ_MIX_MASK, 0xFFFFFFFF, },
- { CS42L43_ASP_MASK, 0xFFFFFFFF, },
- { CS42L43_PLL_MASK, 0xFFFFFFFF, },
- { CS42L43_SOFT_MASK, 0xFFFFFFFF, },
- { CS42L43_SWIRE_MASK, 0xFFFFFFFF, },
- { CS42L43_MSM_MASK, 0xFFFFFFFF, },
- { CS42L43_ACC_DET_MASK, 0xFFFFFFFF, },
- { CS42L43_I2C_TGT_MASK, 0xFFFFFFFF, },
- { CS42L43_SPI_MSTR_MASK, 0xFFFFFFFF, },
- { CS42L43_SW_TO_SPI_BRIDGE_MASK, 0xFFFFFFFF, },
- { CS42L43_OTP_MASK, 0xFFFFFFFF, },
- { CS42L43_CLASS_D_AMP_MASK, 0xFFFFFFFF, },
- { CS42L43_GPIO_INT_MASK, 0xFFFFFFFF, },
- { CS42L43_ASRC_MASK, 0xFFFFFFFF, },
- { CS42L43_HPOUT_MASK, 0xFFFFFFFF, },
- };
int ret;
ret = pm_runtime_resume_and_get(dev);
@@ -1143,14 +1125,6 @@ static int cs42l43_suspend(struct device *dev)
return ret;
}
- /* The IRQs will be re-enabled on resume by the cache sync */
- ret = regmap_multi_reg_write_bypassed(cs42l43->regmap,
- mask_all, ARRAY_SIZE(mask_all));
- if (ret) {
- dev_err(cs42l43->dev, "Failed to mask IRQs: %d\n", ret);
- return ret;
- }
-
disable_irq(cs42l43->irq);
ret = pm_runtime_force_suspend(dev);
--
2.47.2
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: (subset) [PATCH 0/6] Improve cs42l43 suspend/IRQ interactions
2025-09-03 9:45 [PATCH 0/6] Improve cs42l43 suspend/IRQ interactions Charles Keepax
` (5 preceding siblings ...)
2025-09-03 9:45 ` [PATCH 6/6] mfd: cs42l43: Remove IRQ masking in suspend Charles Keepax
@ 2025-09-04 18:09 ` Mark Brown
2025-09-11 15:02 ` Lee Jones
7 siblings, 0 replies; 9+ messages in thread
From: Mark Brown @ 2025-09-04 18:09 UTC (permalink / raw)
To: lee, Charles Keepax; +Cc: lgirdwood, linux-sound, linux-kernel, patches
On Wed, 03 Sep 2025 10:45:43 +0100, Charles Keepax wrote:
> cs42l43 uses pm_runtime_force_suspend() during system suspend, however
> this means care must be taken that IRQ handler code isn't running when
> entering system suspend as force suspend will ignore that the handler
> is holding a pm reference. Typically the result of this is just a few
> error messages, but better to improve the handling and ensure that all
> IRQ processing is synchronised in before system suspend.
>
> [...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
Thanks!
[1/6] ASoC: cs42l43: Rename system suspend callback and fix debug print
commit: 638ca7601f41a3f8368811f3185b06e2547b7a0f
[2/6] ASoC: cs42l43: Store IRQ domain in codec private data
commit: 149dda5f42a8fa6dacf2cff1d16952de28622d30
[3/6] ASoC: cs42l43: Disable IRQs in system suspend
commit: a69b4ba19a07896e7e4246446bad002f5fc0dae1
[4/6] ASoC: cs42l43: Shutdown jack detection on suspend
commit: dd7ae5b8b3c291c0206f127a564ae1e316705ca0
All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying
to this mail.
Thanks,
Mark
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: (subset) [PATCH 0/6] Improve cs42l43 suspend/IRQ interactions
2025-09-03 9:45 [PATCH 0/6] Improve cs42l43 suspend/IRQ interactions Charles Keepax
` (6 preceding siblings ...)
2025-09-04 18:09 ` (subset) [PATCH 0/6] Improve cs42l43 suspend/IRQ interactions Mark Brown
@ 2025-09-11 15:02 ` Lee Jones
7 siblings, 0 replies; 9+ messages in thread
From: Lee Jones @ 2025-09-11 15:02 UTC (permalink / raw)
To: broonie, lee, Charles Keepax
Cc: lgirdwood, linux-sound, linux-kernel, patches
On Wed, 03 Sep 2025 10:45:43 +0100, Charles Keepax wrote:
> cs42l43 uses pm_runtime_force_suspend() during system suspend, however
> this means care must be taken that IRQ handler code isn't running when
> entering system suspend as force suspend will ignore that the handler
> is holding a pm reference. Typically the result of this is just a few
> error messages, but better to improve the handling and ensure that all
> IRQ processing is synchronised in before system suspend.
>
> [...]
Applied, thanks!
[5/6] mfd: cs42l43: Move IRQ enable/disable to encompass force suspend
commit: b3f893e969b6e8bb80bb2307c509ef1619e1c3fa
[6/6] mfd: cs42l43: Remove IRQ masking in suspend
commit: d614c669a205f39ca8be545d5d829a6b9f3cf61c
--
Lee Jones [李琼斯]
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2025-09-11 15:02 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-03 9:45 [PATCH 0/6] Improve cs42l43 suspend/IRQ interactions Charles Keepax
2025-09-03 9:45 ` [PATCH 1/6] ASoC: cs42l43: Rename system suspend callback and fix debug print Charles Keepax
2025-09-03 9:45 ` [PATCH 2/6] ASoC: cs42l43: Store IRQ domain in codec private data Charles Keepax
2025-09-03 9:45 ` [PATCH 3/6] ASoC: cs42l43: Disable IRQs in system suspend Charles Keepax
2025-09-03 9:45 ` [PATCH 4/6] ASoC: cs42l43: Shutdown jack detection on suspend Charles Keepax
2025-09-03 9:45 ` [PATCH 5/6] mfd: cs42l43: Move IRQ enable/disable to encompass force suspend Charles Keepax
2025-09-03 9:45 ` [PATCH 6/6] mfd: cs42l43: Remove IRQ masking in suspend Charles Keepax
2025-09-04 18:09 ` (subset) [PATCH 0/6] Improve cs42l43 suspend/IRQ interactions Mark Brown
2025-09-11 15:02 ` Lee Jones
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox