All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] ASoC: davinci-mcasp/evm: PM related changes
@ 2014-01-30 13:21 Peter Ujfalusi
  2014-01-30 13:21 ` [PATCH 1/3] ASoC: davinci-mcasp: Consolidate pm_runtime_get/put() use in the driver Peter Ujfalusi
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Peter Ujfalusi @ 2014-01-30 13:21 UTC (permalink / raw)
  To: Mark Brown, Liam Girdwood; +Cc: alsa-devel, nsekhar, jsarha, zonque

Hi,

In order to be able to benefit from the core's feature to handle the dai pinctrl
default/sleep states the davinci-evm should set it's .pm section snd_soc_pm_ops.

In the McASP driver consolidate the pm_runtime use to avoid unbalanced
refcounting: trigger:start increased while trigger:stop did not decreased the
pm counter.
Move the pm callbacks from platfrom device to the soc_dai_driver.

Now it is only a matter of dts update to enable the pin level power saving for
McASP.

Regards,
Peter
---
Peter Ujfalusi (3):
  ASoC: davinci-mcasp: Consolidate pm_runtime_get/put() use in the
    driver
  ASoC: davinci-evm: Add pm callbacks to platform driver
  ASoC: davinci-mcasp: Move pm callbacks from platform device to
    soc_dai_driver

 sound/soc/davinci/davinci-evm.c   |  1 +
 sound/soc/davinci/davinci-mcasp.c | 97 +++++++++++++++++++--------------------
 2 files changed, 47 insertions(+), 51 deletions(-)

-- 
1.8.5.3

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

* [PATCH 1/3] ASoC: davinci-mcasp: Consolidate pm_runtime_get/put() use in the driver
  2014-01-30 13:21 [PATCH 0/3] ASoC: davinci-mcasp/evm: PM related changes Peter Ujfalusi
@ 2014-01-30 13:21 ` Peter Ujfalusi
  2014-01-31 16:20   ` Mark Brown
  2014-01-30 13:21 ` [PATCH 2/3] ASoC: davinci-evm: Add pm callbacks to platform driver Peter Ujfalusi
  2014-01-30 13:21 ` [PATCH 3/3] ASoC: davinci-mcasp: Move pm callbacks from platform device to soc_dai_driver Peter Ujfalusi
  2 siblings, 1 reply; 7+ messages in thread
From: Peter Ujfalusi @ 2014-01-30 13:21 UTC (permalink / raw)
  To: Mark Brown, Liam Girdwood; +Cc: alsa-devel, nsekhar, jsarha, zonque

The use of pm_runtime in trigger() callback is not correct and it will lead
to unbalanced power.usage_count.
The only place which might need to call pm_runtime is the set_fmt callback.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
---
 sound/soc/davinci/davinci-mcasp.c | 23 +++++++++--------------
 1 file changed, 9 insertions(+), 14 deletions(-)

diff --git a/sound/soc/davinci/davinci-mcasp.c b/sound/soc/davinci/davinci-mcasp.c
index 48079dbad767..be79dba789fb 100644
--- a/sound/soc/davinci/davinci-mcasp.c
+++ b/sound/soc/davinci/davinci-mcasp.c
@@ -263,7 +263,9 @@ static int davinci_mcasp_set_dai_fmt(struct snd_soc_dai *cpu_dai,
 					 unsigned int fmt)
 {
 	struct davinci_mcasp *mcasp = snd_soc_dai_get_drvdata(cpu_dai);
+	int ret = 0;
 
+	pm_runtime_get_sync(mcasp->dev);
 	switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
 	case SND_SOC_DAIFMT_DSP_B:
 	case SND_SOC_DAIFMT_AC97:
@@ -317,7 +319,8 @@ static int davinci_mcasp_set_dai_fmt(struct snd_soc_dai *cpu_dai,
 		break;
 
 	default:
-		return -EINVAL;
+		ret = -EINVAL;
+		goto out;
 	}
 
 	switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
@@ -354,10 +357,12 @@ static int davinci_mcasp_set_dai_fmt(struct snd_soc_dai *cpu_dai,
 		break;
 
 	default:
-		return -EINVAL;
+		ret = -EINVAL;
+		break;
 	}
-
-	return 0;
+out:
+	pm_runtime_put_sync(mcasp->dev);
+	return ret;
 }
 
 static int davinci_mcasp_set_clkdiv(struct snd_soc_dai *dai, int div_id, int div)
@@ -675,19 +680,9 @@ static int davinci_mcasp_trigger(struct snd_pcm_substream *substream,
 	case SNDRV_PCM_TRIGGER_RESUME:
 	case SNDRV_PCM_TRIGGER_START:
 	case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
-		ret = pm_runtime_get_sync(mcasp->dev);
-		if (IS_ERR_VALUE(ret))
-			dev_err(mcasp->dev, "pm_runtime_get_sync() failed\n");
 		davinci_mcasp_start(mcasp, substream->stream);
 		break;
-
 	case SNDRV_PCM_TRIGGER_SUSPEND:
-		davinci_mcasp_stop(mcasp, substream->stream);
-		ret = pm_runtime_put_sync(mcasp->dev);
-		if (IS_ERR_VALUE(ret))
-			dev_err(mcasp->dev, "pm_runtime_put_sync() failed\n");
-		break;
-
 	case SNDRV_PCM_TRIGGER_STOP:
 	case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
 		davinci_mcasp_stop(mcasp, substream->stream);
-- 
1.8.5.3

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

* [PATCH 2/3] ASoC: davinci-evm: Add pm callbacks to platform driver
  2014-01-30 13:21 [PATCH 0/3] ASoC: davinci-mcasp/evm: PM related changes Peter Ujfalusi
  2014-01-30 13:21 ` [PATCH 1/3] ASoC: davinci-mcasp: Consolidate pm_runtime_get/put() use in the driver Peter Ujfalusi
