vhost: fix vdpa driver multi-queue initialization failure
PATCH 1/1 vhost: fix vdpa driver multi-queue initialization failure
When 'virtio_is_Ready' returns 1, 'vdpa_dev->ops->dev_conf' will be called, and the vdpa driver called 'rte_vhost_get_vhost_vring' to get the vring addr info from 'vhost_devices->virtqueue[]'. virtio_is_ready's nr_vring is VIRTIO_BUILTIN_NUM_VQS_TO_BE_READY(2), multi-queue's nr_vring is greater than 2.
Only 'vhost_devices->virtqueue[0]' and 'vhost_devices->virtqueue[1]' are obtained in the for loop. Other queues of multiple queues cannot obtain the corresponding 'vhost_devices->virtqueue[i]', which will cause 'vdpa_dev->ops->dev_conf' to obtain QEMU vring addr information from 'vhost_devices->virtqueue[i]' failed.
Here, nr_ving is modified to dev->nr_vring, so that multiple queues can obtain the corresponding 'vhost_devices->virtqueue[i]'.
--- lib/vhost/vhost_user.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/vhost/vhost_user.c +1 -1
@@ -1473,7 +1473,7 @@ virtio_is_ready(struct virtio_net *dev)if (dev->nr_vring < nr_vring)return 0 ; -for (i =0 ; i < nr_vring; i++) { +for (i =0 ; i < dev->nr_vring; i++) { vq = dev->virtqueue[i];if (!vq_is_ready (dev, vq))
Signature · 1 line
2.27.0
PATCH 1/1 vhost: fix vdpa driver multi-queue initialization failure
When 'virtio_is_Ready' returns 1, 'vdpa_dev->ops->dev_conf' will be called, and the vdpa driver called 'rte_vhost_get_vhost_vring' to get the vring addr info from 'vhost_devices->virtqueue[]'. virtio_is_ready's nr_vring is VIRTIO_BUILTIN_NUM_VQS_TO_BE_READY(2), multi-queue's nr_vring is greater than 2.
Only 'vhost_devices->virtqueue[0]' and 'vhost_devices->virtqueue[1]' are obtained in the for loop. Other queues of multiple queues cannot obtain the corresponding 'vhost_devices->virtqueue[i]', which will cause 'vdpa_dev->ops->dev_conf' to obtain QEMU vring addr information from 'vhost_devices->virtqueue[i]' failed.
Here, nr_ving is modified to dev->nr_vring, so that multiple queues can obtain the corresponding 'vhost_devices->virtqueue[i]'.
--- lib/vhost/vhost_user.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/vhost/vhost_user.c +1 -1
@@ -1473,7 +1473,7 @@ virtio_is_ready(struct virtio_net *dev)if (dev->nr_vring < nr_vring)return 0 ; -for (i =0 ; i < nr_vring; i++) { +for (i =0 ; i < dev->nr_vring; i++) { vq = dev->virtqueue[i];if (!vq_is_ready (dev, vq))
Signature · 1 line
2.27.0
Maxime Coquelin
NAKQuoted 23 lines · Hao Chen
When '
virtio_is_Ready' returns 1, 'vdpa_dev->ops->dev_conf' will be called, and the vdpa driver called 'rte_vhost_get_vhost_vring' to get the vring addr info from 'vhost_devices->virtqueue[]'. virtio_is_ready'snr_vringisVIRTIO_BUILTIN_NUM_VQS_TO_BE_READY(2), multi-queue'snr_vringis greater than 2.
Only 'vhost_devices->virtqueue[0]' and 'vhost_devices->virtqueue[1]' are obtained in the for loop. Other queues of multiple queues cannot obtain the corresponding 'vhost_devices->virtqueue[i]', which will cause 'vdpa_dev->ops->dev_conf' to obtain QEMU vring addr information from 'vhost_devices->virtqueue[i]' failed.
Here,nr_vingis modified todev->nr_vring, so that multiple queues can obtain the corresponding 'vhost_devices->virtqueue[i]'.Signed-off-by Hao Chen <[email protected]>--- lib/vhost/vhost_user.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)lib/vhost/vhost_user.c +0
-0
lib/vhost/vhost_user.c virtio_is_ready(struct virtio_net *dev) · line 1479
Quoted 8 lines
lib/vhost/vhost_user.c +1
-1@@ -1473,7 +1473,7 @@ virtio_is_ready(struct virtio_net *dev)if (dev->nr_vring < nr_vring)return 0 ; -for (i =0 ; i < nr_vring; i++) { +for (i =0 ; i < dev->nr_vring; i++) { vq = dev->virtqueue[i];if (!vq_is_ready (dev, vq))
Nack.
We can start processing the vrings as soon as the first queue pair is initialized. I think you may want to rely on vdpa_dev->ops->set_vring_state to initialize other vrings.
What is the vDPA driver/device affected by this issue?
Regards,
Maxime
Maxime Coquelin
NAKQuoted 23 lines · Hao Chen
When '
virtio_is_Ready' returns 1, 'vdpa_dev->ops->dev_conf' will be called, and the vdpa driver called 'rte_vhost_get_vhost_vring' to get the vring addr info from 'vhost_devices->virtqueue[]'. virtio_is_ready'snr_vringisVIRTIO_BUILTIN_NUM_VQS_TO_BE_READY(2), multi-queue'snr_vringis greater than 2.
Only 'vhost_devices->virtqueue[0]' and 'vhost_devices->virtqueue[1]' are obtained in the for loop. Other queues of multiple queues cannot obtain the corresponding 'vhost_devices->virtqueue[i]', which will cause 'vdpa_dev->ops->dev_conf' to obtain QEMU vring addr information from 'vhost_devices->virtqueue[i]' failed.
Here,nr_vingis modified todev->nr_vring, so that multiple queues can obtain the corresponding 'vhost_devices->virtqueue[i]'.Signed-off-by Hao Chen <[email protected]>--- lib/vhost/vhost_user.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)lib/vhost/vhost_user.c +0
-0
lib/vhost/vhost_user.c virtio_is_ready(struct virtio_net *dev) · line 1479
Quoted 8 lines
lib/vhost/vhost_user.c +1
-1@@ -1473,7 +1473,7 @@ virtio_is_ready(struct virtio_net *dev)if (dev->nr_vring < nr_vring)return 0 ; -for (i =0 ; i < nr_vring; i++) { +for (i =0 ; i < dev->nr_vring; i++) { vq = dev->virtqueue[i];if (!vq_is_ready (dev, vq))
(reiterate my reply since the patch was posted twice, and I replied to the one discarded in PW)
Nack.
We can start processing the vrings as soon as the first queue pair is initialized. I think you may want to rely on vdpa_dev->ops->set_vring_state to initialize other vrings.
What is the vDPA driver/device affected by this issue?
Regards,
Maxime
Quoted 36 lines · Maxime Coquelin
Quoted 23 lines · Hao Chen
When '
virtio_is_Ready' returns 1, 'vdpa_dev->ops->dev_conf' will be called, and the vdpa driver called 'rte_vhost_get_vhost_vring' to get the vring addr info from 'vhost_devices->virtqueue[]'. virtio_is_ready'snr_vringisVIRTIO_BUILTIN_NUM_VQS_TO_BE_READY(2), multi-queue'snr_vringis greater than 2.
Only 'vhost_devices->virtqueue[0]' and 'vhost_devices->virtqueue[1]' are obtained in the for loop. Other queues of multiple queues cannot obtain the corresponding 'vhost_devices->virtqueue[i]', which will cause 'vdpa_dev->ops->dev_conf' to obtain QEMU vring addr information from 'vhost_devices->virtqueue[i]' failed.
Here,nr_vingis modified todev->nr_vring, so that multiple queues can obtain the corresponding 'vhost_devices->virtqueue[i]'.Signed-off-by Hao Chen <[email protected]>---
lib/vhost/vhost_user.c| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)lib/vhost/vhost_user.c +0
-0lib/vhost/vhost_user.c virtio_is_ready(struct virtio_net *dev) · line 1478
Quoted 6 lines
lib/vhost/vhost_user.c +1
-0@@ -1473,7 +1473,7 @@ virtio_is_ready(struct virtio_net *dev) if (dev->nr_vring < nr_vring) return 0; - for (i = 0; i < nr_vring; i++) { + for (i = 0; i < dev->nr_vring; i++) { vq = dev->virtqueue[i]; if (!vq_is_ready(dev, vq))(reiterate my reply since the patch was posted twice, and I replied to the one discarded in PW)
Quoted 6 lines
Nack.
We can start processing the vrings as soon as the first queue pair is initialized. I think you may want to rely on
vdpa_dev->ops->set_vring_stateto initialize other vrings.
Does this mean that the queue should be initialized and enabled in vdpa_dev->ops->set_vring_state, not in vdpa_dev->ops->dev_conf?
Quoted 1 line
What is the vDPA driver/device affected by this issue?
After tracking the code, I found that the dpdk-vdpa example's log shows the calling order of multiple queues as follow:
"VHOST_USER_SET_VRING_ADDRVHOST_USER_SET_VRING_KICK
vdpa_dev->ops->set_vring_state (vq_idx=0)VHOST_USER_SET_VRING_CALL
vdpa_dev->ops->set_vring_state (vq_idx=0)
...VHOST_USER_SET_VRING_ADDRVHOST_USER_SET_VRING_KICK
vdpa_dev->ops->set_vring_state (vq_idx=1)VHOST_USER_SET_VRING_CALL
vdpa_dev->ops->set_vring_state (vq_idx=1)
"
then virtio_is_ready return 1, vdpa_dev->ops->dev_conf is called.
After that, other queues will call vdpa_dev->ops->set_vring_state (vq_idx=i)
The dev->virtqueue[]->desc/available/used is assigned in VHOST_USER_SET_VRING_KICK's translate_ring_addresses() , so vdpa driver should not initialize all queues in vdpa_dev->ops->dev_conf , otherwise other queue's dev->virtqueue[i]->desc/available/used are NULL , vring's hpa to gpa will fail by rte_vhost_get_vhost_vring(). dev->virtqueue[i]->desc/available/used should be accessed after queue(i)'s VHOST_USER_SET_VRING_KICK is called.
I see that all of ifc/sfc vdpa driver's queues acessed all queues's dev->virtqueue[i]->desc/available/used in vdpa_dev->ops->dev_conf, maybe they should move the code?
Quoted 4 lines
Regards,
Maxime