From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by dpdk.org (Postfix) with ESMTP id 9B9802C24 for ; Tue, 21 Feb 2017 08:29:45 +0100 (CET) Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga104.jf.intel.com with ESMTP; 20 Feb 2017 23:29:44 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.35,188,1484035200"; d="scan'208";a="68256428" Received: from yliu-dev.sh.intel.com (HELO yliu-dev) ([10.239.67.162]) by fmsmga006.fm.intel.com with ESMTP; 20 Feb 2017 23:29:42 -0800 Date: Tue, 21 Feb 2017 15:31:57 +0800 From: Yuanhan Liu To: shahafs Cc: stable@dpdk.org Message-ID: <20170221073157.GG18844@yliu-dev.sh.intel.com> References: <1487661809-33942-1-git-send-email-shahafs@mellanox.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1487661809-33942-1-git-send-email-shahafs@mellanox.com> User-Agent: Mutt/1.5.23 (2014-03-12) Subject: Re: [dpdk-stable] [PATCH] net/mlx5: fix inconsistent link status 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: Tue, 21 Feb 2017 07:29:46 -0000 On Tue, Feb 21, 2017 at 09:23:29AM +0200, shahafs wrote: > From: Shahaf Shuler > > [ backported from upstream commit a9f2fbc42f0c58df614896a407fd694899315233 ] Applied to dpdk-stable/16.11. Thanks for the backport. --yliu > > Querying the link status can end up being in an inconsistent state, > like the port is reporting speed although it is down. > > For this case another query is scheduled. > > A race condition can occur between the scheduled query and link > status interrupt handlers. > > When the scheduled query by-pass interrupt handlers, the link status > will be stuck in an inconsistent state. > > This patch addresses the race condition by not blocking link status > queries in case delayed query is used. > > Fixes: 198a3c339a8f ("mlx5: handle link status interrupts") > Cc: stable@dpdk.org > > Signed-off-by: Shahaf Shuler > Acked-by: Nelio Laranjeiro > --- > drivers/net/mlx5/mlx5_ethdev.c | 26 +++++++++++--------------- > 1 file changed, 11 insertions(+), 15 deletions(-) > > diff --git a/drivers/net/mlx5/mlx5_ethdev.c b/drivers/net/mlx5/mlx5_ethdev.c > index a709a3a..06cfd01 100644 > --- a/drivers/net/mlx5/mlx5_ethdev.c > +++ b/drivers/net/mlx5/mlx5_ethdev.c > @@ -1183,7 +1183,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. */ > @@ -1191,29 +1191,24 @@ 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_unlocked(dev, 0); > - if (((link->link_speed == 0) && link->link_status) || > - ((link->link_speed != 0) && !link->link_status)) { > + mlx5_link_update(dev, 0); > + if (((link->link_speed == 0) && link->link_status) || > + ((link->link_speed != 0) && !link->link_status)) { > + if (!priv->pending_alarm) { > /* 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; > + } > + } else { > + ret = 1; > } > return ret; > } > @@ -1233,6 +1228,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