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 8C29B4554B; Tue, 2 Jul 2024 09:40:36 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2C14540684; Tue, 2 Jul 2024 09:40:32 +0200 (CEST) Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam02on2100.outbound.protection.outlook.com [40.107.212.100]) by mails.dpdk.org (Postfix) with ESMTP id EAF254066F; Tue, 2 Jul 2024 09:40:29 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=T+aE+mGZofhe9olxZp2BV8/+D+cAAFeh+3/ixFRyxDDN63hy84XDvpNn78WB98Kk5YQNVmRbEha6SqYdrzo5ysTa9ovSt+a3ZeTbKZUnDEWlKpMnOZ9uAtmaJl8BPXkv+WepBRAQWz/kleNl2uOt0DZtR2F0sevHB1QqFKN9pJmzh531ySUDRkHRY2zUpryohEcXYMwgoCT8ndCQZTq+3w2CO6NyvejFhuEUa5gLP+zFLn6Uv70C4GkHtaNQWvLAwpsloeYv7Z0tfcHAKhYI/2O8p6k55m2tgZ37SSkdefUYTgXqlhk5M5P+cXl3MXxXGWIi+VGv3Z/CEMmC283TdA== 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=XJQeoicuNCC7p8zrW/fq0EJ8aZWdLItHmtfdqMtLwJM=; b=ex0K70O6LeSDbVULhfquRTKDOygwlhQ9dAwVk/p3ymMdCJiqqF9wz2fkY5zbyvz3DMHXO94fdY0qi3aD2NYieLBLlEuUc2UKZtg4wfbiz/8gzCTZ7D6K4LlXtph4iTKQtuuTfMjoDf6F7pKlA+CaK5SMObIiGFvJT6F+OdNTDikLraKOFTGhCR8vvcSZRNt/Agsuy3bN3GXkf+iyGlpixDonDX5UvCTFQu48QFfXClsjlelCY2J3gbZsvm37gYHGQJIB91kjhZYjiqfquomEU4mjRYgDw/TUFCxzlo1dQIeeoX1K9qCkwMWx8L+3IujUcCaO+I+Gw5MHx+o+JcV6PQ== 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=XJQeoicuNCC7p8zrW/fq0EJ8aZWdLItHmtfdqMtLwJM=; b=HX/z0MGWT4YqkWue8akEScyVOuQrzc3al1zH4MHYpx1cOLNVJSAo/MVx6t7UFJc+ouA3b0yU82RcCOOWxipN21C3XAlnheIge+26fuLN8fZCmZZjHoACTtO9ZiugyjfWIkm+8r6TOqerNOSBFDr3wBle5sIgM8rIztXlHTihqis= 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:28 +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:28 +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 1/2] bus/pci: fix secondary process PCI uio resource map problem Date: Tue, 2 Jul 2024 15:40:06 +0800 Message-Id: <20240702074007.1547-2-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: a1191921-2d25-4da3-937a-08dc9a6a3e41 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?Jr1ZIKsXuAr8WAjO2WX+em4YfOv6ki7ofeVMRolVfbsIFPFLH4BMBWOPxQeV?= =?us-ascii?Q?yvpaE8FYSExjDlAzRtXN50+G9ZudEjj+KnL7hghNdl104cK8qYI7gyAuUOb3?= =?us-ascii?Q?xVTWQ+HZcvrKGzeA5I+Hi8NzW6uXt2ix9jss3UMHQje6XvtrRpGsslpt0wkW?= =?us-ascii?Q?nwqYuGDtMtXigC81/Z7tNTRbQ4Cb76rH4qm3fgtca/hXrKXHIXReF9A/O4dI?= =?us-ascii?Q?hBZKkomnSbsCVmnt4rU/pBH58Ko11ieXGyiVh28qb4iEJl36EpXbIsEL2z7k?= =?us-ascii?Q?XOARnqecz/qsCj1J122mnoacm5lEPPJGOj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Z3EigdSDSJ6XKk6V++TAwFZaAirGePh1zfWwxqMh40p7R/3Q41iOsBMaLXd?= =?us-ascii?Q?kY1DNR4DQI/uXe9I42RpzhSE+fTTqbuO4WZeCY2X5C6dQdrNQJlew5OuPk7G?= =?us-ascii?Q?ChGmJuIvpQIDafN43pGD6i7RZnrO0YdrKzr7VEhF/cfZav4txpOP6EC7haID?= =?us-ascii?Q?0Zk3Xv0ijHBx+bJl13LBqqr5h8PubleJZPcpfiCuiU1dncm31A=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?dsvnfBOS9kF0v1ChsbMb7fUTXSmmekDIQWdRu5BAPGQVLctVJ4RhrbcW1Gz3?= =?us-ascii?Q?bmqXdQtvFjIgx/U6fHJfO8phlhvSeMI/FiD25cRwi4x9XbSsdOmJNRouydCF?= =?us-ascii?Q?EYBm8DJ1NUYEA5kaulGkxVEGLsvbu6gtARAFpAuFHEd60ErV+5u5u5a+2fgf?= =?us-ascii?Q?fw2jUre2oxnN8tX5YENM/ZL65cmIsN34JTRadxBiGMOEY1nUjg0Xct0crx9u?= =?us-ascii?Q?X4WEI6GvZQ0eI+VUnnZDg8r7m74FJd6oExG79Kf90j1hmT+F7EQBHC5xuoZJ?= =?us-ascii?Q?mwb7j6cVWZmsGbVocIVDfwAUNP5qHrvBDYZSdD2DrI9AQob/PHH73yoObOGa?= =?us-ascii?Q?DcyVVeyZakHppJccNf0sPMzNrTW/AFDlkSLEl9Sqp73jnyh8dYjqXnPw9ftV?= =?us-ascii?Q?hVszjaBylYpaKaCZqREA8anQusO/MjasVLCb3aatTwOCN2U4Hucww2z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3It5Hz7cfdF/ZeCbZNHhGtrc1daYilMRCs/JqnXU6c5MmSsNy?= =?us-ascii?Q?Pf7MYrP50wGLIc5B925bOxvi9l3k2kppVYEzlmfNkyOIsgeevlDtrmp0gXrx?= =?us-ascii?Q?+3N+FU/TDQbVfLH7DgEXo1NMPHIJkLMpHIEq4fyZoyR3K96qT67TgyzYL+BN?= =?us-ascii?Q?aputGrT3k/QYJnIUryrFFAV3a/Rz0fdb6GRlyg9KmT0mKoNRy/GGcYJbBRVf?= =?us-ascii?Q?OWJDh94bkINAnjSxN1CDI/S1dBER8GlQEx6a+nDkQhh+qF7YpP6MtSb/SNU0?= =?us-ascii?Q?9A=3D=3D?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: a1191921-2d25-4da3-937a-08dc9a6a3e41 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:28.4071 (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: huSb1TF4/9xpXkF0fX6uuTmJzWjuXPPijoqWaoAODNGLcvxhChfGNLitX3dpGWUQDU1FRaMT888GwL61CkNkOHfO4BNYYd5N73/rpCnAmiU= 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 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 Acked-by: Anatoly Burakov --- 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 76c661f054..f44ccdf27c 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, j; + int fd, i = 0, j, 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 (i = 0; i != uio_res->nb_maps; i++) { + /* 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 (i >= 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[i].addr = mapaddr; + dev->mem_resource[res_idx].addr = mapaddr; + + i++; } return 0; } -- 2.39.1