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 B43DB45804 for ; Fri, 23 Aug 2024 18:23:07 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id AEBC34337C; Fri, 23 Aug 2024 18:23:07 +0200 (CEST) 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 454BA402BE for ; Fri, 23 Aug 2024 18:23:05 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1724430184; 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=rr2MhsydcSv6InVlbouOrkCdkiEETmhQoAQinv45QUw=; b=Se45fBLQCOWOJSpo6dx/rl1r7Evq6O5wku+ZYiqBVvS/MOn35ArcXae84U48c1oAG9w5gf u0QcEdp3vGeXPrriglZ+9ddL5jV07L3qTLdf5rVXYy7SNFutpiVdI+CQEEfRbLqLsKt7/H xqKimFKJSyOEqocQKbdSYcvYmKJ0UTM= 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-562-NvqhJ82dN_a-12f3RFK81w-1; Fri, 23 Aug 2024 12:23:03 -0400 X-MC-Unique: NvqhJ82dN_a-12f3RFK81w-1 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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 769971955D4C; Fri, 23 Aug 2024 16:23:02 +0000 (UTC) Received: from rh.redhat.com (unknown [10.39.193.224]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 522C51956053; Fri, 23 Aug 2024 16:23:01 +0000 (UTC) From: Kevin Traynor To: Jiawen Wu Cc: dpdk stable Subject: patch 'net/txgbe: fix Tx hang on queue disable' has been queued to stable release 21.11.8 Date: Fri, 23 Aug 2024 17:18:44 +0100 Message-ID: <20240823161929.1004778-96-ktraynor@redhat.com> In-Reply-To: <20240823161929.1004778-1-ktraynor@redhat.com> References: <20240823161929.1004778-1-ktraynor@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Mimecast-Spam-Score: 0 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 21.11.8 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 08/28/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/kevintraynor/dpdk-stable This queued commit can be viewed at: https://github.com/kevintraynor/dpdk-stable/commit/d298093543513b0f01376628bc7af2c740514f18 Thanks. Kevin --- >From d298093543513b0f01376628bc7af2c740514f18 Mon Sep 17 00:00:00 2001 From: Jiawen Wu Date: Tue, 18 Jun 2024 15:11:34 +0800 Subject: [PATCH] net/txgbe: fix Tx hang on queue disable [ upstream commit 8a31f4bbbbb73baf77297f00887f4b267feb7b8e ] The problem of Tx hang also occurs on Wangxun 10Gb NICs, when stop device under heavy traffic. Refer to commit ac6c5e9af56a ("net/ngbe: fix Tx hang on queue disable") Disable PCIe bus master to clear BME when stop hardware, and verify there are no pending requests. Move disabling Tx queue after disabling PCIe bus master to ensure that there are no packets left to cause Tx hang. Fixes: b1f596677d8e ("net/txgbe: support device start") Signed-off-by: Jiawen Wu --- drivers/net/txgbe/base/meson.build | 2 +- drivers/net/txgbe/base/txgbe_hw.c | 60 +++++++++++++++++++++++----- drivers/net/txgbe/base/txgbe_hw.h | 1 + drivers/net/txgbe/base/txgbe_osdep.h | 1 + drivers/net/txgbe/base/txgbe_regs.h | 3 ++ drivers/net/txgbe/base/txgbe_type.h | 1 + drivers/net/txgbe/txgbe_ethdev.c | 7 ++++ 7 files changed, 65 insertions(+), 10 deletions(-) diff --git a/drivers/net/txgbe/base/meson.build b/drivers/net/txgbe/base/meson.build index a81d6890fe..4cf90a394a 100644 --- a/drivers/net/txgbe/base/meson.build +++ b/drivers/net/txgbe/base/meson.build @@ -23,5 +23,5 @@ endforeach base_lib = static_library('txgbe_base', sources, - dependencies: [static_rte_eal, static_rte_net], + dependencies: [static_rte_eal, static_rte_net, static_rte_bus_pci], c_args: c_args) base_objs = base_lib.extract_all_objects(recursive: true) diff --git a/drivers/net/txgbe/base/txgbe_hw.c b/drivers/net/txgbe/base/txgbe_hw.c index 1083431055..2a42f18381 100644 --- a/drivers/net/txgbe/base/txgbe_hw.c +++ b/drivers/net/txgbe/base/txgbe_hw.c @@ -463,5 +463,5 @@ void txgbe_set_lan_id_multi_port(struct txgbe_hw *hw) s32 txgbe_stop_hw(struct txgbe_hw *hw) { - u32 reg_val; + s32 status = 0; u16 i; @@ -485,14 +485,24 @@ s32 txgbe_stop_hw(struct txgbe_hw *hw) wr32(hw, TXGBE_ICR(1), TXGBE_ICR_MASK); + wr32(hw, TXGBE_BMECTL, 0x3); + + /* Disable the receive unit by stopping each queue */ + for (i = 0; i < hw->mac.max_rx_queues; i++) + wr32(hw, TXGBE_RXCFG(i), 0); + + /* flush all queues disables */ + txgbe_flush(hw); + msec_delay(2); + + /* Prevent the PCI-E bus from hanging by disabling PCI-E master + * access and verify no pending requests + */ + status = txgbe_set_pcie_master(hw, false); + if (status) + return status; + /* Disable the transmit unit. Each queue must be disabled. */ for (i = 0; i < hw->mac.max_tx_queues; i++) - wr32(hw, TXGBE_TXCFG(i), TXGBE_TXCFG_FLUSH); - - /* Disable the receive unit by stopping each queue */ - for (i = 0; i < hw->mac.max_rx_queues; i++) { - reg_val = rd32(hw, TXGBE_RXCFG(i)); - reg_val &= ~TXGBE_RXCFG_ENA; - wr32(hw, TXGBE_RXCFG(i), reg_val); - } + wr32(hw, TXGBE_TXCFG(i), 0); /* flush all queues disables */ @@ -1181,4 +1191,36 @@ out: } +s32 txgbe_set_pcie_master(struct txgbe_hw *hw, bool enable) +{ + struct rte_pci_device *pci_dev = (struct rte_pci_device *)hw->back; + s32 status = 0; + u32 i; + + if (rte_pci_set_bus_master(pci_dev, enable) < 0) { + DEBUGOUT("Cannot configure PCI bus master."); + return -1; + } + + if (enable) + goto out; + + /* Exit if master requests are blocked */ + if (!(rd32(hw, TXGBE_BMEPEND))) + goto out; + + /* Poll for master request bit to clear */ + for (i = 0; i < TXGBE_PCI_MASTER_DISABLE_TIMEOUT; i++) { + usec_delay(100); + if (!(rd32(hw, TXGBE_BMEPEND))) + goto out; + } + + DEBUGOUT("PCIe transaction pending bit also did not clear."); + status = TXGBE_ERR_MASTER_REQUESTS_PENDING; + +out: + return status; +} + /** * txgbe_acquire_swfw_sync - Acquire SWFW semaphore diff --git a/drivers/net/txgbe/base/txgbe_hw.h b/drivers/net/txgbe/base/txgbe_hw.h index fd2f7d784c..bf656bb53e 100644 --- a/drivers/net/txgbe/base/txgbe_hw.h +++ b/drivers/net/txgbe/base/txgbe_hw.h @@ -41,4 +41,5 @@ s32 txgbe_validate_mac_addr(u8 *mac_addr); s32 txgbe_acquire_swfw_sync(struct txgbe_hw *hw, u32 mask); void txgbe_release_swfw_sync(struct txgbe_hw *hw, u32 mask); +s32 txgbe_set_pcie_master(struct txgbe_hw *hw, bool enable); s32 txgbe_get_san_mac_addr(struct txgbe_hw *hw, u8 *san_mac_addr); diff --git a/drivers/net/txgbe/base/txgbe_osdep.h b/drivers/net/txgbe/base/txgbe_osdep.h index b62c0b0824..30d671540e 100644 --- a/drivers/net/txgbe/base/txgbe_osdep.h +++ b/drivers/net/txgbe/base/txgbe_osdep.h @@ -20,4 +20,5 @@ #include #include +#include #include "../txgbe_logs.h" diff --git a/drivers/net/txgbe/base/txgbe_regs.h b/drivers/net/txgbe/base/txgbe_regs.h index dc22ef53e3..c96bdd984b 100644 --- a/drivers/net/txgbe/base/txgbe_regs.h +++ b/drivers/net/txgbe/base/txgbe_regs.h @@ -1235,4 +1235,7 @@ enum txgbe_5tuple_protocol { #define TXGBE_ITRSEL 0x000180 +#define TXGBE_BMECTL 0x012020 +#define TXGBE_BMEPEND 0x000168 + /* P2V Mailbox */ #define TXGBE_MBMEM(i) (0x005000 + 0x40 * (i)) /* 0-63 */ diff --git a/drivers/net/txgbe/base/txgbe_type.h b/drivers/net/txgbe/base/txgbe_type.h index e7971ccf1d..3b86d8bb8c 100644 --- a/drivers/net/txgbe/base/txgbe_type.h +++ b/drivers/net/txgbe/base/txgbe_type.h @@ -29,4 +29,5 @@ #define TXGBE_FDIRCMD_CMD_POLL 10 #define TXGBE_VF_INIT_TIMEOUT 200 /* Number of retries to clear RSTI */ +#define TXGBE_PCI_MASTER_DISABLE_TIMEOUT 800 #define TXGBE_ALIGN 128 /* as intel did */ diff --git a/drivers/net/txgbe/txgbe_ethdev.c b/drivers/net/txgbe/txgbe_ethdev.c index 170bea9dd0..ce3b50a65d 100644 --- a/drivers/net/txgbe/txgbe_ethdev.c +++ b/drivers/net/txgbe/txgbe_ethdev.c @@ -597,4 +597,5 @@ eth_txgbe_dev_init(struct rte_eth_dev *eth_dev, void *init_params __rte_unused) /* Vendor and Device ID need to be set before init of shared code */ + hw->back = pci_dev; hw->device_id = pci_dev->id.device_id; hw->vendor_id = pci_dev->id.vendor_id; @@ -1674,4 +1675,6 @@ txgbe_dev_start(struct rte_eth_dev *dev) hw->dev_start = true; + txgbe_set_pcie_master(hw, true); + /* configure PF module if SRIOV enabled */ txgbe_pf_host_configure(dev); @@ -1928,4 +1931,6 @@ txgbe_dev_stop(struct rte_eth_dev *dev) wr32m(hw, TXGBE_LEDCTL, 0xFFFFFFFF, TXGBE_LEDCTL_SEL_MASK); + txgbe_set_pcie_master(hw, true); + hw->adapter_stopped = true; dev->data->dev_started = 0; @@ -2010,4 +2015,6 @@ txgbe_dev_close(struct rte_eth_dev *dev) txgbe_dev_free_queues(dev); + txgbe_set_pcie_master(hw, false); + /* reprogram the RAR[0] in case user changed it. */ txgbe_set_rar(hw, 0, hw->mac.addr, 0, true); -- 2.46.0 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2024-08-23 17:18:12.550618472 +0100 +++ 0096-net-txgbe-fix-Tx-hang-on-queue-disable.patch 2024-08-23 17:18:09.813430430 +0100 @@ -1 +1 @@ -From 8a31f4bbbbb73baf77297f00887f4b267feb7b8e Mon Sep 17 00:00:00 2001 +From d298093543513b0f01376628bc7af2c740514f18 Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit 8a31f4bbbbb73baf77297f00887f4b267feb7b8e ] + @@ -17 +18,0 @@ -Cc: stable@dpdk.org @@ -42 +43 @@ -index d19fd0065d..7094551fee 100644 +index 1083431055..2a42f18381 100644 @@ -85 +86 @@ -@@ -1175,4 +1185,36 @@ out: +@@ -1181,4 +1191,36 @@ out: @@ -123 +124 @@ -index 7031589f7c..4bf9da2d4c 100644 +index fd2f7d784c..bf656bb53e 100644 @@ -133 +134 @@ -index 4fce355000..62d16a6abb 100644 +index b62c0b0824..30d671540e 100644 @@ -139 +140 @@ -+#include ++#include @@ -143 +144 @@ -index 79290a7afe..86896d11dc 100644 +index dc22ef53e3..c96bdd984b 100644 @@ -146 +147 @@ -@@ -1237,4 +1237,7 @@ enum txgbe_5tuple_protocol { +@@ -1235,4 +1235,7 @@ enum txgbe_5tuple_protocol { @@ -155 +156 @@ -index 75e839b7de..f52736cae9 100644 +index e7971ccf1d..3b86d8bb8c 100644 @@ -158 +159,2 @@ -@@ -30,4 +30,5 @@ +@@ -29,4 +29,5 @@ + #define TXGBE_FDIRCMD_CMD_POLL 10 @@ -160 +161,0 @@ - #define TXGBE_SPI_TIMEOUT 10000 @@ -165 +166 @@ -index fa68a5d2ca..121dccb5eb 100644 +index 170bea9dd0..ce3b50a65d 100644 @@ -168 +169 @@ -@@ -602,4 +602,5 @@ eth_txgbe_dev_init(struct rte_eth_dev *eth_dev, void *init_params __rte_unused) +@@ -597,4 +597,5 @@ eth_txgbe_dev_init(struct rte_eth_dev *eth_dev, void *init_params __rte_unused) @@ -174 +175 @@ -@@ -1718,4 +1719,6 @@ txgbe_dev_start(struct rte_eth_dev *dev) +@@ -1674,4 +1675,6 @@ txgbe_dev_start(struct rte_eth_dev *dev) @@ -179,3 +180,3 @@ - /* workaround for GPIO intr lost when mng_veto bit is set */ - if (txgbe_check_reset_blocked(hw)) -@@ -1981,4 +1984,6 @@ txgbe_dev_stop(struct rte_eth_dev *dev) + /* configure PF module if SRIOV enabled */ + txgbe_pf_host_configure(dev); +@@ -1928,4 +1931,6 @@ txgbe_dev_stop(struct rte_eth_dev *dev) @@ -188 +189 @@ -@@ -2063,4 +2068,6 @@ txgbe_dev_close(struct rte_eth_dev *dev) +@@ -2010,4 +2015,6 @@ txgbe_dev_close(struct rte_eth_dev *dev)