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 78D7641E9B; Wed, 15 Mar 2023 09:25:22 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id F0F3E4161A; Wed, 15 Mar 2023 09:25:21 +0100 (CET) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by mails.dpdk.org (Postfix) with ESMTP id 9EA00400EF; Wed, 15 Mar 2023 09:25:19 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1678868719; x=1710404719; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=2DaSDwJMNFRthM+0+AOPu9foU6HZNztEw/qEYj88UZ4=; b=cuDbQAbuPjycr1Ucf2sv8XKrCYgExs0KhM6aN3DNfzrw8eqieid7LF98 Zhb544yzybkqf3dvs3Yo/fQWn3kcojqH+QUqe12jY/tM/Qn/5yKB+cKuW fydZ7aV1nT3joMKFNFBNrS8zI0FpB+sIgzWlnmXdtjmd7Rw68j0A0Umqr MPR7fIBxT7Hcv+gtwmedv2Xtrl9Zrsb2U3M1YDbAi8VsGkawE5shWshZY 776E8B4g/8yRXSkMFjdpZp171d5+t0C9rZtCaYtZ74VNOoGWDTddE/YUc s/Dan4bCAG7uo1uFJPBbuClCJY6LAypCPcUftxBaUMaDUMT8WD9ylz7xD g==; X-IronPort-AV: E=McAfee;i="6500,9779,10649"; a="318038656" X-IronPort-AV: E=Sophos;i="5.98,262,1673942400"; d="scan'208";a="318038656" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Mar 2023 01:25:18 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10649"; a="803181135" X-IronPort-AV: E=Sophos;i="5.98,262,1673942400"; d="scan'208";a="803181135" Received: from unknown (HELO localhost.localdomain) ([10.239.252.253]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Mar 2023 01:25:16 -0700 From: Mingjin Ye To: dev@dpdk.org Cc: qiming.yang@intel.com, stable@dpdk.org, yidingx.zhou@intel.com, Mingjin Ye , Ke Zhang , Qi Zhang Subject: [PATCH v3] net/ice: fix ice dcf control thread crash Date: Wed, 15 Mar 2023 08:20:18 +0000 Message-Id: <20230315082018.4260-1-mingjinx.ye@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230213071648.326123-1-ke1x.zhang@intel.com> References: <20230213071648.326123-1-ke1x.zhang@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org The control thread accesses the hardware resources after the resources were released, resulting in a segment error. This commit fixes the issue by waiting for all `ice-reset` threads to finish before reclaiming resources. Fixes: b71573ec2fc2 ("net/ice: retry getting VF VSI map after failure") Fixes: 7564d5509611 ("net/ice: add DCF hardware initialization") Cc: stable@dpdk.org Signed-off-by: Ke Zhang Signed-off-by: Mingjin Ye --- v2: add pthread_exit() for windows --- V3: Optimization. It is unsafe for a thread to forcibly exit, which will cause the spin lock to not be released correctly --- drivers/net/ice/ice_dcf.c | 15 +++++++++++++-- drivers/net/ice/ice_dcf.h | 2 ++ drivers/net/ice/ice_dcf_parent.c | 1 - 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/drivers/net/ice/ice_dcf.c b/drivers/net/ice/ice_dcf.c index 1c3d22ae0f..b3dea779aa 100644 --- a/drivers/net/ice/ice_dcf.c +++ b/drivers/net/ice/ice_dcf.c @@ -543,6 +543,8 @@ ice_dcf_handle_vsi_update_event(struct ice_dcf_hw *hw) ice_dcf_disable_irq0(hw); for (;;) { + if (hw->vc_event_msg_cb == NULL) + break; if (ice_dcf_get_vf_resource(hw) == 0 && ice_dcf_get_vf_vsi_map(hw) >= 0) { err = 0; @@ -555,8 +557,10 @@ ice_dcf_handle_vsi_update_event(struct ice_dcf_hw *hw) rte_delay_ms(ICE_DCF_ARQ_CHECK_TIME); } - rte_intr_enable(pci_dev->intr_handle); - ice_dcf_enable_irq0(hw); + if (hw->vc_event_msg_cb != NULL) { + rte_intr_enable(pci_dev->intr_handle); + ice_dcf_enable_irq0(hw); + } rte_spinlock_unlock(&hw->vc_cmd_send_lock); @@ -749,6 +753,8 @@ ice_dcf_uninit_hw(struct rte_eth_dev *eth_dev, struct ice_dcf_hw *hw) struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev); struct rte_intr_handle *intr_handle = pci_dev->intr_handle; + hw->vc_event_msg_cb = NULL; + if (hw->vf_res->vf_cap_flags & VIRTCHNL_VF_OFFLOAD_QOS) if (hw->tm_conf.committed) { ice_dcf_clear_bw(hw); @@ -760,6 +766,9 @@ 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); + rte_delay_us(ICE_DCF_VSI_UPDATE_SERVICE_INTERVAL); + rte_spinlock_lock(&hw->vc_cmd_send_lock); + ice_dcf_mode_disable(hw); iavf_shutdown_adminq(&hw->avf); @@ -783,6 +792,8 @@ ice_dcf_uninit_hw(struct rte_eth_dev *eth_dev, struct ice_dcf_hw *hw) rte_free(hw->ets_config); hw->ets_config = NULL; + + rte_spinlock_unlock(&hw->vc_cmd_send_lock); } int diff --git a/drivers/net/ice/ice_dcf.h b/drivers/net/ice/ice_dcf.h index 7f42ebabe9..f9465f60a6 100644 --- a/drivers/net/ice/ice_dcf.h +++ b/drivers/net/ice/ice_dcf.h @@ -15,6 +15,8 @@ #include "base/ice_type.h" #include "ice_logs.h" +#define ICE_DCF_VSI_UPDATE_SERVICE_INTERVAL 100000 /* us */ + /* ICE_DCF_DEV_PRIVATE_TO */ #define ICE_DCF_DEV_PRIVATE_TO_ADAPTER(adapter) \ ((struct ice_dcf_adapter *)adapter) diff --git a/drivers/net/ice/ice_dcf_parent.c b/drivers/net/ice/ice_dcf_parent.c index 01e390ddda..d1b227c431 100644 --- a/drivers/net/ice/ice_dcf_parent.c +++ b/drivers/net/ice/ice_dcf_parent.c @@ -12,7 +12,6 @@ #include "ice_dcf_ethdev.h" #include "ice_generic_flow.h" -#define ICE_DCF_VSI_UPDATE_SERVICE_INTERVAL 100000 /* us */ static rte_spinlock_t vsi_update_lock = RTE_SPINLOCK_INITIALIZER; struct ice_dcf_reset_event_param { -- 2.25.1