public inbox for virtualization@lists.linux-foundation.org
 help / color / mirror / Atom feed
From: Jason Wang <jasowang@redhat.com>
To: "Eugenio Pérez" <eperezma@redhat.com>
Cc: "Michael S . Tsirkin" <mst@redhat.com>,
	Xuan Zhuo <xuanzhuo@linux.alibaba.com>,
	 Cindy Lu <lulu@redhat.com>, Laurent Vivier <lvivier@redhat.com>,
	 Stefano Garzarella <sgarzare@redhat.com>,
	linux-kernel@vger.kernel.org,
	 Maxime Coquelin <mcoqueli@redhat.com>,
	Yongji Xie <xieyongji@bytedance.com>,
	 virtualization@lists.linux.dev
Subject: Re: [PATCH 5/6] vduse: add F_QUEUE_READY feature
Date: Thu, 29 Jan 2026 10:12:39 +0800	[thread overview]
Message-ID: <CACGkMEtuAG-uZYJWZcsT1A0+QBCTOnkr7m0dt8MdbTwd5UNyNw@mail.gmail.com> (raw)
In-Reply-To: <20260128124524.875271-6-eperezma@redhat.com>

On Wed, Jan 28, 2026 at 8:45 PM Eugenio Pérez <eperezma@redhat.com> wrote:
>
> Add the VDUSE_F_QUEUE_READY feature flag. This allows the kernel module
> to explicitly signal userspace when a specific virtqueue has been
> enabled.
>
> In scenarios like Live Migration of VirtIO net devices, the dataplane
> starts after the control virtqueue allowing QEMU to apply configuration
> in the destination device.
>
> Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
> ---
>  drivers/vdpa/vdpa_user/vduse_dev.c | 28 +++++++++++++++++++++++++++-
>  include/uapi/linux/vduse.h         | 19 +++++++++++++++++++
>  2 files changed, 46 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/vdpa/vdpa_user/vduse_dev.c b/drivers/vdpa/vdpa_user/vduse_dev.c
> index e7da69c2ad71..1d93b540db4d 100644
> --- a/drivers/vdpa/vdpa_user/vduse_dev.c
> +++ b/drivers/vdpa/vdpa_user/vduse_dev.c
> @@ -9,6 +9,7 @@
>   */
>
>  #include "linux/virtio_net.h"
> +#include <linux/bits.h>
>  #include <linux/cleanup.h>
>  #include <linux/init.h>
>  #include <linux/module.h>
> @@ -53,7 +54,7 @@
>  #define IRQ_UNBOUND -1
>
>  /* Supported VDUSE features */
> -static const uint64_t vduse_features;
> +static const uint64_t vduse_features = BIT_U64(VDUSE_F_QUEUE_READY);
>
>  /*
>   * VDUSE instance have not asked the vduse API version, so assume 0.
> @@ -120,6 +121,7 @@ struct vduse_dev {
>         char *name;
>         struct mutex lock;
>         spinlock_t msg_lock;
> +       u64 vduse_features;
>         u64 msg_unique;
>         u32 msg_timeout;
>         wait_queue_head_t waitq;
> @@ -619,7 +621,30 @@ static void vduse_vdpa_set_vq_ready(struct vdpa_device *vdpa,
>  {
>         struct vduse_dev *dev = vdpa_to_vduse(vdpa);
>         struct vduse_virtqueue *vq = dev->vqs[idx];
> +       struct vduse_dev_msg msg = { 0 };
> +       int r;
> +
> +       if (!(dev->vduse_features & BIT_U64(VDUSE_F_QUEUE_READY)))
> +               goto out;
> +
> +       msg.req.type = VDUSE_SET_VQ_READY;
> +       msg.req.vq_ready.num = idx;
> +       msg.req.vq_ready.ready = !!ready;
> +
> +       r = vduse_dev_msg_sync(dev, &msg);
>
> +       if (r < 0) {
> +               dev_dbg(&vdpa->dev, "device refuses to set vq %u ready %u",
> +                       idx, ready);
> +
> +               /* We can't do better than break the device in this case */
> +               spin_lock(&dev->msg_lock);
> +               vduse_dev_broken(dev);

This has been done by vduse_dev_msg_sync().

Thanks

