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 98D7348A44 for ; Fri, 31 Oct 2025 15:38:54 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9275140150; Fri, 31 Oct 2025 15:38:54 +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 49A884067E for ; Fri, 31 Oct 2025 15:38:53 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1761921532; 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=tTaQbMySklupt8+VVQ9u/v9gm/myhkuBjpwPOEoCcKA=; b=bEDESDaJk0EsUqKqMP8KZxPWZUPIE8s5GABERE64cWiv4uHJAFQgSUleu52hoIK3ROzp5u mcOvLrGmMFybwBSC2XMtcPUHAhwDS7u66Nl4fy25Mqi4ZwNV5662wspbK4OlECql7ae+cH pR2GO8fwlR4mveJCSqXCBkGA3qV8BIk= Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-518-J5S4AoV8M4KSDvo5n1jcbg-1; Fri, 31 Oct 2025 10:38:51 -0400 X-MC-Unique: J5S4AoV8M4KSDvo5n1jcbg-1 X-Mimecast-MFC-AGG-ID: J5S4AoV8M4KSDvo5n1jcbg_1761921530 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-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 9276118002C9; Fri, 31 Oct 2025 14:38:50 +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 55361180044F; Fri, 31 Oct 2025 14:38:49 +0000 (UTC) From: Kevin Traynor To: Dengdui Huang Cc: dpdk stable Subject: patch 'net/hns3: fix inconsistent lock' has been queued to stable release 24.11.4 Date: Fri, 31 Oct 2025 14:33:34 +0000 Message-ID: <20251031143421.324432-92-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: PTuIjK97LcQQomOnvPxxg72HXcZ9YiU8PBBQla0bUnc_1761921530 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/bdc2be7156ac4f9a5b07c58d7c138166f28e4395 Thanks. Kevin --- >From bdc2be7156ac4f9a5b07c58d7c138166f28e4395 Mon Sep 17 00:00:00 2001 From: Dengdui Huang Date: Wed, 13 Aug 2025 15:33:15 +0800 Subject: [PATCH] net/hns3: fix inconsistent lock [ upstream commit d441169bd20415691ea86707e7bf852eb6fcda46 ] The hns3 driver supports configuring RSS through both ops API and rte_flow API. The ops API uses spin lock, while the rte_flow API uses pthread mutex. When concurrent calls occur, issues may arise. This patch replaces the lock in the flow API with spin lock. With the pthread mutex no longer needed, the pthread attributes can also be removed. Fixes: 1bdcca8006e4 ("net/hns3: fix flow director lock") Signed-off-by: Dengdui Huang --- drivers/net/hns3/hns3_ethdev.h | 2 -- drivers/net/hns3/hns3_fdir.c | 13 -------- drivers/net/hns3/hns3_flow.c | 60 +++++++++++++--------------------- 3 files changed, 22 insertions(+), 53 deletions(-) diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h index 01d473fd2e..9b8566139b 100644 --- a/drivers/net/hns3/hns3_ethdev.h +++ b/drivers/net/hns3/hns3_ethdev.h @@ -6,5 +6,4 @@ #define HNS3_ETHDEV_H -#include #include #include @@ -681,5 +680,4 @@ struct hns3_hw { struct hns3_port_base_vlan_config port_base_vlan_cfg; - pthread_mutex_t flows_lock; /* rte_flow ops lock */ struct hns3_fdir_rule_list flow_fdir_list; /* flow fdir rule list */ struct hns3_rss_filter_list flow_rss_list; /* flow RSS rule list */ diff --git a/drivers/net/hns3/hns3_fdir.c b/drivers/net/hns3/hns3_fdir.c index aacad40e61..50572ae430 100644 --- a/drivers/net/hns3/hns3_fdir.c +++ b/drivers/net/hns3/hns3_fdir.c @@ -1146,15 +1146,4 @@ int hns3_restore_all_fdir_filter(struct hns3_adapter *hns) return 0; - /* - * This API is called in the reset recovery process, the parent function - * must hold hw->lock. - * There maybe deadlock if acquire hw->flows_lock directly because rte - * flow driver ops first acquire hw->flows_lock and then may acquire - * hw->lock. - * So here first release the hw->lock and then acquire the - * hw->flows_lock to avoid deadlock. - */ - rte_spinlock_unlock(&hw->lock); - pthread_mutex_lock(&hw->flows_lock); TAILQ_FOREACH(fdir_filter, &fdir_info->fdir_list, entries) { ret = hns3_config_action(hw, &fdir_filter->fdir_conf); @@ -1167,6 +1156,4 @@ int hns3_restore_all_fdir_filter(struct hns3_adapter *hns) } } - pthread_mutex_unlock(&hw->flows_lock); - rte_spinlock_lock(&hw->lock); if (err) { diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c index c0238d2bfa..f2d1e4ec3a 100644 --- a/drivers/net/hns3/hns3_flow.c +++ b/drivers/net/hns3/hns3_flow.c @@ -2211,16 +2211,4 @@ hns3_reconfig_all_rss_filter(struct hns3_hw *hw) } -static int -hns3_restore_rss_filter(struct hns3_hw *hw) -{ - int ret; - - pthread_mutex_lock(&hw->flows_lock); - ret = hns3_reconfig_all_rss_filter(hw); - pthread_mutex_unlock(&hw->flows_lock); - - return ret; -} - int hns3_restore_filter(struct hns3_adapter *hns) @@ -2233,5 +2221,5 @@ hns3_restore_filter(struct hns3_adapter *hns) return ret; - return hns3_restore_rss_filter(hw); + return hns3_reconfig_all_rss_filter(hw); } @@ -2625,8 +2613,8 @@ hns3_flow_validate_wrap(struct rte_eth_dev *dev, int ret; - pthread_mutex_lock(&hw->flows_lock); + rte_spinlock_lock(&hw->lock); ret = hns3_flow_validate(dev, attr, pattern, actions, error, &filter_info); - pthread_mutex_unlock(&hw->flows_lock); + rte_spinlock_unlock(&hw->lock); return ret; @@ -2642,7 +2630,7 @@ hns3_flow_create_wrap(struct rte_eth_dev *dev, const struct rte_flow_attr *attr, struct rte_flow *flow; - pthread_mutex_lock(&hw->flows_lock); + rte_spinlock_lock(&hw->lock); flow = hns3_flow_create(dev, attr, pattern, actions, error); - pthread_mutex_unlock(&hw->flows_lock); + rte_spinlock_unlock(&hw->lock); return flow; @@ -2656,7 +2644,7 @@ hns3_flow_destroy_wrap(struct rte_eth_dev *dev, struct rte_flow *flow, int ret; - pthread_mutex_lock(&hw->flows_lock); + rte_spinlock_lock(&hw->lock); ret = hns3_flow_destroy(dev, flow, error); - pthread_mutex_unlock(&hw->flows_lock); + rte_spinlock_unlock(&hw->lock); return ret; @@ -2669,7 +2657,7 @@ hns3_flow_flush_wrap(struct rte_eth_dev *dev, struct rte_flow_error *error) int ret; - pthread_mutex_lock(&hw->flows_lock); + rte_spinlock_lock(&hw->lock); ret = hns3_flow_flush(dev, error); - pthread_mutex_unlock(&hw->flows_lock); + rte_spinlock_unlock(&hw->lock); return ret; @@ -2684,7 +2672,7 @@ hns3_flow_query_wrap(struct rte_eth_dev *dev, struct rte_flow *flow, int ret; - pthread_mutex_lock(&hw->flows_lock); + rte_spinlock_lock(&hw->lock); ret = hns3_flow_query(dev, flow, actions, data, error); - pthread_mutex_unlock(&hw->flows_lock); + rte_spinlock_unlock(&hw->lock); return ret; @@ -2734,5 +2722,5 @@ hns3_flow_action_create(struct rte_eth_dev *dev, return NULL; - pthread_mutex_lock(&hw->flows_lock); + rte_spinlock_lock(&hw->lock); act_count = (const struct rte_flow_action_count *)action->conf; @@ -2759,9 +2747,9 @@ hns3_flow_action_create(struct rte_eth_dev *dev, handle.counter_id = counter->id; - pthread_mutex_unlock(&hw->flows_lock); + rte_spinlock_unlock(&hw->lock); return (struct rte_flow_action_handle *)handle.val64; err_exit: - pthread_mutex_unlock(&hw->flows_lock); + rte_spinlock_unlock(&hw->lock); return NULL; } @@ -2776,9 +2764,9 @@ hns3_flow_action_destroy(struct rte_eth_dev *dev, struct hns3_flow_counter *counter; - pthread_mutex_lock(&hw->flows_lock); + rte_spinlock_lock(&hw->lock); indir.val64 = (uint64_t)handle; if (indir.indirect_type != HNS3_INDIRECT_ACTION_TYPE_COUNT) { - pthread_mutex_unlock(&hw->flows_lock); + rte_spinlock_unlock(&hw->lock); return rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION_CONF, @@ -2788,5 +2776,5 @@ hns3_flow_action_destroy(struct rte_eth_dev *dev, counter = hns3_counter_lookup(dev, indir.counter_id); if (counter == NULL) { - pthread_mutex_unlock(&hw->flows_lock); + rte_spinlock_unlock(&hw->lock); return rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION_CONF, @@ -2795,5 +2783,5 @@ hns3_flow_action_destroy(struct rte_eth_dev *dev, if (counter->ref_cnt > 1) { - pthread_mutex_unlock(&hw->flows_lock); + rte_spinlock_unlock(&hw->lock); return rte_flow_error_set(error, EBUSY, RTE_FLOW_ERROR_TYPE_HANDLE, @@ -2803,5 +2791,5 @@ hns3_flow_action_destroy(struct rte_eth_dev *dev, (void)hns3_counter_release(dev, indir.counter_id); - pthread_mutex_unlock(&hw->flows_lock); + rte_spinlock_unlock(&hw->lock); return 0; } @@ -2818,9 +2806,9 @@ hns3_flow_action_query(struct rte_eth_dev *dev, int ret; - pthread_mutex_lock(&hw->flows_lock); + rte_spinlock_lock(&hw->lock); indir.val64 = (uint64_t)handle; if (indir.indirect_type != HNS3_INDIRECT_ACTION_TYPE_COUNT) { - pthread_mutex_unlock(&hw->flows_lock); + rte_spinlock_unlock(&hw->lock); return rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION_CONF, @@ -2832,5 +2820,5 @@ hns3_flow_action_query(struct rte_eth_dev *dev, ret = hns3_counter_query(dev, &flow, (struct rte_flow_query_count *)data, error); - pthread_mutex_unlock(&hw->flows_lock); + rte_spinlock_unlock(&hw->lock); return ret; } @@ -2866,12 +2854,8 @@ hns3_flow_init(struct rte_eth_dev *dev) { struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); - pthread_mutexattr_t attr; if (rte_eal_process_type() != RTE_PROC_PRIMARY) return; - pthread_mutexattr_init(&attr); - pthread_mutexattr_setpshared(&attr, PTHREAD_PROCESS_SHARED); - pthread_mutex_init(&hw->flows_lock, &attr); dev->data->dev_flags |= RTE_ETH_DEV_FLOW_OPS_THREAD_SAFE; -- 2.51.0 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2025-10-31 13:53:55.051343982 +0000 +++ 0092-net-hns3-fix-inconsistent-lock.patch 2025-10-31 13:53:52.266524086 +0000 @@ -1 +1 @@ -From d441169bd20415691ea86707e7bf852eb6fcda46 Mon Sep 17 00:00:00 2001 +From bdc2be7156ac4f9a5b07c58d7c138166f28e4395 Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit d441169bd20415691ea86707e7bf852eb6fcda46 ] + @@ -15 +16,0 @@ -Cc: stable@dpdk.org @@ -25 +26 @@ -index d602bfa02f..f6bb1b5d43 100644 +index 01d473fd2e..9b8566139b 100644 @@ -34 +35 @@ -@@ -680,5 +679,4 @@ struct hns3_hw { +@@ -681,5 +680,4 @@ struct hns3_hw {