From nobody Sun Dec 28 23:13:31 2025 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 4A6A9C4167B for ; Tue, 5 Dec 2023 08:36:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346337AbjLEIgI (ORCPT ); Tue, 5 Dec 2023 03:36:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41448 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235483AbjLEIfa (ORCPT ); Tue, 5 Dec 2023 03:35:30 -0500 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 702BE191 for ; Tue, 5 Dec 2023 00:35:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1701765336; 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=+OP1NgMKKCzWtLe7quAE0mrqWNiRYPYGvVhdKqorCyI=; b=Ii06pIdtsAxZGf3JEaT1+koVOziYStQCAt8y3NeqqCevhAZjGV6cBJLbStb5lfVkO7oOoR BBJYOFhIFEqBumHTzBWWDgBdmCMU/h8QZhixUfNv8n4Ol44Cu9Uho+22dQ5BclvtwOS7X/ kGTknM6cJ0k2edJUKQzrDMUAUEJNEJs= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-56-Ts2cfc3cOLGP9ypVf0uzsA-1; Tue, 05 Dec 2023 03:35:35 -0500 X-MC-Unique: Ts2cfc3cOLGP9ypVf0uzsA-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id DDC833C0263D; Tue, 5 Dec 2023 08:35:34 +0000 (UTC) Received: from server.redhat.com (unknown [10.72.112.70]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5CBBB3C27; Tue, 5 Dec 2023 08:35:32 +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 v3 6/7] vduse: Update the vq_info in ioctl VDUSE_VQ_GET_INFO Date: Tue, 5 Dec 2023 16:34:43 +0800 Message-Id: <20231205083444.3029239-7-lulu@redhat.com> In-Reply-To: <20231205083444.3029239-1-lulu@redhat.com> References: <20231205083444.3029239-1-lulu@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.1 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Once the reconnect memory pages are mapped to userspace, the userspace application will update the "reconnected" bit in the "struct vduse_dev_reconnect_data". The kernel will then check this bit. If it is not set to "VDUSE_NOT_RECONNECT", it means that the application has been reconnected, and the kernel will synchronize the vq information. Signed-off-by: Cindy Lu --- drivers/vdpa/vdpa_user/vduse_dev.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/drivers/vdpa/vdpa_user/vduse_dev.c b/drivers/vdpa/vdpa_user/vd= use_dev.c index f55f415629de..422f1aedebac 100644 --- a/drivers/vdpa/vdpa_user/vduse_dev.c +++ b/drivers/vdpa/vdpa_user/vduse_dev.c @@ -1193,6 +1193,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; + unsigned long vaddr; + struct vduse_vq_state *vq_reconnect; + struct vduse_dev_reconnect_data *dev_reconnect; =20 ret =3D -EFAULT; if (copy_from_user(&vq_info, argp, sizeof(vq_info))) @@ -1209,6 +1212,12 @@ static long vduse_dev_ioctl(struct file *file, unsig= ned int cmd, vq_info.device_addr =3D vq->device_addr; vq_info.num =3D vq->num; =20 + vaddr =3D dev->vdpa_reconnect_vaddr; + dev_reconnect =3D (struct vduse_dev_reconnect_data *)vaddr; + + vaddr =3D vq->vdpa_reconnect_vaddr; + vq_reconnect =3D (struct vduse_vq_state *)vaddr; + if (dev->driver_features & BIT_ULL(VIRTIO_F_RING_PACKED)) { vq_info.packed.last_avail_counter =3D vq->state.packed.last_avail_counter; @@ -1218,9 +1227,22 @@ static long vduse_dev_ioctl(struct file *file, unsig= ned int cmd, vq->state.packed.last_used_counter; vq_info.packed.last_used_idx =3D vq->state.packed.last_used_idx; - } else + /*check if the vq is reconnect, if yes then update the info*/ + if (dev_reconnect->reconnected !=3D VDUSE_NOT_RECONNECT) { + vq_info.packed.last_avail_idx =3D + vq_reconnect->packed.last_avail_idx; + vq_info.packed.last_avail_counter =3D + vq_reconnect->packed.last_avail_counter; + } + } else { vq_info.split.avail_index =3D vq->state.split.avail_index; + /*check if the vq is reconnect, if yes then update the info*/ + if (dev_reconnect->reconnected !=3D VDUSE_NOT_RECONNECT) { + vq_info.split.avail_index =3D + vq_reconnect->split.avail_index; + } + } =20 vq_info.ready =3D vq->ready; =20 --=20 2.34.3