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 279FF45546 for ; Tue, 2 Jul 2024 04:20:16 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 11F1B40677; Tue, 2 Jul 2024 04:20:16 +0200 (CEST) Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2139.outbound.protection.outlook.com [40.107.93.139]) by mails.dpdk.org (Postfix) with ESMTP id AFD7C40658; Tue, 2 Jul 2024 04:20:12 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CbjsRtUV4L88xbUtO1vNPkyFSWlRcAD6EIdMRw7cnpWAgD0G663S3gRkLesYVr4BpPOiU1bIMWxBZB+KeNFFchRTR6AUBY+6aGrJaEwZPVy8ZyAsupdvma36h+ceytf5+75GY4fNvue+esXFoNMlR/ZVdcsoQIrEarLwQr5oVW8o+Xv23+Nq/iwet0Mutn1CrlqXGHzq5XYpsmHRANHVHgcLJITnUE8MQz0V+VnGeYWLJQnmNaGyI34BC0HNfEzeDfkixcPnp4uyA7JA/6TBtWT0i2QVq59Yl7JT4IlPFWYs/qGogGzUPHCh2IbxA/exomtzwnur4Zs6GWnrHlZoBg== 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=8DpkGr+4O1mCUCkX2MWge2hveo9hcGyZbJ3qftMBMgs=; b=eC40hnTt5QLZSqrOk8q7Y0Plvc0b4XTVQXkHSFmRX1E4SUkdQ0Gn0nFJL0srnoxqRm3FkZVKuxbV+GjwRGkozc/SdXWROFLu2gK974S4tg2UGn1bnQjZMBE88YLrNW7DKPbV+IOLOEotTayqxpAZjGyV1vcMbLhj1U6LmxPQVjCw/Ukd8tGHvWBC0E5HRV/oUNIICT4AcCM0eRhQuUvU2WjGLTny0j0UPpCGtKijvBK2qh7BrFlEkE04htLy6IPrYXDt8+OaB9aryXwCMtRJbxbEqyohFvA2NNAyv0TXRG+6B0dopXZv1aL+fwRlzKRBrxDPqU2j+T0ICAC4dEfmSQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=corigine.com; dmarc=pass action=none header.from=corigine.com; dkim=pass header.d=corigine.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=corigine.onmicrosoft.com; s=selector2-corigine-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=8DpkGr+4O1mCUCkX2MWge2hveo9hcGyZbJ3qftMBMgs=; b=VUmVWSrZRNcNRfRgSsdkKLHxEc3vtslfOPCBTIusRdkLO/8tzeWTGlwODE0LM1Y6NMzu2klYJ811EvKaG+wq+o3zXRm2Q+Xu9ZTXeQs+Y2R6vEysM/fGYfbX/olMR2kwPM72Ux5GWXkr1w6y/sRvXFdiCQhgibsQpCxu3318ynI= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=corigine.com; Received: from SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) by IA3PR13MB6950.namprd13.prod.outlook.com (2603:10b6:208:532::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7719.29; Tue, 2 Jul 2024 02:20:11 +0000 Received: from SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::b900:5f05:766f:833]) by SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::b900:5f05:766f:833%4]) with mapi id 15.20.7719.028; Tue, 2 Jul 2024 02:20:11 +0000 From: Chaoyong He To: dev@dpdk.org Cc: oss-drivers@corigine.com, Zerun Fu , mukawa@igel.co.jp, stable@dpdk.org, Chaoyong He , Long Wu , Peng Zhang Subject: [PATCH v5 3/3] bus/pci: fix secondary process save 'FD' problem Date: Tue, 2 Jul 2024 10:19:46 +0800 Message-Id: <20240702021946.4194102-4-chaoyong.he@corigine.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20240702021946.4194102-1-chaoyong.he@corigine.com> References: <20240628073624.4122899-1-chaoyong.he@corigine.com> <20240702021946.4194102-1-chaoyong.he@corigine.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: SJ0PR03CA0040.namprd03.prod.outlook.com (2603:10b6:a03:33e::15) To SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR13MB5545:EE_|IA3PR13MB6950:EE_ X-MS-Office365-Filtering-Correlation-Id: 3e05ef6c-30b0-4409-9512-08dc9a3d7feb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|52116014|1800799024|366016|38350700014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?scPTY1elI6/BJB2G8qJnxBX1QO4WiR0C1nQlftn4119TnpAXjQSYlqdDMIiz?= =?us-ascii?Q?h9fhtrJP//vpmwlrPhgQj1stbv4OKTjJAc3ZAqA0siCQMl7DopUU5tP+aWdE?= =?us-ascii?Q?UGwjvi4B3ayNIUW00lrZGEl3IKbU0Wr5np0nQVcbkH3Lckl88X5GcgH1NFZg?= =?us-ascii?Q?LSfMryZaGN6oIe65g6l/RuCgCn34UPpXtxI86G9wwKDvIaCHU6EKHDjT67Ub?= =?us-ascii?Q?02CWFVKNIJpRP9TznAL9AIoLF7WbJcbdJdXHRHYOkW03PiF3hCd4LUXGi+ZR?= =?us-ascii?Q?sPG2O64T038FIRv3CHyk/R5TBbk95BL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+viuFLjLmJCSjfd0rXRNb7QlxUmE+wnVvrXGGlQwPMAvfr0v9Tqdkr?= =?us-ascii?Q?+8LFEOBOOFwk/Kcp3XoON9s+jjI+n+i9K2narbcTjPjf9hrTpf1Zu4PgcDM1?= =?us-ascii?Q?2apuPv6Vu/W+AmlTFLXFMis6BTXTllfOQiIXOqJCVFhNTrG0PNh8n/ZXnOEF?= =?us-ascii?Q?bBJfquAYeCK7BO2NwLM0wGdYO1q4EQ/gpRg8hPmL0Gz011mKhg=3D=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SJ0PR13MB5545.namprd13.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(376014)(52116014)(1800799024)(366016)(38350700014); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?6S8tDL9Et6Mah+FDJyabU8fkQdwfeMQD34pCE+YjE12mByROzOsm2vPS5Kgf?= =?us-ascii?Q?bKMfudeD8ZXDaQcSASQSCqYSo1LB0u3MVeJmHBCEWLBqLWvyfFf4mJ/OBl/U?= =?us-ascii?Q?gMAAMHO9l/mD4UMCJtwBRHc6n2CxyrwK9Ffyi/jWff9HqCMEz2mQVOFfg3Xz?= =?us-ascii?Q?/dOCTgcfXSiawm/Aj+TlN4cYjiG1EKbwFK08GMdFq81nu9ge3q3n6h4Odr5Z?= =?us-ascii?Q?GtpUU7GDfM72+eEkAK6+tp0V2jooC3I1VpHcVXSw1wRgBzzU/Ev4C6LJXWOO?= =?us-ascii?Q?/b7Taf7xlYM8UErCROa8oLhQqkkPQ7RuDNCvYq4F71ZjKYUVqgAiWeGwe9fG?= =?us-ascii?Q?Lnen4dJC26gy09uKQHTM9geTsJxCMykkc9Ht3MBqc4OWU4I8l3l94zlpS01u?= =?us-ascii?Q?1JFKON8KmYzCOGO3bXVKlnG7+o5ryTSJgn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Mmrg3e1JJaQ3fDDVps/Sk2GJ9poCUwprhjvmxkJlfT2?= =?us-ascii?Q?1QOeRjoNqZo7bfRdvk+OQaXeJoyK2TLFMaJFfATv4cSgmmq6Orf/KtU0M+gG?= =?us-ascii?Q?BilQ3U4yyhL69uzxNcigZpEA78GpwSHvLIftai1ZhkLRkBE9ksp+Qupof3ZM?= =?us-ascii?Q?4Pox9+vQF6c132WBs+7ESaUKcb6Gx/fBfnwIzcg2eQkHl55P+9h4AFwbwxba?= =?us-ascii?Q?0yPGsjXTorw2WlQ4U66FWxafZBzWgCpSjMq29NmJRhtqbaSCJFXLJ7ooJDN1?= =?us-ascii?Q?Og=3D=3D?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3e05ef6c-30b0-4409-9512-08dc9a3d7feb X-MS-Exchange-CrossTenant-AuthSource: SJ0PR13MB5545.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Jul 2024 02:20:11.2400 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: fe128f2c-073b-4c20-818e-7246a585940c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: VHeA7Kk8i65Dtl/M6ER/SwdBNSHVMXWIGoZHpE5Rap9dyia7iX77mSfV0X+D05bq+ybm5kN7OBTh4EPVrbfqkCAvm4zfab/JU8WrnBT4++0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA3PR13MB6950 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org From: Zerun Fu In the previous logic the 'fd' was only saved in the primary process, but for some devices this value is also used in the secondary logic. For example, the call of 'rte_pci_find_ext_capability()' will fail in the secondary process. Fix this problem by getting and saving the value of 'fd' also in the secondary process logic. Fixes: 9b957f378abf ("pci: merge uio functions for linux and bsd") Cc: mukawa@igel.co.jp Cc: stable@dpdk.org Signed-off-by: Zerun Fu Reviewed-by: Chaoyong He Reviewed-by: Long Wu Reviewed-by: Peng Zhang --- drivers/bus/pci/linux/pci_uio.c | 5 ++++- drivers/bus/pci/pci_common_uio.c | 32 ++++++++++++++++---------------- 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/drivers/bus/pci/linux/pci_uio.c b/drivers/bus/pci/linux/pci_uio.c index 97d740dfe5..4afda97858 100644 --- a/drivers/bus/pci/linux/pci_uio.c +++ b/drivers/bus/pci/linux/pci_uio.c @@ -237,7 +237,7 @@ pci_uio_alloc_resource(struct rte_pci_device *dev, } snprintf(devname, sizeof(devname), "/dev/uio%u", uio_num); - /* save fd if in primary process */ + /* save fd */ fd = open(devname, O_RDWR); if (fd < 0) { RTE_LOG(ERR, EAL, "Cannot open %s: %s\n", @@ -275,6 +275,9 @@ pci_uio_alloc_resource(struct rte_pci_device *dev, } } + if (rte_eal_process_type() != RTE_PROC_PRIMARY) + return 0; + /* allocate the mapping details for secondary processes*/ *uio_res = rte_zmalloc("UIO_RES", sizeof(**uio_res), 0); if (*uio_res == NULL) { diff --git a/drivers/bus/pci/pci_common_uio.c b/drivers/bus/pci/pci_common_uio.c index 432d68b12c..09f30bee6c 100644 --- a/drivers/bus/pci/pci_common_uio.c +++ b/drivers/bus/pci/pci_common_uio.c @@ -106,15 +106,15 @@ pci_uio_map_resource(struct rte_pci_device *dev) if (rte_intr_dev_fd_set(dev->intr_handle, -1)) return -1; - /* secondary processes - use already recorded details */ - if (rte_eal_process_type() != RTE_PROC_PRIMARY) - return pci_uio_map_secondary(dev); - /* allocate uio resource */ ret = pci_uio_alloc_resource(dev, &uio_res); if (ret) return ret; + /* secondary processes - use already recorded details */ + if (rte_eal_process_type() != RTE_PROC_PRIMARY) + return pci_uio_map_secondary(dev); + /* Map all BARs */ for (i = 0; i != PCI_MAX_RESOURCE; i++) { /* skip empty BAR */ @@ -230,6 +230,18 @@ pci_uio_unmap_resource(struct rte_pci_device *dev) if (uio_res == NULL) return; + /* close fd */ + if (rte_intr_fd_get(dev->intr_handle) >= 0) + close(rte_intr_fd_get(dev->intr_handle)); + uio_cfg_fd = rte_intr_dev_fd_get(dev->intr_handle); + if (uio_cfg_fd >= 0) { + close(uio_cfg_fd); + rte_intr_dev_fd_set(dev->intr_handle, -1); + } + + rte_intr_fd_set(dev->intr_handle, -1); + rte_intr_type_set(dev->intr_handle, RTE_INTR_HANDLE_UNKNOWN); + /* secondary processes - just free maps */ if (rte_eal_process_type() != RTE_PROC_PRIMARY) return pci_uio_unmap(uio_res); @@ -241,16 +253,4 @@ pci_uio_unmap_resource(struct rte_pci_device *dev) /* free uio resource */ rte_free(uio_res); - - /* close fd if in primary process */ - if (rte_intr_fd_get(dev->intr_handle) >= 0) - close(rte_intr_fd_get(dev->intr_handle)); - uio_cfg_fd = rte_intr_dev_fd_get(dev->intr_handle); - if (uio_cfg_fd >= 0) { - close(uio_cfg_fd); - rte_intr_dev_fd_set(dev->intr_handle, -1); - } - - rte_intr_fd_set(dev->intr_handle, -1); - rte_intr_type_set(dev->intr_handle, RTE_INTR_HANDLE_UNKNOWN); } -- 2.39.1