All of lore.kernel.org
 help / color / mirror / Atom feed
From: Liam Girdwood <liam.r.girdwood@linux.intel.com>
To: David Henningsson <david.henningsson@canonical.com>
Cc: "alsa-devel@alsa-project.org" <alsa-devel@alsa-project.org>,
	"Zanoni, Paulo R" <paulo.r.zanoni@intel.com>,
	Takashi Iwai <tiwai@suse.de>,
	Daniel Vetter <daniel.vetter@ffwll.ch>,
	"intel-gfx@lists.freedesktop.org"
	<intel-gfx@lists.freedesktop.org>,
	"Wysocki, Rafael J" <rafael.j.wysocki@intel.com>,
	Wang Xingchao <xingchao.wang@linux.intel.com>,
	"Li, Jocelyn" <jocelyn.li@intel.com>,
	"Hindman, Gavin" <gavin.hindman@intel.com>,
	Jesse Barnes <jesse.barnes@intel.com>,
	"Lin, Mengdong" <mengdong.lin@intel.com>
Subject: Re: [alsa-devel] [PATCH] drm/i915: Add private api for power well usage -- alignment between graphic team and audio team
Date: Tue, 30 Apr 2013 15:41:22 +0100	[thread overview]
Message-ID: <1367332882.2460.14.camel@loki> (raw)
In-Reply-To: <517F9D11.3020905@canonical.com>

