From nobody Fri Jan 2 13:50:12 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id ABFD0CD98C7 for ; Wed, 11 Oct 2023 06:43:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345678AbjJKGnS (ORCPT ); Wed, 11 Oct 2023 02:43:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34154 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345551AbjJKGnP (ORCPT ); Wed, 11 Oct 2023 02:43:15 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B6BDF90 for ; Tue, 10 Oct 2023 23:42:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1697006546; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vn5HgvZLw9PSHjZMkQbhZJX5Gv2GT+cE9/aT+ZvVDqM=; b=hbCFNvVjzuVH9Kdf0UI6wqBQM2xr3U7xY2ymBeAW+UgrmGvwefc3pfm162iHVtNGwyE/TZ FzYSVRVlxAH4YH4itKRxNZtPQEEvqyw/f3C/A9gFP5YZ6zIWpI3Q7yDylkjSlAVEgD+1YP XW1Al6BgIH7hzOHl8JuYb2Aowjc2cVM= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-620-8nlMUVOiOHqTiyPZ8B1Ueg-1; Wed, 11 Oct 2023 02:42:24 -0400 X-MC-Unique: 8nlMUVOiOHqTiyPZ8B1Ueg-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8075B1C2B66B; Wed, 11 Oct 2023 06:42:24 +0000 (UTC) Received: from server.redhat.com (unknown [10.72.112.145]) by smtp.corp.redhat.com (Postfix) with ESMTP id ECE3863F55; Wed, 11 Oct 2023 06:42:21 +0000 (UTC) From: Cindy Lu To: lulu@redhat.com, jasowang@redhat.com, mst@redhat.com, xieyongji@bytedance.com, linux-kernel@vger.kernel.org, maxime.coquelin@redhat.com Subject: [PATCH v1 1/4] vduse: Add function to get/free the pages for reconnection Date: Wed, 11 Oct 2023 14:42:05 +0800 Message-Id: <20231011064208.2143245-2-lulu@redhat.com> In-Reply-To: <20231011064208.2143245-1-lulu@redhat.com> References: <20231011064208.2143245-1-lulu@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add the function vduse_alloc_reconnnect_info_mem and vduse_alloc_reconnnect_info_mem In this 2 function, vduse will get/free (vq_num + 1)*page =C2=A0 Page 0 will be used=C2=A0to save the reconnection information, The Userspace App will maintain this. Page 1 ~ vq_num + 1 will save the reconnection information for vqs. Signed-off-by: Cindy Lu --- drivers/vdpa/vdpa_user/vduse_dev.c | 78 ++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) diff --git a/drivers/vdpa/vdpa_user/vduse_dev.c b/drivers/vdpa/vdpa_user/vd= use_dev.c index 26b7e29cb900..565126a9ab01 100644 --- a/drivers/vdpa/vdpa_user/vduse_dev.c +++ b/drivers/vdpa/vdpa_user/vduse_dev.c @@ -30,6 +30,10 @@ #include #include =20 +#ifdef CONFIG_X86 +#include +#endif + #include "iova_domain.h" =20 #define DRV_AUTHOR "Yongji Xie " @@ -41,6 +45,19 @@ #define VDUSE_IOVA_SIZE (128 * 1024 * 1024) #define VDUSE_MSG_DEFAULT_TIMEOUT 30 =20 +/* struct vdpa_reconnect_info saved the alloc pages info + * these pages will mmaped to userspace for reconnection + */ +struct vdpa_reconnect_info { + /* Offset (within vm_file) in PAGE_SIZE + */ + u32 index; + /* virtual address for this page*/ + unsigned long vaddr; + /* allocated memory size, */ + phys_addr_t size; +}; + struct vduse_virtqueue { u16 index; u16 num_max; @@ -57,6 +74,7 @@ struct vduse_virtqueue { struct vdpa_callback cb; struct work_struct inject; struct work_struct kick; + struct vdpa_reconnect_info reconnect_info; }; =20 struct vduse_dev; @@ -106,6 +124,7 @@ struct vduse_dev { u32 vq_align; struct vduse_umem *umem; struct mutex mem_lock; + struct vdpa_reconnect_info reconnect_status; }; =20 struct vduse_dev_msg { @@ -1030,6 +1049,61 @@ static int vduse_dev_reg_umem(struct vduse_dev *dev, return ret; } =20 +static int vduse_alloc_reconnnect_info_mem(struct vduse_dev *dev) +{ + struct vdpa_reconnect_info *info; + struct vduse_virtqueue *vq; + void *addr; + + /*page 0 is use to save status,dpdk will use this to save the information + *needed in reconnection,kernel don't need to maintain this + */ + info =3D &dev->reconnect_status; + addr =3D (void *)get_zeroed_page(GFP_KERNEL); + if (!addr) + return -1; + + info->vaddr =3D (unsigned long)(addr); + info->size =3D PAGE_SIZE; + /* index is vm Offset in PAGE_SIZE */ + info->index =3D 0; + + /*page 1~ vq_num + 1 save the reconnect info for vqs*/ + for (int i =3D 0; i < dev->vq_num + 1; i++) { + vq =3D &dev->vqs[i]; + info =3D &vq->reconnect_info; + addr =3D (void *)get_zeroed_page(GFP_KERNEL); + if (!addr) + return -1; + + info->vaddr =3D (unsigned long)(addr); + info->size =3D PAGE_SIZE; + info->index =3D i + 1; + } + + return 0; +} + +static int vduse_free_reconnnect_info_mem(struct vduse_dev *dev) +{ + struct vdpa_reconnect_info *info; + struct vduse_virtqueue *vq; + + info =3D &dev->reconnect_status; + free_page(info->vaddr); + info->size =3D 0; + info->vaddr =3D 0; + for (int i =3D 0; i < dev->vq_num + 1; i++) { + vq =3D &dev->vqs[i]; + info =3D &vq->reconnect_info; + free_page(info->vaddr); + info->size =3D 0; + info->vaddr =3D 0; + } + + return 0; +} + static long vduse_dev_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { @@ -1390,6 +1464,8 @@ static int vduse_destroy_dev(char *name) mutex_unlock(&dev->lock); return -EBUSY; } + vduse_free_reconnnect_info_mem(dev); + dev->connected =3D true; mutex_unlock(&dev->lock); =20 @@ -1542,6 +1618,8 @@ static int vduse_create_dev(struct vduse_dev_config *= config, ret =3D PTR_ERR(dev->dev); goto err_dev; } + + vduse_alloc_reconnnect_info_mem(dev); __module_get(THIS_MODULE); =20 return 0; --=20 2.34.3 From nobody Fri Jan 2 13:50:12 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0EDAACD98C7 for ; Wed, 11 Oct 2023 06:43:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345700AbjJKGnU (ORCPT ); Wed, 11 Oct 2023 02:43:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34176 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345610AbjJKGnP (ORCPT ); Wed, 11 Oct 2023 02:43:15 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D82E998 for ; Tue, 10 Oct 2023 23:42:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1697006551; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=29YtgXv8n6Z+jTzRGYkc/Q2mHLXGKB5JoSFvVPqVJn0=; b=U54Za9U1wzF4vjM+nEsCKN5vMuAeDYCPrFB3nQ0XetQvix9KmC9S7eZPspABzRd/ZYVBK6 rYl5W6uwm4GFBVtC4EqaEe7svz4uTQug+eJ5qAeEtOpjO0yVV8HDbJkPkick1ikLXI1/dX ODWLoS7xh+diKkU4ZgSV7lJiUhXIaZg= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-674-gybUZXM6MsiCPClNZE-oFA-1; Wed, 11 Oct 2023 02:42:28 -0400 X-MC-Unique: gybUZXM6MsiCPClNZE-oFA-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A9DFE382134A; Wed, 11 Oct 2023 06:42:27 +0000 (UTC) Received: from server.redhat.com (unknown [10.72.112.145]) by smtp.corp.redhat.com (Postfix) with ESMTP id 226CC51E3; Wed, 11 Oct 2023 06:42:24 +0000 (UTC) From: Cindy Lu To: lulu@redhat.com, jasowang@redhat.com, mst@redhat.com, xieyongji@bytedance.com, linux-kernel@vger.kernel.org, maxime.coquelin@redhat.com Subject: [PATCH v1 2/4] vduse: Add file operation for mmap Date: Wed, 11 Oct 2023 14:42:06 +0800 Message-Id: <20231011064208.2143245-3-lulu@redhat.com> In-Reply-To: <20231011064208.2143245-1-lulu@redhat.com> References: <20231011064208.2143245-1-lulu@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Add the operation for mmap, The user space APP will use this function to map the pages to userspace Signed-off-by: Cindy Lu --- drivers/vdpa/vdpa_user/vduse_dev.c | 66 ++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/drivers/vdpa/vdpa_user/vduse_dev.c b/drivers/vdpa/vdpa_user/vd= use_dev.c index 565126a9ab01..05e72d752fb6 100644 --- a/drivers/vdpa/vdpa_user/vduse_dev.c +++ b/drivers/vdpa/vdpa_user/vduse_dev.c @@ -1380,6 +1380,70 @@ static struct vduse_dev *vduse_dev_get_from_minor(in= t minor) return dev; } =20 +static vm_fault_t vduse_vm_fault(struct vm_fault *vmf) +{ + struct vduse_dev *dev =3D vmf->vma->vm_file->private_data; + struct vm_area_struct *vma =3D vmf->vma; + u16 index =3D vma->vm_pgoff; + struct vduse_virtqueue *vq; + struct vdpa_reconnect_info *info; + + /* index 0 page reserved for vduse status*/ + if (index =3D=3D 0) { + info =3D &dev->reconnect_status; + } else { + /* index 1+vq_number page reserved for vduse vqs*/ + vq =3D &dev->vqs[index - 1]; + info =3D &vq->reconnect_info; + } + if (remap_pfn_range(vma, vmf->address & PAGE_MASK, + PFN_DOWN(virt_to_phys((void *)info->vaddr)), + PAGE_SIZE, vma->vm_page_prot)) + return VM_FAULT_SIGBUS; + return VM_FAULT_NOPAGE; +} + +static const struct vm_operations_struct vduse_vm_ops =3D { + .fault =3D vduse_vm_fault, +}; + +static int vduse_dev_mmap(struct file *file, struct vm_area_struct *vma) +{ + struct vduse_dev *dev =3D file->private_data; + struct vdpa_reconnect_info *info; + unsigned long index =3D vma->vm_pgoff; + struct vduse_virtqueue *vq; + + if (vma->vm_end - vma->vm_start !=3D PAGE_SIZE) + return -EINVAL; + if ((vma->vm_flags & VM_SHARED) =3D=3D 0) + return -EINVAL; + + if (index > dev->vq_num + 1) + return -EINVAL; + + /* index 0 page reserved for vduse status*/ + if (index =3D=3D 0) { + info =3D &dev->reconnect_status; + } else { + /* index 1+vq_number page reserved for vduse vqs*/ + vq =3D &dev->vqs[index - 1]; + info =3D &vq->reconnect_info; + } + if (info->vaddr =3D=3D 0) + return -ENOTSUPP; + + if (virt_to_phys((void *)info->vaddr) & (PAGE_SIZE - 1)) + return -EINVAL; + if (vma->vm_end - vma->vm_start !=3D info->size) + return -EOPNOTSUPP; + + vm_flags_set(vma, VM_IO | VM_DONTDUMP); + vma->vm_ops =3D &vduse_vm_ops; + + return 0; +} + static int vduse_dev_open(struct inode *inode, struct file *file) { int ret; @@ -1412,6 +1476,8 @@ static const struct file_operations vduse_dev_fops = =3D { .unlocked_ioctl =3D vduse_dev_ioctl, .compat_ioctl =3D compat_ptr_ioctl, .llseek =3D noop_llseek, + .mmap =3D vduse_dev_mmap, + }; =20 static struct vduse_dev *vduse_dev_create(void) --=20 2.34.3 From nobody Fri Jan 2 13:50:12 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7105ACD98F3 for ; Wed, 11 Oct 2023 06:43:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345813AbjJKGna (ORCPT ); Wed, 11 Oct 2023 02:43:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34184 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345840AbjJKGnW (ORCPT ); Wed, 11 Oct 2023 02:43:22 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 022E99E for ; Tue, 10 Oct 2023 23:42:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1697006552; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=csqBKeBkUZLQ+DInT3ODQljj1j3iH3HbX8W5xJ28ftc=; b=CRGl/ABCFt8cIeSlSDHagbI02GU1LHIzPAS32KojAgsVj15r2tma8vFigAarq2I4LPNxud dOTazPnoV74iJroDbtavF14Hi0EFyXnPR7jNnM9D7F3UiwMO7n3gH8+UW3HHz+qw/1lA55 n3L7f7NfWrGjvYe4uBbXzojFAh3eV5Y= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-28-ejz1fDbsMlCzYq1-sYFuig-1; Wed, 11 Oct 2023 02:42:31 -0400 X-MC-Unique: ejz1fDbsMlCzYq1-sYFuig-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D321F3C1E9D3; Wed, 11 Oct 2023 06:42:30 +0000 (UTC) Received: from server.redhat.com (unknown [10.72.112.145]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4BC8A51E3; Wed, 11 Oct 2023 06:42:27 +0000 (UTC) From: Cindy Lu To: lulu@redhat.com, jasowang@redhat.com, mst@redhat.com, xieyongji@bytedance.com, linux-kernel@vger.kernel.org, maxime.coquelin@redhat.com Subject: [PATCH v1 3/4] vduse: Add new ioctl VDUSE_GET_RECONNECT_INFO Date: Wed, 11 Oct 2023 14:42:07 +0800 Message-Id: <20231011064208.2143245-4-lulu@redhat.com> In-Reply-To: <20231011064208.2143245-1-lulu@redhat.com> References: <20231011064208.2143245-1-lulu@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" In VDUSE_GET_RECONNECT_INFO, the Userspace App can get the map size and The number of mapping memory pages from the kernel. The userspace App can use this information to map the pages. Add struct vhost_reconnect_data/vhost_reconnect_vring for sync the information in reconnection Signed-off-by: Cindy Lu --- drivers/vdpa/vdpa_user/vduse_dev.c | 15 +++++++++++ include/uapi/linux/vduse.h | 43 ++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) diff --git a/drivers/vdpa/vdpa_user/vduse_dev.c b/drivers/vdpa/vdpa_user/vd= use_dev.c index 05e72d752fb6..0f15e7ac716b 100644 --- a/drivers/vdpa/vdpa_user/vduse_dev.c +++ b/drivers/vdpa/vdpa_user/vduse_dev.c @@ -1347,6 +1347,21 @@ static long vduse_dev_ioctl(struct file *file, unsig= ned int cmd, ret =3D 0; break; } + case VDUSE_GET_RECONNECT_INFO: { + struct vduse_reconnect_mmap_info info; + + ret =3D -EFAULT; + if (copy_from_user(&info, argp, sizeof(info))) + break; + + info.size =3D PAGE_SIZE; + info.max_index =3D dev->vq_num + 1; + + if (copy_to_user(argp, &info, sizeof(info))) + break; + ret =3D 0; + break; + } default: ret =3D -ENOIOCTLCMD; break; diff --git a/include/uapi/linux/vduse.h b/include/uapi/linux/vduse.h index 11bd48c72c6c..5ccac535fba6 100644 --- a/include/uapi/linux/vduse.h +++ b/include/uapi/linux/vduse.h @@ -350,4 +350,47 @@ struct vduse_dev_response { }; }; =20 +/** + * struct vhost_reconnect_data - saved the reconnect info for device + * @reconnect_time: reconnect time for this device. userspace APP needs to= do ++ + * while reconnecting + * @version; version for userspace APP + * @features; Device features negotiated in the last reconnect. + * @status; Device status in last reconnect + * @nr_vrings; number of vqs + */ + +struct vhost_reconnect_data { + __u32 reconnect_time; + __u32 version; + __u64 features; + __u8 status; + __u32 nr_vrings; +}; + +/** + * struct vhost_reconnect_vring -saved the reconnect info for vqs + * @last_avail_idx: device available index + * @avail_wrap_counter: Driver ring wrap counter + */ +struct vhost_reconnect_vring { + __u16 last_avail_idx; + __u16 avail_wrap_counter; +}; + +/** + * struct vduse_reconnect_mmap_info + * @size: mapping memory size, here we use page_size + * @max_index: the number of pages allocated in kernel,just + * use for check + */ + +struct vduse_reconnect_mmap_info { + __u32 size; + __u32 max_index; +}; + +#define VDUSE_GET_RECONNECT_INFO \ + _IOWR(VDUSE_BASE, 0x1b, struct vduse_reconnect_mmap_info) + #endif /* _UAPI_VDUSE_H_ */ --=20 2.34.3 From nobody Fri Jan 2 13:50:12 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E8BC7CD98C7 for ; Wed, 11 Oct 2023 06:43:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345344AbjJKGnn (ORCPT ); Wed, 11 Oct 2023 02:43:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51076 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345661AbjJKGnj (ORCPT ); Wed, 11 Oct 2023 02:43:39 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D01D3B8 for ; Tue, 10 Oct 2023 23:42:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1697006579; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=J8XfKBq2pmFc/Yny5pdd3hd4sd8TR2HWxYu52ROyThk=; b=d12E2CWimQfAHJTaeBq5l3vl1whAGzrP97mYzBi1C1Ljl0sKpkHS0Jwt7KEUnjaQIUd5oW xzVOQBIkQ8fdRyOcmhhb+G+AzAZKrPKLX55l2QXCd3CIyE5Hl4fe08nPOlFyVYNviiCe+b fPrtBkIbcOlDS3LLjcQL56ZDpQT50UU= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-556-6Uomc1_pNba6ikcqIYWJBQ-1; Wed, 11 Oct 2023 02:42:55 -0400 X-MC-Unique: 6Uomc1_pNba6ikcqIYWJBQ-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 997D28F5DA3; Wed, 11 Oct 2023 06:42:55 +0000 (UTC) Received: from server.redhat.com (unknown [10.72.112.145]) by smtp.corp.redhat.com (Postfix) with ESMTP id 07AD01C06533; Wed, 11 Oct 2023 06:42:52 +0000 (UTC) From: Cindy Lu To: lulu@redhat.com, jasowang@redhat.com, mst@redhat.com, xieyongji@bytedance.com, linux-kernel@vger.kernel.org, maxime.coquelin@redhat.com Subject: [PATCH v1 4/4] vduse: update the vq_info in ioctl Date: Wed, 11 Oct 2023 14:42:08 +0800 Message-Id: <20231011064208.2143245-5-lulu@redhat.com> In-Reply-To: <20231011064208.2143245-1-lulu@redhat.com> References: <20231011064208.2143245-1-lulu@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.7 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" In VDUSE_VQ_GET_INFO, the driver will sync the last_avail_idx with reconnect info, After mapping the reconnect pages to userspace The userspace App will update the reconnect_time in struct vhost_reconnect_vring, If this is not 0 then it means this vq is reconnected and will update the last_avail_idx Signed-off-by: Cindy Lu --- drivers/vdpa/vdpa_user/vduse_dev.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/drivers/vdpa/vdpa_user/vduse_dev.c b/drivers/vdpa/vdpa_user/vd= use_dev.c index 0f15e7ac716b..42e7a90ab74c 100644 --- a/drivers/vdpa/vdpa_user/vduse_dev.c +++ b/drivers/vdpa/vdpa_user/vduse_dev.c @@ -1213,6 +1213,9 @@ static long vduse_dev_ioctl(struct file *file, unsign= ed int cmd, struct vduse_vq_info vq_info; struct vduse_virtqueue *vq; u32 index; + struct vdpa_reconnect_info *area; + struct vhost_reconnect_vring *vq_reconnect; + struct vhost_reconnect_data *dev_reconnect; =20 ret =3D -EFAULT; if (copy_from_user(&vq_info, argp, sizeof(vq_info))) @@ -1244,6 +1247,19 @@ static long vduse_dev_ioctl(struct file *file, unsig= ned int cmd, =20 vq_info.ready =3D vq->ready; =20 + area =3D &dev->reconnect_status; + dev_reconnect =3D (struct vhost_reconnect_data *)area->vaddr; + + area =3D &vq->reconnect_info; + vq_reconnect =3D (struct vhost_reconnect_vring *)area->vaddr; + /*check if the vq is reconnect, if yes then update the last_avail_idx*/ + if ((vq_reconnect->last_avail_idx !=3D + vq_info.split.avail_index) && + (dev_reconnect->reconnect_time !=3D 0)) { + vq_info.split.avail_index =3D + vq_reconnect->last_avail_idx; + } + ret =3D -EFAULT; if (copy_to_user(argp, &vq_info, sizeof(vq_info))) break; --=20 2.34.3