> +               spin_unlock(&dev->msg_lock);
> +               return;
> +       }
> +
> +out:
>         vduse_vq_set_ready(vq, ready);
>  }
>
> @@ -2121,6 +2146,7 @@ static int vduse_create_dev(struct vduse_dev_config *config,
>         dev->device_features = config->features;
>         dev->device_id = config->device_id;
>         dev->vendor_id = config->vendor_id;
> +       dev->vduse_features = config->vduse_features;
>
>         dev->nas = (dev->api_version < VDUSE_API_VERSION_1) ? 1 : config->nas;
>         dev->as = kcalloc(dev->nas, sizeof(dev->as[0]), GFP_KERNEL);
> diff --git a/include/uapi/linux/vduse.h b/include/uapi/linux/vduse.h
> index 1f68e556cbf2..1e27395692ea 100644
> --- a/include/uapi/linux/vduse.h
> +++ b/include/uapi/linux/vduse.h
> @@ -18,6 +18,9 @@
>
>  #define VDUSE_API_VERSION_2    2
>
> +/* The VDUSE instance expects a request for vq ready */
> +#define VDUSE_F_QUEUE_READY    0
> +
>  /*
>   * Get the version of VDUSE API that kernel supported (VDUSE_API_VERSION).
>   * This is used for future extension.
> @@ -330,6 +333,7 @@ enum vduse_req_type {
>         VDUSE_SET_STATUS,
>         VDUSE_UPDATE_IOTLB,
>         VDUSE_SET_VQ_GROUP_ASID,
> +       VDUSE_SET_VQ_READY,
>  };
>
>  /**
> @@ -376,6 +380,15 @@ struct vduse_iova_range_v2 {
>         __u32 asid;
>  };
>
> +/**
> + * struct vduse_vq_ready - Virtqueue ready request message
> + * @num: Virtqueue number
> + */
> +struct vduse_vq_ready {
> +       __u32 num;
> +       __u32 ready;
> +};
> +
>  /**
>   * struct vduse_dev_request - control request
>   * @type: request type
> @@ -386,6 +399,7 @@ struct vduse_iova_range_v2 {
>   * @iova: IOVA range for updating
>   * @iova_v2: IOVA range for updating if API_VERSION >= 1
>   * @vq_group_asid: ASID of a virtqueue group
> + * @vq_ready: Virtqueue ready request
>   * @padding: padding
>   *
>   * Structure used by read(2) on /dev/vduse/$NAME.
> @@ -403,6 +417,11 @@ struct vduse_dev_request {
>                  */
>                 struct vduse_iova_range_v2 iova_v2;
>                 struct vduse_vq_group_asid vq_group_asid;
> +               /*
> +                * Following members but padding exist only if vduse api
> +                * version >= 2
> +                */
> +               struct vduse_vq_ready vq_ready;
>                 __u32 padding[32];
>         };
>  };
> --
> 2.52.0
>


  reply	other threads:[~2026-01-29  2:12 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-28 12:45 [PATCH 0/6] Add queue ready message to VDUSE Eugenio Pérez
2026-01-28 12:45 ` [PATCH 1/6] vduse: ensure vq->ready access is smp safe Eugenio Pérez
2026-01-29  1:16   ` Jason Wang
2026-01-29  6:20     ` Eugenio Perez Martin
2026-01-30  2:18       ` Jason Wang
2026-01-30  7:56         ` Eugenio Perez Martin
2026-02-03  4:05           ` Jason Wang
2026-02-03 10:35             ` Eugenio Perez Martin
2026-02-04  2:48               ` Jason Wang
2026-02-04  8:53                 ` Eugenio Perez Martin
2026-02-05  4:04                   ` Jason Wang
2026-02-05  6:30                     ` Eugenio Perez Martin
2026-01-28 12:45 ` [PATCH 2/6] vduse: store control device pointer Eugenio Pérez
2026-01-28 12:45 ` [PATCH 3/6] vduse: Add API v2 definition Eugenio Pérez
2026-01-29  2:00   ` Jason Wang
2026-01-29  8:07     ` Eugenio Perez Martin
2026-01-30  2:17       ` Jason Wang
2026-01-30  8:12         ` Eugenio Perez Martin
2026-01-28 12:45 ` [PATCH 4/6] vduse: add VDUSE_GET_FEATURES ioctl Eugenio Pérez
2026-01-29  2:10   ` Jason Wang
2026-01-29  8:03     ` Eugenio Perez Martin
2026-01-28 12:45 ` [PATCH 5/6] vduse: add F_QUEUE_READY feature Eugenio Pérez
2026-01-29  2:12   ` Jason Wang [this message]
2026-01-29  6:26     ` Eugenio Perez Martin
2026-01-30  2:17       ` Jason Wang
2026-01-30  8:14         ` Eugenio Perez Martin
2026-02-03  4:00           ` Jason Wang
2026-02-03  7:27             ` Eugenio Perez Martin
2026-02-04  2:44               ` Jason Wang
2026-02-04  7:34                 ` Eugenio Perez Martin
2026-02-05  4:08                   ` Jason Wang
2026-02-05  6:38                     ` Eugenio Perez Martin
2026-01-28 12:45 ` [PATCH 6/6] vduse: advertise API V2 support Eugenio Pérez

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CACGkMEtuAG-uZYJWZcsT1A0+QBCTOnkr7m0dt8MdbTwd5UNyNw@mail.gmail.com \
    --to=jasowang@redhat.com \
    --cc=eperezma@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lulu@redhat.com \
    --cc=lvivier@redhat.com \
    --cc=mcoqueli@redhat.com \
    --cc=mst@redhat.com \
    --cc=sgarzare@redhat.com \
    --cc=virtualization@lists.linux.dev \
    --cc=xieyongji@bytedance.com \
    --cc=xuanzhuo@linux.alibaba.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox