All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] ASoC: cs35l45: Use modern pm_ops
       [not found] <20231206160318.1255034-1-rriveram@opensource.cirrus.com>
@ 2023-12-06 16:03 ` Ricardo Rivera-Matos
  2023-12-07 13:59   ` Mark Brown
  2023-12-06 16:03 ` [PATCH 2/3] ASoC: cs35l45: Prevent IRQ handling when suspending/resuming Ricardo Rivera-Matos
  2023-12-06 16:03 ` [PATCH 3/3] ASoC: cs35l45: Prevents spinning during runtime suspend Ricardo Rivera-Matos
  2 siblings, 1 reply; 4+ messages in thread
From: Ricardo Rivera-Matos @ 2023-12-06 16:03 UTC (permalink / raw)
  To: James Schulman, David Rhodes, Lucas Tanure, Richard Fitzgerald,
	Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai
  Cc: Ricardo Rivera-Matos, Charles Keepax, alsa-devel, patches, linux-kernel

Make use of the recently introduced EXPORT_GPL_DEV_PM_OPS() macro, to
conditionally export the runtime/system PM functions.

Replace the old SET_{RUNTIME,SYSTEM_SLEEP,NOIRQ_SYSTEM_SLEEP}_PM_OPS()
helpers with their modern alternatives and get rid of the now
unnecessary '__maybe_unused' annotations on all PM functions.

Additionally, use the pm_ptr() macro to fix the following errors when
building with CONFIG_PM disabled:

Signed-off-by: Ricardo Rivera-Matos <rriveram@opensource.cirrus.com>
Acked-by: Charles Keepax <ckeepax@opensource.cirrus.com>
---
 sound/soc/codecs/cs35l45-i2c.c | 2 +-
 sound/soc/codecs/cs35l45-spi.c | 2 +-
 sound/soc/codecs/cs35l45.c     | 9 ++++-----
 3 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/sound/soc/codecs/cs35l45-i2c.c b/sound/soc/codecs/cs35l45-i2c.c
