From: Cezary Rojewski <cezary.rojewski@intel.com>
To: "Takashi Iwai" <tiwai@suse.de>,
"Amadeusz Sławiński" <amadeuszx.slawinski@linux.intel.com>
Cc: "alsa-devel@alsa-project.org" <alsa-devel@alsa-project.org>
Subject: Re: HDA, power saving and recording
Date: Wed, 17 May 2023 15:15:13 +0200 [thread overview]
Message-ID: <4cc5cd11-e1c4-1ff2-ec66-328a00b5703f@intel.com> (raw)
In-Reply-To: <87cz31pq2d.wl-tiwai@suse.de>
On 2023-05-15 5:33 PM, Takashi Iwai wrote:
> On Mon, 15 May 2023 16:49:48 +0200,
> Amadeusz Sławiński wrote:
...
>> I think there are two problems:
>>
>> 1. After probe codec is powered down
>> (https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/sound/pci/hda/hda_codec.c#n833),
>> even though according to power management it is still running
>
> I guess it's in the auto-suspend state, so it's still not suspended
> but the device itself is active, while the usage count is 0.
>
> That's fine, and I thought my second patch handling it. That is, if
> the usage count is 0 and the device is not suspended, it should return
> -EAGAIN and make the caller retry with the full power up.
> The code path is with CALL_RUN_FUNC() macro in hdac_regmap.c, and with
> -EAGAIN return value, it tries snd_hdac_power_up_pm() and call the
> function again.
>
>> 2. When stream is started before first suspend, resume function
>> doesn't run and it is a function which syncs cached registers. By
>> resume function I mean
>> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/sound/pci/hda/hda_codec.c#n2899
>> which calls snd_hda_regmap_sync() or through in case of the platform I
>> test it on codec->patch_ops.resume(codec) -> alc269_resume, which also
>> calls snd_hda_regmap_sync().
>
> It's also expected, per se. Since it's been not suspended, it assumes
> that the value got already written, and no resume is needed.
After reading this conversation few times I came to conclusion that
codec device should be kept up as long as its runtime_status=0
(RPM_ACTIVE), regardless if usage_count is 0 or not. Basically, in
autosuspend case usage_count and runtime_status for the device are both
0 so, if we are not ignoring the former by calling
pm_runtime_get_if_in_use() then we end up caching the writes during the
autosuspend period - period when the device is no longer used but there
is still some time left before it's suspended.
--- a/sound/hda/hdac_device.c
+++ b/sound/hda/hdac_device.c
@@ -611,7 +611,7 @@ EXPORT_SYMBOL_GPL(snd_hdac_power_up_pm);
int snd_hdac_keep_power_up(struct hdac_device *codec)
{
if (!atomic_inc_not_zero(&codec->in_pm)) {
- int ret = pm_runtime_get_if_in_use(&codec->dev);
+ int ret = pm_runtime_get_if_active(&codec->dev, true);
if (!ret)
return -1;
if (ret < 0)
Results for the above look good.
next prev parent reply other threads:[~2023-05-17 13:17 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-09 10:10 HDA, power saving and recording Amadeusz Sławiński
2023-05-10 12:21 ` Takashi Iwai
2023-05-11 15:31 ` Amadeusz Sławiński
2023-05-11 15:58 ` Takashi Iwai
2023-05-11 17:20 ` Amadeusz Sławiński
2023-05-12 11:23 ` Takashi Iwai
2023-05-12 11:33 ` Takashi Iwai
2023-05-12 12:00 ` Amadeusz Sławiński
2023-05-12 12:24 ` Takashi Iwai
2023-05-15 11:19 ` Amadeusz Sławiński
2023-05-15 13:02 ` Takashi Iwai
2023-05-15 14:49 ` Amadeusz Sławiński
2023-05-15 15:33 ` Takashi Iwai
2023-05-17 13:15 ` Cezary Rojewski [this message]
2023-05-17 14:52 ` Takashi Iwai
2023-05-18 9:00 ` Cezary Rojewski
2023-05-18 11:02 ` Takashi Iwai
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=4cc5cd11-e1c4-1ff2-ec66-328a00b5703f@intel.com \
--to=cezary.rojewski@intel.com \
--cc=alsa-devel@alsa-project.org \
--cc=amadeuszx.slawinski@linux.intel.com \
--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