[PORT FROM R2]audio: sst: Fix sst_wait_timeout and replace sst_wait_interruptible_timeout
authorJouni Hogander <jouni.hogander@intel.com>
Wed, 22 Feb 2012 16:13:17 +0000 (18:13 +0200)
committerbuildbot <buildbot@intel.com>
Wed, 7 Mar 2012 11:19:57 +0000 (03:19 -0800)
BZ: 24061 24813

sst_wait_timeout is improperly using wait_event_interruptible_timeout. Fix it to
use wait_event_timeout. Also, replace all usages of
sst_wait_interruptible_timeout with sst_wait_timeout since driver needs to wait
for reply from firmware in any case.

Change-Id: Ic67678ea020874f63c447d75695a9d5cd44060dc
Signed-off-by: Omair Mohammed Abdullah <omair.m.abdullah@linux.intel.com>
Reviewed-on: http://android.intel.com:8080/36791
Reviewed-by: Hogander, Jouni <jouni.hogander@intel.com>
Reviewed-by: Abdullah, Omair M <omair.m.abdullah@intel.com>
Reviewed-by: Noziska, PatrickX J <patrickx.j.noziska@intel.com>
Reviewed-by: Koul, Vinod <vinod.koul@intel.com>
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.c
sound/pci/sst/intel_sst_app_interface.c
sound/pci/sst/intel_sst_common.h
sound/pci/sst/intel_sst_drv_interface.c
sound/pci/sst/intel_sst_dsp.c
sound/pci/sst/intel_sst_pvt.c
sound/pci/sst/intel_sst_stream.c
sound/pci/sst/intel_sst_stream_encoded.c

index 8efb4b6..c616e0b 100644 (file)
@@ -479,8 +479,9 @@ static void sst_save_dsp_context(void)
        spin_unlock(&sst_drv_ctx->list_spin_lock);
        sst_post_message(&sst_drv_ctx->ipc_post_msg_wq);
        /*wait for reply*/
-       if (sst_wait_timeout(sst_drv_ctx, &sst_drv_ctx->alloc_block[0]))
-               pr_debug("err fw context save timeout  ...\n");
+       if (sst_wait_timeout(sst_drv_ctx,
+                               &sst_drv_ctx->alloc_block[0].ops_block))
+               pr_err("sst: err fw context save timeout  ...\n");
        sst_drv_ctx->alloc_block[0].sst_id = BLOCK_UNINIT;
        pr_debug("fw context saved  ...\n");
        return;
index 2fe916b..ecbe585 100644 (file)
@@ -870,8 +870,7 @@ static int sst_send_algo_ipc(struct ipc_post **msg)
        list_add_tail(&(*msg)->node, &sst_drv_ctx->ipc_dispatch_list);
        spin_unlock(&sst_drv_ctx->list_spin_lock);
        sst_post_message(&sst_drv_ctx->ipc_post_msg_wq);
-       return sst_wait_interruptible_timeout(sst_drv_ctx,
-                       &sst_drv_ctx->ppp_params_blk, SST_BLOCK_TIMEOUT);
+       return sst_wait_timeout(sst_drv_ctx, &sst_drv_ctx->ppp_params_blk);
 }
 
 /**
index 49d8ea7..37f80c6 100644 (file)
@@ -56,11 +56,7 @@ enum sst_states {
 #define MAX_ACTIVE_STREAM      3
 #define MAX_ENC_STREAM         1
 #define MAX_AM_HANDLES         1
-#define ALLOC_TIMEOUT          5000
-/* SST numbers */
 #define SST_BLOCK_TIMEOUT      5000
-#define TARGET_DEV_BLOCK_TIMEOUT       5000
-
 #define BLOCK_UNINIT           -1
 #define RX_TIMESLOT_UNINIT     -1
 
@@ -536,10 +532,8 @@ int sst_get_block_stream(struct intel_sst_drv *sst_drv_ctx);
 
 int sst_wait_interruptible(struct intel_sst_drv *sst_drv_ctx,
                                struct sst_block *block);
