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 78D34439FC for ; Mon, 29 Jan 2024 10:22:59 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6E74D40DFB; Mon, 29 Jan 2024 10:22:59 +0100 (CET) Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2109.outbound.protection.outlook.com [40.107.93.109]) by mails.dpdk.org (Postfix) with ESMTP id 7BCA640DCE; Mon, 29 Jan 2024 10:22:56 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aGwqRB0Awakt0Q5sYf+Zssc0m+kDI5mR9ije2vO3x8NuQbUz4N5/m+SnO+Ervfk1FaULebikxm2RtnUKOB2cxaiIoZg/fLTnLeqBIJcqEui1GvMiHdaXbCQQa7Bba08wzlDMsabXIO9YABzsbmJzqBVXlyWPe+4m1Apfco19GveypbBtfOhu1/wSfDwe//IwuNYz2DHIP8rZ7Fp6Dd/GzA/xujUR4XbvJjIVX3TZBXkXLkDpUPjvpEwellLRmYzs32icYaY8QQSVW+MzsJEQryOhyNSVKrJTtcoYDE770P9iY2vrPKycjBuPnd+OJA/qxLB4n1FldRn9zDpuYvhsZw== 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=aHFb/kb5ED5T5jmJpy4Mtx4j0jHzLar2ahRECY/e1zs=; b=dY6ALQC+4ZikGwjwYnmyvdvx7MHayTfToET8VUzGIrMCn1Nxqn4PLcER6z9tgFNuau2Gc/sUQzdxY4bUw0oc7nz7kvKS9hPn4n495D3t6ww9u5XUG49et4My3PIbCb5v4IQmiY6mgEMPhKBVu8XFCsCQPoQSt6YJlON5x2DLPgrCBqteS4vK3+5uh9cIFhPLKesdvHocES2ODLq4FT8zva+zEb9DaUIvbMMp+bzkgnGKEk8dnmqu8uxrMN4HnX9Tq+aKtAyGmrf9ySW46u8uyCkDaCCmjSrWmRiepUkIV6U3XTaJqYjO3VA98+oI21tR+3EU4ZcQc3GqYkfJzcunEw== 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=aHFb/kb5ED5T5jmJpy4Mtx4j0jHzLar2ahRECY/e1zs=; b=lt2DsSB5i/c+iA6STwOk5ugtypWpTP/uy8tFfaaixkk7mOSlrPeZzjxxeY7ww3+oTlg7v2VN2e6KTpfSxwgqsO1wlabpI7tHx5EVs6//dLfalxwGUXoh27NYLZYEV2h9t9iy4ZzNCQzg5Lh1sU0ShxYUuvoU/LGLhoHVryGOj7U= 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 PH7PR13MB5868.namprd13.prod.outlook.com (2603:10b6:510:15a::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.34; Mon, 29 Jan 2024 09:22:55 +0000 Received: from SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::8e02:f738:570a:f8aa]) by SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::8e02:f738:570a:f8aa%7]) with mapi id 15.20.7228.029; Mon, 29 Jan 2024 09:22:55 +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 v2 2/2] bus/pci: fix secondary process save 'FD' problem Date: Mon, 29 Jan 2024 17:22:31 +0800 Message-Id: <20240129092231.3531217-3-chaoyong.he@corigine.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20240129092231.3531217-1-chaoyong.he@corigine.com> References: <20240124104523.2022242-1-chaoyong.he@corigine.com> <20240129092231.3531217-1-chaoyong.he@corigine.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: BYAPR21CA0021.namprd21.prod.outlook.com (2603:10b6:a03:114::31) To SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR13MB5545:EE_|PH7PR13MB5868:EE_ X-MS-Office365-Filtering-Correlation-Id: 65acb366-40cc-45d9-5a28-08dc20abe010 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: KKhMsdpaLZdkIAouo3xP0UMdelepFU1TPmka9wJYMssO6wY4+c3EwThYwc7GtCpyXpt6tqGlEvU3wYq/zZzqfXhq6CIdovgsCg+Q+oeXNKdZ2rusZ66YynufAHfSQsXp4nsYDjnFrtL6Q+ZF8/D/gEI91fx00BcAt+nMu86BWu/sNYmUWqjVYY+ZiL4JkFz46u+47fnXTAkQj+/Qop9xlD8Sxl+25+1Lj3VCs1CCIkud+zTOLkwIgPETBVGPQw5WXPrjXvhVGMZZTwLkR6nC1beIrHHHwW7HrxI6Oov9fpcYuvXmhPrHoCvQtuYNvKn5AOH86qm/NPyQ8k3H4XFdRGN2X7LHibKy/lCH45rqRUsZCyA+W2J0fII7gXtv2AZFeQqQf2kiQsfvoiIMh0C2gV1B+jjm1Pz+b3LBacbaL4u2KXQ/ftBh1p2Dg9a1iSbGY+BPtSgKV1K6z1iqe8cLka+OicRt6MozwZS0jv58LdzYGkZp0YKL/zUtm/mxpz1D1pJDxhagsoniOCCabo6/ns2tKiGgmoFnaLxYHliMEDEH8YR4bixPK4SZEjkQ/kGtPFeUQnCF9zE+TPSFfJceZS9qPa0b8Lyn0O8U6OKehUecYP89bVykbYVR7t2P1wuR 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)(396003)(39830400003)(366004)(346002)(136003)(376002)(230922051799003)(451199024)(64100799003)(186009)(1800799012)(83380400001)(2906002)(5660300002)(38100700002)(6486002)(66556008)(66476007)(316002)(66946007)(41300700001)(54906003)(6916009)(107886003)(26005)(1076003)(2616005)(8936002)(8676002)(6506007)(44832011)(6666004)(6512007)(52116002)(4326008)(478600001)(36756003)(86362001)(38350700005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?atxXzHM0a1oHTczsmoRESEW3x9WRaR+VSecHnDgFcZteRXkmCLte5nY/7uwV?= =?us-ascii?Q?RrALvJ8AOf/0JjgVKVRjb4Zcp1XwxvgOKNlsSdZhP7HASLBntG9prqc5uO9+?= =?us-ascii?Q?zOch2kZ8TFHxHNTVUv4Hl1Z8T13+pjgYxIcUyv4N4Fl+GtnI01OpSnPOPQvY?= =?us-ascii?Q?nfY6HZHt5Ew85IQ5gPF/yhBiSPJ+4abIhUX07kF0XA5xhYDCKc1BkQaVXUFi?= =?us-ascii?Q?gzryFvZ27uqD4UoM2YNdkzxp/rZes+jd1oIxjG94HAuK9Fg01QcZez+N59l9?= =?us-ascii?Q?pb/1342ejBGmiq2BXHLZ8fmb8qxhPM9l1FStxHUtBANl8VrL63yqO83mdEw+?= =?us-ascii?Q?7un8EaFzNSS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?= =?us-ascii?Q?KjSnVSz/d2vsSxltaq8uw2H55AuWUkJjZwZhkauefAGubsdhX1VmpvJCr337?= =?us-ascii?Q?RClrKPsnXiudU0z6VcGa3H/ONi1BtIsOI6qNVzgB+sIWnTEyoX/y0EIiXGQ1?= =?us-ascii?Q?9ksCek/6dSaHXUorzx9iDAk/TdaTtVpreGWpiIXrB8gPlKVlzdkW5HGu0SED?= =?us-ascii?Q?mnBARORec2BkdqVArxWHYMigqaaz0TrrGZtFMbOmoO8ICq6XBiADcqPELczO?= =?us-ascii?Q?VVBjN+9/1f3lmKrUApVLrzFCCIrenUKl9hWwB4wLQ/XSoTg1f8P9EYdXG+Tj?= =?us-ascii?Q?5TjyERiDIwhJVYWrgrOoM+y9FHUp9Y9NLHs6CEg6/m5h56UBBf08EAlHEMJe?= =?us-ascii?Q?cg=3D=3D?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 65acb366-40cc-45d9-5a28-08dc20abe010 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR13MB5545.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Jan 2024 09:22:55.3404 (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: oI0EmRt7hlXodqzL9frZPohHtj6vy0Uu8WptKgmKGVUsntvY1NEGaT0G9eZFSJrtTNJAkLwtCyEloHKdipPHq7L7vQ1KPENS6xKGwx5IW+E= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR13MB5868 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 | 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 fcd8a49daf..b6f79b067d 100644 --- a/drivers/bus/pci/pci_common_uio.c +++ b/drivers/bus/pci/pci_common_uio.c @@ -122,15 +122,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