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 5A6E545887; Wed, 28 Aug 2024 12:40:24 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1BDAC41132; Wed, 28 Aug 2024 12:40:23 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.13]) by mails.dpdk.org (Postfix) with ESMTP id 5ECDC40150 for ; Wed, 28 Aug 2024 12:40:21 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1724841622; x=1756377622; h=from:to:cc:subject:date:message-id: content-transfer-encoding:mime-version; bh=u1AlmhYidftgRmwkC43VNupdMuwHG5w9VlaR2VlyzDI=; b=NzPyHu57t0SkuFcgx9oW62XTSoRpdo7RT0StgAoHzeD1zAt49iRdtgN0 xQQO9cV70pac89XrYTXeFnZXOoIIuC6UCDLk+InZJAIyRi3yqwz+vgSID fII9Qw9n9faczmzb6E4TnEgiIMfJHkrge0FdPBBZxl/EWnc8LRumGMi/e YxssSHp4mXwn3aDjTw45JyXNs/5Hj9R3GZ5eGZl+P1lxRgjQVxyNv7BZv 70tAqdcw827t0oZQ9k/oldeDJhHWtlzQC6JK9st5mgYVufSAggOEz5qmW 2cODe/qmOkT2FChNVhfet2lVG4ktF22ynu985AeffW+72DuqM/eMTu89p w==; X-CSE-ConnectionGUID: oP/Di1sPQ7GzVnmEJQkfVQ== X-CSE-MsgGUID: Ilpw12lhT8CUMQH8+jqFIQ== X-IronPort-AV: E=McAfee;i="6700,10204,11177"; a="34519688" X-IronPort-AV: E=Sophos;i="6.10,182,1719903600"; d="scan'208";a="34519688" Received: from fmviesa008.fm.intel.com ([10.60.135.148]) by orvoesa105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Aug 2024 03:40:20 -0700 X-CSE-ConnectionGUID: ELcAIPfVSPSr8O6iLj76Vg== X-CSE-MsgGUID: /thdhsEyRwiwPkrCprMbKw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.10,182,1719903600"; d="scan'208";a="63175295" Received: from orsmsx603.amr.corp.intel.com ([10.22.229.16]) by fmviesa008.fm.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 28 Aug 2024 03:40:19 -0700 Received: from orsmsx603.amr.corp.intel.com (10.22.229.16) by ORSMSX603.amr.corp.intel.com (10.22.229.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Wed, 28 Aug 2024 03:40:19 -0700 Received: from orsedg603.ED.cps.intel.com (10.7.248.4) by orsmsx603.amr.corp.intel.com (10.22.229.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39 via Frontend Transport; Wed, 28 Aug 2024 03:40:19 -0700 Received: from NAM04-DM6-obe.outbound.protection.outlook.com (104.47.73.40) by edgegateway.intel.com (134.134.137.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Wed, 28 Aug 2024 03:40:18 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=fuC9+S7CvdtynEpgoBq+myMmpH8luqIcbk+jonHBlHnfE/GcmcqDiNA4PBUsG/unNyDJn9qlFdlybXwO0l7Sgq1f5AfzCbg/pJ2dv1gd3pL3zgasCCkQE56cYr7aw6DyBuYSdxwoEcS6AFc6Csd4/vfqn8s+d/K82EuV4EKxR/4st71mzMPHSiuUW3BFZHvQRoH8kBHrKTR8zctoPnw5ePQjFh8U+wGaxJ5HusFRY1zKN8Y4liUIw619CpqhSSTURUUl6xU6uBrar1U9rTpkKEs4nlEGgg8HutjYeYdPTY0tY78fzmwb2nHIFviL52+ISNAUNS3izmTPoIFKerNMrA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=IakpAyI93r+5s5x+CKIze0FIkWbUTRGDKM2aDh8Vd3Q=; b=qwYxxJs4eIJfAqkOVbKrP4JI6NUcB0BhMAwmMccUNHwBoqDwWbNilQcZmpasFdh1k+75m5KwEkOg2Wwb2JeqPdgqXnjF1X4kj88jev2HnXJB5Qo1co6q9KNM1hfsXPcjO1L+ve3QZeVWGid8VpZZyqBozJkyp4dbfdThi2XPIuhDRWxHCwz9Kv2TfsuBMy19f+L99sghNhme6/y9i+/HoCJc5meHlsYR6sebn/UGBq6FU7tbexVJ5SBdnLrpZQw44mC/mzQfme8RaI40Cg4cvew6N453R1bUvVSkb4Y4GYSCj/5apmRY/OxoJxMp4k2dHBGoY8W2o7i7f13hY2pbbA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; Received: from PH0PR11MB5578.namprd11.prod.outlook.com (2603:10b6:510:e7::8) by IA1PR11MB6123.namprd11.prod.outlook.com (2603:10b6:208:3ed::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.25; Wed, 28 Aug 2024 10:40:16 +0000 Received: from PH0PR11MB5578.namprd11.prod.outlook.com ([fe80::ae6c:ad18:eae9:e7e5]) by PH0PR11MB5578.namprd11.prod.outlook.com ([fe80::ae6c:ad18:eae9:e7e5%4]) with mapi id 15.20.7897.021; Wed, 28 Aug 2024 10:40:16 +0000 From: Konrad Sztyber To: CC: Konrad Sztyber , Chenbo Xia , Nipun Gupta , Peng Zhang , Long Wu , Zerun Fu , Chaoyong He Subject: [PATCH] bus/pci: don't open uio device in secondary process Date: Wed, 28 Aug 2024 12:40:02 +0200 Message-ID: <20240828104002.226704-1-konrad.sztyber@intel.com> X-Mailer: git-send-email 2.45.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: VI1PR08CA0260.eurprd08.prod.outlook.com (2603:10a6:803:dc::33) To PH0PR11MB5578.namprd11.prod.outlook.com (2603:10b6:510:e7::8) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH0PR11MB5578:EE_|IA1PR11MB6123:EE_ X-MS-Office365-Filtering-Correlation-Id: d86639a7-1571-4003-493c-08dcc74dce11 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|366016; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?wc7j3UFEEn9ZukiLcSJjspDf81umta4/tH4DHV8ZJfJrD1UPyaAxZDm7O6XV?= =?us-ascii?Q?uzoiyJ4IFanAPDi0DKzMzlfIU8bkNw4eUhlKXKkx2/4bqmEOL69i6QrJNSBa?= =?us-ascii?Q?Bfket7tlSqltmwG4NgGa4re6aI1ZIf3hskAjAJLVo3tzYk1B2zIsTDr/wY+4?= =?us-ascii?Q?tUw2lEc9wXtuzhRo42bZ5btXOs7hDOAZvaMhaopHuZLtq4sa7+wtNjyZUQc8?= =?us-ascii?Q?trf9DUv9TM6Elft538mJ/NMekmGp+mUV6fgKLxliGzET3HptuvVH0fnQdF33?= =?us-ascii?Q?oPRd7qWtAtJdjXTlzgLTl1kS8eVPsz691nsJ5VEFzkOAE3eNxEwPE2KLY5ed?= =?us-ascii?Q?ekj4Y5nMK46kBjNu1eZF0wAs6jygGzZnOF/yjs46zRTO+xD+kn2oJHLkFheO?= =?us-ascii?Q?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H/+f4MAM7WQOK?= =?us-ascii?Q?q5dI1l0pFNAQDLhzDqoHCAYjnbYrxiwg3SOFePddRS6c5A=3D=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PH0PR11MB5578.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(376014)(1800799024)(366016); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?0DCiAvB6Ts2mldzBm2wusS2c2ArZBR7nTtzI5Y00Y5udWPPQdDL3NUpVFXea?= =?us-ascii?Q?Gx57vRM99OB8y2fS9PrQuJaAEa1B5yIw/ymbZgsORRrEZ6wIZADt1dGtnFno?= =?us-ascii?Q?+znLCKH3xt0amQY3PFXVexcAk4/HRP7HM5DzdIcJ4d4t1yJcLiCGjYP+kdOC?= =?us-ascii?Q?fSh7JAgwB2xyRrwFZ+LZVdELC+afNgYQ8VXCvDitoBN8frZpMg4yptXx3+OX?= =?us-ascii?Q?eQRWY34QrciQ/DRoKBcfhL8p/PrbliaLkM53YZWsiej9YMGDIkbCr3HrlKos?= =?us-ascii?Q?VmNJAZBcrKhZci8EHrZFGqzY7NlYk5f0rJz8tH7FCv96bK+Op1NaAZGZygcv?= =?us-ascii?Q?ZyIkwt2YmZeTv7P9sIkEsFAcYOiHPc9H/YYvXjffNfzOdUwX5U4Np7J0BIAF?= =?us-ascii?Q?SdXU5W9ttzS08HgJrUPp4DTlbflelV/3lvOXwVDp1G50S6EfdbG49TOAZhrU?= =?us-ascii?Q?Ogw1P/0Gf5SOQngEZw+hfJV8+rff6x+Xxx4l91Z6l1DPwSYjYoKDZeTwwCKG?= =?us-ascii?Q?rREmiZkQ46NVoUTySxKcJc6WDATlNNH6jOWwaYQ+CsF6lvsnqOfbWlFpnypK?= =?us-ascii?Q?Ol3/BNvFi5e8m0zuD2yeOGxPgulbn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ascii?Q?/Q3e11R4glr34WCkWFBHRiYS4GTWQ+PPetJngNKPF4gQ44tJ8+y9EtqZbV7S?= =?us-ascii?Q?ktVvjPOlgwfBSW8tirD6o7Ex8iq0NNCc//NDm4dbJBQfOeiS2LHvJaj4wgx2?= =?us-ascii?Q?Yg=3D=3D?= X-MS-Exchange-CrossTenant-Network-Message-Id: d86639a7-1571-4003-493c-08dcc74dce11 X-MS-Exchange-CrossTenant-AuthSource: PH0PR11MB5578.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Aug 2024 10:40:16.4645 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Kp6q4sqtTXz+Dl071DYnt4FCqFYIg7nRsmzisUJT3JagnA2dcvo3i3J/6+XJGW89DTUEhDRwEoaeDetpe/ZPcZDNzbYhMzA/MpLDdFdhZZo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR11MB6123 X-OriginatorOrg: intel.com 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 The uio_pci_generic driver clears the bus master bit when the device file is closed. So, when the secondary process terminates after probing a device, that device becomes unusable in the primary process. To avoid that, the device file is now opened only in the primary process. The commit that introduced this regression, 847d78fb95 ("bus/pci: fix FD in secondary process"), only mentioned enabling access to config space from secondary process, which still works, as it doesn't rely on the device file. Fixes: 847d78fb95 ("bus/pci: fix FD in secondary process") Signed-off-by: Konrad Sztyber --- drivers/bus/pci/linux/pci_uio.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/drivers/bus/pci/linux/pci_uio.c b/drivers/bus/pci/linux/pci_uio.c index 4c1d3327a9..432316afcc 100644 --- a/drivers/bus/pci/linux/pci_uio.c +++ b/drivers/bus/pci/linux/pci_uio.c @@ -232,18 +232,6 @@ pci_uio_alloc_resource(struct rte_pci_device *dev, loc->domain, loc->bus, loc->devid, loc->function); return 1; } - snprintf(devname, sizeof(devname), "/dev/uio%u", uio_num); - - /* save fd */ - fd = open(devname, O_RDWR); - if (fd < 0) { - PCI_LOG(ERR, "Cannot open %s: %s", devname, strerror(errno)); - goto error; - } - - if (rte_intr_fd_set(dev->intr_handle, fd)) - goto error; - snprintf(cfgname, sizeof(cfgname), "/sys/class/uio/uio%u/device/config", uio_num); @@ -273,6 +261,19 @@ pci_uio_alloc_resource(struct rte_pci_device *dev, if (rte_eal_process_type() != RTE_PROC_PRIMARY) return 0; + /* the uio_pci_generic driver clears the bus master enable bit when the device file is + * closed, so open it only in the primary process */ + snprintf(devname, sizeof(devname), "/dev/uio%u", uio_num); + /* save fd */ + fd = open(devname, O_RDWR); + if (fd < 0) { + PCI_LOG(ERR, "Cannot open %s: %s", devname, strerror(errno)); + goto error; + } + + if (rte_intr_fd_set(dev->intr_handle, fd)) + goto error; + /* allocate the mapping details for secondary processes*/ *uio_res = rte_zmalloc("UIO_RES", sizeof(**uio_res), 0); if (*uio_res == NULL) { -- 2.45.0