From: Takashi Iwai Subject: Re: [PATCH] ALSA: hda - Fix runtime PM accounting Date: Fri, 31 Aug 2012 18:17:23 +0200 Message-ID: References: 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 50E72266462 for ; Fri, 31 Aug 2012 18:17:26 +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 Fri, 31 Aug 2012 01:57:09 +0000, Lin, Mengdong wrote: > > > -----Original Message----- > > From: Takashi Iwai [mailto:tiwai@suse.de] > > Sent: Thursday, August 30, 2012 10:45 PM > > > > Yeah, the check seems slipped from my previous post by some reason. > > Maybe I cherry-picked a wrong branch. > > It should be > > if (codec->power_on) > > hda_call_pm_notify(codec->bus, false); and it should be called > > before module_put(). > > > > It's not needed. In the case of snd_hda_codec_free(), the only interest is > > whether pm_notify down was already called for this this particular codec. > > And this can be checked by codec->power_on flag. > > > > Yes, an extra power flag is not needed. > > I think 'codec->d3_stop_clk_ok' flag is more suitable than 'codec->power_on' for this check: > if (!codec->d3_stop_clk_ok) ... either not suspended or d3_stop_clk_ok is not set for last suspending > hda_call_pm_notify(codec->bus, false); Right, this should be something like that. It's overall confusing to check codec->d3_stop_clk_ok at that point, though. And the confusion comes from the fact that we are using this flag for multiple purposes -- the flag indicating the hardware status and the flag indicating whether the pm-notification has been done. So I did a few clean ups in my tree now. Essentially I replaced codec->d3_stop_clk_ok with codec->pm_down_notified to make the meaning clearer. Also the check of D3_STOP_CLK_OK bit was moved to the hda_power_down_work() so that it's performed only in the power save. thanks, Takashi