alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
From: Anshuman Gupta <anshuman.gupta@intel.com>
To: "Rafael J. Wysocki" <rafael@kernel.org>,
	"Subhransu S. Prusty" <subhransu.s.prusty@intel.com>
Cc: "moderated list:SOUND - SOC LAYER / DYNAMIC AUDIO POWER
	MANAGEM..." <alsa-devel@alsa-project.org>,
	Liam Girdwood <lgirdwood@gmail.com>,
	Linux PM <linux-pm@vger.kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Takashi Iwai <tiwai@suse.com>, Mark Brown <broonie@kernel.org>
Subject: Re: [alsa-devel] [PATCH] [sound] hdac-codec runtime suspended at PM:Suspend.
Date: Wed, 14 Mar 2018 21:07:14 +0530	[thread overview]
Message-ID: <20180314153714.GA11459@anshuman.gupta@intel.com> (raw)
In-Reply-To: <CAJZ5v0jrKPNFhgpoL97Ac-k9jAmMa-vzgc-4PD+uuynSMqE2Fw@mail.gmail.com>

On Wed, Mar 14, 2018 at 11:53:58AM +0100, Rafael J. Wysocki wrote:
> On Wed, Mar 14, 2018 at 11:38 AM, Anshuman Gupta
> <anshuman.gupta@intel.com> wrote:
> > On Mon, Mar 12, 2018 at 12:26:53PM +0100, Rafael J. Wysocki wrote:
> >> On Mon, Mar 12, 2018 at 12:17 PM, Anshuman Gupta
> >> <anshuman.gupta@intel.com> wrote:
> >> > Keep hdac-codec to be in runtime suspended while entering to suspend.
> >> > If hdac-codec is already in runtime suspend state skip its power down
> >> > sequence in prepare, power up sequence in complete phase.
> >> >
> >> > Avoid resuming hdac controller PCI device 00:1f.3 from runtime suspend
> >> > state in case  hdac-codec already in runtime-suspend state, this is
> >> > unnecessary and block the direct complete even for hdac controller
> >> > PCI device 00:1f.3.
> >> >
> >> > This enabled direct complete path for hdac-codec and PCI device 00:1f.3.
> >> >
> >> > Signed-off-by: Anshuman Gupta <anshuman.gupta@intel.com>
> >> > ---
> >> >  sound/soc/codecs/hdac_hdmi.c | 4 ++++
> >> >  1 file changed, 4 insertions(+)
> >> >
> >> > diff --git a/sound/soc/codecs/hdac_hdmi.c b/sound/soc/codecs/hdac_hdmi.c
> >> > index f3b4f4d..810a8a6 100644
> >> > --- a/sound/soc/codecs/hdac_hdmi.c
> >> > +++ b/sound/soc/codecs/hdac_hdmi.c
> >> > @@ -1852,6 +1852,8 @@ static int hdmi_codec_prepare(struct device *dev)
> >> >         struct hdac_ext_device *edev = to_hda_ext_device(dev);
> >> >         struct hdac_device *hdac = &edev->hdac;
> >> >
> >> > +       if (pm_runtime_status_suspended(dev))
> >> > +               return 1;
> >>
> >> This is racy in principle, because the runtime PM status can still
> >> change after you've checked here.
> >   Will using pm_runtime_disable/pm_runtime_enable for safe check of runtime
> >   status avoids this race?
> 
> It might help, but is this a leaf device or does it have children?
  In kernel traces this hdac hdmi codec device appear with name 
  "HDA Codec ehdaudio0D2", and it seems to be a leaf device do not 
  have any child. So it would be ok to use pm_runtime_disable to
  avoid any race ?
