Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp2006957imm; Thu, 24 May 2018 04:24:54 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqbUjXj2paJoRAs1E63m16Ct8n9gjlK9HUEciN6duvSA+VQ8/uuXjdMoWSAE7/vdcDI1Pnb X-Received: by 2002:a63:7145:: with SMTP id b5-v6mr5578230pgn.45.1527161094477; Thu, 24 May 2018 04:24:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527161094; cv=none; d=google.com; s=arc-20160816; b=wieP3fNOffymJTPyj/RRMvzYOs4XK+qru2UDJXhVksRea0mRCMCtZ89pq3//Ryryts hKollJuAQ/QjJnD2y3J46rLnt2zf28SB/HNSvVlwpNHh9e92XeiCbPlmUCJtZDu8vuH2 8C1lLGWyVvJ0ZB4Kx5jFtPKP7p9rtGoRW3BwtOMUcNPLd5qkVHBxo4mVlUGoQspQlumN ksabNjMcR7Fhxjv92v51bGR8l2yRi9cT8xD5UBKKlUQVVU4LY3hvBErdZ1g0U3HXiZSd FxDRxUiwM56QozJ2T4sosAVG53Q/qnF7duTCpuLR84OrsErXxFqJSYgwva9v1qRSxZHP 9Gag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=cXmjA84Xqhe4IEjfZFByvU/EepibEAoeF1MVkxAJ7A0=; b=uElq00ovZUYK80+wmoB6R226vrwZJ+HNwRS9/wyxWF5T0ZcPQa5dKDXtWpyiShInfh 9QuR36ZhSBPtKvTRAsDPTlG9Vv8O9O1sIwjBWv6+FKbVgknTEf0pwt0YcZ9jiK3AaWra QbRJwAW6DPL/7h1efKAcCT4cz9AjGkPA80o4FafNIuvHCO5qjhuK77/rRqshezfeKF4g p7VfO5o8YNKLrbsk6EmUnj/o80TvtAQEnoEyXRJr8OBsLEWb2RrlJoqKAKglSHVSsvY9 LtlK3Ido15bzlSEDzfhgFMJgKWMFr0YoKHEGNo2UglltQnxVo6w+iih794livnCjwiL5 n7WA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=mJvqUwCP; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q4-v6si17252614pgr.549.2018.05.24.04.24.39; Thu, 24 May 2018 04:24:54 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=mJvqUwCP; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S967913AbeEXLXu (ORCPT + 99 others); Thu, 24 May 2018 07:23:50 -0400 Received: from mail.kernel.org ([198.145.29.99]:49312 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S967807AbeEXJwG (ORCPT ); Thu, 24 May 2018 05:52:06 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (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 DF59320847; Thu, 24 May 2018 09:52:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527155525; bh=fdLUq8DkfOsIWLP+90Ygt1fNIH8y172JSfbGB0IRv2Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mJvqUwCPMKA8jvDzHExl2LHZagrh+B6AVSd2Ie/HnU/Ky+LCIwHlgRJlUim3dwwg0 I/CuwXJCq37DYJkNRBMZGQLbj/cjy3VTkFBo3Hau4cQn/SKS4bGxALfunKh+Vsj8qG DDpUTOjp1wFSo8NIIt72rx1D589DJVlfdbJ+Z9b4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Stephen Hemminger , "David S. Miller" Subject: [PATCH 4.14 021/165] hv_netvsc: avoid retry on send during shutdown Date: Thu, 24 May 2018 11:37:07 +0200 Message-Id: <20180524093622.835733732@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180524093621.979359379@linuxfoundation.org> References: <20180524093621.979359379@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Stephen Hemminger [ Commit 12f69661a49446840d742d8feb593ace022d9f66 upstream. ] Change the initialization order so that the device is ready to transmit (ie connect vsp is completed) before setting the internal reference to the device with RCU. This avoids any races on initialization and prevents retry issues on shutdown. Signed-off-by: Stephen Hemminger Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- drivers/net/hyperv/netvsc.c | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) --- a/drivers/net/hyperv/netvsc.c +++ b/drivers/net/hyperv/netvsc.c @@ -850,13 +850,6 @@ int netvsc_send(struct net_device *ndev, if (unlikely(!net_device || net_device->destroy)) return -ENODEV; - /* We may race with netvsc_connect_vsp()/netvsc_init_buf() and get - * here before the negotiation with the host is finished and - * send_section_map may not be allocated yet. - */ - if (unlikely(!net_device->send_section_map)) - return -EAGAIN; - nvchan = &net_device->chan_table[packet->q_idx]; packet->send_buf_index = NETVSC_INVALID_INDEX; packet->cp_partial = false; @@ -864,10 +857,8 @@ int netvsc_send(struct net_device *ndev, /* Send control message directly without accessing msd (Multi-Send * Data) field which may be changed during data packet processing. */ - if (!skb) { - cur_send = packet; - goto send_now; - } + if (!skb) + return netvsc_send_pkt(device, packet, net_device, pb, skb); /* batch packets in send buffer if possible */ msdp = &nvchan->msd; @@ -951,7 +942,6 @@ int netvsc_send(struct net_device *ndev, } } -send_now: if (cur_send) ret = netvsc_send_pkt(device, cur_send, net_device, pb, skb); @@ -1308,11 +1298,6 @@ struct netvsc_device *netvsc_device_add( napi_enable(&net_device->chan_table[0].napi); - /* Writing nvdev pointer unlocks netvsc_send(), make sure chn_table is - * populated. - */ - rcu_assign_pointer(net_device_ctx->nvdev, net_device); - /* Connect with the NetVsp */ ret = netvsc_connect_vsp(device, net_device, device_info); if (ret != 0) { @@ -1321,6 +1306,11 @@ struct netvsc_device *netvsc_device_add( goto close; } + /* Writing nvdev pointer unlocks netvsc_send(), make sure chn_table is + * populated. + */ + rcu_assign_pointer(net_device_ctx->nvdev, net_device); + return net_device; close: