Skip to content

Commit 454e4f3

Browse files
emuslngregkh
authored andcommitted
vhost_vdpa: tell vqs about the negotiated
[ Upstream commit 376daf3 ] 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]> Signed-off-by: Sasha Levin <[email protected]>
1 parent 1af1cd7 commit 454e4f3

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
@@ -377,7 +377,10 @@ static long vhost_vdpa_set_features(struct vhost_vdpa *v, u64 __user *featurep)
377377
{
378378
struct vdpa_device *vdpa = v->vdpa;
379379
const struct vdpa_config_ops *ops = vdpa->config;
380+
struct vhost_dev *d = &v->vdev;
381+
u64 actual_features;
380382
u64 features;
383+
int i;
381384

382385
/*
383386
* It's not allowed to change the features after they have
@@ -392,6 +395,16 @@ static long vhost_vdpa_set_features(struct vhost_vdpa *v, u64 __user *featurep)
392395
if (vdpa_set_features(vdpa, features))
393396
return -EINVAL;
394397

398+
/* let the vqs know what has been configured */
399+
actual_features = ops->get_driver_features(vdpa);
400+
for (i = 0; i < d->nvqs; ++i) {
401+
struct vhost_virtqueue *vq = d->vqs[i];
402+
403+
mutex_lock(&vq->mutex);
404+
vq->acked_features = actual_features;
405+
mutex_unlock(&vq->mutex);
406+
}
407+
395408
return 0;
396409
}
397410

0 commit comments

Comments
 (0)