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 765DA45895; Thu, 29 Aug 2024 10:58:15 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9E4E9427DF; Thu, 29 Aug 2024 10:58:14 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) by mails.dpdk.org (Postfix) with ESMTP id AEE4C427CF; Thu, 29 Aug 2024 10:58:12 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1724921893; x=1756457893; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=3Mxr4RPAUdd2daaZ+KfTfPi0LTQkl60TypIm9Bx5k74=; b=ZabAz60ogC8hn1rq+Ay0hMS7ZzlISzUaOxnQgNol5GIDHLqsZlaMYzFk ocH8OQa2s+lWQIsFf1sYPoy0jvbmb+NLMIqDRusYCVpstp0hfSWuvrhKt o9EUeT6+u/MN7jmxNeZZ54urx74JNyGxhEnoG3ruXFFXVVQPbMqkmCDRo UZUeum7S1y0rm1tsGlY9vHhE5mxjZgw3jul7cy6veajvWTxmRl9ahJbxF cYF3zAfyS/HGrcMcxXVhleIfJcoDr7XLFBq18bYuUVcj7rvyMLRzya0zh 3jukIltb+oadXHvNIwww8oGWTjyTLvqFChv8BOXHp6T73E5hKW+WPAVms A==; X-CSE-ConnectionGUID: YWyh9czaTH2+lNe4/OcLZA== X-CSE-MsgGUID: 2ChsrtMwRrSufOBePMiVpA== X-IronPort-AV: E=McAfee;i="6700,10204,11178"; a="40972043" X-IronPort-AV: E=Sophos;i="6.10,185,1719903600"; d="scan'208";a="40972043" Received: from fmviesa010.fm.intel.com ([10.60.135.150]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Aug 2024 01:58:11 -0700 X-CSE-ConnectionGUID: WYB+WK2bSDargOh3mc3UPw== X-CSE-MsgGUID: ItSfjARFRYeSLm+L9sOYhw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.10,185,1719903600"; d="scan'208";a="63699444" Received: from fmsmsx602.amr.corp.intel.com ([10.18.126.82]) by fmviesa010.fm.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 29 Aug 2024 01:58:10 -0700 Received: from fmsmsx612.amr.corp.intel.com (10.18.126.92) by fmsmsx602.amr.corp.intel.com (10.18.126.82) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 29 Aug 2024 01:58:10 -0700 Received: from fmsmsx610.amr.corp.intel.com (10.18.126.90) by fmsmsx612.amr.corp.intel.com (10.18.126.92) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 29 Aug 2024 01:58:10 -0700 Received: from FMSEDG603.ED.cps.intel.com (10.1.192.133) by fmsmsx610.amr.corp.intel.com (10.18.126.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39 via Frontend Transport; Thu, 29 Aug 2024 01:58:10 -0700 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (104.47.55.170) by edgegateway.intel.com (192.55.55.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Thu, 29 Aug 2024 01:58:10 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=fDKfdXXGor1V19w5h3YsRilvzHIvsvVYCTrgM367A3i9cFYB6jJJh1rkmVzSnffU1YhcGuiT31Zui0YraUv7M8aJdDe9uQ4ld8VvBnuwi5cKCgQ/WGK0K750Db3+CaYrMCGVZw8TA+PZVIhoPpVgAxs8FjOEx5UBG9JkNMm16tWyOlxgPakwjc9dE6klNdUvl3THDFZi9gLGtYgB/U6iz3WHl+SMTKwmtlT+2740Ubi0SbjvKkCIazUuhIPsJlhOdWtHMHwx9FuIa5pdoAvXPu/xrEkx8UCspEFsqkwLaTVMckdq2RMBVK62mRWaEIthwNsYdysBSqRsJtdfIxm6xw== 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=7h2+DQ7ix8OwV72fbtmrbspUdPYg2O+EskHSrnKwKdE=; b=s8n4VeYjOGVbf49vmX/Y2KGc9TMzMHDqmtdsb0/xYfEi2h5OZUc/W4GwXBhEfduRYk1HquGyomA9NEy9c2086Bo3ws25unh8tNKLbgKczni0oHLqcUq0lzNF/XDc23mubfKqeluXxhtAS+rluDmZ/3BzBKk/OJir/SZo5zPofXp8ekJQ+7W2MqXFmv5s+l7CqAxt640KF41sotRFoLN+VBxeK3kL8wJFgJAK27Z0VmnjsK8vvMPiuOlSkcV1xQFg0XCoVKtVlLUkX/jzm4enId0yiZ44u9v7VCyJbgMCmPYsuILxEWyzSzvhM0iQaLsBQ1lGGpavXAm3gDs3+v28+g== 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 SA0PR11MB4542.namprd11.prod.outlook.com (2603:10b6:806:9f::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.20; Thu, 29 Aug 2024 08:58:08 +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; Thu, 29 Aug 2024 08:58:08 +0000 From: Konrad Sztyber To: CC: , Konrad Sztyber , , Chenbo Xia , Nipun Gupta , Zerun Fu , Anatoly Burakov , Peng Zhang , Long Wu Subject: [PATCH v2] bus/pci: don't open uio device in secondary process Date: Thu, 29 Aug 2024 10:57:24 +0200 Message-ID: <20240829085724.270041-1-konrad.sztyber@intel.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240828104002.226704-1-konrad.sztyber@intel.com> References: <20240828104002.226704-1-konrad.sztyber@intel.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: VI1P190CA0009.EURP190.PROD.OUTLOOK.COM (2603:10a6:802:2b::22) To PH0PR11MB5578.namprd11.prod.outlook.com (2603:10b6:510:e7::8) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH0PR11MB5578:EE_|SA0PR11MB4542:EE_ X-MS-Office365-Filtering-Correlation-Id: ff541002-1e58-48b3-8174-08dcc808b394 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|376014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?A2lW+LMjus+wvBstDwKWukytVD7ECGep9pdM4ZrQbgin8o3mEH2p61bzULgc?= =?us-ascii?Q?0VLe1dUVawKPWScf8HOGkd8G5aZvdsMPEioOV+EtqUJKXhd93wrOAKpEGM7e?= =?us-ascii?Q?DDpqRXBPh21tklgtRhkObmGxMBnLXeedpMsFBsJ2Q2xeIdiK8dSkgunpIBkA?= =?us-ascii?Q?cT9SXp5f+3pqQFBFWvoDj0atx8gyxt9WuLUFxgtlsKYbiLan8n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uE2zNyRRQ4j3Y9oXV9Ir5NdMeTt?= =?us-ascii?Q?q/glkfPGbklM716JgYoAX6SjOXCLc+9g6VS6U0NJ8P4m+KPWQv6x8jFymoZE?= =?us-ascii?Q?f8xe6/3b9eD1sqAL+T5mV5N6f2nVSd+A7eXpkrN/o46K/Vl2w73715gEpqAD?= =?us-ascii?Q?0ZQtRLYmyo3EgP2u9ZFdN5SFFj+FZVrWXcNDXLARiJ7ucwft3jnfBIRHiEGs?= =?us-ascii?Q?FpckWHR69ccQbGYabuX45YpE2DDZSbxvWT2AOQY510EmVw=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)(1800799024)(366016)(376014); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?sZj80a5hILJakfDTYifCfzil0yv8jEoxDNf0TRA6eiHzhaT3esRrXv5BZw/Y?= =?us-ascii?Q?8j2179IeEKi5FgbIGOWmQ0ImseotbJ09YbbDy/9zKmjrFbCgYUHRWzuonf2r?= =?us-ascii?Q?+ZDrRiiQGl1A8WSNm+0HC9mVlcxYgb/vkqTriYVqWY4CJb/PfAlcmgjbpMla?= =?us-ascii?Q?M0w8d4AxChsXMAZDxnFXpFtfS4ZMQhh/pvzCQ8H2DMvvTatUD1E3Gu57V08m?= =?us-ascii?Q?231kPP89qxcQTYywy5XLenhfNVbdRTh6kv4xrjTa2HTFl+eZj6iLtaBEf1yd?= =?us-ascii?Q?4L/tJ9djuJq2OUbD19XLmHy5DGmmlPc2x1o8is/ZFsHj5xzb9FxzGwAUBatl?= =?us-ascii?Q?KmvESJM2PRb+Hzsv4D2Zi9ZAjOt8RvQQTedMO1yjf5ynrhw6L/hsolnsQVg2?= =?us-ascii?Q?PHwTzG8FgsioZpigO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VHe5lq9?= =?us-ascii?Q?d6eijiRSqT02yKjxC/Q969Nbr+TLjsQGc9zrGf0cjmHSKF0DFwz23xEGqlYq?= =?us-ascii?Q?wIgpYdkcUdTr9CuaxtbRSNinqQeZaqQKepqHyx82bcEt2Ux8ecQLtOntsXLe?= =?us-ascii?Q?E3CZ/G/7l8DVqGygtT3RnbZ6bIjt38Lta5ltg34rtVw6/YDrcZYMKpygWfvV?= =?us-ascii?Q?+YnlS9OT9RxFlIBum6S//IAAxSNj2YhyL8CRu6gg1Sc2G49/+0mXiiNGj0cO?= =?us-ascii?Q?kQPY2Zvp6AQtUaFuz6Ak+KGS7yXS52Speby/7rP08/cDxZzaeet0Drijcf7G?= =?us-ascii?Q?tQ=3D=3D?= X-MS-Exchange-CrossTenant-Network-Message-Id: ff541002-1e58-48b3-8174-08dcc808b394 X-MS-Exchange-CrossTenant-AuthSource: PH0PR11MB5578.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Aug 2024 08:58:08.0372 (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: c2xQ6bPi9NvlpQ3EN+uyqcVXiord61HyfltIbITQldL6URLzCXOIuZ8N9niZpA7XZbbZsMCsqvUeyvqycaHX3uKE+WfUC/s/xDRLQvg/sl0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR11MB4542 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, 847d78fb9530 ("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: 847d78fb9530 ("bus/pci: fix FD in secondary process") Cc: stable@dpdk.org Signed-off-by: Konrad Sztyber --- drivers/bus/pci/linux/pci_uio.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/drivers/bus/pci/linux/pci_uio.c b/drivers/bus/pci/linux/pci_uio.c index 4c1d3327a9..5c4ba8098c 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,21 @@ 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