From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124])
	by inbox.dpdk.org (Postfix) with ESMTP id 46A59A0C4D;
	Thu,  7 Oct 2021 00:04:23 +0200 (CEST)
Received: from [217.70.189.124] (localhost [127.0.0.1])
	by mails.dpdk.org (Postfix) with ESMTP id 2C00A4118D;
	Thu,  7 Oct 2021 00:04:20 +0200 (CEST)
Received: from NAM04-DM6-obe.outbound.protection.outlook.com
 (mail-dm6nam08on2050.outbound.protection.outlook.com [40.107.102.50])
 by mails.dpdk.org (Postfix) with ESMTP id E71CE4116B;
 Thu,  7 Oct 2021 00:04:17 +0200 (CEST)
ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none;
 b=TGq7HXwHiM9LsfJSBVcvkBPkiZ533jCYoxza/XD3EREsev9N/1AECzh1dbbA7ifL1hF+qFf6kv0+H676k132uT1umu5KckIwlXU/dOXT/hYH1W68+VL18BVVpruttLSlrZCzdff3+waDyZVpcgBYK+H6IyrmxP/P2EzJFMQBB4Cni77nO1naaledkZ1aVkLaQEPNv6zfahhDiroE7KrWYHr4cl7s/qw+6xPQBcdzNIAv/OBWLJR6zwPvzsFQ/SMGygL+tztnOuf6uVDwQ1FpSciDJTXt+uXpwK1eCkeYiDvesy9o9vdYGC/LVxTHTwg3jfbAEnbc4MndXFhvaQO+AA==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; 
 s=arcselector9901;
 h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1;
 bh=JTFX3lSI9yoy35hHZ/ittCrShuad8icPBzu/iw1sVtk=;
 b=abCVeZljRuq6xhlg1bTqxwCcLwMB3VwkGqSNhVoflmdEWD+PxXaxO9GmRh5nlrnhI6zq0MiGL7LcbvIV8N8KXZuXGULrXM/zb/165YuxuToy0puWrXMsMvSAT4FJpynzJmXbgquWtGrg94lCZXkCzP2m+1RzvRv1gG97CwWn5Q6xy/BpdxmV7aMVcLcgXzAV1vXbSVa800MtwRQ34Kiu3lutmwSLt1G7FTWuxf7lcbVhKkRP04MJOTaRNwReLpy2Uq+UUjS4shhQjuWwnRzV9vSMhjIkHdWYLvCEhrJWDDO5hoxlsd4fOin/51ZpoTjs9GAy+XGWMTgu7bnohKXJmg==
ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is
 216.228.112.34) smtp.rcpttodomain=dpdk.org smtp.mailfrom=nvidia.com;
 dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=nvidia.com; 
 dkim=none (message not signed); arc=none
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com;
 s=selector2;
 h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;
 bh=JTFX3lSI9yoy35hHZ/ittCrShuad8icPBzu/iw1sVtk=;
 b=L/BZ64EHlw/lUFIAgtI2J8wU6ilWoIcnmgqp6keFlT5cRfQXJGNe+27p0m3NuaigPN/LaYpcMnPhE4FdTD2R9xvvYi8wopvbT62GdYCxjxwXWq42AfamoDG8sIioLuLU2ES/BRkhlcCSPlW/01mcWAFBplZO9GJD1xhHxBC0kKgcXDo6RPsDRaNmhw6XfzN0cKRHK8s/9la++C7pWD9xHYqV4APHt1uLD2I3dnIRP9LHcqrLDm4rOAI/rWPlMy2aoWQjhdu8+sbIyjIvmShiSKJTBP9xC2dfngKPEaAZ7zdfbuBO9a6No6++u26ZV0lxy/u8IMS9Jfx9+bg0BLPYMA==
Received: from MW4PR03CA0031.namprd03.prod.outlook.com (2603:10b6:303:8e::6)
 by CH0PR12MB5043.namprd12.prod.outlook.com (2603:10b6:610:e2::20) with
 Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.14; Wed, 6 Oct
 2021 22:04:16 +0000
Received: from CO1NAM11FT048.eop-nam11.prod.protection.outlook.com
 (2603:10b6:303:8e:cafe::2c) by MW4PR03CA0031.outlook.office365.com
 (2603:10b6:303:8e::6) with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4587.18 via Frontend
 Transport; Wed, 6 Oct 2021 22:04:16 +0000
X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34)
 smtp.mailfrom=nvidia.com; dpdk.org; dkim=none (message not signed)
 header.d=none;dpdk.org; dmarc=pass action=none header.from=nvidia.com;
Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates
 216.228.112.34 as permitted sender) receiver=protection.outlook.com;
 client-ip=216.228.112.34; helo=mail.nvidia.com;
Received: from mail.nvidia.com (216.228.112.34) by
 CO1NAM11FT048.mail.protection.outlook.com (10.13.175.148) with Microsoft SMTP
 Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id
 15.20.4587.18 via Frontend Transport; Wed, 6 Oct 2021 22:04:15 +0000
