ALSA: HDA: Disable all references of clocks at end of suspend
Sumit Bhattacharya [Thu, 15 Dec 2011 13:03:06 +0000 (18:03 +0530)]
HDA driver used to enable clocks during suspend only if there is no
active clock. But this logic causes a race condition when hda codec
power work thread disables the active instance of hda clocks in
middle of suspend. To avoid this race condition always enable
HDA clocks at start of suspend operation and disable all active
references of HDA clocks at end of suspend. Since HDA driver
suspend also suspends all active codecs there is no chance of
getting HDA clock disable call after completion of suspend.

Bug 915436

Change-Id: I4956ba28488d6d445ea2d53fb2592897a2ad83bb
Signed-off-by: Sumit Bhattacharya <sumitb@nvidia.com>
Reviewed-on: http://git-master/r/70315
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Scott Peterson <speterson@nvidia.com>

sound/pci/hda/hda_intel.c

index 973e467..79af229 100644 (file)
@@ -2421,7 +2421,7 @@ static int azx_suspend(struct azx *chip, pm_message_t state)
 
 #if defined(CONFIG_SND_HDA_PLATFORM_DRIVER) && \
        defined(CONFIG_SND_HDA_POWER_SAVE)
-       if (!chip->platform_clk_enable)
+       if (chip->pdev)
                azx_platform_enable_clocks(chip);
 #endif
 
@@ -2447,8 +2447,11 @@ static int azx_suspend(struct azx *chip, pm_message_t state)
        }
 
 #ifdef CONFIG_SND_HDA_PLATFORM_DRIVER
-       if (chip->pdev)
-               azx_platform_disable_clocks(chip);
+       if (chip->pdev) {
+               /* Disable all clk references */
+               while (chip->platform_clk_enable)
+                       azx_platform_disable_clocks(chip);
+       }
 #endif
 
        return 0;