Skip to contentSkip to conversation

ASoC: Intel: Add support for PM ops in bxt-da7219_max98357a

PATCH Superseded Vinod Koul 3 participants 11 messages Jun 17, 2016 – Jun 20, 2016

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Vinod Koul

author
#0 lore raw

PATCH 1/1 ASoC: Intel: Add support for PM ops in bxt-da7219_max98357a

We need card to be early suspended and late resumed, so use prepare and complete for card suspend and resume.

---
 sound/soc/intel/boards/bxt_da7219_max98357a.c | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)
sound/soc/intel/boards/bxt_da7219_max98357a.c +20 -1
index 3774b117d365..df5f269a9b67 100644
@@ -441,11 +441,30 @@ static int broxton_audio_probe(struct platform_device *pdev)
 	return devm_snd_soc_register_card(&pdev->dev, &broxton_audio_card);
 }
 
+#ifdef CONFIG_PM_SLEEP
+
+static void broxton_complete(struct device *dev)
+{
+	snd_soc_resume(dev);
+}
+
+#else
+#define broxton_complete NULL
+#endif
+
+static const struct dev_pm_ops broxton_pm_ops = {
+	.prepare = snd_soc_suspend,
+	.complete = broxton_complete,
+	.freeze = snd_soc_suspend,
+	.thaw = snd_soc_resume,
+	.poweroff = snd_soc_poweroff,
+	.restore = snd_soc_resume,
+};
 static struct platform_driver broxton_audio = {
 	.probe = broxton_audio_probe,
 	.driver = {
 		.name = "bxt_da7219_max98357a_i2s",
-		.pm = &snd_soc_pm_ops,
+		.pm = &broxton_pm_ops,
 	},
 };
 module_platform_driver(broxton_audio)
Signature · 1 line
1.9.1
maintainer
#1 lore raw

sound/soc/intel/boards/bxt_da7219_max98357a.c static int broxton_audio_probe(struct platform_device *pdev) · line 453

Quoted 8 lines · Vinod Koul
sound/soc/intel/boards/bxt_da7219_max98357a.c +8 -0
+static void broxton_complete(struct device *dev)
+{
+	snd_soc_resume(dev);
+}
+
+#else
+#define broxton_complete NULL
+#endif

Just use snd_soc_resume() directly.

author
#2 lore raw
Quoted 12 lines · Mark Brown

sound/soc/intel/boards/bxt_da7219_max98357a.c static int broxton_audio_probe(struct platform_device *pdev) · line 453

Quoted 8 lines · Vinod Koul
sound/soc/intel/boards/bxt_da7219_max98357a.c +8 -0
+static void broxton_complete(struct device *dev)
+{
+	snd_soc_resume(dev);
+}
+
+#else
+#define broxton_complete NULL
+#endif

Just use snd_soc_resume() directly.

Nope, that leads to warnings.

.complete is the only callback that expects void return whereas snd_soc_resume like other returns int.

struct dev_pm_ops {
        int (*prepare)(struct device *dev);
        void (*complete)(struct device *dev);
        int (*suspend)(struct device *dev);
        int (*resume)(struct device *dev);
	...
}

Thanks

Signature · 1 line
~Vinod
maintainer
#3 lore raw
Quoted 8 lines · Vinod Koul
Quoted 1 line · Mark Brown

Just use snd_soc_resume() directly.

Nope, that leads to warnings.

.complete is the only callback that expects void return whereas snd_soc_resume like other returns int.

This is possibly an indication that you're abusing things then - this is a very unusual interface to use as well... the patch just looks very fishy as is, and as we were talking about in the other thread Lars started it seems like this is bodging around something rather than solving the right problem.

author
#4 lore raw
Quoted 7 lines · Mark Brown
Quoted 5 lines · Vinod Koul
Quoted 1 line · Mark Brown

Just use snd_soc_resume() directly.

Nope, that leads to warnings.

Quoted 8 lines
Quoted 2 lines

.complete is the only callback that expects void return whereas snd_soc_resume like other returns int.

