From nobody Thu Apr 2 23:53:33 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5A66A3C9443 for ; Tue, 10 Mar 2026 19:08:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773169693; cv=none; b=GmfoMU4rJmeT15fMBd9r0kyajkcCRe+Iwz3FnZY7X75brZpFuRfquxTWhFudrxb4myWQaRXstcYKxtURbMrLuVOe44hohiQ/lOz4nd9/3zj/cAkHZeHDemPKifbEvOB4DOvqCsFXfLJ7MY559STC22+d3uTsTqzqf6adTmUhL38= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773169693; c=relaxed/simple; bh=3mS3+X9vmE7OTqs95H53lzU4UWMzZeS/2AcTH4YfG/0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=l8QV/snV1L3seENtwn2jb/jPnekebKgHU6S5wFG3A0gHp+J/fP2nXnkTi36QwLu8tgFpRvfdxoTf+YbWgjnyPBjer+n5unDoTFXEucVEBjcVXwKn8O2cr7CzE/KJwQkfibWqOzTgMrRez8jsaJPlkXRIj7gJm7p1hmwQ9qMExjI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=PMW0Oq53; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="PMW0Oq53" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1773169691; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=P+OGNrV7q92SEw+n+ligigLv3apRvr4chwlhOB9DrX4=; b=PMW0Oq537hQ7k6yqie3tMHRxmnop5L6Uwvd6bt+gZFtmp+0x8u+zf7b7qi9W2K29Vn4ZWo dOSeyB99wjf6LGXZ+GGhEifHzv5nxgLFoODtDa2AKedyW0JoTssW7M/+oyIiBtFfnfJYHY zcowyVCE8gzrfEnH6my3RcToX3PqXTc= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-424-vFe0Z5kDMuusEFhdDMHAVQ-1; Tue, 10 Mar 2026 15:08:10 -0400 X-MC-Unique: vFe0Z5kDMuusEFhdDMHAVQ-1 X-Mimecast-MFC-AGG-ID: vFe0Z5kDMuusEFhdDMHAVQ_1773169689 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (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 mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 212851956059; Tue, 10 Mar 2026 19:08:09 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.44.32.202]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 9EA623000223; Tue, 10 Mar 2026 19:08:05 +0000 (UTC) From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: "Michael S . Tsirkin" Cc: Cindy Lu , Xuan Zhuo , Jason Wang , linux-kernel@vger.kernel.org, Maxime Coquelin , Stefano Garzarella , =?UTF-8?q?Eugenio=20P=C3=A9rez?= , Laurent Vivier , Yongji Xie , virtualization@lists.linux.dev Subject: [PATCH v3 1/3] vduse: store control device pointer Date: Tue, 10 Mar 2026 20:07:57 +0100 Message-ID: <20260310190759.1097506-2-eperezma@redhat.com> In-Reply-To: <20260310190759.1097506-1-eperezma@redhat.com> References: <20260310190759.1097506-1-eperezma@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 This helps log the errors in next patches. The alternative is to perform a linear search for it with class_find_device_by_devt(class, devt), as device_destroy do for cleaning. Signed-off-by: Eugenio P=C3=A9rez --- drivers/vdpa/vdpa_user/vduse_dev.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/vdpa/vdpa_user/vduse_dev.c b/drivers/vdpa/vdpa_user/vd= use_dev.c index 405d59610f76..d1da7c15d98b 100644 --- a/drivers/vdpa/vdpa_user/vduse_dev.c +++ b/drivers/vdpa/vdpa_user/vduse_dev.c @@ -164,6 +164,7 @@ static DEFINE_IDR(vduse_idr); =20 static dev_t vduse_major; static struct cdev vduse_ctrl_cdev; +static const struct device *vduse_ctrl_dev; static struct cdev vduse_cdev; static struct workqueue_struct *vduse_irq_wq; static struct workqueue_struct *vduse_irq_bound_wq; @@ -2396,7 +2397,6 @@ static void vduse_mgmtdev_exit(void) static int vduse_init(void) { int ret; - struct device *dev; =20 ret =3D class_register(&vduse_class); if (ret) @@ -2413,9 +2413,9 @@ static int vduse_init(void) if (ret) goto err_ctrl_cdev; =20 - dev =3D device_create(&vduse_class, NULL, vduse_major, NULL, "control"); - if (IS_ERR(dev)) { - ret =3D PTR_ERR(dev); + vduse_ctrl_dev =3D device_create(&vduse_class, NULL, vduse_major, NULL, "= control"); + if (IS_ERR(vduse_ctrl_dev)) { + ret =3D PTR_ERR(vduse_ctrl_dev); goto err_device; } =20 --=20 2.53.0 From nobody Thu Apr 2 23:53:33 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6B7673B9DAF for ; Tue, 10 Mar 2026 19:08:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773169700; cv=none; b=WIfoAE53VynqPQbSvv+Q7PDx1yHjzYfW/bdKGoQWBoccmdNm7+UgbR2cD3d79XxwuI5DEfotc9r7bwKKflmAQg87sd2PljbdR5IyXr5V36IighQYhMdjlJ3M/yg8xzhDYKpUCMmyr9NsXhZtayq8ibBx11m0+g4P1IAWHv8fo2U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773169700; c=relaxed/simple; bh=ncC/iKjULSF6le8tRXIlP7leZiC3yrangGbjJey/sMo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Vpo2xjzaeM94NdW2IsPVHTJJRf1+Bs5+ac/eLiUQ9P62PEoFQiE0uCFekoWOBE3Lwt8/YMuv+ZRETl9W+iPMi0AmyJ3xL5sWi/E8TWEFlhU+fBQtElwL14+dnK0HVMqIhtNaXrnbWNQ7hlHgSN6N15LFSr6JlXuc5ObbzRen/Fc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=hQCH+h+X; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="hQCH+h+X" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1773169698; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lVibb6yQ9XHTIlzDSmdiJcpXSy41pi5u06RNTpNQkTA=; b=hQCH+h+XTvqQnpOJmk/iUzggHuu+w/jQt/ieUp8rgs+CNGMgLsiVpezh8SPIO/pyNHd7N2 8805QvLK9eHPt+livKJcKeFMITbEp0re1THlcgg8gT9O861ONaAWkyS8N4kQrbf7myJMP5 KX54TcutHg/feIyp8VCQDFNtHfuetkA= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-416-Urv9Ocu_PtWg8W8els8ONQ-1; Tue, 10 Mar 2026 15:08:15 -0400 X-MC-Unique: Urv9Ocu_PtWg8W8els8ONQ-1 X-Mimecast-MFC-AGG-ID: Urv9Ocu_PtWg8W8els8ONQ_1773169693 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (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 mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 2471C19560A7; Tue, 10 Mar 2026 19:08:13 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.44.32.202]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 9BA313000223; Tue, 10 Mar 2026 19:08:09 +0000 (UTC) From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: "Michael S . Tsirkin" Cc: Cindy Lu , Xuan Zhuo , Jason Wang , linux-kernel@vger.kernel.org, Maxime Coquelin , Stefano Garzarella , =?UTF-8?q?Eugenio=20P=C3=A9rez?= , Laurent Vivier , Yongji Xie , virtualization@lists.linux.dev Subject: [PATCH v3 2/3] vduse: add VDUSE_GET_FEATURES ioctl Date: Tue, 10 Mar 2026 20:07:58 +0100 Message-ID: <20260310190759.1097506-3-eperezma@redhat.com> In-Reply-To: <20260310190759.1097506-1-eperezma@redhat.com> References: <20260310190759.1097506-1-eperezma@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 Add an ioctl to allow VDUSE instances to query the available features supported by the kernel module. Signed-off-by: Eugenio P=C3=A9rez --- A simple u64 bitmap is used for feature flags. While a flexible array could support indefinite expansion, 64 bits is sufficient for the foreseeable future and simplifies the implementation. Also, dev_dbg is used for logging rather than dev_err as these can be triggered from userspace. --- v3: * Remove check for API_VERSION < 2 * Add comment about struct vduse_dev_config:vduse_features is only valid if VDUSE_GET_FEATURES success. v2: * return -EINVAL if ioctl called with version < 2, so userland visible reply is kept (Jason). --- drivers/vdpa/vdpa_user/vduse_dev.c | 7 +++++++ include/uapi/linux/vduse.h | 7 ++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/drivers/vdpa/vdpa_user/vduse_dev.c b/drivers/vdpa/vdpa_user/vd= use_dev.c index d1da7c15d98b..17e0358d3a68 100644 --- a/drivers/vdpa/vdpa_user/vduse_dev.c +++ b/drivers/vdpa/vdpa_user/vduse_dev.c @@ -52,6 +52,9 @@ =20 #define IRQ_UNBOUND -1 =20 +/* Supported VDUSE features */ +static const uint64_t vduse_features; + /* * VDUSE instance have not asked the vduse API version, so assume 0. * @@ -2207,6 +2210,10 @@ static long vduse_ioctl(struct file *file, unsigned = int cmd, ret =3D vduse_destroy_dev(name); break; } + case VDUSE_GET_FEATURES: + ret =3D put_user(vduse_features, (u64 __user *)argp); + break; + default: ret =3D -EINVAL; break; diff --git a/include/uapi/linux/vduse.h b/include/uapi/linux/vduse.h index 361eea511c21..e9b5f32a452d 100644 --- a/include/uapi/linux/vduse.h +++ b/include/uapi/linux/vduse.h @@ -33,6 +33,7 @@ * @vq_align: the allocation alignment of virtqueue's metadata * @ngroups: number of vq groups that VDUSE device declares * @nas: number of address spaces that VDUSE device declares + * @vduse_features: VDUSE features * @reserved: for future use, needs to be initialized to zero * @config_size: the size of the configuration space * @config: the buffer of the configuration space @@ -49,7 +50,8 @@ struct vduse_dev_config { __u32 vq_align; __u32 ngroups; /* if VDUSE_API_VERSION >=3D 1 */ __u32 nas; /* if VDUSE_API_VERSION >=3D 1 */ - __u32 reserved[11]; + __u64 vduse_features; /* if VDUSE_GET_FEATURES is not EINVAL */ + __u32 reserved[9]; __u32 config_size; __u8 config[]; }; @@ -63,6 +65,9 @@ struct vduse_dev_config { */ #define VDUSE_DESTROY_DEV _IOW(VDUSE_BASE, 0x03, char[VDUSE_NAME_MAX]) =20 +/* Get the VDUSE supported features */ +#define VDUSE_GET_FEATURES _IOR(VDUSE_BASE, 0x04, __u64) + /* The ioctls for VDUSE device (/dev/vduse/$NAME) */ =20 /** --=20 2.53.0 From nobody Thu Apr 2 23:53:33 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7A4183C457B for ; Tue, 10 Mar 2026 19:08:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773169703; cv=none; b=jR6eGu3/CwlCUNL26FgdPKpSxuK8N51IAMGyplIG4wMImEj5VnvKu9u2p58nXJp69rvfwuffaAAPbFp9aB66Ws+OFdvaL7rKMOHTYB88hmksO8hEMXQILkf66jDGMi2qz301jp+l+ony8oDc3dzChvwxOfIw2hS9ENl0MMxakY4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773169703; c=relaxed/simple; bh=H7lHk3Ysx6GZZZBAF6qLzH/CGGQwTNr7krSzUUGBMAQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=q60gm0+dEXoR0J8BaKWIYvpNTf4I/C5R7qNn7QSMjf2M0Y4xAnIfPMoEqxmqUsOMD9H9eG+bmZw0nEsZgqx+5buEP3xaPz0ePsP0VbBs9rkII9gsmpTIC3Gx3HE4nqW0F6JAKsMbUib2glPtR3ksu47gjw5VnEgbgrbQ0AwlCVw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=EVz9YDj+; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="EVz9YDj+" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1773169701; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QJUqS2imEFwTX0IL+wAxAJuGtqlBQ80n/ZGFHgQMJOI=; b=EVz9YDj+DKijoZQk/kPre9heXYkZ22gxjmje6vhE37DMH660tfn293/Y7zgnZz+4KXy9Ln Ip8CboHWkBuE1kt2XvsgiahUYtYh9J34IuWBQDCYb/EroI+m0sKOFBohjtDVZvQACAkyHl c/hnsB8oOF3KAsoyBl6AcUejXesvROQ= Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-511-ltkdpPluNVSUG8ex8nyaPw-1; Tue, 10 Mar 2026 15:08:18 -0400 X-MC-Unique: ltkdpPluNVSUG8ex8nyaPw-1 X-Mimecast-MFC-AGG-ID: ltkdpPluNVSUG8ex8nyaPw_1773169697 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (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 mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 205AF180060D; Tue, 10 Mar 2026 19:08:17 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.44.32.202]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 9D7F23000223; Tue, 10 Mar 2026 19:08:13 +0000 (UTC) From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: "Michael S . Tsirkin" Cc: Cindy Lu , Xuan Zhuo , Jason Wang , linux-kernel@vger.kernel.org, Maxime Coquelin , Stefano Garzarella , =?UTF-8?q?Eugenio=20P=C3=A9rez?= , Laurent Vivier , Yongji Xie , virtualization@lists.linux.dev Subject: [PATCH v3 3/3] vduse: add F_QUEUE_READY feature Date: Tue, 10 Mar 2026 20:07:59 +0100 Message-ID: <20260310190759.1097506-4-eperezma@redhat.com> In-Reply-To: <20260310190759.1097506-1-eperezma@redhat.com> References: <20260310190759.1097506-1-eperezma@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 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=C3=A9rez --- v2: * Fix comment of vduse_dev_request.vq_ready * Set vq_ready before sending the message to the VDUSE userland instance, avoiding the need for SMP sync after receiving the message. --- drivers/vdpa/vdpa_user/vduse_dev.c | 28 +++++++++++++++++++++++++++- include/uapi/linux/vduse.h | 18 ++++++++++++++++++ 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/drivers/vdpa/vdpa_user/vduse_dev.c b/drivers/vdpa/vdpa_user/vd= use_dev.c index 17e0358d3a68..4f642b95a7cb 100644 --- a/drivers/vdpa/vdpa_user/vduse_dev.c +++ b/drivers/vdpa/vdpa_user/vduse_dev.c @@ -9,6 +9,7 @@ */ =20 #include "linux/virtio_net.h" +#include #include #include #include @@ -53,7 +54,7 @@ #define IRQ_UNBOUND -1 =20 /* Supported VDUSE features */ -static const uint64_t vduse_features; +static const uint64_t vduse_features =3D BIT_U64(VDUSE_F_QUEUE_READY); =20 /* * 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; @@ -601,8 +603,29 @@ static void vduse_vdpa_set_vq_ready(struct vdpa_device= *vdpa, { struct vduse_dev *dev =3D vdpa_to_vduse(vdpa); struct vduse_virtqueue *vq =3D dev->vqs[idx]; + struct vduse_dev_msg msg =3D { 0 }; + int r; =20 vq->ready =3D ready; + + if (!(dev->vduse_features & BIT_U64(VDUSE_F_QUEUE_READY))) + return; + + msg.req.type =3D VDUSE_SET_VQ_READY; + msg.req.vq_ready.num =3D idx; + msg.req.vq_ready.ready =3D !!ready; + + r =3D 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); + spin_unlock(&dev->msg_lock); + } } =20 static bool vduse_vdpa_get_vq_ready(struct vdpa_device *vdpa, u16 idx) @@ -2078,6 +2101,9 @@ static int vduse_create_dev(struct vduse_dev_config *= config, dev->device_features =3D config->features; dev->device_id =3D config->device_id; dev->vendor_id =3D config->vendor_id; + dev->vduse_features =3D config->vduse_features; + dev_dbg(vduse_ctrl_dev, "Creating device %s with features 0x%llx", + config->name, config->vduse_features); =20 dev->nas =3D (dev->api_version < VDUSE_API_VERSION_1) ? 1 : config->nas; dev->as =3D kcalloc(dev->nas, sizeof(dev->as[0]), GFP_KERNEL); diff --git a/include/uapi/linux/vduse.h b/include/uapi/linux/vduse.h index e9b5f32a452d..7324faea5df4 100644 --- a/include/uapi/linux/vduse.h +++ b/include/uapi/linux/vduse.h @@ -14,6 +14,9 @@ =20 #define VDUSE_API_VERSION_1 1 =20 +/* 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, }; =20 /** @@ -377,6 +381,15 @@ struct vduse_iova_range_v2 { __u32 padding; }; =20 +/** + * 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 @@ -387,6 +400,7 @@ struct vduse_iova_range_v2 { * @iova: IOVA range for updating * @iova_v2: IOVA range for updating if API_VERSION >=3D 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. @@ -404,6 +418,10 @@ struct vduse_dev_request { */ struct vduse_iova_range_v2 iova_v2; struct vduse_vq_group_asid vq_group_asid; + + /* Only if VDUSE_F_QUEUE_READY is negotiated */ + struct vduse_vq_ready vq_ready; + __u32 padding[32]; }; }; --=20 2.53.0