alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/5] ASoC: Hold runtime PM references to components of active DAIs
@ 2011-12-05  0:01 Mark Brown
  2011-12-05  0:01 ` [PATCH 2/5] ASoC: Use core pm_runtime callbacks for omap-dmic Mark Brown
                   ` (5 more replies)
  0 siblings, 6 replies; 15+ messages in thread
From: Mark Brown @ 2011-12-05  0:01 UTC (permalink / raw)
  To: Liam Girdwood, Kuninori Morimoto, Peter Ujfalusi,
	Guennadi Liakhovetski
  Cc: alsa-devel, Mark Brown

Every device that implements runtime power management for DAIs is doing
it in pretty much the same way: in the startup callback they take a
runtime PM reference and then in the shutdown callback they release that
reference, keeping the device active while the DAI is active. Given the
frequency with which this is done and the obviousness of the need to keep
the device active in this period factor the code out into the core, taking
references on the device for each CPU DAI, CODEC DAI and DMA device in the
core.

As runtime PM is reference counted this shouldn't interfere with any
other reference holding by the drivers, and since (in common with the
existing implementations) we don't check for errors on enabling it
shouldn't matter if the device actually has runtime PM enabled or not.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
---
 sound/soc/soc-pcm.c |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
index 49aa71e..8aa7cec 100644
--- a/sound/soc/soc-pcm.c
+++ b/sound/soc/soc-pcm.c
@@ -19,6 +19,7 @@
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/delay.h>
+#include <linux/pm_runtime.h>
 #include <linux/slab.h>
 #include <linux/workqueue.h>
 #include <sound/core.h>
@@ -77,6 +78,10 @@ static int soc_pcm_open(struct snd_pcm_substream *substream)
 	struct snd_soc_dai_driver *codec_dai_drv = codec_dai->driver;
 	int ret = 0;
 
+	pm_runtime_get_sync(cpu_dai->dev);
+	pm_runtime_get_sync(codec_dai->dev);
+	pm_runtime_get_sync(platform->dev);
+
 	mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass);
 
 	/* startup the audio subsystem */
@@ -233,6 +238,11 @@ platform_err:
 		cpu_dai->driver->ops->shutdown(substream, cpu_dai);
 out:
 	mutex_unlock(&rtd->pcm_mutex);
+
+	pm_runtime_put(platform->dev);
+	pm_runtime_put(codec_dai->dev);
+	pm_runtime_put(cpu_dai->dev);
+
 	return ret;
 }
 
@@ -339,6 +349,11 @@ static int soc_pcm_close(struct snd_pcm_substream *substream)
 	}
 
 	mutex_unlock(&rtd->pcm_mutex);
+
+	pm_runtime_put(platform->dev);
+	pm_runtime_put(codec_dai->dev);
+	pm_runtime_put(cpu_dai->dev);
+
 	return 0;
 }
 
-- 
1.7.7.3

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

end of thread, other threads:[~2011-12-07  7:48 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-05  0:01 [PATCH 1/5] ASoC: Hold runtime PM references to components of active DAIs Mark Brown
2011-12-05  0:01 ` [PATCH 2/5] ASoC: Use core pm_runtime callbacks for omap-dmic Mark Brown
2011-12-05  8:02   ` Peter Ujfalusi
2011-12-05  0:01 ` [PATCH 3/5] ASoC: Use core pm_runtime callbacks for omap-mcpdm Mark Brown
2011-12-05  8:32   ` Peter Ujfalusi
2011-12-05  0:01 ` [PATCH 4/5] ASoC: Use core pm_runtime callbacks for siu_dai Mark Brown
2011-12-05  0:01 ` [PATCH 5/5] ASoC: Use core pm_runtime callbacks for fsi Mark Brown
2011-12-05  8:01 ` [PATCH 1/5] ASoC: Hold runtime PM references to components of active DAIs Peter Ujfalusi
2011-12-05 11:39   ` Mark Brown
2011-12-05 13:32     ` Peter Ujfalusi
2011-12-05 13:46       ` Mark Brown
2011-12-05 14:53         ` Peter Ujfalusi
2011-12-05 15:07           ` Mark Brown
2011-12-07  7:47             ` Peter Ujfalusi
2011-12-07  7:48 ` Peter Ujfalusi

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).