summaryrefslogtreecommitdiff
path: root/drivers/media
diff options
context:
space:
mode:
authorJubeom Kim <jubeomk@nvidia.com>2011-06-14 15:32:15 +0900
committerDan Willemsen <dwillemsen@nvidia.com>2011-11-30 21:47:22 -0800
commit3a091bc0c17558f0e4f84d2cceceb33142badf24 (patch)
tree53d13018cab5c370c522641ccd768dfbfd87751f /drivers/media
parentee95306a08528e24f4303bf2cc5bd6993940a452 (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 Reviewed-on: http://git-master/r/36439 (cherry picked from commit bdc441e9bebeb893b7e9ec383fd77869dbcefc09) Original-Change-Id: Ie5b31a50fb61691055ad41f0ac3ce627c08e0ebd Reviewed-on: http://git-master/r/38450 Tested-by: Jubeom Kim <jubeomk@nvidia.com> Reviewed-by: Bharat Nihalani <bnihalani@nvidia.com> Rebase-Id: R54b77903470a07927d37a220c5865b0ba6ff000d
Diffstat (limited to 'drivers/media')
-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 c5911b965026..e62da4ff4540 100644
--- a/drivers/media/video/tegra/avp/avp.c
+++ b/drivers/media/video/tegra/avp/avp.c
@@ -370,7 +370,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 {
@@ -548,6 +548,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);
@@ -602,16 +604,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__,