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 8661A489EF for ; Mon, 27 Oct 2025 17:23:48 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 808EE4028B; Mon, 27 Oct 2025 17:23:48 +0100 (CET) Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) by mails.dpdk.org (Postfix) with ESMTP id D2FFD4028B for ; Mon, 27 Oct 2025 17:23:44 +0100 (CET) Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-4770e7062b5so11984345e9.2 for ; Mon, 27 Oct 2025 09:23:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1761582224; x=1762187024; 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=TFonFx4nIwQY41oJ1JbwCWLHBq54AtQAZcOAIVPN4o0=; b=geMgvU3tNYOQxcBpXxDUCDFoHS11ACCN9QSkvu+GEisCBPIT7Ww1+8lwxZcbEKrCSR SeI7x5VvO1zxhhifDBoI5l03upOUyT10Rrm8Xtfzy34ujQ7cq5R5v61C6CSn2Yn5ByL5 mcPP4vCaT9Z308oUhZeO0LooAJjorsRaWFT/YubQ8gGqvz3ADEhSWIS/rvCskA+1oJh7 QkotAE+gRqgDNBNEStzjS4mB95l2dzCr+uSc4moMS1fg2B/Zyb6VF5OpEWazjf+nnKG8 n6JkiR/6pcdAIU2g+KwB5bhoOX3NwWR9GygPyHpqy8yKET+Dv3meyNT1jbCNtxjr+ynO sD9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761582224; x=1762187024; 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=TFonFx4nIwQY41oJ1JbwCWLHBq54AtQAZcOAIVPN4o0=; b=ZHifecBO9YkhCd1onqtblU1FKckhCrZ/eRqH0Ly8hkZtgfdwuGOMiDkUUGQk7vHtlO pYNvgIbtdrvxnA54bhtpojAlE4rRvB5WsGevCLYC3rotDl8Vx/MG0oqPFDaK4KsdTCbO jpWbVFSbcRZnzpSMi7htF8v5GONl4UvlDwR0EAudNZojdxquv4PR5JhMk3p5dRzjavTt i7cyJC0EjycrJYCljaf6kF4uEGMVLg0VnV+NC6SaWKgKKz6D1LN7Y5zYnUdLcQ01Bni1 ZIjyXQKr0nqgLpcqQ/e0HC5TFI2YooIxrNfPxtVyAtwLwYEfasg61K9CAyZ1Yk9qkDDR t5EA== X-Forwarded-Encrypted: i=1; AJvYcCXvuSQR2GgDno9tp2RGtiFtXI4J2WtcsfhIHnKMtA1wsFguZeEFAiqqZfiZmaeWkHbsM5UX7a8=@dpdk.org X-Gm-Message-State: AOJu0YxcSilMJgIy3/rNTChmu5i6wsZl5HqY0TzOMj7NRn/vY0R3fsFr vp4VYAAhweDXwKw3lLaWxjYj+z/Ep6yK3THieyeVuJYHWuTJQy5ajoAFKp9AIXFc X-Gm-Gg: ASbGncs+uq5GpVBaSEY4pc2JV0fIV3cxqAXOJ1ac0mUCO4cF0g88z427Ib8f5sybJk7 pcBdLySue1aB2TNS7Z2jfyfAu33D/IFefiQTQzpATxDttJbK9FUjSTc2OB9ahbddLt1ozEgQOwq bMRk3qQSRzQ0RdnusoNKZs8s2md3iyfT4ki00NgvpCYGRutH1okGZ4J0EDZqcnc8qH35WV5WjzJ PtuAJOYjV1TX1e/BWdUU/QinDxalt5EOL3269qNiqCtpFh7QpLN5HBuSonWKsC2i2LtXsovmMVH ulrEpKQEWuhANjCyESoBSkmJaywF6xkf40w5qMaiZM4j/4qhBbHInIFeu1bxNOCUF43tHg8G9et efUF7bW93dhT+aDgB1oSY1O7UqQpDCnKcsowTFABMEVpsBptq6VXORotSKi+xHtkA+uRqWcusTO 4ZvD/BPXRJamyLuHbd X-Google-Smtp-Source: AGHT+IHQKuVucm9Jr4auY89MTTeCbimNGnocJNr1e0XZYeHHmHQgU1ubqsjpe3tN+lQTNKDlIDRSMQ== X-Received: by 2002:a05:600c:5295:b0:475:df91:ddf0 with SMTP id 5b1f17b1804b1-47717e703d6mr1889425e9.33.1761582224354; Mon, 27 Oct 2025 09:23:44 -0700 (PDT) Received: from localhost ([2a01:4b00:d036:ae00:6fc5:c3bc:147e:832c]) by smtp.gmail.com with UTF8SMTPSA id 5b1f17b1804b1-475dd4924a4sm147076385e9.7.2025.10.27.09.23.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Oct 2025 09:23:43 -0700 (PDT) From: luca.boccassi@gmail.com To: Shai Brandes Cc: Amit Bernstein , Yosef Raisman , dpdk stable Subject: patch 'net/ena: fix PCI BAR mapping on 64K page size' has been queued to stable release 22.11.11 Date: Mon, 27 Oct 2025 16:19:46 +0000 Message-ID: <20251027162001.3710450-68-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251027162001.3710450-1-luca.boccassi@gmail.com> References: <20251027162001.3710450-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.11 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 10/29/25. 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/a27f262b008305bdf84343509f9a70c13c1e16c5 Thanks. Luca Boccassi --- >From a27f262b008305bdf84343509f9a70c13c1e16c5 Mon Sep 17 00:00:00 2001 From: Shai Brandes Date: Wed, 15 Oct 2025 15:09:16 +0300 Subject: [PATCH] net/ena: fix PCI BAR mapping on 64K page size [ upstream commit c71e3fbee65637084e1e42500e9e6300d50f467b ] On 64K page systems, DPDK `pci_uio` driver aligns the physical address to a 64K boundary before assigning a virtual address. If the original physical BAR address is not 64K-aligned, this adjustment leads to an incorrect mapping. This patch ensures the BAR virtual address received in the driver accounts for both PAGE size and BAR physical offset to correctly map each BAR. The fix is compatible for every PAGE size, applies to every used BAR, and supports both 32/64 bit DPDK builds. Example issue: - BAR0 physical address: 0x80208000 (not 64K-aligned) - DPDK aligned physical address: 0x80208000 -> 0x80200000 (masking 0x8000 offset) - DPDK mapped physical to virtual address: 0x80200000 -> 0x1140000000 - Driver accessed BAR0 virtual address = 0x1140000000 (causing init failure) - Resolution is to add correct offset to driver BAR0 address: 0x1140000000 + 0x8000 Fixes: 1173fca25af9 ("ena: add polling-mode driver") Signed-off-by: Amit Bernstein Signed-off-by: Shai Brandes Reviewed-by: Yosef Raisman --- drivers/net/ena/ena_ethdev.c | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/drivers/net/ena/ena_ethdev.c b/drivers/net/ena/ena_ethdev.c index e640bbae3d..079fc23f05 100644 --- a/drivers/net/ena/ena_ethdev.c +++ b/drivers/net/ena/ena_ethdev.c @@ -8,6 +8,7 @@ #include #include #include +#include #include "ena_ethdev.h" #include "ena_logs.h" @@ -2084,6 +2085,24 @@ static int ena_init_once(void) return 0; } +/* + * Returns PCI BAR virtual address. + * If the physical address is not page-aligned, + * adjusts the virtual address by the page offset. + * Assumes page size is a power of 2. + */ +static void *pci_bar_addr(struct rte_pci_device *dev, uint32_t bar) +{ + const struct rte_mem_resource *res = &dev->mem_resource[bar]; + size_t offset = res->phys_addr % rte_mem_page_size(); + void *vaddr = RTE_PTR_ADD(res->addr, offset); + + PMD_INIT_LOG(INFO, "PCI BAR [%u]: phys_addr=0x%" PRIx64 ", addr=%p, offset=0x%zx, adjusted_addr=%p\n", + bar, res->phys_addr, res->addr, offset, vaddr); + + return vaddr; +} + static int eth_ena_dev_init(struct rte_eth_dev *eth_dev) { struct ena_calc_queue_size_ctx calc_queue_ctx = { 0 }; @@ -2128,16 +2147,17 @@ static int eth_ena_dev_init(struct rte_eth_dev *eth_dev) intr_handle = pci_dev->intr_handle; - adapter->regs = pci_dev->mem_resource[ENA_REGS_BAR].addr; - adapter->dev_mem_base = pci_dev->mem_resource[ENA_MEM_BAR].addr; - + adapter->regs = pci_bar_addr(pci_dev, ENA_REGS_BAR); if (!adapter->regs) { PMD_INIT_LOG(CRIT, "Failed to access registers BAR(%d)\n", ENA_REGS_BAR); return -ENXIO; } - ena_dev->reg_bar = adapter->regs; + + /* Memory BAR may be NULL on non LLQ supported devices */ + adapter->dev_mem_base = pci_bar_addr(pci_dev, ENA_MEM_BAR); + /* Pass device data as a pointer which can be passed to the IO functions * by the ena_com (for example - the memory allocation). */ -- 2.47.3 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2025-10-27 15:54:37.270665819 +0000 +++ 0068-net-ena-fix-PCI-BAR-mapping-on-64K-page-size.patch 2025-10-27 15:54:34.843950754 +0000 @@ -1 +1 @@ -From c71e3fbee65637084e1e42500e9e6300d50f467b Mon Sep 17 00:00:00 2001 +From a27f262b008305bdf84343509f9a70c13c1e16c5 Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit c71e3fbee65637084e1e42500e9e6300d50f467b ] + @@ -27 +28,0 @@ -Cc: stable@dpdk.org @@ -33,16 +34,3 @@ - doc/guides/rel_notes/release_25_11.rst | 1 + - drivers/net/ena/ena_ethdev.c | 28 ++++++++++++++++++++++---- - 2 files changed, 25 insertions(+), 4 deletions(-) - -diff --git a/doc/guides/rel_notes/release_25_11.rst b/doc/guides/rel_notes/release_25_11.rst -index 94e5182016..863d111c8d 100644 ---- a/doc/guides/rel_notes/release_25_11.rst -+++ b/doc/guides/rel_notes/release_25_11.rst -@@ -109,6 +109,7 @@ New Features - * **Updated Amazon ENA (Elastic Network Adapter) ethernet driver.** - - * Added support for retrieving HW timestamps for Rx packets with nanosecond resolution. -+ * Fixed PCI BAR mapping on 64K page size. - - * **Added Huawei hinic3 ethernet driver.** - + drivers/net/ena/ena_ethdev.c | 28 ++++++++++++++++++++++++---- + 1 file changed, 24 insertions(+), 4 deletions(-) + @@ -50 +38 @@ -index 5147a754b2..aaa4feb11b 100644 +index e640bbae3d..079fc23f05 100644 @@ -53 +41 @@ -@@ -9,6 +9,7 @@ +@@ -8,6 +8,7 @@ @@ -61 +49 @@ -@@ -2364,6 +2365,24 @@ static int ena_init_once(void) +@@ -2084,6 +2085,24 @@ static int ena_init_once(void) @@ -77 +65 @@ -+ PMD_INIT_LOG_LINE(INFO, "PCI BAR [%u]: phys_addr=0x%" PRIx64 ", addr=%p, offset=0x%zx, adjusted_addr=%p", ++ PMD_INIT_LOG(INFO, "PCI BAR [%u]: phys_addr=0x%" PRIx64 ", addr=%p, offset=0x%zx, adjusted_addr=%p\n", @@ -86 +74 @@ -@@ -2409,16 +2428,17 @@ static int eth_ena_dev_init(struct rte_eth_dev *eth_dev) +@@ -2128,16 +2147,17 @@ static int eth_ena_dev_init(struct rte_eth_dev *eth_dev) @@ -95 +83 @@ - PMD_INIT_LOG_LINE(CRIT, "Failed to access registers BAR(%d)", + PMD_INIT_LOG(CRIT, "Failed to access registers BAR(%d)\n",