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 8B6C24569C for ; Wed, 24 Jul 2024 13:34:48 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 85053433CC; Wed, 24 Jul 2024 13:34:48 +0200 (CEST) Received: from mail-wr1-f52.google.com (mail-wr1-f52.google.com [209.85.221.52]) by mails.dpdk.org (Postfix) with ESMTP id 533C3433CC for ; Wed, 24 Jul 2024 13:34:47 +0200 (CEST) Received: by mail-wr1-f52.google.com with SMTP id ffacd0b85a97d-36868fcb919so3309332f8f.2 for ; Wed, 24 Jul 2024 04:34:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721820887; x=1722425687; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=qTCk01Opeck/g0q1nmSUlD5hu8mi9L+WPlTyf+ad2MQ=; b=nYuXB5IkKLiQNTTJieI2jIHUZZPLfo10HEgPdBAKtSdXZb+CIw2saT0dXxz0hR8+X0 HunuG2jHTVwDJ9iBcPCIZUhT27lBDl8hsPaVZM+zD0Fa1jmaMZojZre/ExZWH9cqdtap ShcXGOc1dLm+eUsqYl/hRWXwej8fp87vGC9FvlyxhGzwOLtdOGdv9hk/HFPiAD+OsxIx vi6qmmzfqomua9V32ntar64+IEPSs/2Sx4qRAvXVhXQxgpqNVgQ7shgvUM9alxo5XzTH oAlkGFrzAntH8tlNdQ2oBm69MK75laUmeN6GDtFhXKHSsrNIfestMYApVXmp9II9FU9x gw5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721820887; x=1722425687; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=qTCk01Opeck/g0q1nmSUlD5hu8mi9L+WPlTyf+ad2MQ=; b=bLgGHHRhlkV1iz16En9KbbSoAzDvxcMVfQTBrMEdGmbnHPlRRxhujQRHgxJ9YQd8gQ KjOcnqJ00WVH9WqilFQUfwpy6Cw02EiAz4L1oQ+MYLQOoY/NYNSLM6giA3pelO3tiZHZ WfS9hHFE8T9iE5QBNW35CIBcISbJfykZag5apIsswaH/bKLUPoIEEVIDqfzrgxUydJk3 xa7enMYXyc8xujGvG89GsIcPitBaFlDukB+cTozLR0GmFEJDPAxOPkbTOP+ItZ6rSsMH EcGA4cRhi9u0K/D1mRVucFZ2qRwKH3uIAtnPceC2zoegUer3C5GAsM3HbcaEeMXt2Nxa 6eog== X-Forwarded-Encrypted: i=1; AJvYcCWSeYhLV61tb4Ug8UTDewFMvK2b98pRCo6otNVEAzJiNUom9XnpSy5zrXEn3My2e62geNSnCboSgVzNSV+jLBo= X-Gm-Message-State: AOJu0YyFv9oL7b90aXVRG81N3va5z9+1YjcBXcmZg3PaoXK67+gx9eF9 0GRG/wkCmb3eT9H7khuIM5NKniW5dlJIo9F6vEcX/5UxYOSvJp612mKfqD4T X-Google-Smtp-Source: AGHT+IEg2+O21RLf6Pd8jttFQBd97BDuZAlcYXkOSRY+kn1IyG5gxhLmnh+J0tQhxR/85RGtDr1XhQ== X-Received: by 2002:adf:f6c1:0:b0:368:5a86:c1b7 with SMTP id ffacd0b85a97d-369f5b8e5eemr1540638f8f.55.1721820886807; Wed, 24 Jul 2024 04:34:46 -0700 (PDT) Received: from localhost ([2a01:4b00:d036:ae00:7aef:1aaa:3dff:d546]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427f937e85csm26321195e9.15.2024.07.24.04.34.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jul 2024 04:34:46 -0700 (PDT) From: luca.boccassi@gmail.com To: Zerun Fu Cc: Chaoyong He , Long Wu , Peng Zhang , Anatoly Burakov , Chenbo Xia , dpdk stable Subject: patch 'bus/pci: fix FD in secondary process' has been queued to stable release 22.11.6 Date: Wed, 24 Jul 2024 12:33:05 +0100 Message-Id: <20240724113318.616754-27-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240724113318.616754-1-luca.boccassi@gmail.com> References: <20240715152704.2229503-86-luca.boccassi@gmail.com> <20240724113318.616754-1-luca.boccassi@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Hi, FYI, your patch has been queued to stable release 22.11.6 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 07/26/24. So please shout if anyone has objections. Also note that after the patch there's a diff of the upstream commit vs the patch applied to the branch. This will indicate if there was any rebasing needed to apply to the stable branch. If there were code changes for rebasing (ie: not only metadata diffs), please double check that the rebase was correctly done. Queued patches are on a temporary branch at: https://github.com/bluca/dpdk-stable This queued commit can be viewed at: https://github.com/bluca/dpdk-stable/commit/635c7eaa5ee36df3fd2ad6cc727078b8a55cb209 Thanks. Luca Boccassi --- >From 635c7eaa5ee36df3fd2ad6cc727078b8a55cb209 Mon Sep 17 00:00:00 2001 From: Zerun Fu Date: Tue, 2 Jul 2024 15:40:07 +0800 Subject: [PATCH] bus/pci: fix FD in secondary process [ upstream commit 847d78fb9530fff401bf167298aad22766a1f04a ] 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") Signed-off-by: Zerun Fu Reviewed-by: Chaoyong He Reviewed-by: Long Wu Reviewed-by: Peng Zhang Acked-by: Anatoly Burakov Reviewed-by: Chenbo Xia --- drivers/bus/pci/linux/pci_uio.c | 5 ++++- drivers/bus/pci/pci_common_uio.c | 34 ++++++++++++++++---------------- 2 files changed, 21 insertions(+), 18 deletions(-) diff --git a/drivers/bus/pci/linux/pci_uio.c b/drivers/bus/pci/linux/pci_uio.c index d52125e49b..81a1ed6fa0 100644 --- a/drivers/bus/pci/linux/pci_uio.c +++ b/drivers/bus/pci/linux/pci_uio.c @@ -245,7 +245,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", @@ -283,6 +283,9 @@ pci_uio_alloc_resource(struct rte_pci_device *dev, } } + if (rte_eal_process_type() != RTE_PROC_PRIMARY) + return 0; + /* allocate the mapping details for secondary processes*/ *uio_res = rte_zmalloc("UIO_RES", sizeof(**uio_res), 0); if (*uio_res == NULL) { diff --git a/drivers/bus/pci/pci_common_uio.c b/drivers/bus/pci/pci_common_uio.c index f44ccdf27c..a06378b239 100644 --- a/drivers/bus/pci/pci_common_uio.c +++ b/drivers/bus/pci/pci_common_uio.c @@ -106,15 +106,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 */ @@ -230,19 +230,7 @@ pci_uio_unmap_resource(struct rte_pci_device *dev) if (uio_res == NULL) return; - /* secondary processes - just free maps */ - if (rte_eal_process_type() != RTE_PROC_PRIMARY) - return pci_uio_unmap(uio_res); - - TAILQ_REMOVE(uio_res_list, uio_res, next); - - /* unmap all resources */ - pci_uio_unmap(uio_res); - - /* free uio resource */ - rte_free(uio_res); - - /* close fd if in primary process */ + /* close fd */ if (rte_intr_fd_get(dev->intr_handle) >= 0) close(rte_intr_fd_get(dev->intr_handle)); uio_cfg_fd = rte_intr_dev_fd_get(dev->intr_handle); @@ -253,4 +241,16 @@ pci_uio_unmap_resource(struct rte_pci_device *dev) rte_intr_fd_set(dev->intr_handle, -1); rte_intr_type_set(dev->intr_handle, RTE_INTR_HANDLE_UNKNOWN); + + /* secondary processes - just free maps */ + if (rte_eal_process_type() != RTE_PROC_PRIMARY) + return pci_uio_unmap(uio_res); + + TAILQ_REMOVE(uio_res_list, uio_res, next); + + /* unmap all resources */ + pci_uio_unmap(uio_res); + + /* free uio resource */ + rte_free(uio_res); } -- 2.39.2 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2024-07-24 12:29:22.832583302 +0100 +++ 0027-bus-pci-fix-FD-in-secondary-process.patch 2024-07-24 12:29:20.795026614 +0100 @@ -1 +1 @@ -From 847d78fb9530fff401bf167298aad22766a1f04a Mon Sep 17 00:00:00 2001 +From 635c7eaa5ee36df3fd2ad6cc727078b8a55cb209 Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit 847d78fb9530fff401bf167298aad22766a1f04a ] + @@ -16 +17,0 @@ -Cc: stable@dpdk.org @@ -30 +31 @@ -index f7d990d33f..4c1d3327a9 100644 +index d52125e49b..81a1ed6fa0 100644 @@ -33 +34 @@ -@@ -234,7 +234,7 @@ pci_uio_alloc_resource(struct rte_pci_device *dev, +@@ -245,7 +245,7 @@ pci_uio_alloc_resource(struct rte_pci_device *dev, @@ -41,2 +42,2 @@ - PCI_LOG(ERR, "Cannot open %s: %s", devname, strerror(errno)); -@@ -270,6 +270,9 @@ pci_uio_alloc_resource(struct rte_pci_device *dev, + RTE_LOG(ERR, EAL, "Cannot open %s: %s\n", +@@ -283,6 +283,9 @@ pci_uio_alloc_resource(struct rte_pci_device *dev, @@ -53 +54 @@ -index 65f72b7cc6..30503bd23a 100644 +index f44ccdf27c..a06378b239 100644 @@ -56 +57 @@ -@@ -105,15 +105,15 @@ pci_uio_map_resource(struct rte_pci_device *dev) +@@ -106,15 +106,15 @@ pci_uio_map_resource(struct rte_pci_device *dev) @@ -76 +77 @@ -@@ -225,19 +225,7 @@ pci_uio_unmap_resource(struct rte_pci_device *dev) +@@ -230,19 +230,7 @@ pci_uio_unmap_resource(struct rte_pci_device *dev) @@ -97 +98 @@ -@@ -248,4 +236,16 @@ pci_uio_unmap_resource(struct rte_pci_device *dev) +@@ -253,4 +241,16 @@ pci_uio_unmap_resource(struct rte_pci_device *dev)