From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: <3chas3@gmail.com> Received: from mail-it0-f67.google.com (mail-it0-f67.google.com [209.85.214.67]) by dpdk.org (Postfix) with ESMTP id 8416A4CA2 for ; Wed, 19 Sep 2018 17:47:33 +0200 (CEST) Received: by mail-it0-f67.google.com with SMTP id f14-v6so8906615ita.4 for ; Wed, 19 Sep 2018 08:47:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:sender:from:date:message-id :subject:to:cc; bh=p8wgMbE29blLe3aFzQYEV3vMApL95RLMhhU2FAYzHV0=; b=FZmmW3mO0pzQ+yJ47fVc392RLXKh2WVhMmjMxKv0owwiT0VMR90bjwRgPMFKUHTwrk X2D0IShSLMZsQArS31AOVTbKdQvP1DLgD/v1fxxMcPDOMewRemBt0u1dwkkEMFbUmCdf KGD0+9t0APxgjPaiYLOUG9Ecmbc1MK/PTn6RlcbAuhIxss4WErqztznuINGIlSlpjie2 /mrxXcgmxziLb+a5mrbUt9JTMflRE4lCo7hEROvwOGWYrq9aSiNyE5rsqmZz6trV7ZXZ WBCZxDc88wprIz9nLUIEqC05SuxYk2N9SCrSmPHnjlcqpZG119aZhn8ycal6ctKQ08O9 dcSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:sender:from :date:message-id:subject:to:cc; bh=p8wgMbE29blLe3aFzQYEV3vMApL95RLMhhU2FAYzHV0=; b=I2T0S5DxpnMDydvTo7U4ev6EXFf5S51s541PKgMwabcv4Hn3GZ8Qx665EChRfoMi33 8Zb0uLZfBcIX2pDH3iC9CC5F4H048TMzrNMWqASyBTl0a0BhbNjdXCm4Y7x+OoHeuf8Y BGF8ou5n0Xamesne6DTw3pgDQ7n5ZuyLelydFEU5ci4mW8JIL81NFOVL0ORlo0TejG+f D5JdQgiO4bne4ySLWQdakJWIYs8DHc4IDiKCqNkz+1JR6NGr5PKS5IlZlv8Cc+siNUXG 55K4pfnoSCLzNBhjMqTicrlbJ0ItnXidSBA4nNYjFvnrjEXY0E7B2drtSf5qMZIVhVlL XWEw== X-Gm-Message-State: APzg51CMABrbbQu/lyPiDDcXZfocE2kK3JndbcMxeL/NIZ5vUo3UKo4G uE4Q2uLugy1dA4W9L8BvyD1c9sgQfRgfQ+78kSU= X-Google-Smtp-Source: ANB0VdboPa2hwrtL+9eTpI22uthEi0wU/dGBHx4W/umXQr0FsY8AMJWB7DFmiL9LrevdaBaOfzjNTM5a8NeTUdr6oJU= X-Received: by 2002:a02:b38c:: with SMTP id p12-v6mr31202811jan.79.1537372052775; Wed, 19 Sep 2018 08:47:32 -0700 (PDT) MIME-Version: 1.0 References: <20180816135032.28283-1-bluca@debian.org> <20180919125757.17938-1-bluca@debian.org> <20180919125757.17938-2-bluca@debian.org> In-Reply-To: <20180919125757.17938-2-bluca@debian.org> Sender: chasmosaurus@gmail.com X-Google-Sender-Delegation: chasmosaurus@gmail.com From: Chas Williams <3chas3@gmail.com> Date: Wed, 19 Sep 2018 11:47:21 -0400 X-Google-Sender-Auth: 0uw-W2TKriCQrPEss2T26ijCvUQ Message-ID: To: bluca@debian.org Cc: dev@dpdk.org, Maxime Coquelin , tiwei.bie@intel.com, yongwang@vmware.com, Bruce Richardson , Jianfeng Tan , "Burakov, Anatoly" , llouis@vmware.com, brussell@vyatta.att-mail.com Content-Type: text/plain; charset="UTF-8" Subject: Re: [dpdk-dev] [PATCH v2 2/3] net/vmxnet3: fix vmxnet3 dev_uninit() hot-unplug X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 19 Sep 2018 15:47:33 -0000 On Wed, Sep 19, 2018 at 8:58 AM Luca Boccassi wrote: > > The vmxnet3 driver can't call back into dev_close(), and possibly > dev_stop(), in dev_uninit(). When dev_uninit() is called, anything > that those routines would want to clean up has already been released. > Further, for complete cleanup, it is necessary to release any of the > queue resources during dev_close(). > This allows a vmxnet3 device to be hot-unplugged without leaking > queues. > > Fixes: dfaff37fc46d ("vmxnet3: import new vmxnet3 poll mode driver implementation") > Cc: stable@dpdk.org > > Signed-off-by: Brian Russell > Signed-off-by: Luca Boccassi > --- > v2: add back extra close() call in uninit() for buggy applications as > requested by the reviewers, and add debug log noting the issue > > drivers/net/vmxnet3/vmxnet3_ethdev.c | 35 +++++++++++++++++++++++----- > 1 file changed, 29 insertions(+), 6 deletions(-) > > diff --git a/drivers/net/vmxnet3/vmxnet3_ethdev.c b/drivers/net/vmxnet3/vmxnet3_ethdev.c > index f1596ab19d..98e5d01890 100644 > --- a/drivers/net/vmxnet3/vmxnet3_ethdev.c > +++ b/drivers/net/vmxnet3/vmxnet3_ethdev.c > @@ -354,8 +354,10 @@ eth_vmxnet3_dev_uninit(struct rte_eth_dev *eth_dev) > if (rte_eal_process_type() != RTE_PROC_PRIMARY) > return 0; This should probably be EPERM as well. Out of scope though. > > - if (hw->adapter_stopped == 0) > + if (hw->adapter_stopped == 0) { > + PMD_INIT_LOG(DEBUG, "Device has not been closed."); > vmxnet3_dev_close(eth_dev); This just seems wrong. You have called uninit() will the driver is still busy. Instead of "fixing" the state of the driver, return EBUSY here. > + } > > eth_dev->dev_ops = NULL; > eth_dev->rx_pkt_burst = NULL; > @@ -802,7 +804,7 @@ vmxnet3_dev_stop(struct rte_eth_dev *dev) > PMD_INIT_FUNC_TRACE(); > > if (hw->adapter_stopped == 1) { > - PMD_INIT_LOG(DEBUG, "Device already closed."); > + PMD_INIT_LOG(DEBUG, "Device already stopped."); > return; > } > > @@ -826,7 +828,6 @@ vmxnet3_dev_stop(struct rte_eth_dev *dev) > /* reset the device */ > VMXNET3_WRITE_BAR1_REG(hw, VMXNET3_REG_CMD, VMXNET3_CMD_RESET_DEV); > PMD_INIT_LOG(DEBUG, "Device reset."); > - hw->adapter_stopped = 0; > > vmxnet3_dev_clear_queues(dev); > > @@ -836,6 +837,30 @@ vmxnet3_dev_stop(struct rte_eth_dev *dev) > link.link_speed = ETH_SPEED_NUM_10G; > link.link_autoneg = ETH_LINK_FIXED; > rte_eth_linkstatus_set(dev, &link); > + > + hw->adapter_stopped = 1; > +} > + > +static void > +vmxnet3_free_queues(struct rte_eth_dev *dev) > +{ > + int i; > + > + PMD_INIT_FUNC_TRACE(); > + > + for (i = 0; i < dev->data->nb_rx_queues; i++) { > + void *rxq = dev->data->rx_queues[i]; > + > + vmxnet3_dev_rx_queue_release(rxq); > + } > + dev->data->nb_rx_queues = 0; > + > + for (i = 0; i < dev->data->nb_tx_queues; i++) { > + void *txq = dev->data->tx_queues[i]; > + > + vmxnet3_dev_tx_queue_release(txq); > + } > + dev->data->nb_tx_queues = 0; > } > > /* > @@ -844,12 +869,10 @@ vmxnet3_dev_stop(struct rte_eth_dev *dev) > static void > vmxnet3_dev_close(struct rte_eth_dev *dev) > { > - struct vmxnet3_hw *hw = dev->data->dev_private; > - > PMD_INIT_FUNC_TRACE(); > > vmxnet3_dev_stop(dev); > - hw->adapter_stopped = 1; > + vmxnet3_free_queues(dev); > } > > static void > -- > 2.18.0 >