Skip to content

Commit 376daf3

Browse files
emuslnmstsirkin
authored andcommitted
vhost_vdpa: tell vqs about the negotiated
As is done in the net, iscsi, and vsock vhost support, let the vdpa vqs know about the features that have been negotiated. This allows vhost to more safely make decisions based on the features, such as when using PACKED vs split queues. Signed-off-by: Shannon Nelson <[email protected]> Acked-by: Jason Wang <[email protected]> Message-Id: <[email protected]> Signed-off-by: Michael S. Tsirkin <[email protected]>
1 parent 73790bd commit 376daf3

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

drivers/vhost/vdpa.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,10 @@ static long vhost_vdpa_set_features(struct vhost_vdpa *v, u64 __user *featurep)
407407
{
408408
struct vdpa_device *vdpa = v->vdpa;
409409
const struct vdpa_config_ops *ops = vdpa->config;
410+
struct vhost_dev *d = &v->vdev;
411+
u64 actual_features;
410412
u64 features;
413+
int i;
411414

412415
/*
413416
* It's not allowed to change the features after they have
@@ -422,6 +425,16 @@ static long vhost_vdpa_set_features(struct vhost_vdpa *v, u64 __user *featurep)
422425
if (vdpa_set_features(vdpa, features))
423426
return -EINVAL;
424427

428+
/* let the vqs know what has been configured */
429+
actual_features = ops->get_driver_features(vdpa);
430+
for (i = 0; i < d->nvqs; ++i) {
431+
struct vhost_virtqueue *vq = d->vqs[i];
432+
433+
mutex_lock(&vq->mutex);
434+
vq->acked_features = actual_features;
435+
mutex_unlock(&vq->mutex);
436+
}
437+
425438
return 0;
426439
}
427440

0 commit comments

Comments
 (0)