tegra_gr_comm: retry if tegra_gr_comm_send timeout

Bug 2779333

Change-Id: I337ed034258d298f1c46673be6c2ca4006967e6b
Signed-off-by: Haley Teng <hteng@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2268246
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Mikko Perttunen <mperttunen@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
Haley Teng
2019-12-25 00:08:28 +08:00
committed by Laxman Dewangan
parent 7fa087bc72
commit 85c3986920

View File

@@ -1,7 +1,7 @@
/*
* Tegra Graphics Virtualization Communication Framework
*
* Copyright (c) 2013-2018, NVIDIA Corporation. All rights reserved.
* Copyright (c) 2013-2019, NVIDIA Corporation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
@@ -469,6 +469,7 @@ int tegra_gr_comm_send(u32 peer, u32 index, void *data,
{
struct gr_comm_ivc_context *ivc_ctx;
struct gr_comm_queue *queue;
int retries = 10;
int ret;
if (index >= NUM_QUEUES)
@@ -487,14 +488,23 @@ int tegra_gr_comm_send(u32 peer, u32 index, void *data,
return -EINVAL;
if (!tegra_hv_ivc_can_write(ivc_ctx->cookie)) {
ret = wait_event_timeout(ivc_ctx->wq,
tegra_hv_ivc_can_write(ivc_ctx->cookie),
msecs_to_jiffies(500));
if (!ret) {
dev_err(&ivc_ctx->pdev->dev,
"%s timeout waiting for buffer\n", __func__);
return -ENOMEM;
}
do {
ret = wait_event_timeout(ivc_ctx->wq,
tegra_hv_ivc_can_write(ivc_ctx->cookie),
msecs_to_jiffies(500));
if (!ret) {
if (retries > 0) {
dev_warn(&ivc_ctx->pdev->dev,
"%s retrying (remaining %d times)\n",
__func__, retries--);
} else {
dev_err(&ivc_ctx->pdev->dev,
"%s timeout waiting for buffer\n",
__func__);
return -ENOMEM;
}
}
} while (!ret);
}
ret = tegra_hv_ivc_write(ivc_ctx->cookie, data, size);