From: K. Y. Srinivasan Date: Wed, 27 Aug 2014 23:25:31 +0000 (-0700) Subject: Drivers: hv: vmbus: Cleanup vmbus_post_msg() X-Git-Tag: firefly_0821_release~3679^2~1355 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=55a5b2114b4783803cd5dfb6d237be2158329b6b;p=firefly-linux-kernel-4.4.55.git Drivers: hv: vmbus: Cleanup vmbus_post_msg() commit fdeebcc62279119dbeafbc1a2e39e773839025fd upstream. Posting messages to the host can fail because of transient resource related failures. Correctly deal with these failures and increase the number of attempts to post the message before giving up. In this version of the patch, I have normalized the error code to Linux error code. Signed-off-by: K. Y. Srinivasan Tested-by: Sitsofe Wheeler Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/hv/connection.c b/drivers/hv/connection.c index b9f5d295cbec..a3b555808768 100644 --- a/drivers/hv/connection.c +++ b/drivers/hv/connection.c @@ -393,10 +393,21 @@ int vmbus_post_msg(void *buffer, size_t buflen) * insufficient resources. Retry the operation a couple of * times before giving up. */ - while (retries < 3) { - ret = hv_post_message(conn_id, 1, buffer, buflen); - if (ret != HV_STATUS_INSUFFICIENT_BUFFERS) + while (retries < 10) { + ret = hv_post_message(conn_id, 1, buffer, buflen); + + switch (ret) { + case HV_STATUS_INSUFFICIENT_BUFFERS: + ret = -ENOMEM; + case -ENOMEM: + break; + case HV_STATUS_SUCCESS: return ret; + default: + pr_err("hv_post_msg() failed; error code:%d\n", ret); + return -EINVAL; + } + retries++; msleep(100); }