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 AB76E4554B; Tue, 2 Jul 2024 09:40:45 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1B420406B8; Tue, 2 Jul 2024 09:40:34 +0200 (CEST) Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2098.outbound.protection.outlook.com [40.107.220.98]) by mails.dpdk.org (Postfix) with ESMTP id CADE540689; Tue, 2 Jul 2024 09:40:32 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XVD98oyOOrzM2AgPKPIGVjhYVYabhm7FAZntCqc8LYiBN1SCyTFa77dHwH3XnsPN9WK8xCTlk4a8e94XMW1ydoUgr+nNIsRTfJOkYDa4Mq+nSTRHrDff2A45WVlUeWOKPUUZe4mHHmPt69f3/QWepxY60k1q9dY8/HZj89vZZT1k7QEZzgZQ2+oT+wIhyOI9W2uo/4lBHYWiuTgOUfbp9e/hfaEP2smKPwjDWoCiZMBXxVFBGHCgzHTx3D/5dskSRU2UImd29SUdQO3bW/BF43j/AAaJAGcbuYD8s0eXibg8Iy9gxRxu9eG8EgGFV0jhino+AlJ3Lf5s2KVF2qBFUw== 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=MrcGgaCfA0NQJ2SZR6A9DioVe097wbKmfQZrueoe/S8=; b=GtXo4kSD2SA4T6HwJQ93UagbX9vP3aeGI2Yq7V7jkqysyqFWCpqx1834XrFH+P1gNp7ePMF0kzDPNN1/JSvkb/dS1WoKuUJmXop2iC/DDkCiduh419ritF8l1nGyMjxU0XUzo54pb9GN1G4f9Qf/koub1D1DFoREyArq5PUjIeWql4rNXSh2ZSVlGtk/Mf2GawnFYgEYLgPCBhKrpGH77H7msX9lXC/+PIUHcuqIeoi8gZgCHK6Fv+zctkmKxomS7MfKHZuvKjSb2mejZR/zT6UEcnpjsa1syro51Z+RyGrHhMh3vgSN6oIeO63lakOlTpMaT99ooKJ06ZGZ6oyorA== 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=MrcGgaCfA0NQJ2SZR6A9DioVe097wbKmfQZrueoe/S8=; b=pre1M/Exu1iPps1irbBX8JvpNRmmdRUS0SbH8WvpJM/GOw68nhsiBZTi0qnhUPX06kniyxr6vMyO7cHGcIZZh2BC0bGMPD0Q/kLgEThVwx//xUNblYo9K1oupb5irJdiP936U9yuSmlvH2orIEbgzyPAAqjVPwMF74RuNPm0Qdc= 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 MW5PR13MB5439.namprd13.prod.outlook.com (2603:10b6:303:196::22) 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 07:40:31 +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 07:40:31 +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 , Anatoly Burakov Subject: [PATCH v6 2/2] bus/pci: fix secondary process save 'FD' problem Date: Tue, 2 Jul 2024 15:40:07 +0800 Message-Id: <20240702074007.1547-3-chaoyong.he@corigine.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20240702074007.1547-1-chaoyong.he@corigine.com> References: <20240702021946.4194102-1-chaoyong.he@corigine.com> <20240702074007.1547-1-chaoyong.he@corigine.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: BY5PR04CA0023.namprd04.prod.outlook.com (2603:10b6:a03:1d0::33) To SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR13MB5545:EE_|MW5PR13MB5439:EE_ X-MS-Office365-Filtering-Correlation-Id: 090c94fc-b586-4eb0-2c37-08dc9a6a3fce X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|52116014|376014|1800799024|366016|38350700014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?g2sHSh8HoV4KbazacDigxCdzMrLa4+mYi1d4FNBx2cpvOg9PLNabOllYzgtQ?= =?us-ascii?Q?YbxEw8SrbCrIIzHwwXrCijBLOpHWpjPQvuIACaBA5EoQqDfq251u9yghwXAI?= =?us-ascii?Q?Jx5ZkyRiXVff3a4td7cvddlgPNAHHb/qkcysbO8bm2SjNONP7gzY4L8Z0P20?= =?us-ascii?Q?X06fe4HEdNjHyUDdZHS+60qBUC9GBPQoQDWpBpuLvLCNfdmcrVAv9sM7ekVL?= =?us-ascii?Q?FzaIJIel1qNErYV6n2CKsM2fanZfzYdVqIRU5KNSl2MqRSEJeYsWhD/dMU2y?= =?us-ascii?Q?8EaMBVOGCZzLpwHd9ukMqwi/0EPZ/bw8Tjb28dtUIWptt0Fr44UGN+advPV9?= =?us-ascii?Q?D4DwfWWee7Zr7tzBy0TT1trOhUUUcUVrQ4CojGN+t6eCez9EyApN23TARa8F?= =?us-ascii?Q?U2AOyK84GU+4cp1B5rbB/ineEwzSn3U81gk1rzK91qv9oCDz9lU1G9omL1oc?= =?us-ascii?Q?OAL/SCMQugNX7ZYLKmP90NPjKE2hkbJiM9xU1ugptoiN1t72jkKTLa4gte0S?= =?us-ascii?Q?3cLp14P0LBspaS0ta5YJyulJcgl5ius1v7OeT+6TDZv6yPYgHQpHOQj45D22?= =?us-ascii?Q?joDtlC6r1rZk5rtCX365/gjqXY3THjRCZ1Pwvz55f405bgcT24tUOuQjrOZ8?= =?us-ascii?Q?6zRyF/L54e1j/zC13hwd86TIMDkXXYvckp6z+ra3hcVgfezxCKKqmbqT/dp0?= =?us-ascii?Q?eg0Zw5lrGZYq83DSEM/Qujci1bDfMWvk9qyr044KSBWQ8C2ZkYNma5rGYbG1?= =?us-ascii?Q?3gnyyTY54hvxzqombR3Z7ERHI/NtTpIphiiUZ3syE29JeLl39Jt3dS+ft8dl?= =?us-ascii?Q?9xNwMeibhoL801lHAdF3FJkDCIJksDTetqMgOOBaI0nzH0XruQfeb3Cs1FIn?= =?us-ascii?Q?0g/d8LQDq7sNipoZGu968eVeHn/Sb3XgZWvcGRozQi6CevNxTPqriUGnw53N?= =?us-ascii?Q?guqBLVYCA6+UDSDOKYvFFK/kZykOWiGOPQ7FvolhxDo/uYZ62oAGjGZO/YMK?= =?us-ascii?Q?jeMMibf1x7np7ZwuYJfCCpStaxJX2CVQh1U49beC+Nel5tv4e29zd/EMchWV?= =?us-ascii?Q?RhIW3+7A7W/q7AYMSOxkAFJdvyjzpYMKB/GekNdObLhqoSwx0JJ70+aOu9+o?= =?us-ascii?Q?XEs0yVu4oE8/BageIT2LKXFKSht7qZgINfwO/os1a+NuQn6QdcJ4H1Vzd72C?= =?us-ascii?Q?IXokGyhPd1+YEx9f0i0M+ZdhV1DJ5cUXGpUKh8SGuIEkThIMbLNB+GlYAjJ8?= =?us-ascii?Q?1LZfsFGbo4uIv6zQNg8Y+I1oWmqldu+s3YNm08T7rjxkCFALy6s1zzRd2JyC?= =?us-ascii?Q?7j6wp5GMjdX0iK+1pMrdEACiasduOKuqG0rCIVb3Sgu6iYgRXNwrGzguVpYj?= =?us-ascii?Q?mqpEtxgQwYSiEDxs37LAY+K1QVZAcdypKpdJx9WpRMeXgJVcZw=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)(52116014)(376014)(1800799024)(366016)(38350700014); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?siCtrm3bJI754QoXA1V4lLomr7WTK3VJzjg8NcYBwktt2Xqmz/Q9zAE9Caah?= =?us-ascii?Q?AUiDEQ7zS3mV7PuXNVnKCb8SwfhZpN2sydC8A/24Fqfq22eTB6P0ZAvZ/N+z?= =?us-ascii?Q?EjlbMcmN8LFMKxMKGEFwBTjNcYsMmj38xENILiLoH1dvTUsqh0SxsHGkLx7q?= =?us-ascii?Q?Jd4LRGK4TX3sPV0GWwN+GMqt0EZjsGS34VyB6Rfot14NxePrpRvN6XOSNqtZ?= =?us-ascii?Q?Mh3Pgam6Izy33NNBvV2Xz/dMw4Oaah+6pj4EglpKSx9f9g9qy0OugYD3LVpk?= =?us-ascii?Q?hWCzrM3ESsUObe/C3ttDG1xcl88J3reIYpD5+LPdUQksByk/ZLrln9/MIcnp?= =?us-ascii?Q?CjFfWMMkmVlvcp73uS0iDYEHKH639819hZAlSE86yj6e14MmQ8kn6QosjdxC?= =?us-ascii?Q?FP9niGfPN/8lN8x12lgdL2qWIEUyBJKI86k1CrCRfUJBEidayh1ySPkKo7SE?= =?us-ascii?Q?IvI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ycKj/v9VzF?= =?us-ascii?Q?taKfCWp4rw2wN8nDPg0h9SPsD6OSIR0vqngPO561AgCM4KUdVAUI3BDV1myO?= =?us-ascii?Q?HcTJ1BNzgMVvYdCUOb7u/wLTV+A36vO+3+J4rsVWZB+JOwiqS4iH6ufdDoTJ?= =?us-ascii?Q?NXZXmuvjtH8rPCY+8gt+2jGF2+k6V6bodZh9homAb23ynYEzS4gR0qoQ3s5N?= =?us-ascii?Q?S3BQxJq+0PnHgijDYstIqGMG5pk+mHoS1DlqMJEF/9l0UHZj/rwbtFb443l1?= =?us-ascii?Q?RQ=3D=3D?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 090c94fc-b586-4eb0-2c37-08dc9a6a3fce X-MS-Exchange-CrossTenant-AuthSource: SJ0PR13MB5545.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Jul 2024 07:40:31.0263 (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: rHPpQGRRM3SQGCxBGZ+tfAlxpe/TkgZdLvNUujqypVZnmF9DUoeNNBmp1FJYGSIYL1jOVS/mMAv8r3TJBV1DBd1O8CC2JLcM0kdqQEpuy5c= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW5PR13MB5439 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 Acked-by: Anatoly Burakov --- 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 f44ccdf27c..a06378b239 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