From patchwork Thu Aug 1 10:53:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hemant Agrawal X-Patchwork-Id: 142836 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id D3FDC45710; Thu, 1 Aug 2024 12:55:42 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D3CD943402; Thu, 1 Aug 2024 12:53:56 +0200 (CEST) Received: from DU2PR03CU002.outbound.protection.outlook.com (mail-northeuropeazon11012048.outbound.protection.outlook.com [52.101.66.48]) by mails.dpdk.org (Postfix) with ESMTP id F1D35432FC for ; Thu, 1 Aug 2024 12:53:51 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=qW+qJHfZBv+jBIQq4N2fXiqSoeCb3QLK6a1gUd5rccyliVyFg50lzXNkc/3TwYXc4wlYdcH6tKlr4vCPiLPpH0wBtytLoUVGEC64Qe3Dz4MIQRTcHMSQsPKHS9mNfS2RCGn44qMx0xDepNzzufc5zA7GYe7SbB2XC71xdx4p6j9Ey7ImtcVKFfopLAcqlRv0Dj19OI4MFfWdRLMcoaq+vwqqRBPwPLklD/h/Llk6oLGMm74HtAZqK4wlAPS8eb8IULsEw3mNByjbshGl6I8PuLDm1v5l2vjZivmjxECvxz/ubRpBWOEWPVNsrlbMJBoCTTp78Bh2Ibl+tqyX+7lCnA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=OcUTWabos+ukfSNeeUiiYAa/wYagJRcVhunT6thu9O8=; b=qgoBHF+XdnURvyM63eKlNOzgr5jAsNwF+SvJYPaYlXYfU2ocUMtfbTEV5Rwxn98LtkqqI86GwCsEsOve0pfsuTWHRWTG1WO9yqQv3FKrucZMemf3Yw34jXJBLir+k/QyOEj7G7zqLYqAVQeedT2ABvv3LNZLQsieZ3MvGaK8drfg0+4UL8UC+Uix2IsktTfIh9sv+vcAilJ5bg7BySCjaRBh3LRP2vtj/w8XGViAMITnL2pQpUDl18sTaTLhv9TeUjeYnFr05cLyeqVtKdPNKiGMWaQUz/BR0VhKfmFFxObpbR6nPD/HCFcH/aZyd0AcUoBFVDkKSFQzdOXeinJ3cg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=OcUTWabos+ukfSNeeUiiYAa/wYagJRcVhunT6thu9O8=; b=Hy+Q+gatFkiM9N+tOt2wPd9z+xTZSZOICgqiOMVkG4M3jiYybQU4BoCHALVDSW66l0GA79lFSrEtMTNMsfUj25q/U2P2jLIcMK9Zz4d4xs/T82zN8D90Qq0mwPTZJH2vtHCAROxvyr6OA8AyUGOSyOtP6dnwVGdV8J260zsFu8Zt3SWqSxlqS0B4fK+bANpq+4i6r+R9OOM7OyEthEpKoLFHWcuWTstP1oM7r9hLsBXHGeR8I7Q7UhOw6u5fXc/fLJNPBZf+z/mwwmxgjlxEwPSgTP0KluUx4Rg78CqlyXkhBdLFPPnLy9KxDYOJpGePWPXkc/9RI1yMEt31sLbyNA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB9328.eurprd04.prod.outlook.com (2603:10a6:102:2b6::15) by AM8PR04MB7377.eurprd04.prod.outlook.com (2603:10a6:20b:1de::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7828.22; Thu, 1 Aug 2024 10:53:50 +0000 Received: from PAXPR04MB9328.eurprd04.prod.outlook.com ([fe80::367:d59:375:fb87]) by PAXPR04MB9328.eurprd04.prod.outlook.com ([fe80::367:d59:375:fb87%3]) with mapi id 15.20.7828.021; Thu, 1 Aug 2024 10:53:50 +0000 From: Hemant Agrawal To: dev@dpdk.org Cc: ferruh.yigit@amd.com, Gagandeep Singh Subject: [PATCH 16/17] net/dpaa: improve the dpaa port cleanup Date: Thu, 1 Aug 2024 16:23:12 +0530 Message-Id: <20240801105313.630280-17-hemant.agrawal@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240801105313.630280-1-hemant.agrawal@nxp.com> References: <20240801105313.630280-1-hemant.agrawal@nxp.com> X-ClientProxiedBy: SG2P153CA0026.APCP153.PROD.OUTLOOK.COM (2603:1096:4:c7::13) To PAXPR04MB9328.eurprd04.prod.outlook.com (2603:10a6:102:2b6::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9328:EE_|AM8PR04MB7377:EE_ X-MS-Office365-Filtering-Correlation-Id: f4394f52-fd82-4e69-2637-08dcb2183a33 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|52116014|1800799024|376014|366016|38350700014; X-Microsoft-Antispam-Message-Info: wjgu/RRxMAXxy+StpVlh+L6HYFpAGj34olQNM8pkmH4Cx6f4dKzKoHwxbjrfvkRcGtvynT4SD2NaRpSdiKEpsE8l6tCq1SnKP6yTSxRpLWxRlerZAUj0ApB1Pa5v1UUcnzowG4fQcdFfvbFTGIqHEONqWHLXXmWIPS82XcnPt9zBJnQdlADA8nSFIJAdbvFxFHIGGA7T/jw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0TTDsKSEWimRI1Kw5NUcGojoSjcNy/jjDO/I6reZbOXHK7gMjmDDW5Z/DkM/UGfslNKmquFnXKXN4Q6Tv8E1IM41lSlZGVbi6hdSuiq4/OiYXQKJbQAaHCoZNIZyabFAlF+JXv3u8EQ+FmpUesw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PAXPR04MB9328.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(52116014)(1800799024)(376014)(366016)(38350700014); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: YwJuoOvOMKchKXgqKPrxZDaxLTUaLwgJcFib9bolDfnmBGG93HWF1eKF+9lDvcyi8zi1H6u+3biBZ2Q0yAusnf0VW2qxGiYOZL2PgsZyAEc4QEjopw1YRaFxP2zrT7jncEtyrKI+z2Y3Qwf7J6gxQLHZKL9Nofg0mxtlJQlTFKQRU0mXuX1TtuqxTl2PQx/mzAcrLeVzHj6AKtZEKm9gud4oE5QnsmR6Fdf5yMU3zRBU/b9i/g1/JjIkK6WViy8p1mfdXJRic2clhzQWI5z8UP3L+Wdtw27/Ana6ziux/yZvwH8WbzBTCmGDwopFvcud1yWw2Mys1hLGCJJ29Rz5YbmjYQFHpzQOiC+FtkWLBOHaDvV6W89USn+lXt/4nQrwwxqC5PT5N6tPv6HlqDPEeKUC5u5hedKs2zVYkxUdNTU+k7LESz0vgrwL9cqCM5/fdX+yw/zRuExFSUe/U5rl3FaKHiX49hAAB7LV0uMLuC9tfyOZpL8zLbuN7GkN7LuFZZYJuX42z2MQnlAbwq7nd3Tex52C1reMu2QeiIb/z+57iznpcT7XSSgoQzFLZPpilFIaRH9vnoNxTzoWkaiOJnBbGpR7zo6FWwXeKQCY5QvCKbDyesrG+X03GkDgpUuRVrHEq0PQ6L0kPcEo/3dvnkZZkJlmy7GEwD3EQ0dUq/AcQxB9vIAhbEso98CSWn+bZqR8I6PPzcysNCkYVEMw+rBpYxjEPqKbtA9UVLB9pe6TlRur3sKpGU0Ft/2cRy1SdfT1ihXhDOmsNQr9XCFLyIpU4/x/EkOQPOxvm6ckMgZRzBLhcUe5XdaDY+zX+a26rlsYy075GBlGP9PR3rKWWyhqTHe2wCxr4LbRamxD+ufW7E4Xi+3ETNWhrz5CF2DW7BT6SNEX21cMxf2/tcvuW3E0uj0a36Q6VNZMmUh1Otwj2QoRSrYV9XWX874qJay97ZlNo5pRp7yMw2HoxxG3cUOcWJitl2TartI2OHVgGIxbaxH6AlwrTl4hRhABwOxJLOA4XPjUnxX4AxfJOzxdRSPVFUUBGdB9DCkPNSyf9piM6A+xwgZ0lv9CQ3qncWNFc2EYxDPnzuAjlbNPsW3fGOKGWzcpFfHplFp4dR5xWRV0rDtd54GcKS0FF6837JdQEwPomjw1hqI4HAJvEy2iZfdMdhWZTOYl2TdearI6otHvOuIUlBE+2gaFy7S9Bke9WNZxzXTw+R3Rb/oY4y5TdZcksTi/IXG7xRgWS8OPEVbAfAwt49DDGhLn7a0w6e0LtFZBaucw/AroX+5q+XwH6eHX9rEirt6AKPeYErZFUrDTMck1BFL6GPvhJxbA2gv9I0mfF/P/RUOVidbLWO6rAJ8m8pGkiax3qFlR/gNHSdjgBfNTlXGKUCVrrRcJEA3apbds7p6Kvz268VvBrAT+bnRaTpYYghBONKUOpkh8eKndV6GcbjU9expyHdlpgnj8DpNjwdwodH1mNIdRQdhoJeKEAKZRYhDUuwaKJ2r9oNnAl9DCnV52B2mRy/vY2ETa5mhyZOroYfjRcGQbiPU6xK269RYYChXlF1gaCfsiWurR5zBk0fqkojNP+bZZLlMpLNdSkTzaIgaZ0Hr7HFHmbA== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: f4394f52-fd82-4e69-2637-08dcb2183a33 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9328.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Aug 2024 10:53:50.6349 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 6lgeow1nMh2tlGNecG9LkbHZ9y+nhvNJ+qSXQhzKNUP8lCQfToPOvbOwZalDH3uJQVUAvN/lLWSdBRwxsjjZyg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR04MB7377 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 From: Gagandeep Singh During DPAA cleanup in FMCLESS mode, application can see segmentation fault in device close API and in DPAA destructor execution. Segmentation fault in device close is because driver reducing the number of queues initialised during device configuration without releasing the actual queues. And segmentation fault in DPAA destruction is because it is trying to access RTE* devices whose memory has been released in rte_eal_cleanup() call by the application. This patch improves the behavior. Signed-off-by: Gagandeep Singh --- drivers/net/dpaa/dpaa_ethdev.c | 35 ++++++++++++---------------------- drivers/net/dpaa/dpaa_flow.c | 8 ++++---- 2 files changed, 16 insertions(+), 27 deletions(-) diff --git a/drivers/net/dpaa/dpaa_ethdev.c b/drivers/net/dpaa/dpaa_ethdev.c index 56607034a9..863c1155c8 100644 --- a/drivers/net/dpaa/dpaa_ethdev.c +++ b/drivers/net/dpaa/dpaa_ethdev.c @@ -1,7 +1,7 @@ /* SPDX-License-Identifier: BSD-3-Clause * * Copyright 2016 Freescale Semiconductor, Inc. All rights reserved. - * Copyright 2017-2020,2022 NXP + * Copyright 2017-2020,2022-2023 NXP * */ /* System headers */ @@ -557,10 +557,10 @@ static int dpaa_eth_dev_close(struct rte_eth_dev *dev) if (dpaa_intf->cgr_rx) { for (loop = 0; loop < dpaa_intf->nb_rx_queues; loop++) qman_delete_cgr(&dpaa_intf->cgr_rx[loop]); + rte_free(dpaa_intf->cgr_rx); + dpaa_intf->cgr_rx = NULL; } - rte_free(dpaa_intf->cgr_rx); - dpaa_intf->cgr_rx = NULL; /* Release TX congestion Groups */ if (dpaa_intf->cgr_tx) { for (loop = 0; loop < MAX_DPAA_CORES; loop++) @@ -574,6 +574,15 @@ static int dpaa_eth_dev_close(struct rte_eth_dev *dev) rte_free(dpaa_intf->tx_queues); dpaa_intf->tx_queues = NULL; + if (dpaa_intf->port_handle) { + if (dpaa_fm_deconfig(dpaa_intf, fif)) + DPAA_PMD_WARN("DPAA FM " + "deconfig failed\n"); + } + if (fif->num_profiles) { + if (dpaa_port_vsp_cleanup(dpaa_intf, fif)) + DPAA_PMD_WARN("DPAA FM vsp cleanup failed\n"); + } return ret; } @@ -2563,26 +2572,6 @@ static void __attribute__((destructor(102))) dpaa_finish(void) return; if (!(default_q || fmc_q)) { - unsigned int i; - - for (i = 0; i < RTE_MAX_ETHPORTS; i++) { - if (rte_eth_devices[i].dev_ops == &dpaa_devops) { - struct rte_eth_dev *dev = &rte_eth_devices[i]; - struct dpaa_if *dpaa_intf = - dev->data->dev_private; - struct fman_if *fif = - dev->process_private; - if (dpaa_intf->port_handle) - if (dpaa_fm_deconfig(dpaa_intf, fif)) - DPAA_PMD_WARN("DPAA FM " - "deconfig failed"); - if (fif->num_profiles) { - if (dpaa_port_vsp_cleanup(dpaa_intf, - fif)) - DPAA_PMD_WARN("DPAA FM vsp cleanup failed"); - } - } - } if (is_global_init) if (dpaa_fm_term()) DPAA_PMD_WARN("DPAA FM term failed"); diff --git a/drivers/net/dpaa/dpaa_flow.c b/drivers/net/dpaa/dpaa_flow.c index 810b187405..2240f8d27c 100644 --- a/drivers/net/dpaa/dpaa_flow.c +++ b/drivers/net/dpaa/dpaa_flow.c @@ -1,5 +1,5 @@ /* SPDX-License-Identifier: BSD-3-Clause - * Copyright 2017-2019,2021 NXP + * Copyright 2017-2019,2021-2023 NXP */ /* System headers */ @@ -812,8 +812,6 @@ int dpaa_fm_config(struct rte_eth_dev *dev, uint64_t req_dist_set) return -1; } - dpaa_intf->nb_rx_queues = dev->data->nb_rx_queues; - /* Open FM Port and set it in port info */ ret = set_fm_port_handle(dpaa_intf, req_dist_set, fif); if (ret) { @@ -822,7 +820,7 @@ int dpaa_fm_config(struct rte_eth_dev *dev, uint64_t req_dist_set) } if (fif->num_profiles) { - for (i = 0; i < dpaa_intf->nb_rx_queues; i++) + for (i = 0; i < dev->data->nb_rx_queues; i++) dpaa_intf->rx_queues[i].vsp_id = fm_default_vsp_id(fif); @@ -1147,6 +1145,8 @@ int rte_pmd_dpaa_port_set_rate_limit(uint16_t port_id, uint16_t burst, if (ret) { DPAA_PMD_ERR("Failed to set rate limit ret = %#x\n", -ret); + if (!port_handle_exists) + fm_port_close(handle); return -ret; }