Skip to content

Commit 12e0043

Browse files
eugpermarmstsirkin
authored andcommitted
vduse: bump version number
Finalize the series by advertising VDUSE API v1 support to userspace. Now that all required infrastructure for v1 (ASIDs, VQ groups, update_iotlb_v2) is in place, VDUSE devices can opt in to the new features. Assume API version 0 if the VDUSE instance does not call VDUSE_GET_API_VERSION to maintain compatibility. Acked-by: Jason Wang <jasowang@redhat.com> Signed-off-by: Eugenio Pérez <eperezma@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Message-Id: <20260119143306.1818855-13-eperezma@redhat.com>
1 parent 079212f commit 12e0043

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

drivers/vdpa/vdpa_user/vduse_dev.c

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,15 @@
5252

5353
#define IRQ_UNBOUND -1
5454

55+
/*
56+
* VDUSE instance have not asked the vduse API version, so assume 0.
57+
*
58+
* Old devices may not ask for the device version and assume it is 0. Keep
59+
* this value for these. From the moment the VDUSE instance ask for the
60+
* version, convert to the latests supported one and continue regular flow
61+
*/
62+
#define VDUSE_API_VERSION_NOT_ASKED U64_MAX
63+
5564
struct vduse_virtqueue {
5665
u16 index;
5766
u16 num_max;
@@ -2153,6 +2162,8 @@ static long vduse_ioctl(struct file *file, unsigned int cmd,
21532162
mutex_lock(&vduse_lock);
21542163
switch (cmd) {
21552164
case VDUSE_GET_API_VERSION:
2165+
if (control->api_version == VDUSE_API_VERSION_NOT_ASKED)
2166+
control->api_version = VDUSE_API_VERSION_1;
21562167
ret = put_user(control->api_version, (u64 __user *)argp);
21572168
break;
21582169
case VDUSE_SET_API_VERSION: {
@@ -2163,7 +2174,7 @@ static long vduse_ioctl(struct file *file, unsigned int cmd,
21632174
break;
21642175

21652176
ret = -EINVAL;
2166-
if (api_version > VDUSE_API_VERSION)
2177+
if (api_version > VDUSE_API_VERSION_1)
21672178
break;
21682179

21692180
ret = 0;
@@ -2180,6 +2191,8 @@ static long vduse_ioctl(struct file *file, unsigned int cmd,
21802191
break;
21812192

21822193
ret = -EINVAL;
2194+
if (control->api_version == VDUSE_API_VERSION_NOT_ASKED)
2195+
control->api_version = VDUSE_API_VERSION;
21832196
if (!vduse_validate_config(&config, control->api_version))
21842197
break;
21852198

@@ -2230,7 +2243,7 @@ static int vduse_open(struct inode *inode, struct file *file)
22302243
if (!control)
22312244
return -ENOMEM;
22322245

2233-
control->api_version = VDUSE_API_VERSION;
2246+
control->api_version = VDUSE_API_VERSION_NOT_ASKED;
22342247
file->private_data = control;
22352248

22362249
return 0;

0 commit comments

Comments
 (0)