From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.0 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,T_DKIMWL_WL_HIGH,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F005EC28CC0 for ; Thu, 30 May 2019 04:13:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CA059251C5 for ; Thu, 30 May 2019 04:13:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1559189585; bh=kr1mZsj8ygrObG5nQgZ3wG80bWrkj5wGYBAuMQDFlWQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=pp9UTY5UQHJ4ha6W9/JH2F9PyIABPgTEf2UCTAggjA5si6rSDSppnrI3B0oJ3gBBU BF+sy6tU7G2Y/gdZ4USfrsD3l6LO5MFW9q6v1mKm8hjI9R0CnTu3siHxxZYqI/GnoZ IKRng/Bkm+N4nJXy8dtzcF3IZplv+Nxju9Shshq0= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729905AbfE3ENA (ORCPT ); Thu, 30 May 2019 00:13:00 -0400 Received: from mail.kernel.org ([198.145.29.99]:42540 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730673AbfE3DQ1 (ORCPT ); Wed, 29 May 2019 23:16:27 -0400 Received: from localhost (ip67-88-213-2.z213-88-67.customer.algx.net [67.88.213.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E8CF52458C; Thu, 30 May 2019 03:16:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1559186187; bh=kr1mZsj8ygrObG5nQgZ3wG80bWrkj5wGYBAuMQDFlWQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zBvskeImPKfmHsilzgw7fB8c0ygSmsW/bCxU+kO6Cd5obV5u9J3OzePAOtaG+3ugH IOjWqMrgAyRuFRE3g2CvK/n8KW+jSgO0pc26c3zhNicR4i/9yH4PghZmnWj93FHJPE q+RRLb2oHFKb41HoRPpNHHZJRece6xB/1QWJvNe0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Haiyang Zhang , "David S. Miller" , Sasha Levin , Stephan Klein Subject: [PATCH 4.19 055/276] hv_netvsc: fix race that may miss tx queue wakeup Date: Wed, 29 May 2019 20:03:33 -0700 Message-Id: <20190530030528.713320653@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190530030523.133519668@linuxfoundation.org> References: <20190530030523.133519668@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit 93aa4792c3908eac87ddd368ee0fe0564148232b ] When the ring buffer is almost full due to RX completion messages, a TX packet may reach the "low watermark" and cause the queue stopped. If the TX completion arrives earlier than queue stopping, the wakeup may be missed. This patch moves the check for the last pending packet to cover both EAGAIN and success cases, so the queue will be reliably waked up when necessary. Reported-and-tested-by: Stephan Klein Signed-off-by: Haiyang Zhang Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/hyperv/netvsc.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c index fb12b63439c67..35413041dcf81 100644 --- a/drivers/net/hyperv/netvsc.c +++ b/drivers/net/hyperv/netvsc.c @@ -872,12 +872,6 @@ static inline int netvsc_send_pkt( } else if (ret == -EAGAIN) { netif_tx_stop_queue(txq); ndev_ctx->eth_stats.stop_queue++; - if (atomic_read(&nvchan->queue_sends) < 1 && - !net_device->tx_disable) { - netif_tx_wake_queue(txq); - ndev_ctx->eth_stats.wake_queue++; - ret = -ENOSPC; - } } else { netdev_err(ndev, "Unable to send packet pages %u len %u, ret %d\n", @@ -885,6 +879,15 @@ static inline int netvsc_send_pkt( ret); } + if (netif_tx_queue_stopped(txq) && + atomic_read(&nvchan->queue_sends) < 1 && + !net_device->tx_disable) { + netif_tx_wake_queue(txq); + ndev_ctx->eth_stats.wake_queue++; + if (ret == -EAGAIN) + ret = -ENOSPC; + } + return ret; } -- 2.20.1