From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id 297AABD28 for ; Sun, 29 Jan 2017 10:00:48 +0100 (CET) Received: from Internal Mail-Server by MTLPINE1 (envelope-from shahafs@mellanox.com) with ESMTPS (AES256-SHA encrypted); 29 Jan 2017 11:00:47 +0200 Received: from arch010.mtl.labs.mlnx (arch010.mtl.labs.mlnx [10.7.12.210]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id v0T90lsg019112; Sun, 29 Jan 2017 11:00:47 +0200 Received: from arch010.mtl.labs.mlnx (localhost [127.0.0.1]) by arch010.mtl.labs.mlnx (8.14.7/8.14.7) with ESMTP id v0T8MlJv017778; Sun, 29 Jan 2017 10:22:47 +0200 Received: (from root@localhost) by arch010.mtl.labs.mlnx (8.14.7/8.14.7/Submit) id v0T8MhKv017773; Sun, 29 Jan 2017 10:22:43 +0200 From: Shahaf Shuler To: adrien.mazarguil@6wind.com, nelio.laranjeiro@6wind.com Cc: dev@dpdk.og, stable@dpdk.org Date: Sun, 29 Jan 2017 10:22:43 +0200 Message-Id: <1485678163-17737-1-git-send-email-shahafs@mellanox.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <485348339-43905-1-git-send-email-shahafs@mellanox.com> References: <485348339-43905-1-git-send-email-shahafs@mellanox.com> Subject: [dpdk-stable] [PATCH v2] net/mlx5: fix link status is always inconsist X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Jan 2017 09:00:48 -0000 Query the link status can end up in an inconsist state where the port is down but it is reporting speed. For that another query is scheduled for a later time. A race condition is possible between the scheduled call and other link status interrupt handlers. When the scheduled query by-pass those handlers, the link status will be stuck in an in-consist state. This patch addresses the race condition by not blocking link status queries in case delayed query is on the flight. Fixes: 198a3c339a8f ("mlx5: handle link status interrupts") CC: stable@dpdk.org Signed-off-by: Shahaf Shuler --- on v2: * change the commit log to better explain the race * instead of blocking other interrupt handlers allow everyone to query the link status --- drivers/net/mlx5/mlx5_ethdev.c | 35 ++++++++++++++--------------------- 1 file changed, 14 insertions(+), 21 deletions(-) diff --git a/drivers/net/mlx5/mlx5_ethdev.c b/drivers/net/mlx5/mlx5_ethdev.c index e77238f..6219d64 100644 --- a/drivers/net/mlx5/mlx5_ethdev.c +++ b/drivers/net/mlx5/mlx5_ethdev.c @@ -1128,7 +1128,7 @@ struct priv * priv_dev_link_status_handler(struct priv *priv, struct rte_eth_dev *dev) { struct ibv_async_event event; - int port_change = 0; + struct rte_eth_link *link = &dev->data->dev_link; int ret = 0; /* Read all message and acknowledge them. */ @@ -1136,30 +1136,22 @@ struct priv * if (ibv_get_async_event(priv->ctx, &event)) break; - if (event.event_type == IBV_EVENT_PORT_ACTIVE || - event.event_type == IBV_EVENT_PORT_ERR) - port_change = 1; - else + if (event.event_type != IBV_EVENT_PORT_ACTIVE && + event.event_type != IBV_EVENT_PORT_ERR) DEBUG("event type %d on port %d not handled", event.event_type, event.element.port_num); ibv_ack_async_event(&event); } - - if (port_change ^ priv->pending_alarm) { - struct rte_eth_link *link = &dev->data->dev_link; - - priv->pending_alarm = 0; - mlx5_link_update(dev, 0); - if (((link->link_speed == 0) && link->link_status) || - ((link->link_speed != 0) && !link->link_status)) { - /* Inconsistent status, check again later. */ - priv->pending_alarm = 1; - rte_eal_alarm_set(MLX5_ALARM_TIMEOUT_US, - mlx5_dev_link_status_handler, - dev); - } else - ret = 1; - } + mlx5_link_update(dev, 0); + if (((link->link_speed == 0) && link->link_status) || + ((link->link_speed != 0) && !link->link_status)) { + /* Inconsistent status, check again later. */ + priv->pending_alarm = 1; + rte_eal_alarm_set(MLX5_ALARM_TIMEOUT_US, + mlx5_dev_link_status_handler, + dev); + } else + ret = 1; return ret; } @@ -1178,6 +1170,7 @@ struct priv * priv_lock(priv); assert(priv->pending_alarm == 1); + priv->pending_alarm = 0; ret = priv_dev_link_status_handler(priv, dev); priv_unlock(priv); if (ret) -- 1.8.3.1