From: Tzung-Bi Shih <tzungbi@google.com>
To: broonie@kernel.org, lgirdwood@gmail.com
Cc: tzungbi@google.com, alsa-devel@alsa-project.org
Subject: [PATCH] ASoC: dapm: don't call pm_runtime_* on card device
Date: Fri, 24 Jul 2020 15:07:31 +0800 [thread overview]
Message-ID: <20200724070731.451377-1-tzungbi@google.com> (raw)
runtime_usage of sound card has been observed to grow without bound.
For example:
$ cat /sys/devices/platform/sound/power/runtime_usage
46
$ sox -n -t s16 -r 48000 -c 2 - synth 1 sine 440 vol 0.1 | \
aplay -q -D hw:0,0 -f S16_LE -r 48000 -c 2
$ cat /sys/devices/platform/sound/power/runtime_usage
52
Commit 4e872a46823c ("ASoC: dapm: Don't force card bias level to be
updated") stops to force update bias_level on card. If card doesn't
provide set_bias_level callback, the snd_soc_dapm_set_bias_level()
is equivalent to NOP for card device.
As a result, dapm_pre_sequence_async() doesn't change the bias_level of
card device correctly. Thus, pm_runtime_get_sync() would be called in
dapm_pre_sequence_async() without symmetric pm_runtime_put() in
dapm_post_sequence_async().
Don't call pm_runtime_* on card device.
Signed-off-by: Tzung-Bi Shih <tzungbi@google.com>
---
sound/soc/soc-dapm.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
Hi,
I'm not very sure if the patch makes sense.
I was considering:
(1) update the bias_level of card device correctly
(2) skip pm_runtime_* for card device
Per commit message on 4e872a46823c, I believe there is some context
I'm not aware of it. Thus, the patch adopts (2).
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index 5076299abf37..3273161e2787 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -1798,7 +1798,7 @@ static void dapm_pre_sequence_async(void *data, async_cookie_t cookie)
/* If we're off and we're not supposed to go into STANDBY */
if (d->bias_level == SND_SOC_BIAS_OFF &&
d->target_bias_level != SND_SOC_BIAS_OFF) {
- if (d->dev)
+ if (d->dev && cookie)
pm_runtime_get_sync(d->dev);
ret = snd_soc_dapm_set_bias_level(d, SND_SOC_BIAS_STANDBY);
@@ -1845,7 +1845,7 @@ static void dapm_post_sequence_async(void *data, async_cookie_t cookie)
dev_err(d->dev, "ASoC: Failed to turn off bias: %d\n",
ret);
- if (d->dev)
+ if (d->dev && cookie)
pm_runtime_put(d->dev);
}
--
2.28.0.rc0.142.g3c755180ce-goog
next reply other threads:[~2020-07-24 7:08 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-24 7:07 Tzung-Bi Shih [this message]
2020-07-24 11:16 ` [PATCH] ASoC: dapm: don't call pm_runtime_* on card device Mark Brown
2020-07-24 12:26 ` Tzung-Bi Shih
2020-07-24 13:01 ` Mark Brown
2020-07-24 14:41 ` Tzung-Bi Shih
2020-07-24 16:42 ` Mark Brown
2020-07-24 16:38 ` 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=20200724070731.451377-1-tzungbi@google.com \
--to=tzungbi@google.com \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=lgirdwood@gmail.com \
/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).