From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id DDF46A0C4C; Tue, 23 Nov 2021 16:38:51 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 766A940040; Tue, 23 Nov 2021 16:38:51 +0100 (CET) Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2065.outbound.protection.outlook.com [40.107.236.65]) by mails.dpdk.org (Postfix) with ESMTP id 826AA4003C; Tue, 23 Nov 2021 16:38:49 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iZPqC5Zr2r/Ii4Vh4QbFqrnHJGCGxN4xKubnVzJqlOXW7eHTZTyAOpJ260TgQABsT+MuJ0t+B+cQo778PlFsrJ3XooVTC66V37wsK8gMcAIXG+KDMaD1yy9Tp4hXroFf952JGqtRA+PNairvzTtdZieRUVn1BSDIOIobUHBxyztlbTgXU832zme5dhUjs+cx6zzflVYWo+xDQQIa5coNc0lh2OXvU7DJTwRt+fY007hGhrcA5pVFLqTChyhNwZ+I0728DzqF9C3LdNYyh0j2tVMB6xl7+i9sicUs3Hj2V8jhyPPcH1EgStN0U7aWi96lzK4vFvcS6gbr5yMCNOwt7Q== 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=IQ/+oFF5y5aNFOnEzYhkWc/qLePwj3XivpgmGmrDsko=; b=bbjsF6nP8TW+8u+/l2KEKr3M7ekoLHJmZurc1SoMHjo46t2C1Tjht8U9kskl1jB0Gi3NcYeai5tSj/0vnT9dCfZJPb3EsNKeNbqtNOIhXhv21cKPdc8ihaDNX2sI3M2e7jghtRUfIUo0HLhAeOa8YlBRvb1qCjSfYMmk8Ll4pxvk6Qe69uok3tNzUpQm8AJlSk2u5jwDo4VF9wBS6l7/QIv7AsrPKug6eM/FfDaa3pFaBcxeTOHKEtP2eVVP1iGH6yJ8WOZH4vke0E1PhbT5ULrqHiXBG0DFFmE2Bw//ugJ9mVInZx4bkbWW3Qa2OQcjO8jfi9GjjNHGSqy5gWLN/w== 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=quarantine 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=IQ/+oFF5y5aNFOnEzYhkWc/qLePwj3XivpgmGmrDsko=; b=lmdlprkPZ8JxYhdZTjVOjKsUXblhH8QNGwgM6Tu89wMZE3dFUvyA8gBsjNm97jD8DcawJZXX/fX7DEPVDcsrIXlFmRwYmMrSOEYZk/r2im2ZqGu6DsDHPWoB1D5x4F51RFBbz72AGs6TPky3on1vddP2NU2voYVzavXJPZJHt5yokTapKQ+cC2GPJ8SYRD10J9LC/0LTrweAnX+lRg00YAp/7O1FcMGRGTiytOcM4tHrr1RvOPT1OEXu3ul1QrTE+D+VWPe8k2ZrtFGRCepPFVa+NGuuUWk+tUXy98Gie4/7aFf9kP9XVdgGa3LpEvCRlnwNL8gni3/2SOTzvR4x0w== Received: from MW4PR03CA0332.namprd03.prod.outlook.com (2603:10b6:303:dc::7) by BL0PR12MB4945.namprd12.prod.outlook.com (2603:10b6:208:1c4::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4713.19; Tue, 23 Nov 2021 15:38:46 +0000 Received: from CO1NAM11FT008.eop-nam11.prod.protection.outlook.com (2603:10b6:303:dc:cafe::e5) by MW4PR03CA0332.outlook.office365.com (2603:10b6:303:dc::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4713.19 via Frontend Transport; Tue, 23 Nov 2021 15:38:46 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;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 CO1NAM11FT008.mail.protection.outlook.com (10.13.175.191) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4713.20 via Frontend Transport; Tue, 23 Nov 2021 15:38:46 +0000 Received: from nvidia.com (172.20.187.5) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Tue, 23 Nov 2021 15:38:39 +0000 From: Dariusz Sosnowski To: Matan Azrad , Viacheslav Ovsiienko , Dmitry Kozlyuk CC: , Raslan Darawsheh , Subject: [PATCH v4] net/mlx5: fix refcount on detached indirect action Date: Tue, 23 Nov 2021 17:38:05 +0200 Message-ID: <20211123153805.192398-1-dsosnowski@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211122170949.81466-1-dsosnowski@nvidia.com> References: <20211122170949.81466-1-dsosnowski@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [172.20.187.5] X-ClientProxiedBy: HQMAIL105.nvidia.com (172.20.187.12) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f007ceb8-2ef6-4b2f-5bcb-08d9ae975671 X-MS-TrafficTypeDiagnostic: BL0PR12MB4945: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:250; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: RwWzRhYeeS4bvnqwPNrFPVkt+dqZEBkLBu1gTSZDdcckY3ryK/m10vw8537uYGth7Lpp1H6j9murt6ZcBK7+UhCp56KN6WJsIsSDk/EmlTFUlGdxINo7WG8ndLxSYQiGdutZqUT74G3W5lORVnfCk3GEwDQ7NYp5JnS1uexL8TLTBJ1NXDqFsK+tzLMmsyo6XwodYJ35JLxAs2bxV7GfvKCzn3fC0TNHd4Q8tOURjPEQczihvbz7DGabECvg+1wypRoSrunM4G+mdmC47YQTGahTHygYgWFMh4o/N0iBW5oq4ZDX9QA2RiwM0+E/sQoF9OR2lJ4YDsFinGwAnRaJbtUxqMl365i7JnIabDOVmcJuc7jRMui0DQP4xBm6j0zLZZhPrKJsPobgUEbiUQ+WZPsO08hl5FdQpDG81g2JzSUY3MHTiazCT9sacoZKmVzkOoJ9Jgf+qf3+i9RSwvj2y2Rhppe+cKtEIGyeppbdYU27oeFrCpRnrx1y81+zLDJsivTPXsIPC6iFc4+lA0FDr8ORIzTMKrak5360PLODtAvBvnINSIiEfg15wlzgYqbd8m2kiALQYg92Voiux81RavNCBYkNCqQnFyH5pKHo90GK4LOSQqwfBZzMkExpwhmrCn07RjAjoAppLo/YotD69zOnyNFEzryOQUHIepzzMYi8Ii0KKYvg/xIavychYP9QD87chNn75VZ+uXH5yYQUfMPszTR15dCfNRy4aZZz0aA= 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)(70206006)(186003)(16526019)(6636002)(26005)(70586007)(7636003)(7696005)(8936002)(55016003)(1076003)(83380400001)(5660300002)(356005)(8676002)(86362001)(6286002)(2906002)(508600001)(426003)(36756003)(336012)(4326008)(36860700001)(450100002)(2616005)(36906005)(316002)(54906003)(110136005)(6666004)(47076005)(82310400004)(309714004); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Nov 2021 15:38:46.2380 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f007ceb8-2ef6-4b2f-5bcb-08d9ae975671 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: CO1NAM11FT008.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL0PR12MB4945 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org This patch fixes segfault which was triggered when port, with indirect actions created, was closed. Segfault was occurring only when RTE_LIBRTE_MLX5_DEBUG was defined. It was caused by redundant decrement of RX queues refcount: - refcount was decremented when port was stopped and indirect actions were detached from RX queues (port stop), - refcount was decremented when indirect actions objects were destroyed (port close or destroying of indirect action). This patch fixes behavior. Dereferencing RX queues is done if and only if indirect action is explicitly destroyed by the user or detached on port stop. Dereferencing RX queues on action destroy operation depends on an argument to the wrapper of indirect action destroy operation, introduced in this patch. Fixes: ec4e11d41d12 ("net/mlx5: preserve indirect actions on restart") Cc: dkozlyuk@nvidia.com Cc: stable@dpdk.org Signed-off-by: Dariusz Sosnowski Acked-by: Matan Azrad --- v4: * Simplify dev_started checking. * Remove redundant passes of deref_rxqs argument. v3: * Fix handling action destroy in between port start and stop. * Revert moving contents of mlx5_action_handle_destroy v2: * Introduce wrapper over action action destroy operation. * Fix typos in commit message. drivers/net/mlx5/mlx5_flow_dv.c | 5 +++-- drivers/net/mlx5/mlx5_rx.h | 3 ++- drivers/net/mlx5/mlx5_rxq.c | 21 ++++++++++++++------- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c index 2f03e59f9c..1d46fa48b0 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -14732,7 +14732,7 @@ __flow_dv_action_rss_setup(struct rte_eth_dev *dev, error_hrxq_new: err = rte_errno; __flow_dv_action_rss_hrxqs_release(dev, shared_rss); - if (!mlx5_ind_table_obj_release(dev, shared_rss->ind_tbl, true)) + if (!mlx5_ind_table_obj_release(dev, shared_rss->ind_tbl, true, true)) shared_rss->ind_tbl = NULL; rte_errno = err; return -rte_errno; @@ -14875,7 +14875,8 @@ __flow_dv_action_rss_release(struct rte_eth_dev *dev, uint32_t idx, NULL, "shared rss hrxq has references"); queue = shared_rss->ind_tbl->queues; - remaining = mlx5_ind_table_obj_release(dev, shared_rss->ind_tbl, true); + remaining = mlx5_ind_table_obj_release(dev, shared_rss->ind_tbl, true, + !!dev->data->dev_started); if (remaining) return rte_flow_error_set(error, EBUSY, RTE_FLOW_ERROR_TYPE_ACTION, diff --git a/drivers/net/mlx5/mlx5_rx.h b/drivers/net/mlx5/mlx5_rx.h index 9cc1a2703b..b19464bb37 100644 --- a/drivers/net/mlx5/mlx5_rx.h +++ b/drivers/net/mlx5/mlx5_rx.h @@ -225,7 +225,8 @@ struct mlx5_ind_table_obj *mlx5_ind_table_obj_get(struct rte_eth_dev *dev, uint32_t queues_n); int mlx5_ind_table_obj_release(struct rte_eth_dev *dev, struct mlx5_ind_table_obj *ind_tbl, - bool standalone); + bool standalone, + bool deref_rxqs); int mlx5_ind_table_obj_setup(struct rte_eth_dev *dev, struct mlx5_ind_table_obj *ind_tbl); int mlx5_ind_table_obj_modify(struct rte_eth_dev *dev, diff --git a/drivers/net/mlx5/mlx5_rxq.c b/drivers/net/mlx5/mlx5_rxq.c index 480f4f9f07..1f6ddbab8b 100644 --- a/drivers/net/mlx5/mlx5_rxq.c +++ b/drivers/net/mlx5/mlx5_rxq.c @@ -2195,6 +2195,9 @@ mlx5_ind_table_obj_get(struct rte_eth_dev *dev, const uint16_t *queues, * Indirection table to release. * @param standalone * Indirection table for Standalone queue. + * @param deref_rxqs + * If true, then dereference RX queues related to indirection table. + * Otherwise, no additional action will be taken. * * @return * 1 while a reference on it exists, 0 when freed. @@ -2202,7 +2205,8 @@ mlx5_ind_table_obj_get(struct rte_eth_dev *dev, const uint16_t *queues, int mlx5_ind_table_obj_release(struct rte_eth_dev *dev, struct mlx5_ind_table_obj *ind_tbl, - bool standalone) + bool standalone, + bool deref_rxqs) { struct mlx5_priv *priv = dev->data->dev_private; unsigned int i, ret; @@ -2215,8 +2219,10 @@ mlx5_ind_table_obj_release(struct rte_eth_dev *dev, if (ret) return 1; priv->obj_ops.ind_table_destroy(ind_tbl); - for (i = 0; i != ind_tbl->queues_n; ++i) - claim_nonzero(mlx5_rxq_deref(dev, ind_tbl->queues[i])); + if (deref_rxqs) { + for (i = 0; i != ind_tbl->queues_n; ++i) + claim_nonzero(mlx5_rxq_deref(dev, ind_tbl->queues[i])); + } mlx5_free(ind_tbl); return 0; } @@ -2573,7 +2579,7 @@ mlx5_hrxq_modify(struct rte_eth_dev *dev, uint32_t hrxq_idx, if (ind_tbl != hrxq->ind_table) { MLX5_ASSERT(!hrxq->standalone); mlx5_ind_table_obj_release(dev, hrxq->ind_table, - hrxq->standalone); + hrxq->standalone, true); hrxq->ind_table = ind_tbl; } hrxq->hash_fields = hash_fields; @@ -2583,7 +2589,8 @@ mlx5_hrxq_modify(struct rte_eth_dev *dev, uint32_t hrxq_idx, err = rte_errno; if (ind_tbl != hrxq->ind_table) { MLX5_ASSERT(!hrxq->standalone); - mlx5_ind_table_obj_release(dev, ind_tbl, hrxq->standalone); + mlx5_ind_table_obj_release(dev, ind_tbl, hrxq->standalone, + true); } rte_errno = err; return -rte_errno; @@ -2600,7 +2607,7 @@ __mlx5_hrxq_remove(struct rte_eth_dev *dev, struct mlx5_hrxq *hrxq) priv->obj_ops.hrxq_destroy(hrxq); if (!hrxq->standalone) { mlx5_ind_table_obj_release(dev, hrxq->ind_table, - hrxq->standalone); + hrxq->standalone, true); } mlx5_ipool_free(priv->sh->ipool[MLX5_IPOOL_HRXQ], hrxq->idx); } @@ -2666,7 +2673,7 @@ __mlx5_hrxq_create(struct rte_eth_dev *dev, return hrxq; error: if (!rss_desc->ind_tbl) - mlx5_ind_table_obj_release(dev, ind_tbl, standalone); + mlx5_ind_table_obj_release(dev, ind_tbl, standalone, true); if (hrxq) mlx5_ipool_free(priv->sh->ipool[MLX5_IPOOL_HRXQ], hrxq_idx); return NULL; -- 2.25.1