From d91bd5d103d5147481e9ab8912e2a24c5b9178d3 Mon Sep 17 00:00:00 2001 From: Jeeja Kp Date: Sun, 1 Jan 2012 03:34:18 +0530 Subject: [PATCH] [Rebase from R2-R3]audio: Added addtional error handling in SST driver 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 Reviewed-on: http://android.intel.com:8080/31052 Reviewed-by: M, Arulselvan Tested-by: M, Arulselvan Reviewed-by: buildbot Tested-by: buildbot --- sound/pci/sst/intel_sst_drv_interface.c | 12 +++++++++--- sound/soc/mid-x86/sst_platform.c | 6 ++++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/sound/pci/sst/intel_sst_drv_interface.c b/sound/pci/sst/intel_sst_drv_interface.c index 8854060..46f3d93 100644 --- a/sound/pci/sst/intel_sst_drv_interface.c +++ b/sound/pci/sst/intel_sst_drv_interface.c @@ -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++; diff --git a/sound/soc/mid-x86/sst_platform.c b/sound/soc/mid-x86/sst_platform.c index 32dcf4a..e338dd7 100644 --- a/sound/soc/mid-x86/sst_platform.c +++ b/sound/soc/mid-x86/sst_platform.c @@ -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; -- 2.7.4