From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id D2024A0562; Sun, 29 Mar 2020 06:17:56 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 2611D1BF99; Sun, 29 Mar 2020 06:17:56 +0200 (CEST) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by dpdk.org (Postfix) with ESMTP id 9FC621B75C; Sun, 29 Mar 2020 06:17:53 +0200 (CEST) IronPort-SDR: d3aIoTVQhgQdRUY/7BidtvNNC6P7D0pQPT5+Te4T5HLQgJGfRFJpbuRa4QHi0feBntrH6PgJBk wUTrY2iggnPg== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Mar 2020 21:17:52 -0700 IronPort-SDR: +5QpntdVLVRFy7fz1MPkqlJmAtO/0YL8UJg1YAtKsEMAdOyiNWhcnjvMuEsV3be44OIbxf9GdO kT6YRNSw23ew== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,318,1580803200"; d="scan'208";a="447875369" Received: from yexl-server.sh.intel.com (HELO localhost) ([10.67.117.17]) by fmsmga005.fm.intel.com with ESMTP; 28 Mar 2020 21:17:50 -0700 Date: Sun, 29 Mar 2020 12:14:32 +0800 From: Ye Xiaolong To: taox.zhu@intel.com Cc: konstantin.ananyev@intel.com, wenzhuo.lu@intel.com, dev@dpdk.org, stable@dpdk.org Message-ID: <20200329041432.GD29805@intel.com> References: <20200226120637.13109-1-taox.zhu@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200226120637.13109-1-taox.zhu@intel.com> User-Agent: Mutt/1.9.4 (2018-02-28) Subject: Re: [dpdk-dev] [PATCH] net/ixgbe: fix link status inconsistencies X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On 02/26, taox.zhu@intel.com wrote: >From: Zhu Tao > >Setting LINK UP or LINK DOWN is divided into two parts, with >the main task done in a separate thread, which can take up >to 9 seconds. If cancel the thread in execution, may cause state >inconsistencies. Therefore, must wait for the previous setting >to exit normally before setting the new state. > >Note: before using threads, use alarm to handle main tasks. >When canceling alarm, the execution of alarm will not be interrupted. > >Fixes: 819d0d1d57 ("net/ixgbe: fix blocking system events") >Cc: stable@dpdk.org > >Signed-off-by: Zhu Tao >--- > drivers/net/ixgbe/ixgbe_ethdev.c | 24 ++++++++++++++++++++++-- > 1 file changed, 22 insertions(+), 2 deletions(-) > >diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c >index 23b3f5b0c..2c5797635 100644 >--- a/drivers/net/ixgbe/ixgbe_ethdev.c >+++ b/drivers/net/ixgbe/ixgbe_ethdev.c >@@ -4143,16 +4143,35 @@ ixgbevf_check_link(struct ixgbe_hw *hw, ixgbe_link_speed *speed, > return ret_val; > } > >+/* return 1: setup complete, return 0: setup not complete, and wait timeout*/ >+static int >+ixgbe_dev_wait_setup_link_complete(struct rte_eth_dev *dev) >+{ >+#define DELAY_INTERVAL 100 /* 100ms */ >+#define MAX_TIMEOUT 90 /* 9s (90 * 100ms) in total */ >+ struct ixgbe_adapter *ad = dev->data->dev_private; >+ int timeout = MAX_TIMEOUT; >+ >+ while (rte_atomic32_read(&ad->link_thread_running) && timeout) { >+ msec_delay(DELAY_INTERVAL); >+ timeout--; >+ } >+ >+ >+ return !!timeout; >+} >+ > static void > ixgbe_dev_cancel_link_thread(struct rte_eth_dev *dev) > { > struct ixgbe_adapter *ad = dev->data->dev_private; > void *retval; > >- if (rte_atomic32_read(&ad->link_thread_running)) { >+ if (!ixgbe_dev_wait_setup_link_complete(dev)) { > pthread_cancel(ad->link_thread_tid); > pthread_join(ad->link_thread_tid, &retval); > rte_atomic32_clear(&ad->link_thread_running); >+ PMD_DRV_LOG(ERR, "Link thread not complete, cancel it!"); > } > } > >@@ -4263,7 +4282,8 @@ ixgbe_dev_link_update_share(struct rte_eth_dev *dev, > if (link_up == 0) { > if (ixgbe_get_media_type(hw) == ixgbe_media_type_fiber) { > intr->flags |= IXGBE_FLAG_NEED_LINK_CONFIG; >- if (rte_atomic32_test_and_set(&ad->link_thread_running)) { >+ if (ixgbe_dev_wait_setup_link_complete(dev) && >+ rte_atomic32_test_and_set(&ad->link_thread_running)) { > if (rte_ctrl_thread_create(&ad->link_thread_tid, > "ixgbe-link-handler", > NULL, >-- >2.17.1 > Acked-by: Xiaolong Ye Applied to dpdk-next-net-intel, Thanks.