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 66D6A42CBC for ; Thu, 15 Jun 2023 03:36:02 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6080C42D5C; Thu, 15 Jun 2023 03:36:02 +0200 (CEST) Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) by mails.dpdk.org (Postfix) with ESMTP id CF97642D4B for ; Thu, 15 Jun 2023 03:36:00 +0200 (CEST) Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-3f8d0d68530so14717845e9.0 for ; Wed, 14 Jun 2023 18:36:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1686792960; x=1689384960; 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=EaVw2BAiJIiXj9uEmTt9/mchZ0wFMsd/rQCmHSZOpXg=; b=R5LGMmRg4yfVs1ddw68gtfVcxqGN96i9d0Am0LRtguAZhtcMt1uo6Zzb8+6nVWXJd8 9joDN0pIdOZy1Q+BfJNJlQIg3zrURdPgkjtPXrZy0KF3jkm/aeEud22eWt79fN7WU+RQ PrSfnU5mBDrtR3+6/LT2YK249dwS6PEo3FtnPqWL7fSOZdHCiQCHrWuJVfu6Ef2WbRyU 5rGkFTeMkFZXkU8GSU+ZOgGCblGfHzJOYuYuMbKOZ/ZLREY3Zdx4ynk6Eeq4SEstbkmw uCwJ9ZhIhP0eto3a2QsuXoRb/1641N6S5lTYcPGaCYhfE2XWrpO+KrxSEWofgW1IkWb9 bAvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686792960; x=1689384960; 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=EaVw2BAiJIiXj9uEmTt9/mchZ0wFMsd/rQCmHSZOpXg=; b=DOi5qyC1SChrtan7hVP1655ediBkC8b0NNiMWpqcvbqN1I1z5JjkWRWBvuFP2cWCwW hOuhVIOAhskPLsZ6CI5sok7VJ7E+CwFRf6K3RGm02Vy5kDPmv2zPn4dFeaFvkqsEFHtg B72H/YmeAt0G+A5z9xxeQgrkiWQ2fgJcsSPKQ9AEat3pGs9EB5vcV4Za2u/OGLMwCfaP c0RB9tss8/GFf34foRk8Q2W/8eN3uYb7nYA9xOP1l62LkkkUdj1OIG2JPEdbZtsrLkx3 /LGnu89IT4FWWrXGPwKTMBBhdsubKWcz0xTXm0kGSSzJ+UyRl0F1f09MrFGHEoAHYSEx t7hg== X-Gm-Message-State: AC+VfDy6+iMrwNJ+lvsN2lwVDylqcvyTKrIJCGnEmVAc4z9Xu1Un4zcB mg/IXX51jkZ6rdbclXJ3YAAlNOaQ+euzEtoC X-Google-Smtp-Source: ACHHUZ4iaOTUxWG9VNHp697Rc4sOMqybhpJ5hZvYogkgsz1B9nxLkWQpe6B1uPmXSPkXQaRcaLd+QQ== X-Received: by 2002:a5d:4ac8:0:b0:30e:2ff3:8c88 with SMTP id y8-20020a5d4ac8000000b0030e2ff38c88mr10435369wrs.35.1686792960508; Wed, 14 Jun 2023 18:36:00 -0700 (PDT) Received: from localhost ([2a01:4b00:d307:1000:f1d3:eb5e:11f4:a7d9]) by smtp.gmail.com with ESMTPSA id p19-20020a05600c469300b003f7f475c3bcsm1126950wmo.1.2023.06.14.18.35.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Jun 2023 18:36:00 -0700 (PDT) From: luca.boccassi@gmail.com 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 20.11.9 Date: Thu, 15 Jun 2023 02:32:52 +0100 Message-Id: <20230615013258.1439718-57-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230615013258.1439718-1-luca.boccassi@gmail.com> References: <20230615013258.1439718-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 20.11.9 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 06/17/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/bluca/dpdk-stable This queued commit can be viewed at: https://github.com/bluca/dpdk-stable/commit/86d4ff26c435878ba4b52a1e90d1cd3298689ad0 Thanks. Luca Boccassi --- >From 86d4ff26c435878ba4b52a1e90d1cd3298689ad0 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 269d61f414..b77097682e 100644 --- a/drivers/net/ice/ice_dcf.c +++ b/drivers/net/ice/ice_dcf.c @@ -32,6 +32,8 @@ #define ICE_DCF_ARQ_MAX_RETRIES 200 #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) + \ IAVF_MAX_VF_VSI * sizeof(struct virtchnl_vsi_resource)) @@ -609,6 +611,8 @@ ice_dcf_init_hw(struct rte_eth_dev *eth_dev, struct ice_dcf_hw *hw) rte_spinlock_init(&hw->vc_cmd_queue_lock); 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) { PMD_INIT_LOG(ERR, "unable to allocate AdminQ buffer memory"); @@ -710,6 +714,11 @@ ice_dcf_uninit_hw(struct rte_eth_dev *eth_dev, struct ice_dcf_hw *hw) rte_intr_callback_unregister(intr_handle, 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 ff029963bf..6c594754ff 100644 --- a/drivers/net/ice/ice_dcf.h +++ b/drivers/net/ice/ice_dcf.h @@ -39,6 +39,8 @@ struct ice_dcf_hw { void (*vc_event_msg_cb)(struct ice_dcf_hw *dcf_hw, uint8_t *msg, uint16_t msglen); + int vsi_update_thread_num; + uint8_t *arq_buf; uint16_t num_vfs; diff --git a/drivers/net/ice/ice_dcf_parent.c b/drivers/net/ice/ice_dcf_parent.c index c7c1111a67..8456c48a91 100644 --- a/drivers/net/ice/ice_dcf_parent.c +++ b/drivers/net/ice/ice_dcf_parent.c @@ -115,6 +115,9 @@ ice_dcf_vsi_update_service_handler(void *param) container_of(hw, struct ice_dcf_adapter, real_hw); struct ice_adapter *parent_adapter = &adapter->parent; + __atomic_fetch_add(&hw->vsi_update_thread_num, 1, + __ATOMIC_RELAXED); + pthread_detach(pthread_self()); usleep(ICE_DCF_VSI_UPDATE_SERVICE_INTERVAL); @@ -133,6 +136,9 @@ ice_dcf_vsi_update_service_handler(void *param) rte_spinlock_unlock(&vsi_update_lock); + __atomic_fetch_sub(&hw->vsi_update_thread_num, 1, + __ATOMIC_RELEASE); + return NULL; } -- 2.39.2 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2023-06-15 01:56:37.568287886 +0100 +++ 0057-net-ice-fix-DCF-control-thread-crash.patch 2023-06-15 01:56:34.711544450 +0100 @@ -1 +1 @@ -From 6b7621cea2d9470df076c3559a2fa6ee9752f419 Mon Sep 17 00:00:00 2001 +From 86d4ff26c435878ba4b52a1e90d1cd3298689ad0 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 269d61f414..b77097682e 100644 @@ -37 +38 @@ -@@ -31,6 +31,8 @@ +@@ -32,6 +32,8 @@ @@ -46 +47 @@ -@@ -638,6 +640,8 @@ ice_dcf_init_hw(struct rte_eth_dev *eth_dev, struct ice_dcf_hw *hw) +@@ -609,6 +611,8 @@ ice_dcf_init_hw(struct rte_eth_dev *eth_dev, struct ice_dcf_hw *hw) @@ -55 +56 @@ -@@ -759,6 +763,11 @@ ice_dcf_uninit_hw(struct rte_eth_dev *eth_dev, struct ice_dcf_hw *hw) +@@ -710,6 +714,11 @@ ice_dcf_uninit_hw(struct rte_eth_dev *eth_dev, struct ice_dcf_hw *hw) @@ -68 +69 @@ -index 7f42ebabe9..7becf6d187 100644 +index ff029963bf..6c594754ff 100644 @@ -71 +72 @@ -@@ -105,6 +105,8 @@ struct ice_dcf_hw { +@@ -39,6 +39,8 @@ struct ice_dcf_hw { @@ -81 +82 @@ -index 3175d18b5b..d62837840d 100644 +index c7c1111a67..8456c48a91 100644 @@ -84 +85 @@ -@@ -123,6 +123,9 @@ ice_dcf_vsi_update_service_handler(void *param) +@@ -115,6 +115,9 @@ ice_dcf_vsi_update_service_handler(void *param) @@ -91 +92,2 @@ - rte_thread_detach(rte_thread_self()); + pthread_detach(pthread_self()); + usleep(ICE_DCF_VSI_UPDATE_SERVICE_INTERVAL); @@ -93,2 +95 @@ - rte_delay_us(ICE_DCF_VSI_UPDATE_SERVICE_INTERVAL); -@@ -153,6 +156,9 @@ ice_dcf_vsi_update_service_handler(void *param) +@@ -133,6 +136,9 @@ ice_dcf_vsi_update_service_handler(void *param) @@ -96 +97 @@ - free(param); + rte_spinlock_unlock(&vsi_update_lock); @@ -101 +102 @@ - return 0; + return NULL;