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 D5C124551D; Fri, 28 Jun 2024 09:37:12 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 43738427E6; Fri, 28 Jun 2024 09:36:57 +0200 (CEST) Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2099.outbound.protection.outlook.com [40.107.237.99]) by mails.dpdk.org (Postfix) with ESMTP id 2D1A4427B2; Fri, 28 Jun 2024 09:36:53 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fADpAFpw0p7b44YJ0IxVPoY5LM3tTSgTdH0GwzPswm9E1KaEYliEYGOR1Kx4cvYHQqaM3FXOEHbMlpzkcm9Xn8qqn+VCHZEv88+KOnhGPJHmVc8uRO+Wf5LgETnv+y1uQvqlFb4pmn65RX3HU+bUW/9oE+3m58UPIvOa2QSptfyFoxbOOZk+3nVe+6WCzMTLszDR6IPy7V//qCm7eixOn1Y+r7hwnEQTWdBhgwLyPh1uF7U4FCLnul44GdUCpVI7WdRoG5ji/iCDr+GzR3kur+yYXimWBxIJU2OYjFtpmouAjXd4G7RxIh5JySNno4BZEifXaFovRGjst7uL2PDVNA== 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=UuqNr8Is0JRSQFBVXWhI47qUJjPC23+Hdjoh38d2qhePunUdYWD8KPO5EWXKusyquy6OSouOtrhTLcITFauCFpb7gFXHO1Ct+7cN6NZaYZCDyVngHDnxaezrp4OuZlfKApk//4/0z6FKyfCmR06pZeuL+XCc31l3SG59MY7CvuJRoR1SfQLEFiimqR8VfGMfqlh0Nig7R6h1lnZ+eL9CKaT/a/dswsqGjfubQpAMKBg++f91xesS9njUNkyRUQjM2oF/ewCmNVHkg+h1wMFAh29yxvL7hR/zuomQIyDDcILc5l1oYbCV3KSwW4I5HetlBWrDF8JMxOJQgholY1Iy1Q== 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=VdA+XNsfAT07NibB54K3aNzGvAwN4S9GmeIicLceXPdKqaVUYwqp4UyG0/tSRCR+C3gghvy8LsNMsQKdaa92FfP+sfxIzJv5WKei2v47Gm05UP7Wkza/anMX9DcnTwNQU1s+eFURdbQ2hgTXLk4PHUTwa6vWZJybVoaGEPYCSE4= 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 PH7PR13MB6416.namprd13.prod.outlook.com (2603:10b6:510:2e6::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7719.26; Fri, 28 Jun 2024 07:36:51 +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.7698.033; Fri, 28 Jun 2024 07:36:51 +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 v4 3/3] bus/pci: fix secondary process save 'FD' problem Date: Fri, 28 Jun 2024 15:36:24 +0800 Message-Id: <20240628073624.4122899-4-chaoyong.he@corigine.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20240628073624.4122899-1-chaoyong.he@corigine.com> References: <20240419032630.1215256-1-chaoyong.he@corigine.com> <20240628073624.4122899-1-chaoyong.he@corigine.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: SJ0PR03CA0065.namprd03.prod.outlook.com (2603:10b6:a03:331::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_|PH7PR13MB6416:EE_ X-MS-Office365-Filtering-Correlation-Id: 733ebf8b-f6d2-4cf5-177e-08dc97451395 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|366016|376014|52116014|1800799024|38350700014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?cby3IRtNSWhqR90vAeAAu0YYvew+mbcG7Diwizjh041EFczrkq9CpOqT0F+y?= =?us-ascii?Q?MWQLtpcNjXun2HudxcxEtFdF1XIpk6VewGiSvJIK5FCSoqvPqABFAKD/d0zE?= =?us-ascii?Q?bEtTFxmX6kO0CuyG2x9De2MA5J1G32T1f6nyD31Q/ckkAPYlGCD16PJc2CuW?= =?us-ascii?Q?7bOUB7JWX6gwcEJ6qp9FH/0J3HRXfM7C7+DxqTqelRn+WFepk/JHsaoTRHw1?= =?us-ascii?Q?QtbikOfgHTM7yUahbdLO9roLPQmeledZTXK5TEk5SCVevnD+rv8hgby4nELs?= =?us-ascii?Q?xph8hzTqGM4zIZ8jIbaXPN39eMlI8oLaLhB5TUwPql8lxOubqyrF+2yJsJYJ?=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CN2pLDnyFX5e7QSDztvG?= =?us-ascii?Q?LLqc/onV/OrBVZD6HzgYLGpc7XfRhYj3T8UffWc9uwqPqsIJrqzJ1o34ugNr?= =?us-ascii?Q?RJ51SjkqxX36CkXh3tF+pBva7qMrln5LITayEfCxyj8Gbik0ePcvMqObwnIr?= =?us-ascii?Q?fVeCPy3p5IuxvKCfSXhzVCzGI2GJmowyY4PEfCCTQYNnH6aO/g=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)(366016)(376014)(52116014)(1800799024)(38350700014); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?Hj7sFdJSlkstPZqFzaUKHTE1qg3RCaITNXDJ/0Hanh27iCkQiWjLPCujLxc4?= =?us-ascii?Q?Gt350ILyjcN1ih0w4P+X9ygaWVmeNBsQVAyZGA/pT32jb9qHijVCwlHMpksJ?= =?us-ascii?Q?KH3NIPwrEEZWA+a70e6+IL/Syae304/n5yPsbWDz9Ydj0Dccu0u7dCIKhH5H?= =?us-ascii?Q?hauLCkdlOTI7JJSbSvvL+EZPZrFN+uSS6gPVMVyu7m3BSpmnYisw7fkvpZLZ?= =?us-ascii?Q?NtgBcxZjFcYqMD5phbh4w3be9fWRrZMrG0C2OeAsd+x+682V8LDTJCTGWE57?= =?us-ascii?Q?eRJwzegGNWni7lpQb8USX6M1cNaHLPo0txZQ6dNBAQ7hGNZUi/Ju1B2GVPtR?= =?us-ascii?Q?yaT7fqU6k0iQR9/6egFWLAO2dPMDBviXn+nRTWcPdEF9N+5LPqauBM+NEvuF?= =?us-ascii?Q?VETqAg6nefV3umfluIqblsaPJKOMDP64lfOB0iNSBB9AHs0JItYYNMdDdm1m?= =?us-ascii?Q?c7CGRsp967UOmeijmb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CqyhaVAqTI/fRrN2T+pPvcyXLf0+4/BUBqVtITGI/TVkNUcgYJ6vryh0V/mc?= =?us-ascii?Q?OhDBXqVZpN1zTeGsNQ6qTCjeeHX7VHwvIMxDaRQJfToyx/YYHFDZJlE+RNoG?= =?us-ascii?Q?O7rz61eQOQ6NVTMmfqNMXODA8+BpXqzWGfAZ33xn/pH6lKtRVBU0Arxz+9Sl?= =?us-ascii?Q?DA4Ew1zFrV/uCVgpKSyqrgwhYXqfI3BzawQk4KIx0rRH3QmTIKYGXRtyY9n8?= =?us-ascii?Q?9g=3D=3D?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 733ebf8b-f6d2-4cf5-177e-08dc97451395 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR13MB5545.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jun 2024 07:36:51.9558 (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: CddUzMbcpP86RyHV4W3sBP16RbiDplVicPSmqE3CLkrxJ2cYXEKDulJRFkxq8btPGrTvcHoKq79amW1y+dnE15p2asY78nTpnZq2OOsfWpw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR13MB6416 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