summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorJubeom Kim <jubeomk@nvidia.com>2011-06-14 15:32:15 +0900
committerRohan Somvanshi <rsomvanshi@nvidia.com>2011-06-24 02:57:46 -0700
commitbdc441e9bebeb893b7e9ec383fd77869dbcefc09 (patch)
tree7dadf2a19dfdc006ce325c5711ecdb25a8eb8d37 /drivers
parent26c98cb216294230f5cc46055c48a0224989df80 (diff)
media: video: tegra: avp: Retry to connect to the AVP.
Sometimes avp_node_try_connect is failed. It is the timing problem between CPU and AVP. 1) Added the retry routine for avp-connection. 2) Increased the time-out value of msg_wait_ack_locked function from 200ms to 400ms. Bug 822104, 797362 Change-Id: I92cbbf232ee30179480270f41caf13611c101157 Reviewed-on: http://git-master/r/36439 Tested-by: Jubeom Kim <jubeomk@nvidia.com> Reviewed-by: Donghan Ryu <dryu@nvidia.com> Reviewed-by: Mayuresh Kulkarni <mkulkarni@nvidia.com> Reviewed-by: Bharat Nihalani <bnihalani@nvidia.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/media/video/tegra/avp/avp.c33
1 files changed, 24 insertions, 9 deletions
diff --git a/drivers/media/video/tegra/avp/avp.c b/drivers/media/video/tegra/avp/avp.c
index af0a9853f445..74d18f1a2ab6 100644
--- a/drivers/media/video/tegra/avp/avp.c
+++ b/drivers/media/video/tegra/avp/avp.c
@@ -361,7 +361,7 @@ static int msg_wait_ack_locked(struct tegra_avp_info *avp, u32 cmd, u32 *arg)
{
/* rem_ack is a pointer into shared memory that the AVP modifies */
volatile u32 *rem_ack = avp->msg_to_avp;
- unsigned long endtime = jiffies + HZ / 5;
+ unsigned long endtime = jiffies + msecs_to_jiffies(400);
int ret;
do {
@@ -539,6 +539,8 @@ static int avp_node_try_connect(struct trpc_node *node,
int ret;
unsigned long flags;
int len;
+ const int max_retry_cnt = 6;
+ int cnt = 0;
DBG(AVP_DBG_TRACE_TRPC_CONN, "%s: trying connect from %s\n", __func__,
port_name);
@@ -593,16 +595,29 @@ static int avp_node_try_connect(struct trpc_node *node,
* take the from_avp_lock and everything should stay consistent.
*/
recv_msg_lock(avp);
- mutex_lock(&avp->to_avp_lock);
- ret = msg_write(avp, &msg, sizeof(msg), NULL, 0);
- if (ret) {
- pr_err("%s: remote has not acked last message (%s)\n", __func__,
- port_name);
+ for (cnt = 0; cnt < max_retry_cnt; cnt++) {
+ /* Retry to connect to AVP at this function maximum 6 times.
+ * Because this section is protected by mutex and
+ * needed to re-send the CMD_CONNECT command by CPU
+ * if AVP didn't receive the command.
+ */
+ mutex_lock(&avp->to_avp_lock);
+ ret = msg_write(avp, &msg, sizeof(msg), NULL, 0);
+ if (ret) {
+ pr_err("%s: remote has not acked last message (%s)\n",
+ __func__, port_name);
+ mutex_unlock(&avp->to_avp_lock);
+ goto err_msg_write;
+ }
+ ret = msg_wait_ack_locked(avp, CMD_RESPONSE, &rinfo->rem_id);
mutex_unlock(&avp->to_avp_lock);
- goto err_msg_write;
+ if (!ret && rinfo->rem_id)
+ break;
+
+ /* Skip the sleep function at last retry count */
+ if ((cnt + 1) < max_retry_cnt)
+ usleep_range(100, 2000);
}
- ret = msg_wait_ack_locked(avp, CMD_RESPONSE, &rinfo->rem_id);
- mutex_unlock(&avp->to_avp_lock);
if (ret) {
pr_err("%s: remote end won't respond for '%s'\n", __func__,