On Tue, 2013-04-30 at 12:29 +0200, David Henningsson wrote:
> On 04/29/2013 05:02 PM, Jesse Barnes wrote:
> > On Sat, 27 Apr 2013 13:35:29 +0200
> > Daniel Vetter <daniel@ffwll.ch> wrote:
> >
> >> On Sat, Apr 27, 2013 at 09:20:39AM +0000, Wang, Xingchao wrote:
> >>> Let me throw a basic proposal on Audio driver side,  please give your comments freely.
> >>>
> >>> it contains the power well control usage points:
> >>> #1: audio request power well at boot up.
> >>> I915 may shut down power well after bootup initialization, as there's no monitor connected outside or only eDP on pipe A.
> >>> #2: audio request power on resume
> >>> After exit from D3 mode, audio driver quest power on. This may happen at normal resume or runtime resume.
> >>> #3: audio release power well control at suspend
> >>> Audio driver will let i915 know it doensot need power well anymore as it's going to suspend. This may happened at normal suspend or runtime suspend point.
> >>> #4: audio release power well when module unload
> >>> Audio release power well at remove callback to let i915 know.
> >>
> >> I miss the power well grab/dropping at runtime from the audio side. If the
> >> audio driver forces the power well to be on the entire time it's loaded,
> >> that's not good, since the power well stuff is very much for runtime PM.
> >> We _must_ be able to switch off the power well whenever possible.
> >
> > Xingchao, I'm not an audio developer so I'm probably way off.
> >
> > But what we really need is a very small and targeted set of calls into
> > the i915 driver from say the HDMI driver in HDA.  It looks like the
> > prepare/cleanup pair in the pcm_ops structure might be the right place
> > to put things?  If that's too fine grained, you could do it at
> > open/close time I guess, but the danger there is that some app will
> > keep the device open even while it's not playing.
> >
> > If that won't work, maybe calling i915 from hda_power_work in the
> > higher level code would be better?
> >
> > For detecting whether to call i915 at all, you can filter on the PCI
> > IDs (just look for an Intel graphics device and if present, try to get
> > the i915 symbols for the power functions).
> >
> > --- a/sound/pci/hda/hda_codec.c
> > +++ b/sound/pci/hda/hda_codec.c
> > @@ -3860,6 +3860,8 @@ static unsigned int hda_call_codec_suspend(struct hda_code
> >                  codec->patch_ops.suspend(codec);
> >          hda_cleanup_all_streams(codec);
> >          state = hda_set_power_state(codec, AC_PWRST_D3);
> > +       if (i915_shared_power_well)
> > +               i915_put_power_well(codec->i915_data);
> >          /* Cancel delayed work if we aren't currently running from it. */
> >          if (!in_wq)
> >                  cancel_delayed_work_sync(&codec->power_work);
> > @@ -4807,6 +4809,9 @@ static void __snd_hda_power_up(struct hda_codec *codec, bo
> >                  return;
> >          spin_unlock(&codec->power_lock);
> >
> > +       if (i915_shared_power_well)
> > +               i915_get_power_well(codec->i915_data);
> 
> Is it wise that a _get function actually has side effects? Perhaps _push 
> and _pop or something else would be better semantics.
> 

I think the intention here is to model on the PM runtime subsystem where
we can get/put the reference count on a PM resource. I'd expect with
this API that i915_get_power_well() will increment the count and prevent
the shared PM resource from being powered OFF. 

> > +
> >          cancel_delayed_work_sync(&codec->power_work);
> >
> >          spin_lock(&codec->power_lock);
> >
> > With some code at init time to get the i915 symbols you need to call
> > and whether or not the shared power well is present...
> >
> > Takashi, any other ideas?
> >
> > The high level goal here should be for the audio driver to call into
> > i915 with get/put power well around the sequences where it needs the
> > power to be up (reading/writing registers, playing audio), but not
> > across the whole time the driver is loaded, just like you already do
> > with the powersave work functions, e.g. hda_call_codec_suspend.
> 
> I think this sounds about right. The question is how to avoid a 
> dependency on the i915 driver when it's not necessary, such as when the 
> HDMI codec is AMD or Nvidia.
> 
> The most obvious way to me seems to be to create a new 
> snd-hda-codec-hdmi-haswell module (that depends on both i915 and 
> snd-hda-codec-hdmi), and then let that call into i915 and codec-hdmi 
> drivers as necessary, e g using the set_power_state callback for the 
> i915 stuff.
> 
> But maybe there's something smarter to do here, as I'm not experienced 
> in mending kernel pieces together :-)
> 

Interesting idea, we could have something similar to the AC97 ad-hoc
device support where we could load other HW specific AC97 modules (like
touchscreen controllers) without breaking the generic nature of the base
driver. e.g. the WM9712 AC97 touchscreen driver could connect to the
generic AC97 audio driver (get it's device struct ac97 *) and perform
AC97 register IO, ac97 API calls etc.

Regards

Liam

  parent reply	other threads:[~2013-04-30 14:41 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-26  6:58 [PATCH] drm/i915: Add private api for power well usage -- alignment between graphic team and audio team Li, Jocelyn
2013-04-26  7:24 ` Daniel Vetter
2013-04-26  7:53   ` Li, Jocelyn
2013-04-26 14:57     ` Daniel Vetter
2013-04-26 15:12       ` Takashi Iwai
2013-04-26 15:42         ` Daniel Vetter
2013-04-26 15:45           ` Takashi Iwai
2013-04-26 17:17             ` Daniel Vetter
2013-04-27  9:20               ` Wang, Xingchao
2013-04-27 11:35                 ` Daniel Vetter
2013-04-29 15:02                   ` Jesse Barnes
2013-04-30 10:29                     ` David Henningsson
2013-04-30 14:38                       ` Jesse Barnes
2013-05-02  3:17                         ` Lin, Mengdong
2013-04-30 14:41                       ` Liam Girdwood [this message]
2013-05-02 14:49                         ` David Henningsson
2013-05-03  8:28                           ` [alsa-devel] " Wang, Xingchao
2013-05-03 12:02                             ` David Henningsson
2013-05-03 14:31                               ` Takashi Iwai
2013-05-02  7:11                     ` Wang, Xingchao
2013-05-03 14:26                     ` Takashi Iwai
2013-05-03 15:17                       ` Wang, Xingchao
2013-04-27  8:54         ` Wang, Xingchao
2013-04-27  8:46       ` Wang, Xingchao

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=1367332882.2460.14.camel@loki \
    --to=liam.r.girdwood@linux.intel.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=daniel.vetter@ffwll.ch \
    --cc=david.henningsson@canonical.com \
    --cc=gavin.hindman@intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=jesse.barnes@intel.com \
    --cc=jocelyn.li@intel.com \
    --cc=mengdong.lin@intel.com \
    --cc=paulo.r.zanoni@intel.com \
    --cc=rafael.j.wysocki@intel.com \
    --cc=tiwai@suse.de \
    --cc=xingchao.wang@linux.intel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.