-----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);
It's because the codec will call pm_notify down only when PS-ClkStopOk is set on its last suspending to D3. And PS-ClkStopOk is dynamic flag while CLKSTOP is static. It's possible that a codec supports CLKSTOP but does not set PS-ClkStopOk on every transition to D3.
Thanks Mengdong