mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: Kai-Heng Feng <kai.heng.feng@canonical.com>
Cc: tiwai@suse.com, "Kenneth R . Crudup" <kenny@panix.com>,
	Jaroslav Kysela <perex@perex.cz>,
	Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>,
	Kai Vehmanen <kai.vehmanen@linux.intel.com>,
	Ranjani Sridharan <ranjani.sridharan@linux.intel.com>,
	Mark Brown <broonie@kernel.org>,
	Harsha Priya <harshapriya.n@intel.com>,
	alsa-devel@alsa-project.org (moderated list:SOUND),
	linux-kernel@vger.kernel.org (open list)
Subject: Re: [PATCH] ALSA: hda: Balance runtime/system PM if direct-complete is disabled
Date: Mon, 18 Jan 2021 14:21:36 +0100	[thread overview]
Message-ID: <s5hzh16idnj.wl-tiwai@suse.de> (raw)
In-Reply-To: <20210118130937.164650-1-kai.heng.feng@canonical.com>

On Mon, 18 Jan 2021 14:09:36 +0100,
Kai-Heng Feng wrote:
> 
> HDA controller can't be runtime-suspended after commit 215a22ed31a1
> ("ALSA: hda: Refactor codjc PM to use direct-complete optimization"),
> which enables direct-complete for HDA codec.
> 
> The HDA codec driver didn't expect direct-complete will be disabled
> after it returns a positive value from prepare() callback. However,
> there are some places that PM core can disable direct-complete. For
> instance, system hibernation or when codec has subordinates like LEDs.

Hmm.  This sounds rather like the approach using the direct-complete
isn't well suited for the purpose?  The increasing number of
regression reports worries me.

> So if a device is prepared for direct-complete but PM core still calls
> codec's suspend or freeze callback, resume the device to keep PM
> operations balanced.

I find the ping-pong of the resume/suspend there a bit odd.  It's no
refcount management but it invokes the real resume there, which is
involved with lots of operations.

Can we rather skip the hda_codec_suspend() call instead (while
changing dev->power.power_state)?


thanks,

Takashi

> Reported-by: Kenneth R. Crudup <kenny@panix.com>
> Fixes: 215a22ed31a1 ("ALSA: hda: Refactor codec PM to use direct-complete optimization")
> Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
> ---
>  sound/pci/hda/hda_codec.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
> index 687216e74526..0afbced979df 100644
> --- a/sound/pci/hda/hda_codec.c
> +++ b/sound/pci/hda/hda_codec.c
> @@ -2997,6 +2997,9 @@ static void hda_codec_pm_complete(struct device *dev)
>  
>  static int hda_codec_pm_suspend(struct device *dev)
>  {
> +	if (pm_runtime_status_suspended(dev))
> +		pm_runtime_resume(dev);
> +
>  	dev->power.power_state = PMSG_SUSPEND;
>  	return hda_codec_suspend(dev);
>  }
> @@ -3009,6 +3012,9 @@ static int hda_codec_pm_resume(struct device *dev)
>  
>  static int hda_codec_pm_freeze(struct device *dev)
>  {
> +	if (pm_runtime_status_suspended(dev))
> +		pm_runtime_resume(dev);
> +
>  	dev->power.power_state = PMSG_FREEZE;
>  	return hda_codec_suspend(dev);
>  }
> -- 
> 2.29.2
> 

  reply	other threads:[~2021-01-18 13:23 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-18 13:09 Kai-Heng Feng
2021-01-18 13:21 ` Takashi Iwai [this message]
2021-01-18 17:27   ` Kai-Heng Feng

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=s5hzh16idnj.wl-tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=harshapriya.n@intel.com \
    --cc=kai.heng.feng@canonical.com \
    --cc=kai.vehmanen@linux.intel.com \
    --cc=kenny@panix.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=perex@perex.cz \
    --cc=pierre-louis.bossart@linux.intel.com \
    --cc=ranjani.sridharan@linux.intel.com \
    --cc=tiwai@suse.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

all inboxes | Powered by JetHome®