From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-f66.google.com (mail-wm1-f66.google.com [209.85.128.66]) by dpdk.org (Postfix) with ESMTP id 17F3D4C8C for ; Thu, 8 Nov 2018 19:01:34 +0100 (CET) Received: by mail-wm1-f66.google.com with SMTP id p2-v6so2057871wmc.2 for ; Thu, 08 Nov 2018 10:01:34 -0800 (PST) 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:mime-version:content-transfer-encoding; bh=OK0FyauISN753XkLcq2JXm2oXDEeeTY0WV+PqjINUAE=; b=d4WPo00SIDBUsE9aHHtF2qnPK62gFf12Adi7FsSAi62f8ZS3mYTm/X1bYC2AwvNKLF svHZ5CmfrNPivBERtT4DH7U+siJBrC4S4LAA5Fq1lZ3jn9YZA2pgSl6mkXJA/CoCFmqh FIqTji3d/yknPUEZVaI77aDeTAoIQ5P2FkjwUYhnYniloUVM6XdF/lJBA/k574Z7YzBH dXKUM3hHBcwodldno+ABa2C4TRkbP0wP21yfEcK61zV6/zQOOyH+HF0U9HrBjhVILbkz tesFM5iESCTRkywwsSZU/2gZyORGREWl1FvsOvE2r97Gyh58KHYKsqSB09VBGeCt9dES YNpw== X-Gm-Message-State: AGRZ1gL2XpqIfLY/oWPL0NBh3Q6BJxTDqcXo/PohuEYVj2S8n7fD7A5q lqTAzhwosavyYqIZA67/YKU= X-Google-Smtp-Source: AJdET5fYBN9P4ghKhWr3aYm4qEFbZukCzEgapc1iztFifLZt/5pjq8zWNiu9dn1Y1L97mw4it6tfsw== X-Received: by 2002:a1c:7914:: with SMTP id l20-v6mr2164906wme.0.1541700093720; Thu, 08 Nov 2018 10:01:33 -0800 (PST) Received: from localhost ([2a01:4b00:f419:6f00:8361:8946:ba2b:d556]) by smtp.gmail.com with ESMTPSA id r126-v6sm5846110wmg.1.2018.11.08.10.01.32 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 08 Nov 2018 10:01:33 -0800 (PST) From: Luca Boccassi To: Tiwei Bie Cc: Maxime Coquelin , dpdk stable Date: Thu, 8 Nov 2018 18:01:02 +0000 Message-Id: <20181108180111.25873-6-bluca@debian.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181108180111.25873-1-bluca@debian.org> References: <20181029125329.17729-20-bluca@debian.org> <20181108180111.25873-1-bluca@debian.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-stable] patch 'net/virtio-user: do not reset owner when driver resets' has been queued to LTS release 16.11.9 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Nov 2018 18:01:34 -0000 Hi, FYI, your patch has been queued to LTS release 16.11.9 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 11/10/18. So please shout if anyone has objections. Also note that after the patch there's a diff of the upstream commit vs the patch applied to the branch. If the code is different (ie: not only metadata diffs), due for example to a change in context or macro names, please double check it. Thanks. Luca Boccassi --- >>From 4af6a676730e9fbebf916c17fce4bb41f7e52250 Mon Sep 17 00:00:00 2001 From: Tiwei Bie Date: Mon, 29 Oct 2018 13:28:05 +0800 Subject: [PATCH] net/virtio-user: do not reset owner when driver resets [ upstream commit 74dc6746a0f195907ec487df7de18a856108482f ] When driver resets the device, virtio-user just needs to send GET_VRING_BASE messages to stop the vhost backend, and that's what QEMU does. With this change, we won't need to set owner when starting virtio-user device anymore. This will help us to get rid of below error message on startup: vhost_kernel_ioctl(): VHOST_SET_OWNER failed: Device or resource busy Fixes: bce7e9050f9b ("net/virtio-user: fix start with kernel vhost") Fixes: 0d6a8752ac9d ("net/virtio-user: fix crash as features change") Signed-off-by: Tiwei Bie Reviewed-by: Maxime Coquelin --- drivers/net/virtio/virtio_user/virtio_user_dev.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c b/drivers/net/virtio/virtio_user/virtio_user_dev.c index 8bb155d8c..3e6787a04 100644 --- a/drivers/net/virtio/virtio_user/virtio_user_dev.c +++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c @@ -142,9 +142,6 @@ virtio_user_start_device(struct virtio_user_dev *dev) uint64_t features; int ret; - /* Do not check return as already done in init, or reset in stop */ - vhost_user_sock(dev->vhostfd, VHOST_USER_SET_OWNER, NULL); - /* Step 0: tell vhost to create queues */ if (virtio_user_queue_setup(dev, virtio_user_create_queue) < 0) goto error; @@ -185,6 +182,7 @@ error: int virtio_user_stop_device(struct virtio_user_dev *dev) { + struct vhost_vring_state state; uint32_t i; for (i = 0; i < dev->max_queue_pairs * 2; ++i) { @@ -195,6 +193,17 @@ int virtio_user_stop_device(struct virtio_user_dev *dev) for (i = 0; i < dev->max_queue_pairs; ++i) vhost_user_enable_queue_pair(dev->vhostfd, i, 0); + /* Stop the backend. */ + for (i = 0; i < dev->max_queue_pairs * 2; ++i) { + state.index = i; + if (vhost_user_sock(dev->vhostfd, VHOST_USER_GET_VRING_BASE, + &state) < 0) { + PMD_DRV_LOG(ERR, "get_vring_base failed, index=%u\n", + i); + return -1; + } + } + return 0; } -- 2.19.1 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2018-11-08 17:59:30.179161135 +0000 +++ 0006-net-virtio-user-do-not-reset-owner-when-driver-reset.patch 2018-11-08 17:59:30.048751011 +0000 @@ -1,8 +1,10 @@ -From 74dc6746a0f195907ec487df7de18a856108482f Mon Sep 17 00:00:00 2001 +From 4af6a676730e9fbebf916c17fce4bb41f7e52250 Mon Sep 17 00:00:00 2001 From: Tiwei Bie Date: Mon, 29 Oct 2018 13:28:05 +0800 Subject: [PATCH] net/virtio-user: do not reset owner when driver resets +[ upstream commit 74dc6746a0f195907ec487df7de18a856108482f ] + When driver resets the device, virtio-user just needs to send GET_VRING_BASE messages to stop the vhost backend, and that's what QEMU does. With this change, we won't need to set owner @@ -13,67 +15,53 @@ Fixes: bce7e9050f9b ("net/virtio-user: fix start with kernel vhost") Fixes: 0d6a8752ac9d ("net/virtio-user: fix crash as features change") -Cc: stable@dpdk.org Signed-off-by: Tiwei Bie Reviewed-by: Maxime Coquelin --- - .../net/virtio/virtio_user/virtio_user_dev.c | 22 ++++++++++++------- - 1 file changed, 14 insertions(+), 8 deletions(-) + drivers/net/virtio/virtio_user/virtio_user_dev.c | 15 ++++++++++++--- + 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c b/drivers/net/virtio/virtio_user/virtio_user_dev.c -index 0e3563051..0eb0f244b 100644 +index 8bb155d8c..3e6787a04 100644 --- a/drivers/net/virtio/virtio_user/virtio_user_dev.c +++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c -@@ -134,9 +134,6 @@ virtio_user_start_device(struct virtio_user_dev *dev) - if (is_vhost_user_by_type(dev->path) && dev->vhostfd < 0) - goto error; +@@ -142,9 +142,6 @@ virtio_user_start_device(struct virtio_user_dev *dev) + uint64_t features; + int ret; - /* Do not check return as already done in init, or reset in stop */ -- dev->ops->send_request(dev, VHOST_USER_SET_OWNER, NULL); +- vhost_user_sock(dev->vhostfd, VHOST_USER_SET_OWNER, NULL); - /* Step 0: tell vhost to create queues */ if (virtio_user_queue_setup(dev, virtio_user_create_queue) < 0) goto error; -@@ -181,7 +178,9 @@ error: +@@ -185,6 +182,7 @@ error: int virtio_user_stop_device(struct virtio_user_dev *dev) { + struct vhost_vring_state state; uint32_t i; -+ int error = 0; - pthread_mutex_lock(&dev->mutex); - if (!dev->started) -@@ -190,16 +189,23 @@ int virtio_user_stop_device(struct virtio_user_dev *dev) + for (i = 0; i < dev->max_queue_pairs * 2; ++i) { +@@ -195,6 +193,17 @@ int virtio_user_stop_device(struct virtio_user_dev *dev) for (i = 0; i < dev->max_queue_pairs; ++i) - dev->ops->enable_qp(dev, i, 0); + vhost_user_enable_queue_pair(dev->vhostfd, i, 0); -- if (dev->ops->send_request(dev, VHOST_USER_RESET_OWNER, NULL) < 0) { -- PMD_DRV_LOG(INFO, "Failed to reset the device\n"); -- pthread_mutex_unlock(&dev->mutex); -- return -1; + /* Stop the backend. */ + for (i = 0; i < dev->max_queue_pairs * 2; ++i) { + state.index = i; -+ if (dev->ops->send_request(dev, VHOST_USER_GET_VRING_BASE, ++ if (vhost_user_sock(dev->vhostfd, VHOST_USER_GET_VRING_BASE, + &state) < 0) { + PMD_DRV_LOG(ERR, "get_vring_base failed, index=%u\n", + i); -+ error = -1; -+ goto out; ++ return -1; + } - } ++ } + - dev->started = false; - out: - pthread_mutex_unlock(&dev->mutex); - -- return 0; -+ return error; + return 0; } - static inline void -- 2.19.1