From: Takashi Iwai Subject: Re: [PATCH v3 2/2] [ALSA] hda - suspend the controller only if all codecs support stop-clk in D3 Date: Wed, 22 Aug 2012 17:19:11 +0200 Message-ID: References: <1345632404-5629-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 A097D266135 for ; Wed, 22 Aug 2012 17:19:11 +0200 (CEST) In-Reply-To: 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: "Lin, Mengdong" Cc: "alsa-devel@alsa-project.org" List-Id: alsa-devel@alsa-project.org At Wed, 22 Aug 2012 14:58:19 +0000, Lin, Mengdong wrote: > > > -----Original Message----- > > From: Takashi Iwai [mailto:tiwai@suse.de] > > Sent: Wednesday, August 22, 2012 8:17 PM > > > > You shouldn't move pm_runtime_get_noresume() / _put_no_idle() to > > hda_codec.c, but these should be called only in hda_intel.c. > > Basically there is no PCI-specific code in hda_codec.c and patch_*.c. > > All PCI controller code should be in hda_intel.c. > > Okay. I'll move pm_runtime_get_noresume() / _put_no_idle() back to azx_probe_continue() and azx_remove(). > > > (snip) > > > else if (chip->running && power_save_controller && > > > - !bus->power_keep_link_on) { > > > + !bus->power_keep_link_on) > > > azx_stop_chip(chip); > > > > > > - /* TODO: Suspend controller only if all codec support > > > - stop-clock in D3, for wakeup consideration */ > > > + if (!bus->power_keep_link_on > > > + && !codec->power_on && codec->d3_stop_clk_ok) > > > pm_runtime_put_sync(&chip->pci->dev); > > > > Also it should check power_save_controller, too. > > I'll add check on power_save_controller. Thinking on it again, maybe a cleaner option would be something like: static void azx_power_notify(struct hda_bus *bus) { struct azx *chip = bus->private_data; if (bus->power_keep_link_on || !codec->d3_stop_clk_ok) return; if (codec->power_on) pm_runtime_get_sync(&chip->pci->dev); else pm_runtime_put_sync(&chip->pci->dev); } Then in call azx_init_chip() and azx_stop_chip() in the runtime PM. (In the power-down case, it should check power_save_controller there. Eventually we can deprecate this option later.) The azx_init_chip() and azx_stop_chip() calls were needed in azx_power_notify() because the PM resume didn't kick off the initialization immediately in the earlier version, but left uninitialized until the power-ON via power-save is triggered. This was changed because of some ugly bugs (e.g. inconsistent mute LED). Now the hardware is always initialized after PM resume. Thus, for powersave case, chip init/stop can be simply put in the runtime PM side, as far as I see. thanks, Takashi