net/mlx5: register memory event callback in Windows
authorMichael Baum <michaelba@nvidia.com>
Tue, 19 Oct 2021 20:55:45 +0000 (23:55 +0300)
committerThomas Monjalon <thomas@monjalon.net>
Thu, 21 Oct 2021 13:37:23 +0000 (15:37 +0200)
In device initialization, the driver registers to free hugepages events.
When hugepage is released, this callback frees all its related MRs.

In Windows initialization, this callback is not registered what may
cause to use invalid memory.

This patch adds memory event callback registration in Windows
initialization.

Fixes: 980826dc6f0f ("net/mlx5: probe on Windows")
Cc: stable@dpdk.org
Signed-off-by: Michael Baum <michaelba@nvidia.com>
Acked-by: Matan Azrad <matan@nvidia.com>
drivers/net/mlx5/windows/mlx5_os.c

index 4ecf018..75a1f9a 100644 (file)
@@ -122,8 +122,21 @@ error:
 static int
 mlx5_init_once(void)
 {
+       struct mlx5_shared_data *sd;
+
        if (mlx5_init_shared_data())
                return -rte_errno;
+       sd = mlx5_shared_data;
+       rte_spinlock_lock(&sd->lock);
+       MLX5_ASSERT(sd);
+       if (!sd->init_done) {
+               LIST_INIT(&sd->mem_event_cb_list);
+               rte_rwlock_init(&sd->mem_event_rwlock);
+               rte_mem_event_callback_register("MLX5_MEM_EVENT_CB",
+                                               mlx5_mr_mem_event_cb, NULL);
+               sd->init_done = true;
+       }
+       rte_spinlock_unlock(&sd->lock);
        return 0;
 }