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 69C0A42ECF for ; Thu, 20 Jul 2023 17:30:33 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 64FA340685; Thu, 20 Jul 2023 17:30:33 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mails.dpdk.org (Postfix) with ESMTP id 12101400D6 for ; Thu, 20 Jul 2023 17:30:31 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689867031; 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=p02iV1qfJMdPHT++ZEbjM5BWR3yjQBYLNPioetQref0=; b=Z2PEd5aDHsH83MqTpV36K1qSu4jcNhOD4Yy7gqbi65SSniB0eFVN1cAODuw6SJROgdQxvE HU5AIJqLhNPIXhE/mIwp/AV6iq+GlaCi/5ibyUV4MG/pF+Z1W9zj5dd/tQNeJYmXwYJKlU R/RC2LrEe0pxPYlhSMAp3X38gVoI7GA= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-659-pBUGZ85ZP9SD9wqyGAxVAw-1; Thu, 20 Jul 2023 11:22:08 -0400 X-MC-Unique: pBUGZ85ZP9SD9wqyGAxVAw-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C247A1064AFE; Thu, 20 Jul 2023 15:21:48 +0000 (UTC) Received: from rh.redhat.com (unknown [10.39.192.15]) by smtp.corp.redhat.com (Postfix) with ESMTP id 80FDF4CD0E3; Thu, 20 Jul 2023 15:21:47 +0000 (UTC) From: Kevin Traynor To: Mingjin Ye Cc: Ke Zhang , Qi Zhang , dpdk stable Subject: patch 'net/ice: fix DCF control thread crash' has been queued to stable release 21.11.5 Date: Thu, 20 Jul 2023 16:18:22 +0100 Message-ID: <20230720151942.262154-71-ktraynor@redhat.com> In-Reply-To: <20230720151942.262154-1-ktraynor@redhat.com> References: <20230720151942.262154-1-ktraynor@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 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.5 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/25/23. 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/cdd62beeb247245ce953355d4aa850ea45493a57 Thanks. Kevin --- >From cdd62beeb247245ce953355d4aa850ea45493a57 Mon Sep 17 00:00:00 2001 From: Mingjin Ye Date: Tue, 11 Apr 2023 02:08:55 +0000 Subject: [PATCH] net/ice: fix DCF control thread crash [ upstream commit 6b7621cea2d9470df076c3559a2fa6ee9752f419 ] The control thread accesses the hardware resources after the resources were released, which results in a segment error. The 'ice-reset' threads are detached, so thread resources cannot be reclaimed by `pthread_join` calls. This commit synchronizes the number of "ice-reset" threads by adding a variable ("vsi_update_thread_num") to the "struct ice_dcf_hw" and performing an atomic operation on this variable. When releasing HW resources, we wait for the number of "ice-reset" threads to be reduced to 0 before releasing the resources. Fixes: c7e1a1a3bfeb ("net/ice: refactor DCF VLAN handling") Fixes: 3b3757bda3c3 ("net/ice: get VF hardware index in DCF") Fixes: 7564d5509611 ("net/ice: add DCF hardware initialization") Fixes: 0b02c9519432 ("net/ice: handle PF initialization by DCF") Signed-off-by: Ke Zhang Signed-off-by: Mingjin Ye Acked-by: Qi Zhang --- drivers/net/ice/ice_dcf.c | 9 +++++++++ drivers/net/ice/ice_dcf.h | 2 ++ drivers/net/ice/ice_dcf_parent.c | 6 ++++++ 3 files changed, 17 insertions(+) diff --git a/drivers/net/ice/ice_dcf.c b/drivers/net/ice/ice_dcf.c index 5cd53c6c0b..ad4bfa4b11 100644 --- a/drivers/net/ice/ice_dcf.c +++ b/drivers/net/ice/ice_dcf.c @@ -33,4 +33,6 @@ #define ICE_DCF_ARQ_CHECK_TIME 2 /* msecs */ +#define ICE_DCF_CHECK_INTERVAL 100 /* 100ms */ + #define ICE_DCF_VF_RES_BUF_SZ \ (sizeof(struct virtchnl_vf_resource) + \ @@ -617,4 +619,6 @@ ice_dcf_init_hw(struct rte_eth_dev *eth_dev, struct ice_dcf_hw *hw) TAILQ_INIT(&hw->vc_cmd_queue); + __atomic_store_n(&hw->vsi_update_thread_num, 0, __ATOMIC_RELAXED); + hw->arq_buf = rte_zmalloc("arq_buf", ICE_DCF_AQ_BUF_SZ, 0); if (hw->arq_buf == NULL) { @@ -734,4 +738,9 @@ ice_dcf_uninit_hw(struct rte_eth_dev *eth_dev, struct ice_dcf_hw *hw) ice_dcf_dev_interrupt_handler, hw); + /* Wait for all `ice-thread` threads to exit. */ + while (__atomic_load_n(&hw->vsi_update_thread_num, + __ATOMIC_ACQUIRE) != 0) + rte_delay_ms(ICE_DCF_CHECK_INTERVAL); + ice_dcf_mode_disable(hw); iavf_shutdown_adminq(&hw->avf); diff --git a/drivers/net/ice/ice_dcf.h b/drivers/net/ice/ice_dcf.h index 6ec766ebda..84b8232b2a 100644 --- a/drivers/net/ice/ice_dcf.h +++ b/drivers/net/ice/ice_dcf.h @@ -84,4 +84,6 @@ struct ice_dcf_hw { uint8_t *msg, uint16_t msglen); + int vsi_update_thread_num; + uint8_t *arq_buf; diff --git a/drivers/net/ice/ice_dcf_parent.c b/drivers/net/ice/ice_dcf_parent.c index 2f96dedcce..ec01f28a51 100644 --- a/drivers/net/ice/ice_dcf_parent.c +++ b/drivers/net/ice/ice_dcf_parent.c @@ -124,4 +124,7 @@ ice_dcf_vsi_update_service_handler(void *param) struct ice_adapter *parent_adapter = &adapter->parent; + __atomic_fetch_add(&hw->vsi_update_thread_num, 1, + __ATOMIC_RELAXED); + pthread_detach(pthread_self()); @@ -154,4 +157,7 @@ ice_dcf_vsi_update_service_handler(void *param) free(param); + __atomic_fetch_sub(&hw->vsi_update_thread_num, 1, + __ATOMIC_RELEASE); + return NULL; } -- 2.41.0 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2023-07-20 16:18:03.509976643 +0100 +++ 0071-net-ice-fix-DCF-control-thread-crash.patch 2023-07-20 16:17:54.881751406 +0100 @@ -1 +1 @@ -From 6b7621cea2d9470df076c3559a2fa6ee9752f419 Mon Sep 17 00:00:00 2001 +From cdd62beeb247245ce953355d4aa850ea45493a57 Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit 6b7621cea2d9470df076c3559a2fa6ee9752f419 ] + @@ -22 +23,0 @@ -Cc: stable@dpdk.org @@ -34 +35 @@ -index b11d66f45f..c37b56b0d3 100644 +index 5cd53c6c0b..ad4bfa4b11 100644 @@ -37 +38 @@ -@@ -32,4 +32,6 @@ +@@ -33,4 +33,6 @@ @@ -44 +45 @@ -@@ -639,4 +641,6 @@ ice_dcf_init_hw(struct rte_eth_dev *eth_dev, struct ice_dcf_hw *hw) +@@ -617,4 +619,6 @@ ice_dcf_init_hw(struct rte_eth_dev *eth_dev, struct ice_dcf_hw *hw) @@ -51 +52 @@ -@@ -760,4 +764,9 @@ ice_dcf_uninit_hw(struct rte_eth_dev *eth_dev, struct ice_dcf_hw *hw) +@@ -734,4 +738,9 @@ ice_dcf_uninit_hw(struct rte_eth_dev *eth_dev, struct ice_dcf_hw *hw) @@ -62 +63 @@ -index 7f42ebabe9..7becf6d187 100644 +index 6ec766ebda..84b8232b2a 100644 @@ -65 +66 @@ -@@ -106,4 +106,6 @@ struct ice_dcf_hw { +@@ -84,4 +84,6 @@ struct ice_dcf_hw { @@ -73 +74 @@ -index 3175d18b5b..d62837840d 100644 +index 2f96dedcce..ec01f28a51 100644 @@ -82 +83 @@ - rte_thread_detach(rte_thread_self()); + pthread_detach(pthread_self()); @@ -90 +91 @@ - return 0; + return NULL;