@ 2014-01-30 13:21 ` Peter Ujfalusi
  2014-01-31 16:21   ` Mark Brown
  2014-01-30 13:21 ` [PATCH 3/3] ASoC: davinci-mcasp: Move pm callbacks from platform device to soc_dai_driver Peter Ujfalusi
  2 siblings, 1 reply; 7+ messages in thread
From: Peter Ujfalusi @ 2014-01-30 13:21 UTC (permalink / raw)
  To: Mark Brown, Liam Girdwood; +Cc: alsa-devel, nsekhar, jsarha, zonque

Set snd_soc_pm_ops for the pm ops.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
---
 sound/soc/davinci/davinci-evm.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/sound/soc/davinci/davinci-evm.c b/sound/soc/davinci/davinci-evm.c
index 70ff3772079f..5e3bc3c6801a 100644
--- a/sound/soc/davinci/davinci-evm.c
+++ b/sound/soc/davinci/davinci-evm.c
@@ -399,6 +399,7 @@ static struct platform_driver davinci_evm_driver = {
 	.driver		= {
 		.name	= "davinci_evm",
 		.owner	= THIS_MODULE,
+		.pm	= &snd_soc_pm_ops,
 		.of_match_table = of_match_ptr(davinci_evm_dt_ids),
 	},
 };
-- 
1.8.5.3

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

* [PATCH 3/3] ASoC: davinci-mcasp: Move pm callbacks from platform device to soc_dai_driver
  2014-01-30 13:21 [PATCH 0/3] ASoC: davinci-mcasp/evm: PM related changes Peter Ujfalusi
  2014-01-30 13:21 ` [PATCH 1/3] ASoC: davinci-mcasp: Consolidate pm_runtime_get/put() use in the driver Peter Ujfalusi
  2014-01-30 13:21 ` [PATCH 2/3] ASoC: davinci-evm: Add pm callbacks to platform driver Peter Ujfalusi
@ 2014-01-30 13:21 ` Peter Ujfalusi
  2014-01-31 16:41   ` Mark Brown
  2 siblings, 1 reply; 7+ messages in thread
From: Peter Ujfalusi @ 2014-01-30 13:21 UTC (permalink / raw)
  To: Mark Brown, Liam Girdwood; +Cc: alsa-devel, nsekhar, jsarha, zonque

Handle the PM callbacks via the ASoC core instead of device core.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
---
 sound/soc/davinci/davinci-mcasp.c | 74 +++++++++++++++++++--------------------
 1 file changed, 37 insertions(+), 37 deletions(-)

diff --git a/sound/soc/davinci/davinci-mcasp.c b/sound/soc/davinci/davinci-mcasp.c
index be79dba789fb..a8a0f2fb4749 100644
--- a/sound/soc/davinci/davinci-mcasp.c
+++ b/sound/soc/davinci/davinci-mcasp.c
@@ -718,6 +718,41 @@ static const struct snd_soc_dai_ops davinci_mcasp_dai_ops = {
 	.set_sysclk	= davinci_mcasp_set_sysclk,
 };
 
+#ifdef CONFIG_PM_SLEEP
+static int davinci_mcasp_suspend(struct snd_soc_dai *dai)
+{
+	struct davinci_mcasp *mcasp = snd_soc_dai_get_drvdata(dai);
+
+	mcasp->context.txfmtctl = mcasp_get_reg(mcasp, DAVINCI_MCASP_TXFMCTL_REG);
+	mcasp->context.rxfmtctl = mcasp_get_reg(mcasp, DAVINCI_MCASP_RXFMCTL_REG);
+	mcasp->context.txfmt = mcasp_get_reg(mcasp, DAVINCI_MCASP_TXFMT_REG);
+	mcasp->context.rxfmt = mcasp_get_reg(mcasp, DAVINCI_MCASP_RXFMT_REG);
+	mcasp->context.aclkxctl = mcasp_get_reg(mcasp, DAVINCI_MCASP_ACLKXCTL_REG);
+	mcasp->context.aclkrctl = mcasp_get_reg(mcasp, DAVINCI_MCASP_ACLKRCTL_REG);
+	mcasp->context.pdir = mcasp_get_reg(mcasp, DAVINCI_MCASP_PDIR_REG);
+
+	return 0;
+}
+
+static int davinci_mcasp_resume(struct snd_soc_dai *dai)
+{
+	struct davinci_mcasp *mcasp = snd_soc_dai_get_drvdata(dai);
+
+	mcasp_set_reg(mcasp, DAVINCI_MCASP_TXFMCTL_REG, mcasp->context.txfmtctl);
+	mcasp_set_reg(mcasp, DAVINCI_MCASP_RXFMCTL_REG, mcasp->context.rxfmtctl);
+	mcasp_set_reg(mcasp, DAVINCI_MCASP_TXFMT_REG, mcasp->context.txfmt);
+	mcasp_set_reg(mcasp, DAVINCI_MCASP_RXFMT_REG, mcasp->context.rxfmt);
+	mcasp_set_reg(mcasp, DAVINCI_MCASP_ACLKXCTL_REG, mcasp->context.aclkxctl);
+	mcasp_set_reg(mcasp, DAVINCI_MCASP_ACLKRCTL_REG, mcasp->context.aclkrctl);
+	mcasp_set_reg(mcasp, DAVINCI_MCASP_PDIR_REG, mcasp->context.pdir);
+
+	return 0;
+}
+#else
+#define davinci_mcasp_suspend NULL
+#define davinci_mcasp_resume NULL
+#endif
+
 #define DAVINCI_MCASP_RATES	SNDRV_PCM_RATE_8000_192000
 
 #define DAVINCI_MCASP_PCM_FMTS (SNDRV_PCM_FMTBIT_S8 | \
@@ -734,6 +769,8 @@ static const struct snd_soc_dai_ops davinci_mcasp_dai_ops = {
 static struct snd_soc_dai_driver davinci_mcasp_dai[] = {
 	{
 		.name		= "davinci-mcasp.0",
+		.suspend	= davinci_mcasp_suspend,
+		.resume		= davinci_mcasp_resume,
 		.playback	= {
 			.channels_min	= 2,
 			.channels_max	= 32 * 16,
@@ -1126,49 +1163,12 @@ static int davinci_mcasp_remove(struct platform_device *pdev)
 	return 0;
 }
 
-#ifdef CONFIG_PM_SLEEP
-static int davinci_mcasp_suspend(struct device *dev)
-{
-	struct davinci_mcasp *mcasp = dev_get_drvdata(dev);
-
-	mcasp->context.txfmtctl = mcasp_get_reg(mcasp, DAVINCI_MCASP_TXFMCTL_REG);
-	mcasp->context.rxfmtctl = mcasp_get_reg(mcasp, DAVINCI_MCASP_RXFMCTL_REG);
-	mcasp->context.txfmt = mcasp_get_reg(mcasp, DAVINCI_MCASP_TXFMT_REG);
-	mcasp->context.rxfmt = mcasp_get_reg(mcasp, DAVINCI_MCASP_RXFMT_REG);
-	mcasp->context.aclkxctl = mcasp_get_reg(mcasp, DAVINCI_MCASP_ACLKXCTL_REG);
-	mcasp->context.aclkrctl = mcasp_get_reg(mcasp, DAVINCI_MCASP_ACLKRCTL_REG);
-	mcasp->context.pdir = mcasp_get_reg(mcasp, DAVINCI_MCASP_PDIR_REG);
-
-	return 0;
-}
-
-static int davinci_mcasp_resume(struct device *dev)
-{
-	struct davinci_mcasp *mcasp = dev_get_drvdata(dev);
-
-	mcasp_set_reg(mcasp, DAVINCI_MCASP_TXFMCTL_REG, mcasp->context.txfmtctl);
-	mcasp_set_reg(mcasp, DAVINCI_MCASP_RXFMCTL_REG, mcasp->context.rxfmtctl);
-	mcasp_set_reg(mcasp, DAVINCI_MCASP_TXFMT_REG, mcasp->context.txfmt);
-	mcasp_set_reg(mcasp, DAVINCI_MCASP_RXFMT_REG, mcasp->context.rxfmt);
-	mcasp_set_reg(mcasp, DAVINCI_MCASP_ACLKXCTL_REG, mcasp->context.aclkxctl);
-	mcasp_set_reg(mcasp, DAVINCI_MCASP_ACLKRCTL_REG, mcasp->context.aclkrctl);
-	mcasp_set_reg(mcasp, DAVINCI_MCASP_PDIR_REG, mcasp->context.pdir);
-
-	return 0;
-}
-#endif
-
-SIMPLE_DEV_PM_OPS(davinci_mcasp_pm_ops,
-		  davinci_mcasp_suspend,
-		  davinci_mcasp_resume);
-
 static struct platform_driver davinci_mcasp_driver = {
 	.probe		= davinci_mcasp_probe,
 	.remove		= davinci_mcasp_remove,
 	.driver		= {
 		.name	= "davinci-mcasp",
 		.owner	= THIS_MODULE,
-		.pm	= &davinci_mcasp_pm_ops,
 		.of_match_table = mcasp_dt_ids,
 	},
 };
-- 
1.8.5.3

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

* Re: [PATCH 1/3] ASoC: davinci-mcasp: Consolidate pm_runtime_get/put() use in the driver
  2014-01-30 13:21 ` [PATCH 1/3] ASoC: davinci-mcasp: Consolidate pm_runtime_get/put() use in the driver Peter Ujfalusi
