From patchwork Fri Sep 2 14:39:12 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kyle Larose X-Patchwork-Id: 15596 X-Patchwork-Delegate: yuanhan.liu@linux.intel.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id EE23C4CE7; Fri, 2 Sep 2016 16:39:20 +0200 (CEST) Received: from TPC-E3-11-020.phaedrus.sandvine.com (lab.sandvine.com [98.159.241.2]) by dpdk.org (Postfix) with ESMTP id 0FF66FE5 for ; Fri, 2 Sep 2016 16:39:19 +0200 (CEST) Received: by TPC-E3-11-020.phaedrus.sandvine.com (Postfix, from userid 10523) id 47FB017C9; Fri, 2 Sep 2016 10:39:18 -0400 (EDT) From: Kyle Larose To: huawei.xie@intel.com, yuanhan.liu@linux.intel.com Cc: dev@dpdk.org, Kyle Larose Date: Fri, 2 Sep 2016 10:39:12 -0400 Message-Id: <1472827152-4321-1-git-send-email-klarose@sandvine.com> X-Mailer: git-send-email 1.8.3.1 Subject: [dpdk-dev] [PATCH] net/virtio: fix qemu exit on device stop/start X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Starting with DPDK 16.04, performing a start, then stop followed by a start on a virtio NIC sending traffic can cause qemu to exit. Qemu exits with a message like: 2016-09-01T15:45:32.119059Z qemu-kvm: Guest moved used index from 5 to 1 This appears to occur because virtio_dev_start will always reinitialize the virtio queues if virtio_dev_stop has been called. Prior to the patch that introduced the regression, virtio_dev_stop did not mark the device as stopped, so start would not actually reinitialize the queues. This fix reintroduces that behaviour by tracking whether or not the queues require initialization separately from whether or not the device has been stopped. It does this by introducing an "opened" flag to the device. A simple test with testpmd can reproduce the problem. 1. Set up two virtio ports, ideally connecting two devices which can ping one-another. 2. Start pinging between the devices 3. Start testpmd in interactive mode on the two virtio ports e.g. testpmd -w 0000:00:05.0 -w 0000:00:06.0 -- -i 4. Run the following commands a few times: start stop port stop 0 port stop 1 port start 0 port start 1 start 5. Qemu should exit with a "Guest moved ..." message. After applying this patch, I can no longer reproduce this problem. The ping resumes every time I start the ports back up. Test environment: - CPU: Intel(R) Xeon(R) CPU E5-2650 v2 @ 2.60GHz - Host OS: CentOS Linux release 7.1.1503 (Core) - Guest OS: CentOS Linux release 7.2.1511 (Core) - Qemu-kvm version: 1.5.3-86.el7_1.6 Fixes: 9a0615af7746 ("virtio: fix restart") Signed-off-by: Kyle Larose --- drivers/net/virtio/virtio_ethdev.c | 10 ++++++++-- drivers/net/virtio/virtio_pci.h | 1 + 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c index 07d6449..da796cb 100644 --- a/drivers/net/virtio/virtio_ethdev.c +++ b/drivers/net/virtio/virtio_ethdev.c @@ -558,6 +558,9 @@ virtio_dev_close(struct rte_eth_dev *dev) vtpci_reset(hw); virtio_dev_free_mbufs(dev); virtio_free_queues(dev); + + hw->opened = 0; + } static void @@ -1393,9 +1396,10 @@ virtio_dev_start(struct rte_eth_dev *dev) virtio_dev_link_update(dev, 0); /* On restart after stop do not touch queues */ - if (hw->started) + if (hw->opened) { + hw->started = 1; return 0; - + } /* Do final configuration before rx/tx engine starts */ virtio_dev_rxtx_start(dev); vtpci_reinit_complete(hw); @@ -1431,6 +1435,8 @@ virtio_dev_start(struct rte_eth_dev *dev) VIRTQUEUE_DUMP(txvq->vq); } + hw->opened = 1; + return 0; } diff --git a/drivers/net/virtio/virtio_pci.h b/drivers/net/virtio/virtio_pci.h index dd7693f..52911af 100644 --- a/drivers/net/virtio/virtio_pci.h +++ b/drivers/net/virtio/virtio_pci.h @@ -252,6 +252,7 @@ struct virtio_hw { uint8_t vlan_strip; uint8_t use_msix; uint8_t started; + uint8_t opened; uint8_t modern; uint8_t mac_addr[ETHER_ADDR_LEN]; uint32_t notify_off_multiplier;