From patchwork Mon May 14 22:32:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 913313 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=networkplumber.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=networkplumber-org.20150623.gappssmtp.com header.i=@networkplumber-org.20150623.gappssmtp.com header.b="k7jUnIgE"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 40lFnt1GZgz9s1B for ; Tue, 15 May 2018 08:32:50 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752233AbeENWcr (ORCPT ); Mon, 14 May 2018 18:32:47 -0400 Received: from mail-pg0-f67.google.com ([74.125.83.67]:40606 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752186AbeENWcp (ORCPT ); Mon, 14 May 2018 18:32:45 -0400 Received: by mail-pg0-f67.google.com with SMTP id l2-v6so6083716pgc.7 for ; Mon, 14 May 2018 15:32:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=a9UssWTf0vEhq2l19w7vEKJ/Ri6hxy15Bq3p84zambQ=; b=k7jUnIgEjUP5JAiSyxBnRXnZHLKLGWH1OF9SnCwm2HV8FjUGPK7s2ZGQ6iJMSAlHkT FvOUjoBW9GTTPUB1cfYnJPnokxpDXHVvjJE7lljz0zdHukN3vkebVPhnYRsjaqV0hbpU Z0J6nFGlBr4NCMp2HK4Np9adk5STkjIQxBVlUxaGCetNsIzcQlRniFu8upu4ykJrsR3p 1Wxk6QkeDfOh0f/oeLI6+SfpAcc6xvvlJTL08ufJ8DJo08eRhidxgaRp+kfTS8/58gTD T8usw/r4UalHj4BHcUx5S1eZTGBfmKGWmYQ3+Ey43FmNtJ3Co9caKcT5ij5C2rvmI94k BC7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=a9UssWTf0vEhq2l19w7vEKJ/Ri6hxy15Bq3p84zambQ=; b=UldOf7fvqsVt1gCVukWX3dazEAcvqxK4BRhq3mGtA9xdlCYL1zxlKGEaXyyCLA5u0F XsaLRVW/j67VvGJJyD67nEZ76oH7qBd1QnQJacqz5ClPWqoCxd50N78TyGcuSO48Wa13 EpqRDiqJJvGjQdiPPGbaxDRLg3Xs+sggHqgmg4cE2rVOK9+TVXLp2ORa3Eyc68uUZsbI iYZ5Db9SSuXXy147gOV84rU8ErQh6897e6VzuRdB5/oN1eKOoocevv3Ewc9xg904dHiO bbs528r68v2xcEaaiodOPokUp18dzKEgd5glqnh1IQ5+jGia09/sKvTRSCVffuBp7rDo 1fPw== X-Gm-Message-State: ALKqPwc01iKS2pA9QU6SpeeZXYNWfm0MmhAhMDxGkUA/rQCjCaqbx/U9 oeD62dTZddAg23xzXlJp/5dvDA== X-Google-Smtp-Source: AB8JxZqqW6hGhZ/scqqCvYy6ELMFnS5wDo9uDvM2wSP1kWOGuZCm2orblj9SI0MPyKPePRqh+EvCOQ== X-Received: by 2002:a65:6604:: with SMTP id w4-v6mr9899693pgv.102.1526337164936; Mon, 14 May 2018 15:32:44 -0700 (PDT) Received: from xeon-e3.lan (204-195-35-107.wavecable.com. [204.195.35.107]) by smtp.gmail.com with ESMTPSA id y29-v6sm23827830pff.42.2018.05.14.15.32.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 14 May 2018 15:32:43 -0700 (PDT) From: Stephen Hemminger X-Google-Original-From: Stephen Hemminger To: davem@davemloft.net Cc: netdev@vger.kernel.org, Stephen Hemminger , Stephen Hemminger Subject: [PATCH net-stable 10/24] hv_netvsc: avoid retry on send during shutdown Date: Mon, 14 May 2018 15:32:09 -0700 Message-Id: <20180514223223.25433-11-sthemmin@microsoft.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180514223223.25433-1-sthemmin@microsoft.com> References: <20180514223223.25433-1-sthemmin@microsoft.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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 --- drivers/net/hyperv/netvsc.c | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c index 22da6399b37a..839b9d6ecb41 100644 --- 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(struct hv_device *device, 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(struct hv_device *device, 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: