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 517D84569C for ; Wed, 24 Jul 2024 13:34:47 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 47E6242D89; Wed, 24 Jul 2024 13:34:47 +0200 (CEST) Received: from mail-wr1-f51.google.com (mail-wr1-f51.google.com [209.85.221.51]) by mails.dpdk.org (Postfix) with ESMTP id 56DA442D28 for ; Wed, 24 Jul 2024 13:34:46 +0200 (CEST) Received: by mail-wr1-f51.google.com with SMTP id ffacd0b85a97d-3687fd09251so3042427f8f.0 for ; Wed, 24 Jul 2024 04:34:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721820886; x=1722425686; 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=iMKI9YQCNt+Gb9jyfm9w+sgoNv2SVsb9VL2saBeyXdU=; b=F7GLAR3ZGs+gh0jIhPzxd8qR89/TCIJLdOOGnR2GsfUlo/snOrglPdSeo1K52S2em3 WQLDrWj3zrKRVKzbsnohQpZgTDaeGwuXG4U/66RSdG5UePSZ3P9n5TkWQOrn6eo37dzP b2pAc5z1eiTc+RUd1KpT09ZYDMTJd/+pNgkAOOfPgFKRH1wmhlYoukeY53k7gdYWgN1Z xwnk8ObT/Mfv/rq4bhnSvFdQ+AmArQIPDE/mcnxChvArN2h8DifrtS/9xyJhjBZutMWM DbF0P1g9031gXm0fd6w1kaxRMHkgQvmGKm62JAJZBNDBg/kbJDkTxtlNW3tXW3MHVUW+ xOuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721820886; x=1722425686; 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=iMKI9YQCNt+Gb9jyfm9w+sgoNv2SVsb9VL2saBeyXdU=; b=uI7iOBvCxB24bMjUKOTajOLlG066U2zFLcEhOWfH7twtg7kXO4TmvfKyb/vRWogsO5 QqPeNXUujFyzSj8VojEaEorpY8wCOClELULNrCvPq51NR+zyWhsSr56iEMVTrhqpH71f 6ngBZO4jk9hx8RJulcAvxVfT5PJHtot4zviM27Dd2GkM7+FwM50WpA6kC8K2JbNFr79o ltsXeLSeZYf5imFTjUWH5d8wzr1jN1BeylvWRIYb1EeWKEzSb1xUEGrmNeXDH4+mhHAf stmENhoCqABTAFDF4dvP3GJvvmYUN1BRFTxT3aKiX3ThPwJvuYxr6cmBZNwCy1JsmhTj jKXg== X-Forwarded-Encrypted: i=1; AJvYcCU+WX+RscikZTJkOWOaGpSrY6X2cBCBJcwuB8o6DJsyEu9wlQcx95FyRzmlgOolOZU62gKiNUsItiPVTJQ9vs4= X-Gm-Message-State: AOJu0YzspkoEEXXeFgPhr20Mtw4HqdAULVINmzHTXGdN2GLWtlXVdd8T k1qKC4UWvbg95w/43tRrv6r6F8C/+Fx6s7LT5+j3g+5nyasgEiIj X-Google-Smtp-Source: AGHT+IHC04wpsrblUbLqafx+Tpo2P14Fx/FgXmvqUQlNUFX0pD4QSpRqQSQnXFfnUi7KH9sh7Z4nJQ== X-Received: by 2002:a5d:5444:0:b0:367:9881:7d5e with SMTP id ffacd0b85a97d-369f09a23a3mr1616996f8f.8.1721820885730; Wed, 24 Jul 2024 04:34:45 -0700 (PDT) Received: from localhost ([2a01:4b00:d036:ae00:7aef:1aaa:3dff:d546]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36878684767sm14195181f8f.8.2024.07.24.04.34.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jul 2024 04:34:45 -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 UIO resource mapping in secondary process' has been queued to stable release 22.11.6 Date: Wed, 24 Jul 2024 12:33:04 +0100 Message-Id: <20240724113318.616754-26-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/6bf6cd51846b6ac69b690a2ccf3b1fe7b838ce47 Thanks. Luca Boccassi --- >From 6bf6cd51846b6ac69b690a2ccf3b1fe7b838ce47 Mon Sep 17 00:00:00 2001 From: Zerun Fu Date: Tue, 2 Jul 2024 15:40:06 +0800 Subject: [PATCH] bus/pci: fix UIO resource mapping in secondary process [ upstream commit 9e0a0e38ecaa7efaca9d349737d0a5ef9ca33a57 ] 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") 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/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 76c661f054..f44ccdf27c 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, j; + int fd, i = 0, j, 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 (i = 0; i != uio_res->nb_maps; i++) { + /* 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 (i >= 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[i].addr = mapaddr; + dev->mem_resource[res_idx].addr = mapaddr; + + i++; } return 0; } -- 2.39.2 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2024-07-24 12:29:22.774974840 +0100 +++ 0026-bus-pci-fix-UIO-resource-mapping-in-secondary-proces.patch 2024-07-24 12:29:20.795026614 +0100 @@ -1 +1 @@ -From 9e0a0e38ecaa7efaca9d349737d0a5ef9ca33a57 Mon Sep 17 00:00:00 2001 +From 6bf6cd51846b6ac69b690a2ccf3b1fe7b838ce47 Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit 9e0a0e38ecaa7efaca9d349737d0a5ef9ca33a57 ] + @@ -18 +19,0 @@ -Cc: stable@dpdk.org @@ -31 +32 @@ -index ff1b02b6bd..65f72b7cc6 100644 +index 76c661f054..f44ccdf27c 100644 @@ -60 +61 @@ -@@ -70,7 +78,9 @@ pci_uio_map_secondary(struct rte_pci_device *dev) +@@ -71,7 +79,9 @@ pci_uio_map_secondary(struct rte_pci_device *dev)