From: Takashi Iwai Subject: Re: [RFC PATCH] ALSA: hda - add support for runtime power management Date: Fri, 17 Aug 2012 11:52:31 +0200 Message-ID: References: <1345195814-2287-1-git-send-email-mengdong.lin@intel.com> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mx2.suse.de (cantor2.suse.de [195.135.220.15]) by alsa0.perex.cz (Postfix) with ESMTP id B12872652D1 for ; Fri, 17 Aug 2012 11:22:45 +0200 (CEST) In-Reply-To: <1345195814-2287-1-git-send-email-mengdong.lin@intel.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org To: mengdong.lin@intel.com Cc: alsa-devel@alsa-project.org List-Id: alsa-devel@alsa-project.org At Fri, 17 Aug 2012 17:30:14 +0800, mengdong.lin@intel.com wrote: > > From: Mengdong Lin > > This patch is a basic idea about adding runtime PM support to HD audio. > > Support for runtime PM is based on current HDA power saving implementation. > When both power saving and runtime PM are enabled, and if all codecs are > suspended (in D3), the HDA controller can also be suspended to a low power > state by decreasing the power usage counter and triggering PCI device > runtime suspend. And the user IO operation can resume the controller back > to D0. > > The user can enable runtime PM on HDA controller on platfroms that can > provide acceptable latency on transition from D3 to D0. If the runtime PM > is disabled, power saving just works as without runtime PM before. And > if power saving is disabled, the power usage counter will never be 0 so > the HDA controller will not be suspended. > > I've verified this patch on a platfrom on which the HD-A controller can enter > D3hot when suspended. And I plan to allow the controller to suspened only > if all codecs support "stop-clock" in D3, for wakeup request. > > Is this idea doable? Any comments are welcome. I thought we stopped the controller at power save, but this was removed by some reason at some time ago. Basically the patch below should do almost equivalently. It doesn't free/reacquire irq, which I'm not quite sure whether mandatory for power-saving. Takashi --- diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c index 933c2a1..d3c01b1 100644 --- a/sound/pci/hda/hda_intel.c +++ b/sound/pci/hda/hda_intel.c @@ -2402,11 +2402,14 @@ static void azx_power_notify(struct hda_bus *bus) break; } } - if (power_on) + if (power_on) { + pci_set_power_state(chip->pci, PCI_D0); azx_init_chip(chip, 1); - else if (chip->running && power_save_controller && - !bus->power_keep_link_on) + } else if (chip->running && power_save_controller && + !bus->power_keep_link_on) { azx_stop_chip(chip); + pci_set_power_state(chip->pci, PCI_D3hot); + } } #endif /* CONFIG_SND_HDA_POWER_SAVE */