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 C216F43A06; Tue, 30 Jan 2024 07:16:20 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id AF2D3402C2; Tue, 30 Jan 2024 07:16:20 +0100 (CET) Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) by mails.dpdk.org (Postfix) with ESMTP id 525FE4029A; Tue, 30 Jan 2024 07:16:17 +0100 (CET) Received: from mail.maildlp.com (unknown [172.19.163.44]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4TPFHk0ZKbz1gy0p; Tue, 30 Jan 2024 14:14:26 +0800 (CST) Received: from dggpeml500024.china.huawei.com (unknown [7.185.36.10]) by mail.maildlp.com (Postfix) with ESMTPS id 49057140383; Tue, 30 Jan 2024 14:16:15 +0800 (CST) Received: from [10.67.121.161] (10.67.121.161) by dggpeml500024.china.huawei.com (7.185.36.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Tue, 30 Jan 2024 14:16:15 +0800 Subject: Re: [PATCH v2 2/2] bus/pci: fix secondary process save 'FD' problem To: Chaoyong He , CC: , Zerun Fu , , , Long Wu , Peng Zhang References: <20240124104523.2022242-1-chaoyong.he@corigine.com> <20240129092231.3531217-1-chaoyong.he@corigine.com> <20240129092231.3531217-3-chaoyong.he@corigine.com> From: fengchengwen Message-ID: Date: Tue, 30 Jan 2024 14:16:14 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.11.0 MIME-Version: 1.0 In-Reply-To: <20240129092231.3531217-3-chaoyong.he@corigine.com> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.67.121.161] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggpeml500024.china.huawei.com (7.185.36.10) 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 Hi, The pci_uio_alloc_resource in drivers/bus/pci/bsd should also modified. How about add subfunction: pci_uio_init_intr() which includes access/rte_intr_fd_set/rte_intr_fd_get/rte_intr_type_set? Thanks On 2024/1/29 17:22, Chaoyong He wrote: > From: Zerun Fu > > In the previous logic the 'fd' was only saved in the primary process, > but for some devices this value is also used in the secondary logic. > > For example, the call of 'rte_pci_find_ext_capability()' will fail in > the secondary process. > > Fix this problem by getting and saving the value of 'fd' also in the > secondary process logic. > > 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/linux/pci_uio.c | 5 ++++- > drivers/bus/pci/pci_common_uio.c | 8 ++++---- > 2 files changed, 8 insertions(+), 5 deletions(-) > > diff --git a/drivers/bus/pci/linux/pci_uio.c b/drivers/bus/pci/linux/pci_uio.c > index 97d740dfe5..6680e42efb 100644 > --- a/drivers/bus/pci/linux/pci_uio.c > +++ b/drivers/bus/pci/linux/pci_uio.c > @@ -237,7 +237,7 @@ pci_uio_alloc_resource(struct rte_pci_device *dev, > } > snprintf(devname, sizeof(devname), "/dev/uio%u", uio_num); > > - /* save fd if in primary process */ > + /* save fd */ > fd = open(devname, O_RDWR); > if (fd < 0) { > RTE_LOG(ERR, EAL, "Cannot open %s: %s\n", > @@ -261,6 +261,9 @@ pci_uio_alloc_resource(struct rte_pci_device *dev, > if (rte_intr_dev_fd_set(dev->intr_handle, uio_cfg_fd)) > goto error; > > + if (rte_eal_process_type() != RTE_PROC_PRIMARY) > + return 0; > + > if (dev->kdrv == RTE_PCI_KDRV_IGB_UIO) { > if (rte_intr_type_set(dev->intr_handle, RTE_INTR_HANDLE_UIO)) > goto error; > diff --git a/drivers/bus/pci/pci_common_uio.c b/drivers/bus/pci/pci_common_uio.c > index fcd8a49daf..b6f79b067d 100644 > --- a/drivers/bus/pci/pci_common_uio.c > +++ b/drivers/bus/pci/pci_common_uio.c > @@ -122,15 +122,15 @@ pci_uio_map_resource(struct rte_pci_device *dev) > if (rte_intr_dev_fd_set(dev->intr_handle, -1)) > return -1; > > - /* secondary processes - use already recorded details */ > - if (rte_eal_process_type() != RTE_PROC_PRIMARY) > - return pci_uio_map_secondary(dev); > - > /* allocate uio resource */ > ret = pci_uio_alloc_resource(dev, &uio_res); > if (ret) > return ret; > > + /* secondary processes - use already recorded details */ > + if (rte_eal_process_type() != RTE_PROC_PRIMARY) > + return pci_uio_map_secondary(dev); > + > /* Map all BARs */ > for (i = 0; i != PCI_MAX_RESOURCE; i++) { > /* skip empty BAR */ >