> 
> >> But even if it isn't racy in practice, the following
> >> pm_runtime_get_sync() becomes redundant after it, doesn't it?
> >   I have no idea but if there can be a case that PCI 00:1f.3 (hdac controller)
> >   is runtime suspended and hdac hdmi codec is active, in that case it may be
> >   required to use pm_runtime_get_sync() for hdac controller as it is parent of
> >   hdac hdmi codec.
> >>
> >> >         pm_runtime_get_sync(&edev->hdac.dev);
> >> >
> 
> So it sounds like you need the "get" part, but you don't need the
> "sync" one, because you've just checked that the device is not
> suspended.
> 
> I guess the idea is to return 1 for the direct-complete mechanism to
> kick in if the device is already suspended, but otherwise bump up its
> reference counter to prevent it from suspending going forward, right?
> 
  Idea of this patch to remove the PCI 00:1f:3 (hdac controller) direct 
  complete blocker, as hdac hdmi codec is resuming it from runtime suspend
  in its prepare callback to set the hdac hdmi codec in low power state.
  (https://elixir.bootlin.com/linux/v4.16-rc5/source/sound/soc/codecs/hdac_hdmi.c#L1860)
  So if hdac hdmi codec in active state it require to resume hdac controller
  from runtime suspend.      
> >> >         /*
> >> > @@ -1873,6 +1875,8 @@ static void hdmi_codec_complete(struct device *dev)
> >> >         struct hdac_hdmi_priv *hdmi = edev->private_data;
> >> >         struct hdac_device *hdac = &edev->hdac;
> >> >
> >> > +       if (pm_runtime_status_suspended(dev))
> >> > +               return;
> >>
> >> That, again, is somewhat fragile from the concurrency perspective.
> >>
> 
> And here you want to avoid the below if the device is still suspended.
  Yes, if we do not avoid the code below, complete callback takes about 
  3 seconds due to snd_hdac_codec_read timed out because hdac controller 
  would be in runtime suspend state.	
> 
> Why is the below code located in the ->complete callback anyway?
> Shouldn't it be there in the ->resume one?
> 
  Yes even i am also having same doubt, why these power down and power up
  sequences are part of prepare and complete callback.
  Adding driver author "Subhransu S. Prusty" to provide more inputs on this.
> >> >         /* Power up afg */
> >> >         snd_hdac_codec_read(hdac, hdac->afg, 0, AC_VERB_SET_POWER_STATE,
> >> >                                                         AC_PWRST_D0);
> >> > --
> >> > 2.7.4

-- 
Thanks,
Anshuman
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

  reply	other threads:[~2018-03-14 15:38 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-12 11:17 [PATCH] [sound] hdac-codec runtime suspended at PM:Suspend Anshuman Gupta
2018-03-12 11:26 ` Rafael J. Wysocki
2018-03-14 10:38   ` Anshuman Gupta
2018-03-14 10:38   ` [alsa-devel] " Anshuman Gupta
     [not found]   ` <5aa8fbe9.4251620a.c3daa.3711SMTPIN_ADDED_BROKEN@mx.google.com>
2018-03-14 10:53     ` Rafael J. Wysocki
2018-03-14 15:37       ` Anshuman Gupta [this message]
2018-03-15 10:42         ` Subhransu S. Prusty
2018-03-15 15:32           ` Anshuman Gupta
2018-03-15 15:32           ` [alsa-devel] " Anshuman Gupta
2018-03-26  7:03             ` Subhransu S. Prusty
2018-03-26  7:30               ` Takashi Iwai
2018-03-27 15:36                 ` Lukas Wunner
2018-03-14 15:37       ` Anshuman Gupta
2018-08-18 18:12   ` [PATCH v2 0/1] cover-letter " Anshuman Gupta
2018-08-18 18:12     ` [PATCH v2 1/1] " Anshuman Gupta
2018-08-28 16:34       ` Anshuman Gupta
2018-08-28 17:05         ` 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=20180314153714.GA11459@anshuman.gupta@intel.com \
    --to=anshuman.gupta@intel.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=rafael@kernel.org \
    --cc=subhransu.s.prusty@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;
as well as URLs for NNTP newsgroup(s).