From: Phil Yang Date: Fri, 8 May 2020 10:28:27 +0000 (+0800) Subject: net/ixgbe: fix link state timing on fiber ports X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=d70a869db27871db90f86e108fdbb9a22fc6d8c7;p=dpdk.git net/ixgbe: fix link state timing on fiber ports In ixgbe_dev_link_update_share(), if the media type is fiber and the link is down, a flag (IXGBE_FLAG_NEED_LINK_CONFIG) is set. A callback to ixgbe_dev_setup_link_thread_handler() is scheduled which should try to set up the link and clear the flag afterwards. This flag works as a guard variable between threads. To avoid potential race condition between threads, set the IXGBE_FLAG_NEED_LINK_CONFIG flag only when there is no link thread running. Bugzilla ID: 388 Fixes: 819d0d1d57f1 ("net/ixgbe: fix blocking system events") Cc: stable@dpdk.org Signed-off-by: Phil Yang Reviewed-by: Lijian Zhang Acked-by: Xiaolong Ye --- diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c index cf5f1fe709..a4e5c539de 100644 --- a/drivers/net/ixgbe/ixgbe_ethdev.c +++ b/drivers/net/ixgbe/ixgbe_ethdev.c @@ -4281,9 +4281,13 @@ 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; ixgbe_dev_wait_setup_link_complete(dev, 0); if (rte_atomic32_test_and_set(&ad->link_thread_running)) { + /* To avoid race condition between threads, set + * the IXGBE_FLAG_NEED_LINK_CONFIG flag only + * when there is no link thread running. + */ + intr->flags |= IXGBE_FLAG_NEED_LINK_CONFIG; if (rte_ctrl_thread_create(&ad->link_thread_tid, "ixgbe-link-handler", NULL,