Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp139009rdb; Tue, 5 Dec 2023 00:36:32 -0800 (PST) X-Google-Smtp-Source: AGHT+IEUXodur7bRDnSJ1GcEQKT8YWpA0+Sthgx4zr8/jrb2/ekoOHUpQtFrZtKIrMwp4pXhmHCD X-Received: by 2002:a17:903:190:b0:1d0:b066:f83 with SMTP id z16-20020a170903019000b001d0b0660f83mr3190887plg.106.1701765392573; Tue, 05 Dec 2023 00:36:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701765392; cv=none; d=google.com; s=arc-20160816; b=E32aYCLnXxDW/kPm0qWX6TVDehgWSxakwKzJZZeiuUWDxQFEBWHU0/lNRmONOUmqnL IDwQI8a3gvAJLkKLSUPM2vVQ0kJSo2+YQe77dp18QAGJQjTg0mNghyT3HGGbPMCsZ5LG 74r+PfOuER4kP39WmsNQ7zH9eHNUezzp42T0+EEZzhchbHUnoKHZBO6tfSVNY+v59Pyr ysGH/jupdcYZ7rVre7aPtKTPfZCnoyEGeAkGnR8qJD3WwU3CeYBVVHwYTde+MNuRjNW/ wz4ueJZpHVntwUD1r0KjakgD1r7KiPzXU3HoI6eRIrbWgDfcvOaXFYwKYHafGEVL6fX7 Th4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=+OP1NgMKKCzWtLe7quAE0mrqWNiRYPYGvVhdKqorCyI=; fh=ARFoO5Pk7SniYIzyAg9Z8eUcw3AUCiaEHOgWusT66QQ=; b=IMw72sz4i7I+ufGhO3xlL6Jc39KwcS0u4nSuup3RNaqANKmr029tjkhDzvtPh6wq6h 0aPC8J9dJDd+4LqKaAGI9LSZRd8tP2fWgiYI7rXorzySlXKezejYtB9CB6soqMHRCxJN 2NgSfI3mtYwhmhevNNKv8+EjppFxFQ7TTyNqHOE3PhxK1jkub6vThNmXBk5SoL4Fmq75 LUVu2rRqy2kqK07vvv+WBLRa3JcThl11VfiWJNl7ZEb8Y0GR4jYBDTx840HyCeX1RTf1 zchZ0mMVDzZXt8alA7FqHxl7UQM+V6shcXxYPg5+PZRxTrqRH8r+xqkc1Mp3ko9nbuh8 A3SA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Ii06pIdt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id s1-20020a170902a50100b001d08ac11b93si4034265plq.374.2023.12.05.00.36.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Dec 2023 00:36:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Ii06pIdt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 3394980D7F56; Tue, 5 Dec 2023 00:36:29 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346448AbjLEIgH (ORCPT + 99 others); Tue, 5 Dec 2023 03:36:07 -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: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.1 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Tue, 05 Dec 2023 00:36:29 -0800 (PST) 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/vduse_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, unsigned 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; ret = -EFAULT; if (copy_from_user(&vq_info, argp, sizeof(vq_info))) @@ -1209,6 +1212,12 @@ static long vduse_dev_ioctl(struct file *file, unsigned int cmd, vq_info.device_addr = vq->device_addr; vq_info.num = vq->num; + vaddr = dev->vdpa_reconnect_vaddr; + dev_reconnect = (struct vduse_dev_reconnect_data *)vaddr; + + vaddr = vq->vdpa_reconnect_vaddr; + vq_reconnect = (struct vduse_vq_state *)vaddr; + if (dev->driver_features & BIT_ULL(VIRTIO_F_RING_PACKED)) { vq_info.packed.last_avail_counter = vq->state.packed.last_avail_counter; @@ -1218,9 +1227,22 @@ static long vduse_dev_ioctl(struct file *file, unsigned int cmd, vq->state.packed.last_used_counter; vq_info.packed.last_used_idx = vq->state.packed.last_used_idx; - } else + /*check if the vq is reconnect, if yes then update the info*/ + if (dev_reconnect->reconnected != VDUSE_NOT_RECONNECT) { + vq_info.packed.last_avail_idx = + vq_reconnect->packed.last_avail_idx; + vq_info.packed.last_avail_counter = + vq_reconnect->packed.last_avail_counter; + } + } else { vq_info.split.avail_index = vq->state.split.avail_index; + /*check if the vq is reconnect, if yes then update the info*/ + if (dev_reconnect->reconnected != VDUSE_NOT_RECONNECT) { + vq_info.split.avail_index = + vq_reconnect->split.avail_index; + } + } vq_info.ready = vq->ready; -- 2.34.3