vhost: fix vdpa driver multi-queue initialization failure

Message ID 20230128030603.1168073-2-chenh@yusur.tech (mailing list archive)
State Superseded, archived
Delegated to: Maxime Coquelin
Headers
Series vhost: fix vdpa driver multi-queue initialization failure |

Checks

Context Check Description
ci/checkpatch warning coding style issues
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-intel-Functional fail Functional Testing issues
ci/Intel-compilation success Compilation OK
ci/iol-intel-Performance success Performance Testing PASS
ci/github-robot: build success github build: passed
ci/intel-Testing success Testing PASS
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-abi-testing success Testing PASS

Commit Message

Hao Chen Jan. 28, 2023, 3:06 a.m. UTC
  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]'.

Signed-off-by: Hao Chen <chenh@yusur.tech>
---
 lib/vhost/vhost_user.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Maxime Coquelin Feb. 1, 2023, 12:23 p.m. UTC | #1
On 1/28/23 04:06, Hao Chen wrote:
> 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]'.
> 
> Signed-off-by: Hao Chen <chenh@yusur.tech>
> ---
>   lib/vhost/vhost_user.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/lib/vhost/vhost_user.c b/lib/vhost/vhost_user.c
> index 9902ae9944..9249eafc06 100644
> --- a/lib/vhost/vhost_user.c
> +++ b/lib/vhost/vhost_user.c
> @@ -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
  

Patch

diff --git a/lib/vhost/vhost_user.c b/lib/vhost/vhost_user.c
index 9902ae9944..9249eafc06 100644
--- a/lib/vhost/vhost_user.c
+++ b/lib/vhost/vhost_user.c
@@ -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))