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 91A8A43EA9; Fri, 19 Apr 2024 05:27:04 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0C52B40693; Fri, 19 Apr 2024 05:26:58 +0200 (CEST) Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2112.outbound.protection.outlook.com [40.107.236.112]) by mails.dpdk.org (Postfix) with ESMTP id A8BAB40608; Fri, 19 Apr 2024 05:26:54 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DLqa2V47bPauE+0MXnwltAUjXpbcSqibtNurLOKS2XAxcQaBjNXopA39+yc7dQwuqCmMkE4ObN1j5KcTVlYjxeOjucMPCkdpzFieS0VzWfmMh0b0BXxoVQrIgeD1Q3B/FPqf3cjTTna7cjpEP8M5RKoUERTYKkrlFlRAGtkMxG4mqQIzPihIxIQ95ITtKV1RASYei6fUIfkrvKRGEKP4v6Wz4BXC3laCyhtn/33xjspeuntr/UtkFm2PT2LrHJ35t48Oq1Gz03Bw7W60pxChD2IOe8SZeRTIyb502WKVr3tI9dc5S9mfIN3RcE9WySc/ODBMoom8Olpjh8U3ZznV1A== 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=sIAqd443W9sHgM64xZS4RMueawsm4oE8C1S8pBZqJFk=; b=f6RbOYdnKmtmBfXHjtNTaItGihQmvVM/j4EJNhSEZHTfBVobL1wuTimoRsz1gT2O0s5DL4pKN2D3BfMEzzQ+BUbQvEFUZBxUm4KVzkuzrsRnpw5h6utdd8pBnmT8X/+xzXggJWaOuKPQRhiYpkwo/gNlOYTtKCYyUiTcFwvaKwBBOXsmsTd34eu+l0S3+sW66EuQsyJZ3ueX16gnCbY+RfCHP53zBZGKWD6PJBlNmydROtE9tcfdTiCKO6VsTkVtMtBFuoUMjOQRTsRbqWff2yCnNHu2SKv2IAfd3p00Impmyre/U1sLSfEiT3kz7IazG//MGpyR01Yrad2/Qp2IVg== 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=sIAqd443W9sHgM64xZS4RMueawsm4oE8C1S8pBZqJFk=; b=eQv7QBgttDneOM7Qa+RMjHrLaiJAQH37+8voKQj4SILKcK5qzRJroybWQ6jJvxhmtE6Oj4t/HNKZ6e1/7IL30bimbOu1LBO+TLFnAnLixJfDIPbHiMcYcWdzx7jue6TbxoqZTewYaPJE5UpjrUEKnd9mrGr+7ZsY2sLrM64jUB0= 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 PH7PR13MB6170.namprd13.prod.outlook.com (2603:10b6:510:241::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7472.41; Fri, 19 Apr 2024 03:26:53 +0000 Received: from SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::ec12:7411:559a:850e]) by SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::ec12:7411:559a:850e%5]) with mapi id 15.20.7472.042; Fri, 19 Apr 2024 03:26:53 +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 v3 2/2] bus/pci: fix secondary process save 'FD' problem Date: Fri, 19 Apr 2024 11:26:30 +0800 Message-Id: <20240419032630.1215256-3-chaoyong.he@corigine.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20240419032630.1215256-1-chaoyong.he@corigine.com> References: <20240129092231.3531217-1-chaoyong.he@corigine.com> <20240419032630.1215256-1-chaoyong.he@corigine.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: SI2PR01CA0008.apcprd01.prod.exchangelabs.com (2603:1096:4:191::10) To SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR13MB5545:EE_|PH7PR13MB6170:EE_ X-MS-Office365-Filtering-Correlation-Id: 4308a3d4-0e38-4515-3d48-08dc60208ef1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?ug0pFK9zd29/hvuB+T0EaZtHXCykU23VxGsn/sI3VGErX4i6Gmv59xbNhZ9Y?= =?us-ascii?Q?idOtOD2LLUnrWbFPPiqp9JgXCfg3JmrbXlyhQVHe92jRzUAzEuzHihnMPpx/?= =?us-ascii?Q?tXbT5nhzN+uNhKq6ZPrn6n+Qk9j48YdgfIzvtexvYOKRhqJS6oOsaV6GdIKX?= =?us-ascii?Q?4txvxjJ9dWh9Aky8woNuTaOy8sTPkTx9VrSo4O7cWDj/wK7+xsAdg4OBMSLZ?= =?us-ascii?Q?qqBAvmHup4eoU2n9gWdgkhyMxVgMvamgujqQ2IxSy0rZoWlvzwWGZvVFxM3B?= =?us-ascii?Q?q24Ep9oVsPjyg3blp3Li0IyJC0HDiCteeQ92OYojgVOEimN4cqaPT2Pn0F7G?= =?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X59jTdcPQztVhn2hMf/vigHM/9p9ic8aIM?= =?us-ascii?Q?GhmtLlthFfI9XSxcLhFBdxswPOFnLeaL9n+9fWQ8iXrxa6EZux27p1ZE4sPy?= =?us-ascii?Q?+VULSPEEOYl2b5c1IWca0CBYoN3u2mKWKU1YNiwZXDFhtA=3D=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SJ0PR13MB5545.namprd13.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(1800799015)(366007)(376005)(52116005)(38350700005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?x/mjA2tKbUs6wxWFZcP1vH+uJ1VNWumnQulzEeNEPuw8Y9cKsKHUJvmOASB2?= =?us-ascii?Q?gtfJYPkvCvHQSntowaMNrYBn0+eWIU8fw/KlSpMDODm8hxTBHjUM1VhRaa0C?= =?us-ascii?Q?PiBy5EHnPTKIV9KpUY8RVdofftji0brq6bpSxJrzteXcGr6eC2dUWg0odXy3?= =?us-ascii?Q?eM8NLRwHfEXtUuIZUD7SkTNHALKfX/v8aUXklYKSNfnkGh7qCiAmVowiPNkC?= =?us-ascii?Q?YSCgGcTA2EGKftAof7Fr74olhkrPdNHeot2WAqMLRK0mx2+bhPF9RlZCLeP7?= =?us-ascii?Q?Y8PaY55LvUuGzUaVMVZ+1VR+FLkwBB5P/apwKvzWm3D2B5HRW2HA01MWQ5Iw?= =?us-ascii?Q?ugtiuzObsJC2+bEVAA2Ekv5O8V748jDxAt+AJJFEj7BS6fNEXuZynrkHX6UG?= =?us-ascii?Q?b3kXjusM2PX2uivYeQq6kF4etfVXBwxz4lbt//IeQH+WVf9l7CD6jKIq6J9v?= =?us-ascii?Q?AQ+Sk6nuRz0CyAKbWcdlaZW6swo7vbW1HzfHibCnQXN8AkD+GNBvTHFcSCvZ?= =?us-ascii?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D3o4BM?= =?us-ascii?Q?kDYf9MYjAN3oxpoYwHNHzAVGVqdCDTnA0snNReoo5lMLf+kJ048ZgKfpL5iJ?= =?us-ascii?Q?4xdYANATI5sl0y2c857kNm0dEgmCSLdiEp1mMDJdklcr+4CdwvF3N6bsa4VC?= =?us-ascii?Q?zn/ufexiRlqaKWvvDqpq11V55rWgUp42diz6w9GpyqxtFNcyRXYwhWavVl+d?= =?us-ascii?Q?yA=3D=3D?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4308a3d4-0e38-4515-3d48-08dc60208ef1 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR13MB5545.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Apr 2024 03:26:53.4664 (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: j6MzpAPq1yLkNJ5ZyM7kSfBmp35u2HnFYfQ1c/fbRl65HEjjo5h+FgK8MqtEO15wNQNV/sIPgWJRdxH+qVSeiz5exb8fV1AVGnFkG56UOSc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR13MB6170 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: 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 | 8 ++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/bus/pci/linux/pci_uio.c b/drivers/bus/pci/linux/pci_uio.c index 97d740dfe5..6680e42efb 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", @@ -261,6 +261,9 @@ pci_uio_alloc_resource(struct rte_pci_device *dev, if (rte_intr_dev_fd_set(dev->intr_handle, uio_cfg_fd)) goto error; + if (rte_eal_process_type() != RTE_PROC_PRIMARY) + return 0; + if (dev->kdrv == RTE_PCI_KDRV_IGB_UIO) { if (rte_intr_type_set(dev->intr_handle, RTE_INTR_HANDLE_UIO)) goto error; diff --git a/drivers/bus/pci/pci_common_uio.c b/drivers/bus/pci/pci_common_uio.c index 432d68b12c..8688862738 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 */ -- 2.39.1