net/virtio: fix kernel set memory table for multi-queue devices

Message ID 20210423122515.31078-1-thierry.herbelot@6wind.com (mailing list archive)
State Accepted, archived
Delegated to: Maxime Coquelin
Headers
Series net/virtio: fix kernel set memory table for multi-queue devices |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/iol-intel-Performance success Performance Testing PASS
ci/github-robot success github build: passed
ci/Intel-compilation success Compilation OK
ci/iol-testing success Testing PASS
ci/iol-abi-testing success Testing PASS
ci/intel-Testing success Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS

Commit Message

Thierry Herbelot April 23, 2021, 12:25 p.m. UTC
  Restore the original code, where VHOST_SET_MEM_TABLE is applied to
all vhostfds of the device.

Fixes: 539d910c9c768 ("net/virtio: add virtio-user memory tables ops")
Cc: stable@dpdk.org

Signed-off-by: Thierry Herbelot <thierry.herbelot@6wind.com>
---
 drivers/net/virtio/virtio_user/vhost_kernel.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
  

Comments

Maxime Coquelin April 23, 2021, 2:24 p.m. UTC | #1
On 4/23/21 2:25 PM, Thierry Herbelot wrote:
> Restore the original code, where VHOST_SET_MEM_TABLE is applied to
> all vhostfds of the device.
> 
> Fixes: 539d910c9c768 ("net/virtio: add virtio-user memory tables ops")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Thierry Herbelot <thierry.herbelot@6wind.com>
> ---
>  drivers/net/virtio/virtio_user/vhost_kernel.c | 12 +++++++++---
>  1 file changed, 9 insertions(+), 3 deletions(-)
> 

Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>

Thanks,
Maxime
  
Chenbo Xia April 28, 2021, 6:07 a.m. UTC | #2
> -----Original Message-----
> From: Thierry Herbelot <thierry.herbelot@6wind.com>
> Sent: Friday, April 23, 2021 8:25 PM
> To: dev@dpdk.org
> Cc: Thierry Herbelot <thierry.herbelot@6wind.com>; Thomas Monjalon
> <thomas@monjalon.net>; Maxime Coquelin <maxime.coquelin@redhat.com>; Xia,
> Chenbo <chenbo.xia@intel.com>; stable@dpdk.org
> Subject: [PATCH] net/virtio: fix kernel set memory table for multi-queue
> devices
> 
> Restore the original code, where VHOST_SET_MEM_TABLE is applied to
> all vhostfds of the device.
> 
> Fixes: 539d910c9c768 ("net/virtio: add virtio-user memory tables ops")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Thierry Herbelot <thierry.herbelot@6wind.com>
> ---
> 2.29.2

Patch applied to next-virtio/main, Thanks
  

Patch

diff --git a/drivers/net/virtio/virtio_user/vhost_kernel.c b/drivers/net/virtio/virtio_user/vhost_kernel.c
index 58e66bb7b4ae..ad46f10a9300 100644
--- a/drivers/net/virtio/virtio_user/vhost_kernel.c
+++ b/drivers/net/virtio/virtio_user/vhost_kernel.c
@@ -206,6 +206,7 @@  add_memseg_list(const struct rte_memseg_list *msl, void *arg)
 static int
 vhost_kernel_set_memory_table(struct virtio_user_dev *dev)
 {
+	uint32_t i;
 	struct vhost_kernel_data *data = dev->backend_data;
 	struct vhost_memory_kernel *vm;
 	int ret;
@@ -227,9 +228,14 @@  vhost_kernel_set_memory_table(struct virtio_user_dev *dev)
 	if (ret < 0)
 		goto err_free;
 
-	ret = vhost_kernel_ioctl(data->vhostfds[0], VHOST_SET_MEM_TABLE, vm);
-	if (ret < 0)
-		goto err_free;
+	for (i = 0; i < dev->max_queue_pairs; ++i) {
+		if (data->vhostfds[i] < 0)
+			continue;
+
+		ret = vhost_kernel_ioctl(data->vhostfds[i], VHOST_SET_MEM_TABLE, vm);
+		if (ret < 0)
+			goto err_free;
+	}
 
 	free(vm);