This is possibly an indication that you're abusing things then - this is a very unusual interface to use as well... the patch just looks very fishy as is, and as we were talking about in the other thread Lars started it seems like this is bodging around something rather than solving the right problem.

In the hindsight, I do agree that instead of this, we should move platform to do suspend_late and resume_early. That way the dependency between card and platform is taken care in a much bteer fashion.

The problem is two components racing and need of the resume being in serial fashion.

Thanks

Signature · 1 line
~Vinod
#5 lore raw
In reply to Vinod Koul
Quoted 2 lines · Vinod Koul

We need card to be early suspended and late resumed, so use prepare and complete for card suspend and resume.

Why and why is this something that other cards do not need to do?

author
#6 lore raw
Quoted 5 lines · Lars-Peter Clausen
Quoted 2 lines · Vinod Koul

We need card to be early suspended and late resumed, so use prepare and complete for card suspend and resume.

Why and why is this something that other cards do not need to do?

When card suspends, the DAPM suspend closes the widgets, which translates to we sending IPC to DSP for tearing down the pipelines.

So we need the platform to be suspended last and resume first. This way the snd_soc_suspend will tear down pipelines and snd_soc_resume restore those back.

Thanks

Signature · 1 line
~Vinod
maintainer
#7 lore raw
Quoted 10 lines · Vinod Koul
Quoted 1 line · Lars-Peter Clausen

Why and why is this something that other cards do not need to do?

When card suspends, the DAPM suspend closes the widgets, which translates to we sending IPC to DSP for tearing down the pipelines.

So we need the platform to be suspended last and resume first. This way the snd_soc_suspend will tear down pipelines and snd_soc_resume restore those back.

That doesn't answer the question - this applies to any control mechanism.

author
#8 lore raw
Quoted 4 lines · Mark Brown
Quoted 3 lines · Vinod Koul
Quoted 1 line · Lars-Peter Clausen

Why and why is this something that other cards do not need to do?

Other systems do not have a DSP sitting and need to redownload code which takes time and results in card being resumed even when the platform is not ready.

The logs are indicating the snd_soc_resume() is triggered even before the platform resume has returned which needs to be avoided.

One of the ways to ensure a dependency for PM is resolved, we tinker with PM callbacks here to ensure the platform is ready before resume is inoked here

Quoted 9 lines
Quoted 6 lines

When card suspends, the DAPM suspend closes the widgets, which translates to we sending IPC to DSP for tearing down the pipelines.

So we need the platform to be suspended last and resume first. This way the snd_soc_suspend will tear down pipelines and snd_soc_resume restore those back.

That doesn't answer the question - this applies to any control mechanism.

Thanks

Signature · 1 line
~Vinod
maintainer
#9 lore raw
Quoted 9 lines · Vinod Koul
Quoted 4 lines · Mark Brown
Quoted 3 lines · Vinod Koul
Quoted 1 line · Lars-Peter Clausen

Why and why is this something that other cards do not need to do?

Other systems do not have a DSP sitting and need to redownload code which takes time and results in card being resumed even when the platform is not ready.

So what you're actually trying to do here is serialize the resume - this isn't just a thing with DSPs, it's also a thing with I2C, regulators and so on. A quick glance suggests that disabling async suspend might help here.

author
#10 lore raw
Quoted 7 lines · Mark Brown
Quoted 5 lines · Vinod Koul
Quoted 4 lines · Mark Brown
Quoted 3 lines · Vinod Koul
Quoted 1 line · Lars-Peter Clausen

Why and why is this something that other cards do not need to do?

Quoted 8 lines
Quoted 3 lines

Other systems do not have a DSP sitting and need to redownload code which takes time and results in card being resumed even when the platform is not ready.

So what you're actually trying to do here is serialize the resume - this isn't just a thing with DSPs, it's also a thing with I2C, regulators and so on. A quick glance suggests that disabling async suspend might help here.

Okay let me check that

Thanks

Signature · 1 line
~Vinod