@ 2014-01-31 16:20   ` Mark Brown
  0 siblings, 0 replies; 7+ messages in thread
From: Mark Brown @ 2014-01-31 16:20 UTC (permalink / raw)
  To: Peter Ujfalusi; +Cc: alsa-devel, nsekhar, Liam Girdwood, jsarha, zonque


[-- Attachment #1.1: Type: text/plain, Size: 273 bytes --]

On Thu, Jan 30, 2014 at 03:21:30PM +0200, Peter Ujfalusi wrote:
> The use of pm_runtime in trigger() callback is not correct and it will lead
> to unbalanced power.usage_count.
> The only place which might need to call pm_runtime is the set_fmt callback.

Applied, thanks.

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



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

* Re: [PATCH 2/3] ASoC: davinci-evm: Add pm callbacks to platform driver
  2014-01-30 13:21 ` [PATCH 2/3] ASoC: davinci-evm: Add pm callbacks to platform driver Peter Ujfalusi
@ 2014-01-31 16:21   ` Mark Brown
  0 siblings, 0 replies; 7+ messages in thread
From: Mark Brown @ 2014-01-31 16:21 UTC (permalink / raw)
  To: Peter Ujfalusi; +Cc: alsa-devel, nsekhar, Liam Girdwood, jsarha, zonque


[-- Attachment #1.1: Type: text/plain, Size: 119 bytes --]

On Thu, Jan 30, 2014 at 03:21:31PM +0200, Peter Ujfalusi wrote:
> Set snd_soc_pm_ops for the pm ops.

Applied, thanks.

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



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

* Re: [PATCH 3/3] ASoC: davinci-mcasp: Move pm callbacks from platform device to soc_dai_driver
  2014-01-30 13:21 ` [PATCH 3/3] ASoC: davinci-mcasp: Move pm callbacks from platform device to soc_dai_driver Peter Ujfalusi