-int sst_wait_interruptible_timeout(struct intel_sst_drv *sst_drv_ctx,
-               struct sst_block *block, int timeout);
 int sst_wait_timeout(struct intel_sst_drv *sst_drv_ctx,
-               struct stream_alloc_block *block);
+                       struct sst_block *block);
 int sst_create_large_msg(struct ipc_post **arg);
 int sst_create_short_msg(struct ipc_post **arg);
 void sst_wake_up_alloc_block(struct intel_sst_drv *sst_drv_ctx,
index 61a70c4..58befa1 100644 (file)
@@ -73,7 +73,8 @@ static void sst_restore_fw_context(void)
        list_add_tail(&msg->node, &sst_drv_ctx->ipc_dispatch_list);
        spin_unlock(&sst_drv_ctx->list_spin_lock);
        sst_post_message(&sst_drv_ctx->ipc_post_msg_wq);
-       retval = sst_wait_timeout(sst_drv_ctx, &sst_drv_ctx->alloc_block[0]);
+       retval = sst_wait_timeout(sst_drv_ctx,
+                               &sst_drv_ctx->alloc_block[0].ops_block);
        sst_drv_ctx->alloc_block[0].sst_id = BLOCK_UNINIT;
        if (retval)
                pr_err("sst_restore_fw_context..timeout!\n");
@@ -106,7 +107,8 @@ int sst_download_fw(void)
        if (retval)
                goto end_restore;
 
-       retval = sst_wait_timeout(sst_drv_ctx, &sst_drv_ctx->alloc_block[0]);
+       retval = sst_wait_timeout(sst_drv_ctx,
+                               &sst_drv_ctx->alloc_block[0].ops_block);
        if (retval) {
                pr_err("fw download failed %d\n" , retval);
                /* assume FW d/l failed due to timeout*/
@@ -186,8 +188,7 @@ int sst_get_stream_allocated(struct snd_sst_params *str_param,
        str_id = retval;
        str_info = &sst_drv_ctx->streams[str_id];
        /* Block the call for reply */
-       retval = sst_wait_interruptible_timeout(sst_drv_ctx,
-                       &str_info->ctrl_blk, SST_BLOCK_TIMEOUT);
+       retval = sst_wait_timeout(sst_drv_ctx, &str_info->ctrl_blk);
        if ((retval != 0) || (str_info->ctrl_blk.ret_code != 0)) {
                pr_err("sst: FW alloc failed retval %d, ret_code %d\n",
                                retval, str_info->ctrl_blk.ret_code);
index eff7c93..75bdbc7 100644 (file)
@@ -526,7 +526,8 @@ static int sst_download_library(const struct firmware *fw_lib,
        list_add_tail(&msg->node, &sst_drv_ctx->ipc_dispatch_list);
        spin_unlock(&sst_drv_ctx->list_spin_lock);
        sst_post_message(&sst_drv_ctx->ipc_post_msg_wq);
-       retval = sst_wait_timeout(sst_drv_ctx, &sst_drv_ctx->alloc_block[i]);
+       retval = sst_wait_timeout(sst_drv_ctx,
+                               &sst_drv_ctx->alloc_block[i].ops_block);
        if (retval) {
                /* error */
                sst_drv_ctx->alloc_block[i].sst_id = BLOCK_UNINIT;
@@ -586,7 +587,8 @@ static int sst_download_library(const struct firmware *fw_lib,
        sst_post_message(&sst_drv_ctx->ipc_post_msg_wq);
        pr_debug("Waiting for FW response Download complete\n");
        sst_drv_ctx->alloc_block[i].ops_block.condition = false;
-       retval = sst_wait_timeout(sst_drv_ctx, &sst_drv_ctx->alloc_block[i]);
+       retval = sst_wait_timeout(sst_drv_ctx,
+                               &sst_drv_ctx->alloc_block[i].ops_block);
        if (retval) {
                /* error */
                sst_set_fw_state_locked(sst_drv_ctx, SST_UN_INIT);
index 9a0eb05..d78f140 100644 (file)
@@ -100,47 +100,6 @@ int sst_wait_interruptible(struct intel_sst_drv *sst_drv_ctx,
 
 }
 
-
-/*
- * sst_wait_interruptible_timeout - wait on event interruptable
- *
- * @sst_drv_ctx: Driver context
- * @block: Driver block to wait on
- * @timeout: time for wait on
- *
- * This function waits with a timeout value (and is interruptible) on a
- * given block event
- */
-int sst_wait_interruptible_timeout(
-                       struct intel_sst_drv *sst_drv_ctx,
-                       struct sst_block *block, int timeout)
-{
-       int retval = 0;
-
-       pr_debug("sst_wait_interruptible_timeout - waiting....\n");
-       if (wait_event_interruptible_timeout(sst_drv_ctx->wait_queue,
-                                               block->condition,
-                                               msecs_to_jiffies(timeout))) {
-               if (block->ret_code < 0)
-                       pr_err("stream failed %d\n", block->ret_code);
-               else
-                       pr_debug("event up\n");
-               retval = block->ret_code;
-       } else {
-               block->on = false;
-               pr_err("timeout occurred...\n");
-               /*setting firmware state as uninit so that the
-               firmware will get re-downloaded on next request
-               this is because firmare not responding for 5 sec
-               is equalant to some unrecoverable error of FW
-               sst_drv_ctx->sst_state = SST_UN_INIT;*/
-               retval = -EBUSY;
-       }
-       return retval;
-
-}
-
-
 /*
  * sst_wait_timeout - wait on event for timeout
  *
@@ -150,35 +109,32 @@ int sst_wait_interruptible_timeout(
  * This function waits with a timeout value (and is not interruptible) on a
  * given block event
  */
-int sst_wait_timeout(struct intel_sst_drv *sst_drv_ctx,
-               struct stream_alloc_block *block)
+int sst_wait_timeout(struct intel_sst_drv *sst_drv_ctx, struct sst_block *block)
 {
        int retval = 0;
 
        /* NOTE:
        Observed that FW processes the alloc msg and replies even
        before the alloc thread has finished execution */
-       pr_debug("waiting for %x, condition %x\n",
-                      block->sst_id, block->ops_block.condition);
-       if (wait_event_interruptible_timeout(sst_drv_ctx->wait_queue,
-                               block->ops_block.condition,
+       pr_debug("sst: waiting for condition %x\n",
+                      block->condition);
+       if (wait_event_timeout(sst_drv_ctx->wait_queue,
+                               block->condition,
                                msecs_to_jiffies(SST_BLOCK_TIMEOUT))) {
                /* event wake */
-               pr_debug("Event wake %x\n", block->ops_block.condition);
-               pr_debug("message ret: %d\n", block->ops_block.ret_code);
-               retval = block->ops_block.ret_code;
+               pr_debug("sst: Event wake %x\n", block->condition);
+               pr_debug("sst: message ret: %d\n", block->ret_code);
+               retval = block->ret_code;
        } else {
-               block->ops_block.on = false;
-               pr_err("Wait timed-out %x\n", block->ops_block.condition);
+               block->on = false;
+               pr_err("sst: Wait timed-out %x\n", block->condition);
                /* settign firmware state as uninit so that the
                firmware will get redownloaded on next request
                this is because firmare not responding for 5 sec
-               is equalant to some unrecoverable error of FW
-               sst_drv_ctx->sst_state = SST_UN_INIT;*/
+               is equalant to some unrecoverable error of FW */
                retval = -EBUSY;
        }
        return retval;
-
 }
 
 /*
@@ -288,7 +244,6 @@ void sst_wake_up_alloc_block(struct intel_sst_drv *sst_drv_ctx,
  */
 int sst_enable_rx_timeslot(int status)
 {
-       int retval = 0;
        struct ipc_post *msg = NULL;
 
        if (sst_create_short_msg(&msg)) {
@@ -306,7 +261,5 @@ int sst_enable_rx_timeslot(int status)
                        &sst_drv_ctx->ipc_dispatch_list);
        spin_unlock(&sst_drv_ctx->list_spin_lock);
        sst_post_message(&sst_drv_ctx->ipc_post_msg_wq);
-       retval = sst_wait_interruptible_timeout(sst_drv_ctx,
-                               &sst_drv_ctx->hs_info_blk, SST_BLOCK_TIMEOUT);
-       return retval;
+       return sst_wait_timeout(sst_drv_ctx, &sst_drv_ctx->hs_info_blk);
 }
index 174f14f..b52cc7b 100644 (file)
@@ -322,8 +322,7 @@ int sst_get_fw_info(struct snd_sst_fw_info *info)
        list_add_tail(&msg->node, &sst_drv_ctx->ipc_dispatch_list);
        spin_unlock(&sst_drv_ctx->list_spin_lock);
        sst_post_message(&sst_drv_ctx->ipc_post_msg_wq);
-       retval = sst_wait_interruptible_timeout(sst_drv_ctx,
-                       &sst_drv_ctx->fw_info_blk, SST_BLOCK_TIMEOUT);
+       retval = sst_wait_timeout(sst_drv_ctx, &sst_drv_ctx->fw_info_blk);
        if (retval) {
                pr_err("SST ERR: error in fw_info = %d\n", retval);
                retval = -EIO;
@@ -403,8 +402,7 @@ int sst_pause_stream(int str_id)
                                &sst_drv_ctx->ipc_dispatch_list);
                spin_unlock(&sst_drv_ctx->list_spin_lock);
                sst_post_message(&sst_drv_ctx->ipc_post_msg_wq);
-               retval = sst_wait_interruptible_timeout(sst_drv_ctx,
-                               &str_info->ctrl_blk, SST_BLOCK_TIMEOUT);
+               retval = sst_wait_timeout(sst_drv_ctx, &str_info->ctrl_blk);
                if (retval == 0) {
                        str_info->prev = str_info->status;
                        str_info->status = STREAM_PAUSED;
@@ -460,8 +458,7 @@ int sst_resume_stream(int str_id)
                                &sst_drv_ctx->ipc_dispatch_list);
                spin_unlock(&sst_drv_ctx->list_spin_lock);
                sst_post_message(&sst_drv_ctx->ipc_post_msg_wq);
-               retval = sst_wait_interruptible_timeout(sst_drv_ctx,
-                               &str_info->ctrl_blk, SST_BLOCK_TIMEOUT);
+               retval = sst_wait_timeout(sst_drv_ctx, &str_info->ctrl_blk);
                if (!retval) {
                        if (str_info->prev == STREAM_RUNNING)
                                str_info->status = STREAM_RUNNING;
@@ -633,8 +630,7 @@ int sst_free_stream(int str_id)
                str_info->ctrl_blk.on = true;
                str_info->ctrl_blk.condition = false;
                sst_post_message(&sst_drv_ctx->ipc_post_msg_wq);
-               retval = sst_wait_interruptible_timeout(sst_drv_ctx,
-                               &str_info->ctrl_blk, SST_BLOCK_TIMEOUT);
+               retval = sst_wait_timeout(sst_drv_ctx, &str_info->ctrl_blk);
                pr_debug("sst: wait for free returned %d\n", retval);
                mutex_lock(&sst_drv_ctx->stream_lock);
                sst_clean_stream(str_info);
index 7675dc6..074a463 100644 (file)
@@ -87,8 +87,7 @@ int sst_get_stream_params(int str_id,
                list_add_tail(&msg->node, &sst_drv_ctx->ipc_dispatch_list);
                spin_unlock(&sst_drv_ctx->list_spin_lock);
                sst_post_message(&sst_drv_ctx->ipc_post_msg_wq);
-               retval = sst_wait_interruptible_timeout(sst_drv_ctx,
-                               &str_info->ctrl_blk, SST_BLOCK_TIMEOUT);
+               retval = sst_wait_timeout(sst_drv_ctx, &str_info->ctrl_blk);
                if (retval) {
                        get_params->codec_params.result = retval;
                        kfree(fw_params);
@@ -157,8 +156,7 @@ int sst_set_stream_param(int str_id, struct snd_sst_params *str_param)
                list_add_tail(&msg->node, &sst_drv_ctx->ipc_dispatch_list);
                spin_unlock(&sst_drv_ctx->list_spin_lock);
                sst_post_message(&sst_drv_ctx->ipc_post_msg_wq);
-               retval = sst_wait_interruptible_timeout(sst_drv_ctx,
-                               &str_info->ctrl_blk, SST_BLOCK_TIMEOUT);
+               retval = sst_wait_timeout(sst_drv_ctx, &str_info->ctrl_blk);
                if (retval < 0) {
                        retval = -EIO;
                        sst_clean_stream(str_info);
@@ -206,8 +204,7 @@ int sst_get_vol(struct snd_sst_vol *get_vol)
        list_add_tail(&msg->node, &sst_drv_ctx->ipc_dispatch_list);
        spin_unlock(&sst_drv_ctx->list_spin_lock);
        sst_post_message(&sst_drv_ctx->ipc_post_msg_wq);
-       retval = sst_wait_interruptible_timeout(sst_drv_ctx,
-                       &sst_drv_ctx->vol_info_blk, SST_BLOCK_TIMEOUT);
+       retval = sst_wait_timeout(sst_drv_ctx, &sst_drv_ctx->vol_info_blk);
        if (retval)
                retval = -EIO;
        else {
@@ -253,8 +250,7 @@ int sst_set_vol(struct snd_sst_vol *set_vol)
        list_add_tail(&msg->node, &sst_drv_ctx->ipc_dispatch_list);
        spin_unlock(&sst_drv_ctx->list_spin_lock);
        sst_post_message(&sst_drv_ctx->ipc_post_msg_wq);
-       retval = sst_wait_interruptible_timeout(sst_drv_ctx,
-                       &sst_drv_ctx->vol_info_blk, SST_BLOCK_TIMEOUT);
+       retval = sst_wait_timeout(sst_drv_ctx, &sst_drv_ctx->vol_info_blk);
        if (retval) {
                pr_err("error in set_vol = %d\n", retval);
                retval = -EIO;
@@ -296,8 +292,7 @@ int sst_set_mute(struct snd_sst_mute *set_mute)
        list_add_tail(&msg->node, &sst_drv_ctx->ipc_dispatch_list);
        spin_unlock(&sst_drv_ctx->list_spin_lock);
        sst_post_message(&sst_drv_ctx->ipc_post_msg_wq);
-       retval = sst_wait_interruptible_timeout(sst_drv_ctx,
-                       &sst_drv_ctx->mute_info_blk, SST_BLOCK_TIMEOUT);
+       retval = sst_wait_timeout(sst_drv_ctx, &sst_drv_ctx->mute_info_blk);
        if (retval) {
                pr_err("error in set_mute = %d\n", retval);
                retval = -EIO;
@@ -372,9 +367,8 @@ static int sst_send_target(struct snd_sst_target_device *target)
        list_add_tail(&msg->node, &sst_drv_ctx->ipc_dispatch_list);
        spin_unlock(&sst_drv_ctx->list_spin_lock);
        sst_post_message(&sst_drv_ctx->ipc_post_msg_wq);
-       pr_debug("message sent- waiting\n");
-       retval = sst_wait_interruptible_timeout(sst_drv_ctx,
-                       &sst_drv_ctx->tgt_dev_blk, TARGET_DEV_BLOCK_TIMEOUT);
+       pr_debug("sst: message sent- waiting\n");
+       retval = sst_wait_timeout(sst_drv_ctx, &sst_drv_ctx->tgt_dev_blk);
        if (retval)
                pr_err("target device ipc failed = 0x%x\n", retval);
        return retval;