Received: from nvidia.com (172.20.187.6) by HQMAIL107.nvidia.com
 (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Wed, 6 Oct
 2021 22:04:13 +0000
From: <michaelba@nvidia.com>
To: <dev@dpdk.org>
CC: Matan Azrad <matan@nvidia.com>, Thomas Monjalon <thomas@monjalon.net>,
 Michael Baum <michaelba@oss.nvidia.com>, <stable@dpdk.org>
Date: Thu, 7 Oct 2021 01:03:33 +0300
Message-ID: <20211006220350.2357487-2-michaelba@nvidia.com>
X-Mailer: git-send-email 2.25.1
In-Reply-To: <20211006220350.2357487-1-michaelba@nvidia.com>
References: <20210930172822.1949969-1-michaelba@nvidia.com>
 <20211006220350.2357487-1-michaelba@nvidia.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/plain
X-Originating-IP: [172.20.187.6]
X-ClientProxiedBy: HQMAIL107.nvidia.com (172.20.187.13) To
 HQMAIL107.nvidia.com (172.20.187.13)
X-EOPAttributedMessage: 0
X-MS-PublicTrafficType: Email
X-MS-Office365-Filtering-Correlation-Id: e4ec19f1-463d-475e-0990-08d989153d08
X-MS-TrafficTypeDiagnostic: CH0PR12MB5043:
X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr
X-Microsoft-Antispam-PRVS: <CH0PR12MB50435B25EB622BA4C7AE3E00CCB09@CH0PR12MB5043.namprd12.prod.outlook.com>
X-MS-Oob-TLC-OOBClassifiers: OLM:5516;
X-MS-Exchange-SenderADCheck: 1
X-MS-Exchange-AntiSpam-Relay: 0
X-Microsoft-Antispam: BCL:0;
X-Microsoft-Antispam-Message-Info: 8dmbRQTy3p4ZMZB2h8kMEDKhATcHAQaAFiXBfkJpUHhPlWS/llvAhBklw9dUXpdSHpcHldAHdteGS8/0cmy7qwopboglZxpDy7nxX+BbuvOtw+hPcY53vhPd6BQZcHQmXGzSdQg7YGHGi+3V9SEL0gEzhyfUpC3lXs3vIf9SusgszdG55eLv1g3gXK8fkiRygXztOsxahpL6Vq6JezQLtcu7+jLVdguMkMNj0yML4LHA6JYB3fWsctAfWt59zlq96WIsLoi/orvCug1NwmpEcADgJaUIWinX3lpNnWFDkiQFP1N34MzJjNXSIPAT5CX5Se4XvuFHbsk12mzinv3FLFfsX3SKrlWl1HDC+mX6jmizKuBP6YRGHpBTRVpg7xsgs+6aI95JaE1AxFxO0YdODTKTxUNP2uBA0awrNeqn+MHR+M9w+0X4+XMWyGFENeM4F9L9ZDqVQ9fiFTKQ41jR6eHcV3F9xPTzA1zNWu1tMfhXiyn1/8otUCTWdObu/WKFv9tB4VRgwRM1/5SS2H9ZMxZ5ghnhX9LvnZK0wSEFcJJnxw9jZdY2UgPTAU5sm9DFbO0IPRiAB5Ob2MVeSkOGrBSHNur09Wlh3m+f+CZQfQI8oVCpS5Wqrvl8EB4eDvuvVBk4fdQklnXrJr6hIqeRiSeskWIVdPdpBizIHfHKt9Dwe1tnVWoekrz/ARXdfo2hV/tVBm1/v+au0X5XSuP9Xg==
X-Forefront-Antispam-Report: CIP:216.228.112.34; CTRY:US; LANG:en; SCL:1; SRV:;
 IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:schybrid03.nvidia.com; CAT:NONE;
 SFS:(4636009)(36840700001)(46966006)(2616005)(86362001)(1076003)(316002)(356005)(82310400003)(4326008)(426003)(2876002)(2906002)(55016002)(6666004)(54906003)(7696005)(508600001)(6916009)(8676002)(36756003)(26005)(47076005)(83380400001)(36860700001)(5660300002)(8936002)(6286002)(70586007)(336012)(16526019)(7636003)(70206006)(186003);
 DIR:OUT; SFP:1101; 
X-OriginatorOrg: Nvidia.com
X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Oct 2021 22:04:15.8742 (UTC)
X-MS-Exchange-CrossTenant-Network-Message-Id: e4ec19f1-463d-475e-0990-08d989153d08
X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a
X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.112.34];
 Helo=[mail.nvidia.com]
X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT048.eop-nam11.prod.protection.outlook.com
X-MS-Exchange-CrossTenant-AuthAs: Anonymous
X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem
X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR12MB5043
Subject: [dpdk-dev] [PATCH v2 01/18] net/mlx5/windows: fix miss callback
 register for mem event
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org
Sender: "dev" <dev-bounces@dpdk.org>

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(+)

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;
 }
 
-- 
2.25.1