@ 2014-01-31 16:41   ` Mark Brown
  0 siblings, 0 replies; 7+ messages in thread
From: Mark Brown @ 2014-01-31 16:41 UTC (permalink / raw)
  To: Peter Ujfalusi; +Cc: alsa-devel, nsekhar, Liam Girdwood, jsarha, zonque


[-- Attachment #1.1: Type: text/plain, Size: 150 bytes --]

On Thu, Jan 30, 2014 at 03:21:32PM +0200, Peter Ujfalusi wrote:
> Handle the PM callbacks via the ASoC core instead of device core.

Applied, thanks.

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



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

end of thread, other threads:[~2014-01-31 16:41 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-01-30 13:21 [PATCH 0/3] ASoC: davinci-mcasp/evm: PM related changes Peter Ujfalusi
2014-01-30 13:21 ` [PATCH 1/3] ASoC: davinci-mcasp: Consolidate pm_runtime_get/put() use in the driver Peter Ujfalusi
2014-01-31 16:20   ` Mark Brown
2014-01-30 13:21 ` [PATCH 2/3] ASoC: davinci-evm: Add pm callbacks to platform driver Peter Ujfalusi
2014-01-31 16:21   ` Mark Brown
2014-01-30 13:21 ` [PATCH 3/3] ASoC: davinci-mcasp: Move pm callbacks from platform device to soc_dai_driver Peter Ujfalusi
2014-01-31 16:41   ` Mark Brown

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.