index 77e0f8750f37..bc2af1ed0fe9 100644
--- a/sound/soc/codecs/cs35l45-i2c.c
+++ b/sound/soc/codecs/cs35l45-i2c.c
@@ -62,7 +62,7 @@ static struct i2c_driver cs35l45_i2c_driver = {
 	.driver = {
 		.name		= "cs35l45",
 		.of_match_table = cs35l45_of_match,
-		.pm		= &cs35l45_pm_ops,
+		.pm		= pm_ptr(&cs35l45_pm_ops),
 	},
 	.id_table	= cs35l45_id_i2c,
 	.probe		= cs35l45_i2c_probe,
diff --git a/sound/soc/codecs/cs35l45-spi.c b/sound/soc/codecs/cs35l45-spi.c
index 5efb77530cc3..39e203a5f060 100644
--- a/sound/soc/codecs/cs35l45-spi.c
+++ b/sound/soc/codecs/cs35l45-spi.c
@@ -64,7 +64,7 @@ static struct spi_driver cs35l45_spi_driver = {
 	.driver = {
 		.name		= "cs35l45",
 		.of_match_table = cs35l45_of_match,
-		.pm		= &cs35l45_pm_ops,
+		.pm		= pm_ptr(&cs35l45_pm_ops),
 	},
 	.id_table	= cs35l45_id_spi,
 	.probe		= cs35l45_spi_probe,
diff --git a/sound/soc/codecs/cs35l45.c b/sound/soc/codecs/cs35l45.c
index b68853e42fd1..4f4df166f5f0 100644
--- a/sound/soc/codecs/cs35l45.c
+++ b/sound/soc/codecs/cs35l45.c
@@ -982,7 +982,7 @@ static int cs35l45_exit_hibernate(struct cs35l45_private *cs35l45)
 	return -ETIMEDOUT;
 }
 
-static int __maybe_unused cs35l45_runtime_suspend(struct device *dev)
+static int cs35l45_runtime_suspend(struct device *dev)
 {
 	struct cs35l45_private *cs35l45 = dev_get_drvdata(dev);
 
@@ -999,7 +999,7 @@ static int __maybe_unused cs35l45_runtime_suspend(struct device *dev)
 	return 0;
 }
 
-static int __maybe_unused cs35l45_runtime_resume(struct device *dev)
+static int cs35l45_runtime_resume(struct device *dev)
 {
 	struct cs35l45_private *cs35l45 = dev_get_drvdata(dev);
 	int ret;
@@ -1466,10 +1466,9 @@ void cs35l45_remove(struct cs35l45_private *cs35l45)
 }
 EXPORT_SYMBOL_NS_GPL(cs35l45_remove, SND_SOC_CS35L45);
 
-const struct dev_pm_ops cs35l45_pm_ops = {
-	SET_RUNTIME_PM_OPS(cs35l45_runtime_suspend, cs35l45_runtime_resume, NULL)
+EXPORT_GPL_DEV_PM_OPS(cs35l45_pm_ops) = {
+	RUNTIME_PM_OPS(cs35l45_runtime_suspend, cs35l45_runtime_resume, NULL)
 };
-EXPORT_SYMBOL_NS_GPL(cs35l45_pm_ops, SND_SOC_CS35L45);
 
 MODULE_DESCRIPTION("ASoC CS35L45 driver");
 MODULE_AUTHOR("James Schulman, Cirrus Logic Inc, <james.schulman@cirrus.com>");
-- 
2.34.1


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

* [PATCH 2/3] ASoC: cs35l45: Prevent IRQ handling when suspending/resuming
       [not found] <20231206160318.1255034-1-rriveram@opensource.cirrus.com>
  2023-12-06 16:03 ` [PATCH 1/3] ASoC: cs35l45: Use modern pm_ops Ricardo Rivera-Matos
@ 2023-12-06 16:03 ` Ricardo Rivera-Matos
  2023-12-06 16:03 ` [PATCH 3/3] ASoC: cs35l45: Prevents spinning during runtime suspend Ricardo Rivera-Matos
  2 siblings, 0 replies; 4+ messages in thread
From: Ricardo Rivera-Matos @ 2023-12-06 16:03 UTC (permalink / raw)
  To: James Schulman, David Rhodes, Lucas Tanure, Richard Fitzgerald,
	Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai
  Cc: Ricardo Rivera-Matos, Charles Keepax, alsa-devel, patches, linux-kernel

Use the SYSTEM_SLEEP_PM_OPS handlers to prevent handling an IRQ
when the system is in the middle of suspending or resuming.

Signed-off-by: Ricardo Rivera-Matos <rriveram@opensource.cirrus.com>
Acked-by: Charles Keepax <ckeepax@opensource.cirrus.com>
---
 sound/soc/codecs/cs35l45.c | 43 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)

diff --git a/sound/soc/codecs/cs35l45.c b/sound/soc/codecs/cs35l45.c
index 4f4df166f5f0..28f76fccf277 100644
--- a/sound/soc/codecs/cs35l45.c
+++ b/sound/soc/codecs/cs35l45.c
@@ -1026,6 +1026,46 @@ static int cs35l45_runtime_resume(struct device *dev)
 	return ret;
 }
 
+static int cs35l45_sys_suspend(struct device *dev)
+{
+	struct cs35l45_private *cs35l45 = dev_get_drvdata(dev);
+
+	dev_dbg(cs35l45->dev, "System suspend, disabling IRQ\n");
+	disable_irq(cs35l45->irq);
+
+	return 0;
+}
+
+static int cs35l45_sys_suspend_noirq(struct device *dev)
+{
+	struct cs35l45_private *cs35l45 = dev_get_drvdata(dev);
+
+	dev_dbg(cs35l45->dev, "Late system suspend, reenabling IRQ\n");
+	enable_irq(cs35l45->irq);
+
+	return 0;
+}
+
+static int cs35l45_sys_resume_noirq(struct device *dev)
+{
+	struct cs35l45_private *cs35l45 = dev_get_drvdata(dev);
+
+	dev_dbg(cs35l45->dev, "Early system resume, disabling IRQ\n");
+	disable_irq(cs35l45->irq);
+
+	return 0;
+}
+
+static int cs35l45_sys_resume(struct device *dev)
+{
+	struct cs35l45_private *cs35l45 = dev_get_drvdata(dev);
+
+	dev_dbg(cs35l45->dev, "System resume, reenabling IRQ\n");
+	enable_irq(cs35l45->irq);
+
+	return 0;
+}
+
 static int cs35l45_apply_property_config(struct cs35l45_private *cs35l45)
 {
 	struct device_node *node = cs35l45->dev->of_node;
@@ -1468,6 +1508,9 @@ EXPORT_SYMBOL_NS_GPL(cs35l45_remove, SND_SOC_CS35L45);
 
 EXPORT_GPL_DEV_PM_OPS(cs35l45_pm_ops) = {
 	RUNTIME_PM_OPS(cs35l45_runtime_suspend, cs35l45_runtime_resume, NULL)
+
+	SYSTEM_SLEEP_PM_OPS(cs35l45_sys_suspend, cs35l45_sys_resume)
+	NOIRQ_SYSTEM_SLEEP_PM_OPS(cs35l45_sys_suspend_noirq, cs35l45_sys_resume_noirq)
 };
 
 MODULE_DESCRIPTION("ASoC CS35L45 driver");
-- 
2.34.1


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

* [PATCH 3/3] ASoC: cs35l45: Prevents spinning during runtime suspend
       [not found] <20231206160318.1255034-1-rriveram@opensource.cirrus.com>
  2023-12-06 16:03 ` [PATCH 1/3] ASoC: cs35l45: Use modern pm_ops Ricardo Rivera-Matos
  2023-12-06 16:03 ` [PATCH 2/3] ASoC: cs35l45: Prevent IRQ handling when suspending/resuming Ricardo Rivera-Matos
@ 2023-12-06 16:03 ` Ricardo Rivera-Matos
  2 siblings, 0 replies; 4+ messages in thread
From: Ricardo Rivera-Matos @ 2023-12-06 16:03 UTC (permalink / raw)
  To: James Schulman, David Rhodes, Lucas Tanure, Richard Fitzgerald,
	Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai
  Cc: Ricardo Rivera-Matos, Charles Keepax, alsa-devel, patches, linux-kernel

Masks the "DSP Virtual Mailbox 2 write" interrupt when before
issuing the hibernate command to the DSP. The interrupt is
unmasked when exiting runtime suspend as it is required for
DSP operation.

Without this change the DSP fires an interrupt when hibernating
causing the system spin between runtime suspend and runtime
resume.

Signed-off-by: Ricardo Rivera-Matos <rriveram@opensource.cirrus.com>
Acked-by: Charles Keepax <ckeepax@opensource.cirrus.com>
---
 sound/soc/codecs/cs35l45.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/sound/soc/codecs/cs35l45.c b/sound/soc/codecs/cs35l45.c
index 28f76fccf277..44c221745c3b 100644
--- a/sound/soc/codecs/cs35l45.c
+++ b/sound/soc/codecs/cs35l45.c
@@ -947,6 +947,8 @@ static int cs35l45_enter_hibernate(struct cs35l45_private *cs35l45)
 
 	cs35l45_setup_hibernate(cs35l45);
 
+	regmap_set_bits(cs35l45->regmap, CS35L45_IRQ1_MASK_2, CS35L45_DSP_VIRT2_MBOX_MASK);
+
 	// Don't wait for ACK since bus activity would wake the device
 	regmap_write(cs35l45->regmap, CS35L45_DSP_VIRT1_MBOX_1, CSPL_MBOX_CMD_HIBERNATE);
 
@@ -967,6 +969,8 @@ static int cs35l45_exit_hibernate(struct cs35l45_private *cs35l45)
 					  CSPL_MBOX_CMD_OUT_OF_HIBERNATE);
 			if (!ret) {
 				dev_dbg(cs35l45->dev, "Wake success at cycle: %d\n", j);
+				regmap_clear_bits(cs35l45->regmap, CS35L45_IRQ1_MASK_2,
+						 CS35L45_DSP_VIRT2_MBOX_MASK);
 				return 0;
 			}
 			usleep_range(100, 200);
-- 
2.34.1


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

* Re: [PATCH 1/3] ASoC: cs35l45: Use modern pm_ops
  2023-12-06 16:03 ` [PATCH 1/3] ASoC: cs35l45: Use modern pm_ops Ricardo Rivera-Matos
@ 2023-12-07 13:59   ` Mark Brown
  0 siblings, 0 replies; 4+ messages in thread
From: Mark Brown @ 2023-12-07 13:59 UTC (permalink / raw)
  To: James Schulman, David Rhodes, Lucas Tanure, Richard Fitzgerald,
	Liam Girdwood, Jaroslav Kysela, Takashi Iwai,
	Ricardo Rivera-Matos
  Cc: Charles Keepax, alsa-devel, patches, linux-kernel

On Wed, 06 Dec 2023 10:03:16 -0600, Ricardo Rivera-Matos wrote:
> Make use of the recently introduced EXPORT_GPL_DEV_PM_OPS() macro, to
> conditionally export the runtime/system PM functions.
> 
> Replace the old SET_{RUNTIME,SYSTEM_SLEEP,NOIRQ_SYSTEM_SLEEP}_PM_OPS()
> helpers with their modern alternatives and get rid of the now
> unnecessary '__maybe_unused' annotations on all PM functions.
> 
> [...]

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

Thanks!

[1/3] ASoC: cs35l45: Use modern pm_ops
      commit: 12e102b1bd22ee00361559d57a5876445bcb2407
[2/3] ASoC: cs35l45: Prevent IRQ handling when suspending/resuming
      commit: c3c8b088949b9ccb88da2f84d3c3cc06580a6a43
[3/3] ASoC: cs35l45: Prevents spinning during runtime suspend
      commit: a0ffa8115e1ea9786b03edc3f431d2f4ef3e7a2e

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] 4+ messages in thread

end of thread, other threads:[~2023-12-07 13:59 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20231206160318.1255034-1-rriveram@opensource.cirrus.com>
2023-12-06 16:03 ` [PATCH 1/3] ASoC: cs35l45: Use modern pm_ops Ricardo Rivera-Matos
2023-12-07 13:59   ` Mark Brown
2023-12-06 16:03 ` [PATCH 2/3] ASoC: cs35l45: Prevent IRQ handling when suspending/resuming Ricardo Rivera-Matos
2023-12-06 16:03 ` [PATCH 3/3] ASoC: cs35l45: Prevents spinning during runtime suspend Ricardo Rivera-Matos

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.