* [dpdk-stable] [17.11] net/virtio-user: do not reset owner when driver resets
@ 2018-12-07 6:58 Yahui Cao
2018-12-11 18:54 ` Yongseok Koh
0 siblings, 1 reply; 2+ messages in thread
From: Yahui Cao @ 2018-12-07 6:58 UTC (permalink / raw)
To: tiwei.bie, Yuanhan Liu, Maxime Coquelin; +Cc: stable, zhihong.wang
[ backported from 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 <tiwei.bie@intel.com>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
Signed-off-by: Yahui Cao <yahui.cao@intel.com>
---
.../net/virtio/virtio_user/virtio_user_dev.c | 18 ++++++++++++++----
1 file changed, 14 insertions(+), 4 deletions(-)
diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c b/drivers/net/virtio/virtio_user/virtio_user_dev.c
index 7ce512c76..b13e77f5f 100644
--- a/drivers/net/virtio/virtio_user/virtio_user_dev.c
+++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c
@@ -166,17 +166,27 @@ virtio_user_start_device(struct virtio_user_dev *dev)
int virtio_user_stop_device(struct virtio_user_dev *dev)
{
+ struct vhost_vring_state state;
uint32_t i;
+ int error = 0;
for (i = 0; i < dev->max_queue_pairs; ++i)
dev->ops->enable_qp(dev, i, 0);
- if (dev->ops->send_request(dev, VHOST_USER_RESET_OWNER, NULL) < 0) {
- PMD_DRV_LOG(INFO, "Failed to reset the device\n");
- 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,
+ &state) < 0) {
+ PMD_DRV_LOG(ERR, "get_vring_base failed, index=%u\n",
+ i);
+ error = -1;
+ goto out;
+ }
}
- return 0;
+out:
+ return error;
}
static inline void
--
2.17.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [dpdk-stable] [17.11] net/virtio-user: do not reset owner when driver resets
2018-12-07 6:58 [dpdk-stable] [17.11] net/virtio-user: do not reset owner when driver resets Yahui Cao
@ 2018-12-11 18:54 ` Yongseok Koh
0 siblings, 0 replies; 2+ messages in thread
From: Yongseok Koh @ 2018-12-11 18:54 UTC (permalink / raw)
To: Yahui Cao; +Cc: tiwei.bie, Yuanhan Liu, Maxime Coquelin, stable, zhihong.wang
> On Dec 6, 2018, at 10:58 PM, Yahui Cao <yahui.cao@intel.com> wrote:
>
> [ backported from 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 <tiwei.bie@intel.com>
> Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
> Signed-off-by: Yahui Cao <yahui.cao@intel.com>
> ---
Applied to stable/17.11
Thanks,
Yongseok
> .../net/virtio/virtio_user/virtio_user_dev.c | 18 ++++++++++++++----
> 1 file changed, 14 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c b/drivers/net/virtio/virtio_user/virtio_user_dev.c
> index 7ce512c76..b13e77f5f 100644
> --- a/drivers/net/virtio/virtio_user/virtio_user_dev.c
> +++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c
> @@ -166,17 +166,27 @@ virtio_user_start_device(struct virtio_user_dev *dev)
>
> int virtio_user_stop_device(struct virtio_user_dev *dev)
> {
> + struct vhost_vring_state state;
> uint32_t i;
> + int error = 0;
>
> for (i = 0; i < dev->max_queue_pairs; ++i)
> dev->ops->enable_qp(dev, i, 0);
>
> - if (dev->ops->send_request(dev, VHOST_USER_RESET_OWNER, NULL) < 0) {
> - PMD_DRV_LOG(INFO, "Failed to reset the device\n");
> - 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,
> + &state) < 0) {
> + PMD_DRV_LOG(ERR, "get_vring_base failed, index=%u\n",
> + i);
> + error = -1;
> + goto out;
> + }
> }
>
> - return 0;
> +out:
> + return error;
> }
>
> static inline void
> --
> 2.17.1
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-12-11 18:54 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-07 6:58 [dpdk-stable] [17.11] net/virtio-user: do not reset owner when driver resets Yahui Cao
2018-12-11 18:54 ` Yongseok Koh
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).