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 DA03045546; Tue, 2 Jul 2024 04:20:22 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3BFBD402B9; Tue, 2 Jul 2024 04:20:12 +0200 (CEST) Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2096.outbound.protection.outlook.com [40.107.93.96]) by mails.dpdk.org (Postfix) with ESMTP id AF063402B9; Tue, 2 Jul 2024 04:20:10 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=I3QnP/fF7tpYTN269eK5Z9Cimt/zU+3aVgCbp7u0v34ls+S/FpDZ2QUkgu0Ck1IH1tooMSfCW+I7H925WeJSXqlNis4gzLqzBN2kLII1ojH4qJpXxTGhizyQX78rI9VtSVKtU7/Rebv/OEl54biUjq0QhZseMu2xTsi9N5Hq9zHbLzx2y2vE+RRwVv6EwRfeg5Sh/bjUybb5wvpsy4gLiIgkDNPALG6uKflSKYGpKzEC0s0CP2AiSFEjAM09oktyghbu+UVI3rAvP4hhb5N2PWlNDKFYobdHH9YUObBDVt1GSAhuA9cpUTDJG2sjdLiDTn1I1WoEoGpNC4xN4n+DOQ== 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=IjuK8bWXjq6FqilXTvgqmsr9U5EV6Od2Y1r+Qd8n+J0=; b=J5E5DmDMghIkLpqWJUG0gW+Oqp0HJbTRmd+jLDywtEpDYyLK2hqa0rNkFuoHiMjNoFqaTq3cl1mEX4fV8uQeWIsnRHRhl3peW6zgWWdw8oiscl2K50NNekIWeLksMKy6+1o78OUfWixbo3HKxAOASbX4C0r5P/+5b7fKD4LboicVqSLboDgo9oJZhf/dc3Oq/hEOQbKCmx227brAj02eWmCW1lvYMxkgCKBaTIyBQ+BXtWWb1xR3OZHGCt5hPZ8k7TGIFaHgHgvUGhyK6YV4+r+Jfwf9q8nQSVi/FDgPT4Ari8wMfHACx9g9N7EzjCt+PufVBVflSZTv9e/RdHghNg== 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=IjuK8bWXjq6FqilXTvgqmsr9U5EV6Od2Y1r+Qd8n+J0=; b=KdUrA4AB1imahtt/B9K5RE4oq8ayvzSOxxA1FXnDJGLk6+0+6p5gZBrVwevmoxXjVOIvJqpepMEIkRgF2uW+2oqCG9DcnGS3am9pYALkGyAbWq/Qv2TnH1DEA1+8HiJgRginEKb8pmJsmH1cps8X8IiDzl+YyVcF5BL8KZusXwM= 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:08 +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:08 +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 2/3] bus/pci: fix secondary process PCI uio resource map problem Date: Tue, 2 Jul 2024 10:19:45 +0800 Message-Id: <20240702021946.4194102-3-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: 84ddd0c2-3e41-4f89-adfb-08dc9a3d7e71 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?rbtwHFEr6H1Mw3p11VMabEdkdgx0f+cQQIfvtbAtNYLGByNNJ716v72rbV7v?= =?us-ascii?Q?ROcz9S2jiypxrEe4aca9x6sQdwvwmH8YQnSpLLFb/GsK/jnfjyAoD9cRIGlN?= =?us-ascii?Q?9AHjP/o6i43TyOA8h6nWvfONfByVuyNDyNkH/c4wYcsh64PdcXnFhh79ZH4p?= =?us-ascii?Q?pAVcxT7Iiq7pbmTkMc2lkxUxXdLaqXBGhzl+F3ebsj1uyq3mjjfM4OnfDQoV?= =?us-ascii?Q?ySeT+voFWQP4TR9/mrmm+A9EY22BEyZpX55REELxXaQtcT3smZqxOHAdmG4m?= =?us-ascii?Q?nL6RLjuTr/a3IhLQmH+oZEb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ascii?Q?HKxjikm7tJF4Kqd91qFoHb61hewnTL+7Lajo6/NUYgpasLg+ydGKyJ8W7MRd?= =?us-ascii?Q?Vc26ZXZ7lKmRkinnmFD0ogxoowQA+EGhCZTBHQRglObGS3/xUpOKWKNWEaiv?= =?us-ascii?Q?CZuVXlWsPuJ/FH3kbEUWOXcZVO0KOZPAoL79B2t+WzECx0HE5IQHkNyBSVpB?= =?us-ascii?Q?eS8SkGml2gbZyzKV8cDIKlo+o2PH5g/78ZgE/3hPthhjwKd2JQ=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?W05+NvGAkmm5E2n7wMtap1BTFdsIIoGi6dkjN+OA3h7wWaaYVyScWCKtMqK6?= =?us-ascii?Q?M99DggEMSiMDDYZQupIAzHZ/hYfAF5XwnZ9F3y5+KEV4s22GYIdObSJgZ3MF?= =?us-ascii?Q?ZfbJnBJvHfcnCVP/EcubpLJib4/KAFylRnhh2x1oSJPqfdfM+ATl2tzX65hn?= =?us-ascii?Q?nFGnINNJzfmFGyMjef1utX01/Nv8RwGtXmWH0sBeqNqtkCID5e7PC/GpE2t7?= =?us-ascii?Q?EsfPsK8W4br1vHzlGpL3Yyjbs1PTd1uvO9UlDoVMkvdjsEiNLHMekkqWpook?= =?us-ascii?Q?x91kwrb1mkmdlAVTEXxUJQhF16aMw+5SFzYbWscE+GdEmpMZxaFtD8XMUNmo?= =?us-ascii?Q?Nrn9BwlbHt0XJJvB9E1aY3QUEmG173cFRepdiURUOIE5vqD6QIVT2ZXuueIS?= =?us-ascii?Q?JesZAi0XvDj37st4s/evSpnVl9rZ//3BAwbCqb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c7YT+OfbyEZWxlPAOrYTASW4FztMAXZPKlT3g9p4UF4jZx/od?= =?us-ascii?Q?y4lRFGRTyhVqojPpZuS5eLqLYhOzzYJzdawlEMpAZ2GLx9vhOqAPrtFeK9f0?= =?us-ascii?Q?UQe0zJmDAV37vRe/dqqLvSehvxKz1USOvdxaCgeAkrIXhEHU8cGB+b0Cntkv?= =?us-ascii?Q?dN9shmQklIXDDSVe9+kjRIIsy07i2RIu1CQrX9AcQ8NwIahjFwWrCsQ3Jbyw?= =?us-ascii?Q?9JsiGuuV3ZBKrT8eEJtqjhnGhJGTaIMErumf3MfKDCIclmsa/gwcFKWhRgvw?= =?us-ascii?Q?rQ=3D=3D?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 84ddd0c2-3e41-4f89-adfb-08dc9a3d7e71 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:08.7615 (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: wW64ywk0Y95ogoaLcuAy5DUPHsaaw3hT75Tir1YTSHbT8K3eILsuyugdrH0qigZb91nEaQ0RkkSPMdFSjOezGxhyandfwH1NMLlca+Hn9Ig= X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA3PR13MB6950 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 For the primary process, the logic loops all BARs and will skip the map of BAR with an invalid physical address (0), also will assign 'uio_res->nb_maps' with the real mapped BARs number. But for the secondary process, instead of loops all BARs, the logic using the 'uio_res->nb_map' as index. If the device uses continuous BARs there will be no problem, whereas if it uses discrete BARs, it will lead to mapping errors. Fix this problem by also loops all BARs and skip the map of BAR with an invalid physical address in secondary process. 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/pci_common_uio.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/drivers/bus/pci/pci_common_uio.c b/drivers/bus/pci/pci_common_uio.c index caacbb69d9..432d68b12c 100644 --- a/drivers/bus/pci/pci_common_uio.c +++ b/drivers/bus/pci/pci_common_uio.c @@ -26,7 +26,7 @@ EAL_REGISTER_TAILQ(rte_uio_tailq) static int pci_uio_map_secondary(struct rte_pci_device *dev) { - int fd, i, map_idx; + int fd, i, map_idx = 0, res_idx; struct mapped_pci_resource *uio_res; struct mapped_pci_res_list *uio_res_list = RTE_TAILQ_CAST(rte_uio_tailq.head, mapped_pci_res_list); @@ -37,7 +37,15 @@ pci_uio_map_secondary(struct rte_pci_device *dev) if (rte_pci_addr_cmp(&uio_res->pci_addr, &dev->addr)) continue; - for (map_idx = 0; map_idx != uio_res->nb_maps; map_idx++) { + /* Map all BARs */ + for (res_idx = 0; res_idx != PCI_MAX_RESOURCE; res_idx++) { + /* skip empty BAR */ + if (dev->mem_resource[res_idx].phys_addr == 0) + continue; + + if (map_idx >= uio_res->nb_maps) + return -1; + /* * open devname, to mmap it */ @@ -71,7 +79,9 @@ pci_uio_map_secondary(struct rte_pci_device *dev) } return -1; } - dev->mem_resource[map_idx].addr = mapaddr; + dev->mem_resource[res_idx].addr = mapaddr; + + map_idx++; } return 0; } -- 2.39.1