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 1ADD348A44 for ; Fri, 31 Oct 2025 15:39:38 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1278F40150; Fri, 31 Oct 2025 15:39:38 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mails.dpdk.org (Postfix) with ESMTP id 7A60240150 for ; Fri, 31 Oct 2025 15:39:36 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1761921576; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Qq4+QPXZ9sMqo5z70VSYWq3syvyvuesi6rPoYJ2ti5o=; b=NcMe6KbqfRVc3Aal+tiFRD1FQSxZiM3vXOKOdxopYgpXI1JPE/0pjoGstHxx1cMhd2ifbF 0PsCSwyY5Hm1/dpR16Y1lkpyO/hvW0aPZeTu6uboFYFxB9AMamdKcs+gr87QEsUHtUlnHf przIdH9u1MGIJ0zpfjThIOlLc/f49y0= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-136-Pe8fk7baMFKObshmEdQKGQ-1; Fri, 31 Oct 2025 10:39:33 -0400 X-MC-Unique: Pe8fk7baMFKObshmEdQKGQ-1 X-Mimecast-MFC-AGG-ID: Pe8fk7baMFKObshmEdQKGQ_1761921571 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id D37311956053; Fri, 31 Oct 2025 14:39:31 +0000 (UTC) Received: from rh.redhat.com (unknown [10.44.32.50]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 00272180044F; Fri, 31 Oct 2025 14:39:29 +0000 (UTC) From: Kevin Traynor 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 24.11.4 Date: Fri, 31 Oct 2025 14:33:53 +0000 Message-ID: <20251031143421.324432-111-ktraynor@redhat.com> In-Reply-To: <20251031143421.324432-1-ktraynor@redhat.com> References: <20251031143421.324432-1-ktraynor@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: SfmA-dK5ceJGMbRqSIo6M_0b-kS1uMBB2RucqS0f28Y_1761921571 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit content-type: text/plain; charset="US-ASCII"; x-default=true 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 24.11.4 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 11/05/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/kevintraynor/dpdk-stable This queued commit can be viewed at: https://github.com/kevintraynor/dpdk-stable/commit/a3672a18182b4cc0a9be29ed199ad96c18ffd73a Thanks. Kevin --- >From a3672a18182b4cc0a9be29ed199ad96c18ffd73a 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 160aa79137..110213077f 100644 --- a/drivers/net/ena/ena_ethdev.c +++ b/drivers/net/ena/ena_ethdev.c @@ -10,4 +10,5 @@ #include #include +#include #include "ena_ethdev.h" @@ -2267,4 +2268,22 @@ static int ena_init_once(void) } +/* + * 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_LINE(INFO, "PCI BAR [%u]: phys_addr=0x%" PRIx64 ", addr=%p, offset=0x%zx, adjusted_addr=%p", + bar, res->phys_addr, res->addr, offset, vaddr); + + return vaddr; +} + static int eth_ena_dev_init(struct rte_eth_dev *eth_dev) { @@ -2311,7 +2330,5 @@ 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_LINE(CRIT, "Failed to access registers BAR(%d)", @@ -2319,6 +2336,9 @@ static int eth_ena_dev_init(struct rte_eth_dev *eth_dev) 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.51.0 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2025-10-31 13:53:55.580251660 +0000 +++ 0111-net-ena-fix-PCI-BAR-mapping-on-64K-page-size.patch 2025-10-31 13:53:52.289524158 +0000 @@ -1 +1 @@ -From c71e3fbee65637084e1e42500e9e6300d50f467b Mon Sep 17 00:00:00 2001 +From a3672a18182b4cc0a9be29ed199ad96c18ffd73a Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit c71e3fbee65637084e1e42500e9e6300d50f467b ] + @@ -27 +28,0 @@ -Cc: stable@dpdk.org @@ -33,14 +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 -@@ -110,4 +110,5 @@ New Features - - * 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(-) + @@ -48 +38 @@ -index 5147a754b2..aaa4feb11b 100644 +index 160aa79137..110213077f 100644 @@ -57 +47 @@ -@@ -2365,4 +2366,22 @@ static int ena_init_once(void) +@@ -2267,4 +2268,22 @@ static int ena_init_once(void) @@ -80 +70 @@ -@@ -2410,7 +2429,5 @@ static int eth_ena_dev_init(struct rte_eth_dev *eth_dev) +@@ -2311,7 +2330,5 @@ static int eth_ena_dev_init(struct rte_eth_dev *eth_dev) @@ -89 +79 @@ -@@ -2418,6 +2435,9 @@ static int eth_ena_dev_init(struct rte_eth_dev *eth_dev) +@@ -2319,6 +2336,9 @@ static int eth_ena_dev_init(struct rte_eth_dev *eth_dev)