From patchwork Wed Mar 11 19:04:19 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: KY Srinivasan X-Patchwork-Id: 449111 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 44FAD1400DD for ; Thu, 12 Mar 2015 04:48:56 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752484AbbCKRsZ (ORCPT ); Wed, 11 Mar 2015 13:48:25 -0400 Received: from p3plsmtps2ded04.prod.phx3.secureserver.net ([208.109.80.198]:45808 "EHLO p3plsmtps2ded04.prod.phx3.secureserver.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751360AbbCKRsX (ORCPT ); Wed, 11 Mar 2015 13:48:23 -0400 Received: from linuxonhyperv.com ([72.167.245.219]) by p3plsmtps2ded04.prod.phx3.secureserver.net with : DED : id 2HoN1q05G4kklxU01HoNyR; Wed, 11 Mar 2015 10:48:22 -0700 x-originating-ip: 72.167.245.219 Received: by linuxonhyperv.com (Postfix, from userid 507) id 22FC31908BC; Wed, 11 Mar 2015 12:04:22 -0700 (PDT) From: "K. Y. Srinivasan" To: davem@davemloft.net, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, devel@linuxdriverproject.org, olaf@aepfle.de, apw@canonical.com, jasowang@redhat.com, gregkh@linuxfoundation.org Cc: "K. Y. Srinivasan" Subject: [PATCH V2 2/3 net-next] Drivers: hv: vmbus: Fix a bug in the signalling logic with kick_q Date: Wed, 11 Mar 2015 12:04:19 -0700 Message-Id: <1426100660-9547-2-git-send-email-kys@microsoft.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1426100660-9547-1-git-send-email-kys@microsoft.com> References: <1426100635-9508-1-git-send-email-kys@microsoft.com> <1426100660-9547-1-git-send-email-kys@microsoft.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org When the caller specifies that signalling should be deferred, we need to address the case where we are not able to place the current packet because the buffer is full. In this case, we will signal the host as some packets may have been placed on the ring buffer. I would like to thank Jason Wang for pointing out this issue. Signed-off-by: K. Y. Srinivasan --- drivers/hv/channel.c | 32 ++++++++++++++++++++++++++++++++ 1 files changed, 32 insertions(+), 0 deletions(-) diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c index e58cdb7..ae06ba9 100644 --- a/drivers/hv/channel.c +++ b/drivers/hv/channel.c @@ -614,8 +614,24 @@ int vmbus_sendpacket_ctl(struct vmbus_channel *channel, void *buffer, ret = hv_ringbuffer_write(&channel->outbound, bufferlist, 3, &signal); + /* + * Here is the logic for signalling the host: + * 1. If the host is already draining the ringbuffer, + * don't signal. This is indicated by the parameter + * "signal". + * + * 2. If we are not able to write, signal if kick_q is false. + * kick_q being false indicates that we may have placed zero or + * more packets with more packets to come. We will signal in + * this case even if potentially we may have not placed any + * packet. This is a rare enough condition that it should not + * matter. + */ + if ((ret == 0) && kick_q && signal) vmbus_setevent(channel); + else if ((ret != 0) && !kick_q) + vmbus_setevent(channel); return ret; } @@ -705,8 +721,24 @@ int vmbus_sendpacket_pagebuffer_ctl(struct vmbus_channel *channel, ret = hv_ringbuffer_write(&channel->outbound, bufferlist, 3, &signal); + /* + * Here is the logic for signalling the host: + * 1. If the host is already draining the ringbuffer, + * don't signal. This is indicated by the parameter + * "signal". + * + * 2. If we are not able to write, signal if kick_q is false. + * kick_q being false indicates that we may have placed zero or + * more packets with more packets to come. We will signal in + * this case even if potentially we may have not placed any + * packet. This is a rare enough condition that it should not + * matter. + */ + if ((ret == 0) && kick_q && signal) vmbus_setevent(channel); + else if ((ret != 0) && !kick_q) + vmbus_setevent(channel); return ret; }