[v2,01/18] net/mlx5/windows: fix miss callback register for mem event

Message ID 20211006220350.2357487-2-michaelba@nvidia.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series mlx5: sharing global MR cache between drivers |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/iol-testing warning apply patch failure

Commit Message

Michael Baum Oct. 6, 2021, 10:03 p.m. UTC
  From: Michael Baum <michaelba@oss.nvidia.com>

In device initialization, the driver registers to free hugepages events.
When husepage 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@oss.nvidia.com>
Acked-by: Matan Azrad <matan@nvidia.com>
---
 drivers/net/mlx5/windows/mlx5_os.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
  

Patch

diff --git a/drivers/net/mlx5/windows/mlx5_os.c b/drivers/net/mlx5/windows/mlx5_os.c
index 149253d174..459414d5c2 100644
--- a/drivers/net/mlx5/windows/mlx5_os.c
+++ b/drivers/net/mlx5/windows/mlx5_os.c
@@ -122,8 +122,21 @@  mlx5_init_shared_data(void)
 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;
 }