From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR02-AM5-obe.outbound.protection.outlook.com (mail-eopbgr00077.outbound.protection.outlook.com [40.107.0.77]) by dpdk.org (Postfix) with ESMTP id 76F583989 for ; Sun, 27 May 2018 09:05:12 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=HK9f1LDpilpR7VmmViE58zMJNZifQ8mcmz93+yxui9Y=; b=g6NyWp8FBv8l+z4sKjcefjjoAqFjxPnH/OZ6f3/7K91dFgkt3T/S+bGS1ZO0djH3fJt9qiWjEF9kOIVzRyDOOQSsw0N5EduEeWI+t17LPP0CJlDctwNL0DSwshzI8B+KM/1WlgSbIkVlTB3wSJLAp8rqdeM/NedR99v0DnHhv88= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=yskoh@mellanox.com; Received: from mellanox.com (209.116.155.178) by VI1PR0501MB2047.eurprd05.prod.outlook.com (2603:10a6:800:36::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.797.11; Sun, 27 May 2018 07:05:09 +0000 From: Yongseok Koh To: adrien.mazarguil@6wind.com, nelio.laranjeiro@6wind.com Cc: dev@dpdk.org, shahafs@mellanox.com, ferruh.yigit@intel.com, Yongseok Koh , Xueming Li Date: Sun, 27 May 2018 00:04:55 -0700 Message-Id: <20180527070455.13123-1-yskoh@mellanox.com> X-Mailer: git-send-email 2.11.0 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [209.116.155.178] X-ClientProxiedBy: BYAPR01CA0027.prod.exchangelabs.com (2603:10b6:a02:80::40) To VI1PR0501MB2047.eurprd05.prod.outlook.com (2603:10a6:800:36::21) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(5600026)(48565401081)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020); SRVR:VI1PR0501MB2047; X-Microsoft-Exchange-Diagnostics: 1; VI1PR0501MB2047; 3:zVuC+wOYx4nU1p1Bd5fHNpVegTxO/WzbvuO+Iz1bCY0F3IIHLVLv3nUeieDmG8zqiFwOLXx5XBppIloEesvHkIyVPP2zcRscNPCXfu9OrVHHqVTWoqYG92ZsS0mwy0mHucK8Dcs2SHcjJUHrN7eqY8boyn2MMuXrz0hy42v/uHBdAMoqxfo+/p6oxfispQr+c2U19JxbtNlySxUd4TXJ+LNuAApOpEfeKsPhG/0XRmBV0iT9FPvvWEQgRaVeQgLp; 25:XHforCrGBrl3qr3j8uR7waZ3xedSI2TGljayVSG7H1h3bztrSUAqCSownySRU36fcAq+CWpA9fTFy3Nbt14K7d83rVRdJYIUYbqFBZgXLj4Apnd8XaHXvjsvN0EtGaHMqgAxkhmvARmvgyb72AFdwvbUWlWbYPGdvt5BXK56eYPBVo4oIkGN9mhwqmVvvbm0MIQgarokAIaCSOF7T+U2kOWXlf127EaA4msErmNXBNGYVrgsSCgEum624EXn4y/OHGeITf99N/h2PsvgjzQdf9sVvdsMufkvmg7p3glPkqRv6UEeIFs5Hk4q2NLtQqXamh6Zes2QMULsijtL1VsSJQ==; 31:MvT/Mr7LoTEB5x7PXlG8hP6vpC9L+lR7k9F2qKxShdWyODnI1Fe4iD5aY5PEySevL/lGGAuV0jPoXnj8a/l3R/zNvpso08cPKZXzJXSj/gHV9FDAYQtS0S9Td761DRe88n6GiqPYyEDK3jli33kElhxR5Uub1YSiQrpGbt0Q2I7TOj29SLiYJifZF9guPeaLhlMY1taS3NDBty421H+tvuYXQ/x+SV68QqwxC5HYrNM= X-MS-TrafficTypeDiagnostic: VI1PR0501MB2047: X-LD-Processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtAddr X-Microsoft-Exchange-Diagnostics: 1; VI1PR0501MB2047; 20:OnGpl2yJVPZdg8WLvZHxwGhBs/tmZ6husw0YrSpKyTqSYviaUFYujViWzba/gt9vNwjxCac2I93oszGoC10NWnkzJMzq4okerxuS1hqpUL/TvRcF8F9MiaQqWkBioB8QG6MNKmlGCjlZ6gqOUDZpUTCCC0NnUBx+pAFSZUkgZOe+aucY9FHfyVTQRZ9rG9BmISOjr8kUGuL8xFsVu47sWJSLoxfpFXQLPdssCjwGrKVJ0Y3Eu5/bGX5yzteOsO4YKtO9sEyrGd87IovGIiiwZgbe7ZoDkwcJ8NV6l5Tn7I0eeEcE/A+JRHFYIp3c9mDgox/3Hr8zjtL3knN2PymrxIp/PjSTfgcOtGBNgyKy2fPJoQOcrwuX3nblFNZaGFLrUW0HtE7sN3lFKxZTUXHsL9jAjXp1RLBnEVq4Kic/2u2d7w3LHhrtrCOIUVlO64tMs2QiMrNf3xSw+8RDh+HCgU7GkJ42NMIOhrSqvfh+05EPYAiZ+lhY0zhLFqZTU+xw; 4:LOLpa/JJZKs0rDQQ65Y5J9IwfSnxRJbcuUXytjk0WrgA1+hfq6HVJziwzadNaDfLTZXykSYjSx3cULiBmfZxOxdyYTCqmQeMzmH/PD5+ECJCMmQPqKzMiK59ZbloSJXRmw4Phi/Rd0yYx8jZCh0GmJ71w92g75is6s9UL3MnDN2xBHWQ0/QJM3NG6p8wblDJuHs07hLVhELgR1EBybc84p6Qk/hmV8YDDvnJu+Mibu+pjg/AwYzpGNqQg/TiCMT1CSlTq7zXqNdlyCahP+mc+AzuhhCDSvQixJ8uTtos8pw/n4jLekrF+IDrLZJg4n/P X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(278428928389397); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(3231254)(944501410)(52105095)(3002001)(93006095)(93001095)(10201501046)(6055026)(149027)(150027)(6041310)(20161123558120)(20161123564045)(20161123560045)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011)(7699016); SRVR:VI1PR0501MB2047; BCL:0; PCL:0; RULEID:; SRVR:VI1PR0501MB2047; X-Forefront-PRVS: 0685122203 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(396003)(346002)(39380400002)(39860400002)(376002)(366004)(199004)(189003)(53936002)(5660300001)(8936002)(107886003)(86362001)(486006)(54906003)(36756003)(1857600001)(48376002)(2906002)(51416003)(4326008)(7696005)(50466002)(52116002)(97736004)(50226002)(21086003)(8676002)(81166006)(81156014)(55016002)(68736007)(478600001)(305945005)(59450400001)(6116002)(26005)(66066001)(1076002)(3846002)(186003)(7736002)(16526019)(105586002)(106356001)(25786009)(47776003)(69596002)(476003)(386003)(2616005)(956004)(316002)(6666003)(16586007); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR0501MB2047; H:mellanox.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; VI1PR0501MB2047; 23:EbbR9VU4jEsmYhrTnF9M40JexbxMpVMLCbYrF41?= =?us-ascii?Q?/HKF5BIbK5ImSy/hbbtgT99+ViJbxWlDGPM487exhKu4Gi3rNE5cz4Sci+ZW?= =?us-ascii?Q?jlzsKjtGdSArZW3J122H68WjmLXx45JfcXJXBwtsdUKi6uSYnGGsGJcV8M/Z?= =?us-ascii?Q?JEzrY1fZ87joY3LrsrDG86tVoFOEzxd1Afo9eJXePQ+gDHdfPFqL3tTcpBsF?= =?us-ascii?Q?1b30kCuQLKgCf9Rm1DWtdAz04mtt9IXOL53jejxki5pbAJxgajtxBfZmyI7v?= =?us-ascii?Q?7qyQi9RoXpiKOyasi+n3BObJZsvuYg3hJn+jWkj/rGIoWMyUuwXtIBMmKrwh?= =?us-ascii?Q?kOy5NZquDJ9gYgaDrXiRyBXcsQvUjzFff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Exchange-Diagnostics: 1; VI1PR0501MB2047; 7:/ZiY9JIJZMQSNUhu1EKLN/uHsAwK9cxNIzHo2bMn2vQH3KO3xKCFTyW9DXNLhchsblkWLXvkiSNdJFPmW6xejBC+CrO+lSTlXEmVH90MApziFgIia9unh9z5hnhd2Ar5uGJfokOZxDAqM9utzjfISyfW8ejw/c3LBEeKniHBz+Vz05jwjQ0Vi55SInRKxMkm1o0UxT65Xpj7EKs555TVfQxgzArjfqRE2/v/JUgeR9ZmmDN4j/zCuFwXw9QCwFQV X-MS-Office365-Filtering-Correlation-Id: 1d728dbb-5685-4d7c-fce2-08d5c3a02fe9 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 May 2018 07:05:09.4152 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1d728dbb-5685-4d7c-fce2-08d5c3a02fe9 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0501MB2047 Subject: [dpdk-dev] [PATCH] net/mlx4: fix crash when configure is not called X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 27 May 2018 07:05:12 -0000 Although uncommon, applications may destroy a device immediately after probing it without going through dev_configure() first. This patch addresses a crash which occurs when mlx4_dev_close() calls mlx4_mr_release() due to an uninitialized entry in the private structure. And the device's B-tree should be allocated once. Fixes: 9797bfcce1c9 ("net/mlx4: add new memory region support") Signed-off-by: Adrien Mazarguil Signed-off-by: Xueming Li Signed-off-by: Yongseok Koh --- drivers/net/mlx4/mlx4.c | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/drivers/net/mlx4/mlx4.c b/drivers/net/mlx4/mlx4.c index 9f8ecd072..a29814b3b 100644 --- a/drivers/net/mlx4/mlx4.c +++ b/drivers/net/mlx4/mlx4.c @@ -98,20 +98,6 @@ mlx4_dev_configure(struct rte_eth_dev *dev) if (ret) ERROR("%p: interrupt handler installation failed", (void *)dev); - /* - * Once the device is added to the list of memory event callback, its - * global MR cache table cannot be expanded on the fly because of - * deadlock. If it overflows, lookup should be done by searching MR list - * linearly, which is slow. - */ - if (mlx4_mr_btree_init(&priv->mr.cache, MLX4_MR_BTREE_CACHE_N * 2, - dev->device->numa_node)) { - /* rte_errno is already set. */ - return -rte_errno; - } - rte_rwlock_write_lock(&mlx4_mem_event_rwlock); - LIST_INSERT_HEAD(&mlx4_mem_event_cb_list, priv, mem_event_cb); - rte_rwlock_write_unlock(&mlx4_mem_event_rwlock); exit: return ret; } @@ -761,6 +747,23 @@ mlx4_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev) /* Update link status once if waiting for LSC. */ if (eth_dev->data->dev_flags & RTE_ETH_DEV_INTR_LSC) mlx4_link_update(eth_dev, 0); + /* + * Once the device is added to the list of memory event + * callback, its global MR cache table cannot be expanded + * on the fly because of deadlock. If it overflows, lookup + * should be done by searching MR list linearly, which is slow. + */ + err = mlx4_mr_btree_init(&priv->mr.cache, + MLX4_MR_BTREE_CACHE_N * 2, + eth_dev->device->numa_node); + if (err) { + /* rte_errno is already set. */ + goto port_error; + } + /* Add device to memory callback list. */ + rte_rwlock_write_lock(&mlx4_mem_event_rwlock); + LIST_INSERT_HEAD(&mlx4_mem_event_cb_list, priv, mem_event_cb); + rte_rwlock_write_unlock(&mlx4_mem_event_rwlock); rte_eth_dev_probing_finish(eth_dev); continue; port_error: -- 2.11.0