From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S969929AbdAEAPb (ORCPT ); Wed, 4 Jan 2017 19:15:31 -0500 Received: from p3plsmtps2ded01.prod.phx3.secureserver.net ([208.109.80.58]:44914 "EHLO p3plsmtps2ded01.prod.phx3.secureserver.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965157AbdAEAP3 (ORCPT ); Wed, 4 Jan 2017 19:15:29 -0500 x-originating-ip: 72.167.245.219 From: Long Li To: "K. Y. Srinivasan" , Haiyang Zhang Cc: devel@linuxdriverproject.org, linux-kernel@vger.kernel.org, Long Li Subject: [PATCH v2] hv: retry infinitely on hypercall transient failures Date: Wed, 4 Jan 2017 18:12:20 -0800 Message-Id: <1483582340-26770-1-git-send-email-longli@exchange.microsoft.com> X-Mailer: git-send-email 1.7.4.1 X-CMAE-Envelope: MS4wfB6tA6Ai3opC/oid5V4SAwLdx3uoBvWXWcQzBXI0YtNcgO1pbpN1wL0XDEkD/OutobYgf1XprmPnsyp5xASj8lXw/SVoiMzAXGLdN9h5v1sueHWEptHS 5Q7ZYNZCJVYwp7YF7EzE+sy25SvuEsMuGTzeDiZC5d08iQBE4djStVM1D+YbNCqAeom+yxwmF/iYxW7mmZeKNAqmQBmgTW35S7pTdqfT8BdkPiYlO85Uot6c JJrUsMGzfODt8ELe08nvIFIi/opUvtxGhPsGAFenPGEVjdE/6V79nU348bTU4ooT2CPxCpebM9HN8EVKVVXzH/fTqxC2V4bE1i+t7L75GfQ= Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Long Li Hyper-v host guarantees that a hypercall will finish in reasonable time. Retry infinitely on transient failures to avoid returning error to upper layer. Signed-off-by: Long Li --- drivers/hv/connection.c | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/drivers/hv/connection.c b/drivers/hv/connection.c index 6ce8b87..4b3cfde 100644 --- a/drivers/hv/connection.c +++ b/drivers/hv/connection.c @@ -438,46 +438,44 @@ void vmbus_on_event(unsigned long data) int vmbus_post_msg(void *buffer, size_t buflen) { union hv_connection_id conn_id; - int ret = 0; - int retries = 0; + int ret; u32 usec = 1; conn_id.asu32 = 0; conn_id.u.id = VMBUS_MESSAGE_CONNECTION_ID; /* - * hv_post_message() can have transient failures because of - * insufficient resources. Retry the operation a couple of - * times before giving up. + * hv_post_message() can have transient failures. We retry infinitely + * on these failures because host guarantees hypercall will finish. */ - while (retries < 20) { + while (1) { ret = hv_post_message(conn_id, 1, buffer, buflen); switch (ret) { + /* + * Retry on transient failures: + * 1. HV_STATUS_INVALID_CONNECTION_ID: + * We send messages too frequently. + * + * 2. HV_STATUS_INSUFFICIENT_MEMORY and + * HV_STATUS_INSUFFICIENT_BUFFERS: + * The host is temporariliy running out of resources. + */ case HV_STATUS_INVALID_CONNECTION_ID: - /* - * We could get this if we send messages too - * frequently. - */ - ret = -EAGAIN; - break; case HV_STATUS_INSUFFICIENT_MEMORY: case HV_STATUS_INSUFFICIENT_BUFFERS: - ret = -ENOMEM; break; case HV_STATUS_SUCCESS: - return ret; + return 0; default: pr_err("hv_post_msg() failed; error code:%d\n", ret); return -EINVAL; } - retries++; udelay(usec); if (usec < 2048) usec *= 2; } - return ret; } /* -- 2.7.4