From: Chuansheng Liu <chuansheng.liu@intel.com>
To: broonie@opensource.wolfsonmicro.com, lrg@ti.com, perex@perex.cz,
tiwai@suse.de
Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org,
chuansheng.liu@intel.com
Subject: [PATCH] ASoC: dapm: Fix the unpaired runtime_get/put cases
Date: Wed, 19 Dec 2012 18:36:37 +0800 [thread overview]
Message-ID: <1355913397.17896.10.camel@cliu38-desktop-build> (raw)
Commit f1aac484f7(Take a pm_runtime reference on DAPM devices that are enabled)
introduced runtime_get/put calling when devices are in off/non-off bias.
It is based on:
1/ device from off to non-off bias is called thru dapm_pre_sequence_async;
2/ device from non-off to off bias is called thru dapm_post_sequence_async;
There are the above conditions which then make sure runtime_get/put() are pairs.
But some devices has been set to STANDY bias directly during device probing,
such as cs42l73_probe():
cs42l73_set_bias_level(codec, SND_SOC_BIAS_STANDBY);
Then it will cause runtime_get() not be called but laterly runtime_put() will
be called. Also found some other uppaired cases.
So here add new flag get_runtime, and the logic will be:
1/ when device is from off to non-off bias, runtime_get() will be called if not yet;
2/ When device is off bias, runtime_put() will be called if runtime_get() has
been called;
Signed-off-by: liu chuansheng <chuansheng.liu@intel.com>
---
include/sound/soc-dapm.h | 1 +
sound/soc/soc-dapm.c | 18 ++++++++++++------
2 files changed, 13 insertions(+), 6 deletions(-)
diff --git a/include/sound/soc-dapm.h b/include/sound/soc-dapm.h
index e1ef63d..e52fdcc 100644
--- a/include/sound/soc-dapm.h
+++ b/include/sound/soc-dapm.h
@@ -586,6 +586,7 @@ struct snd_soc_dapm_context {
struct list_head list;
int (*stream_event)(struct snd_soc_dapm_context *dapm, int event);
+ bool get_runtime;
#ifdef CONFIG_DEBUG_FS
struct dentry *debugfs_dapm;
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index 1e36bc8..e6d030a 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -1460,12 +1460,15 @@ static void dapm_pre_sequence_async(void *data, async_cookie_t cookie)
struct snd_soc_dapm_context *d = data;
int ret;
+ if ((d->target_bias_level != SND_SOC_BIAS_OFF) &&
+ (d->dev) && !(d->get_runtime)) {
+ pm_runtime_get_sync(d->dev);
+ d->get_runtime = true;
+ }
+
/* If we're off and we're not supposed to be go into STANDBY */
if (d->bias_level == SND_SOC_BIAS_OFF &&
d->target_bias_level != SND_SOC_BIAS_OFF) {
- if (d->dev)
- pm_runtime_get_sync(d->dev);
-
ret = snd_soc_dapm_set_bias_level(d, SND_SOC_BIAS_STANDBY);
if (ret != 0)
dev_err(d->dev,
@@ -1506,9 +1509,6 @@ static void dapm_post_sequence_async(void *data, async_cookie_t cookie)
if (ret != 0)
dev_err(d->dev, "ASoC: Failed to turn off bias: %d\n",
ret);
-
- if (d->dev)
- pm_runtime_put(d->dev);
}
/* If we just powered up then move to active bias */
@@ -1519,6 +1519,12 @@ static void dapm_post_sequence_async(void *data, async_cookie_t cookie)
dev_err(d->dev, "ASoC: Failed to apply active bias: %d\n",
ret);
}
+
+ if ((d->bias_level == SND_SOC_BIAS_OFF) &&
+ (d->dev) && (d->get_runtime)) {
+ pm_runtime_put(d->dev);
+ d->get_runtime = false;
+ }
}
static void dapm_widget_set_peer_power(struct snd_soc_dapm_widget *peer,
--
1.7.0.4
next reply other threads:[~2012-12-19 10:36 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-12-19 10:36 Chuansheng Liu [this message]
2012-12-19 9:11 ` [PATCH] ASoC: dapm: Fix the unpaired runtime_get/put cases Mark Brown
2012-12-20 6:37 ` Liu, Chuansheng
2012-12-20 13:51 ` Mark Brown
2012-12-21 1:34 ` Liu, Chuansheng
2012-12-21 10:17 ` [PATCH] ASoC: core: giving WARN when device starting from non-off bias with idle_bias_off Chuansheng Liu
2012-12-24 15:35 ` Mark Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1355913397.17896.10.camel@cliu38-desktop-build \
--to=chuansheng.liu@intel.com \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@opensource.wolfsonmicro.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lrg@ti.com \
--cc=perex@perex.cz \
--cc=tiwai@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).