[Rebase from R2-R3]audio: Added addtional error handling in SST driver
authorJeeja Kp <jeeja.kp@intel.com>
Sat, 31 Dec 2011 22:04:18 +0000 (03:34 +0530)
committerbuildbot <buildbot@intel.com>
Mon, 9 Jan 2012 17:15:28 +0000 (09:15 -0800)
BZ: 19267

Old R2 BZ 18108
This patch has the following error handling added
In case of open failure, the system will go to suspend immediately instead
of 2s delay.
Added error handling to check if  firmware is in running state before
sending any request to FW.

Change-Id: Ia7990472b83596dcc7ab9d7fc9c3f8cf280912f8
Old-Change-Id: I292d2086a6564f47733de485f1ada8116e8f10bf
Signed-off-by: Jeeja Kp <jeeja.kp@intel.com>
Reviewed-on: http://android.intel.com:8080/31052
Reviewed-by: M, Arulselvan <arulselvan.m@intel.com>
Tested-by: M, Arulselvan <arulselvan.m@intel.com>
Reviewed-by: buildbot <buildbot@intel.com>
Tested-by: buildbot <buildbot@intel.com>
sound/pci/sst/intel_sst_drv_interface.c
sound/soc/mid-x86/sst_platform.c

index 8854060..46f3d93 100644 (file)
@@ -185,7 +185,7 @@ int sst_get_stream_allocated(struct snd_sst_params *str_param,
        retval = sst_wait_interruptible_timeout(sst_drv_ctx,
                        &str_info->ctrl_blk, SST_BLOCK_TIMEOUT);
        if ((retval != 0) || (str_info->ctrl_blk.ret_code != 0)) {
-               pr_debug("FW alloc failed retval %d, ret_code %d\n",
+               pr_err("sst: FW alloc failed retval %d, ret_code %d\n",
                                retval, str_info->ctrl_blk.ret_code);
                str_id = -str_info->ctrl_blk.ret_code; /*return error*/
                if (str_id == 0)
@@ -418,11 +418,17 @@ static int sst_open_pcm_stream(struct snd_sst_params *str_param)
        }
 
        if (!str_param) {
-               pr_debug("open_pcm, doing rtpm_put\n");
-               pm_runtime_put(&sst_drv_ctx->pci->dev);
+               pr_debug("sst: open_pcm, doing rtpm_put\n");
                return -EINVAL;
        }
 
+       mutex_lock(&sst_drv_ctx->sst_lock);
+       if (sst_drv_ctx->sst_state != SST_FW_RUNNING) {
+               mutex_unlock(&sst_drv_ctx->sst_lock);
+               return -EAGAIN;
+       }
+       mutex_unlock(&sst_drv_ctx->sst_lock);
+
        retval = sst_get_stream(str_param);
        if (retval > 0) {
                sst_drv_ctx->stream_cnt++;
index 32dcf4a..e338dd7 100644 (file)
@@ -376,7 +376,7 @@ static int sst_platform_pcm_prepare(struct snd_pcm_substream *substream)
 
        ret_val = sst_platform_alloc_stream(substream);
        if (ret_val <= 0)
-               return ret_val;
+               goto out;
        snprintf(substream->pcm->id, sizeof(substream->pcm->id),
                        "%d", stream->stream_info.str_id);
 
@@ -385,11 +385,13 @@ static int sst_platform_pcm_prepare(struct snd_pcm_substream *substream)
                return ret_val;
        substream->runtime->hw.info = SNDRV_PCM_INFO_BLOCK_TRANSFER;
 
+
+out:
        /* we are suspending the sink/source here as we want to have
         * device suspended in idle, before handling next request we will send
         * an explict RESUME call  */
        pr_debug("Suspend NOW\n");
-       ret_val = stream->sstdrv_ops->pcm_control->device_control(
+       stream->sstdrv_ops->pcm_control->device_control(
                        SST_SND_DEVICE_SUSPEND, &stream->stream_info.str_id);
        sst_set_stream_status(stream, SST_PLATFORM_SUSPENDED);
        return ret_val;