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 3089F4551D; Fri, 28 Jun 2024 09:37:04 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D9204427B2; Fri, 28 Jun 2024 09:36:55 +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 D05274275C; Fri, 28 Jun 2024 09:36:52 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iC/Kwyi6KguINMyX/G8zFMt6+KCvxVCsIZK0/foH2sM6rPovlov/k+JvQuWXAMPyyPravVQpqAUohoy3Gl55gfjUfX/v1niUCnFi+hFLNTR7FypW6yx3+8YMRyV3G6kBnCHC9OdfVX5FakDbKUD7xDv8uzcSgDByMmzl/2p5/64xCpCblLP4zQu/pvaA29cLfzMENY/I2ktLZf0KMaAVDDY3x8ajJIt1QgMSJpWrdHloc9BxNE0To8D9th75TI7V+EgyLCz9eydfXTLp+qU9WIMGbENBekpQ4pSjr+HXyEHi8rzjYK3lXJCDLRh4K331zESLPDLhVhsjSvFmyAobFw== 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=RL3fi0iZLurVvasF/AwdDgOe68TIwVVNFvgyO4yhbwkj0DITJNRxk0L8HMz4hKtLYI9xZK/Fhl0+2a8VWalNjNaQsGAjbCDM+CI7fo+o+8jWYiRE6NhNGE6wByoBlttic+XsuWCPJjbUqtYqV9JOh+YhiXTRGXoodtUNqL7+rdfPJdWRFUdxSDC2PyfWS200viyHrFB5ksBDRVf6onymwiudhRS9szjly7hJJxbHV3t9OxbmIh2mLxlnBjqjuow+klooNpSEJ9Wp7JLzsXtkf2Y7V9p2R5n6KECghWqWUn6Y8xIW14mvsQltf44UpBmisKVg8YRPi2KZ0cB56JvQCQ== 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=fQWeKKAsFxwcexamT5J/jvsHWTt3K/yPPI861pWK7ROiCksrMXjNFKQBlw36U9CnVeIAsJuv4W4esCF4gsVWEjWqQgYGAnrhwmCkTgRzGFr/stdMq2Fm3UbQpswsqAj+M5ghnGjwSyJ3+5FZRcUkJ1ivttY/gOkka+Wd4k7/zfc= 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:50 +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:49 +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 2/3] bus/pci: fix secondary process PCI uio resource map problem Date: Fri, 28 Jun 2024 15:36:23 +0800 Message-Id: <20240628073624.4122899-3-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: 43b9f6d4-2254-4753-8621-08dc97451211 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?SxR5bVfaGBJ7iCUqxMR5rfHXuzQxkZ/6BjYweOIu2915DtughqZuR98MMDL6?= =?us-ascii?Q?yDQ36btQEZC1xM9Yx9be9CLOOVaYqlZzjHjeDEw0cFJoWhkvY5rOX/RoJ2ia?= =?us-ascii?Q?4ecoWVw/cH90KUbPftxJosqyYWALdWSkjprjpaE58aP0WthWyyf7e2kF5T7I?= =?us-ascii?Q?jQJ0v6X5lb0HSS16IbDW4eGYZUIhNm/ptMg0gxxwbFgV8nN1S9X56OR4E1CM?= =?us-ascii?Q?N7XSOBgvDO5FbNcFbeOXQg+JsSSu1M+Z+c39Q0yXdZIHfgmCJgBmFIHAawvM?= =?us-ascii?Q?1F3z8zkmnF5swXuq/UApfTvV+YQSRO2KZ2VL4e6M5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5F3qoe9+fUcTZT8XQK5a728otC1tvX6OVp/xVe0ycih625wYtF9elL?= =?us-ascii?Q?TfbDTNM+93mekfOYDMmg+jLDumo4EKCtD2b5Ok4DhthwhUFOHQDL/1mfZjBD?= =?us-ascii?Q?dZweMU2+roMOkSgT+yMxj71pwo+chzrDU2pRSpsYCbaDpwZcN1BaNA58PgK0?= =?us-ascii?Q?MwBQ77wXvaIVvZlRltRvMn7aAYOSRbwXDmOlmZE78LN22LRHAw=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?C42W12mywaE1Y60LSQRUHzaHmEfjts9ny1v5zgw1Lz/fXspM2z5jmbn4H8yK?= =?us-ascii?Q?R3a54z4bYwVUWgCRj7qSnyzC955wzAZaqeVbByIgt2cOmAKCwIDL5+S33rNk?= =?us-ascii?Q?lp4RVSrcWmDrn89m3G60wL+NrgpdB8xvCxUJ8+nAQJ95le61sm5EdQYdZFwd?= =?us-ascii?Q?154luvCgBt/OFIiQYNURGKK9uNlsmoiTRDRPUxeSSiQ5bynGf7IMkuwSqXZr?= =?us-ascii?Q?pRJJOZKILUtC66Ix24EFDrrspB9j0jlQbDR0YYWSlYMrJ74Ay4X3uVlOrjmm?= =?us-ascii?Q?Do/lseJ6/KbTJAeERFkSrX5bH+TuA26galLyHofvbOIgny/6joMPqe3Uid05?= =?us-ascii?Q?R/8DwY3Y7K2/5MlErlkNEYVFcdCxYAeXDYzj1NpWzboxnqpb4JmIrftRY5UO?= =?us-ascii?Q?IY0MxHN7fznX1sCL90HREWVmqkeSuwOgjZu4HHbKpqiJFavg2WS1aA9RgkJr?= =?us-ascii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CZyZs4ZS6FbjCa5uFUDxL03M9asbKG/FkX?= =?us-ascii?Q?+gOY2V+Ze6ZPJSFXEbYMvMqce3eQ7AXAA1eAN+It2lQ9tcDmd++rLnb1Fq+I?= =?us-ascii?Q?u2PbRDa+orAGLyrkXMehId0JVHxTcBxPjenFM9e+X6iLwR/Fi9DSMlc4oa6S?= =?us-ascii?Q?xqU7o3vUaTJLFLXa2mNFOyVM8SBg9o0fsCbLSXbNK2lI40NMGPMMAEWEtgVf?= =?us-ascii?Q?ghhFgJ4VLo/x3cOx9DA8qtC2ZNd+z3OMntaVqKkwQ/DvS231XJOOtPpcqdDS?= =?us-ascii?Q?iQ=3D=3D?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 43b9f6d4-2254-4753-8621-08dc97451211 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:49.4642 (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: tI0e30o7ZW0sRojIy2cUGq2eq7UFfS+w6infXjqDDA/Q6rjURRUJi0vSnGsOQY+CGCat1d5oPi7EOQJsHwf5U6XTBop4w5UJsZyfDaxzoRI= 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 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