ASoC: Intel: handle haswell pcm suspend including runtime modules freeing
authorJie Yang <yang.jie@intel.com>
Sat, 30 May 2015 14:33:59 +0000 (22:33 +0800)
committerMark Brown <broonie@kernel.org>
Tue, 2 Jun 2015 14:34:12 +0000 (15:34 +0100)
It needs free pcm runtime modules before unloading firmware, here
add hsw_pcm_suspend() to handle this procedure:
suspends firmware ==> frees runtime modules ==> unloads firmware.

This fixes the broadwell module unload failed issue.

Signed-off-by: Jie Yang <yang.jie@intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/intel/haswell/sst-haswell-pcm.c

index f97fa5ab93d3676112bbf871a4ae85c9a01797ca..e593e7a4b7a7c1f67a56bd57c06ab7dbb36f8ad6 100644 (file)
@@ -1209,6 +1209,20 @@ static int hsw_pcm_runtime_idle(struct device *dev)
        return 0;
 }
 
+static int hsw_pcm_suspend(struct device *dev)
+{
+       struct hsw_priv_data *pdata = dev_get_drvdata(dev);
+       struct sst_hsw *hsw = pdata->hsw;
+
+       /* enter D3 state and stall */
+       sst_hsw_dsp_runtime_suspend(hsw);
+       /* free all runtime modules */
+       hsw_pcm_free_modules(pdata);
+       /* put the DSP to sleep, fw unloaded after runtime modules freed */
+       sst_hsw_dsp_runtime_sleep(hsw);
+       return 0;
+}
+
 static int hsw_pcm_runtime_suspend(struct device *dev)
 {
        struct hsw_priv_data *pdata = dev_get_drvdata(dev);
@@ -1225,8 +1239,7 @@ static int hsw_pcm_runtime_suspend(struct device *dev)
                        return ret;
                sst_hsw_set_module_enabled_rtd3(hsw, SST_HSW_MODULE_WAVES);
        }
-       sst_hsw_dsp_runtime_suspend(hsw);
-       sst_hsw_dsp_runtime_sleep(hsw);
+       hsw_pcm_suspend(dev);
        pdata->pm_state = HSW_PM_STATE_RTD3;
 
        return 0;
@@ -1366,10 +1379,7 @@ static int hsw_pcm_prepare(struct device *dev)
                        if (err < 0)
                                dev_err(dev, "failed to save context for PCM %d\n", i);
                }
-               /* enter D3 state and stall */
-               sst_hsw_dsp_runtime_suspend(hsw);
-               /* put the DSP to sleep */
-               sst_hsw_dsp_runtime_sleep(hsw);
+               hsw_pcm_suspend(dev);
        }
 
        snd_soc_suspend(pdata->soc_card->dev);