From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from out4-smtp.messagingengine.com (out4-smtp.messagingengine.com [66.111.4.28]) by dpdk.org (Postfix) with ESMTP id 28CF21B1B9 for ; Wed, 24 Jan 2018 16:40:40 +0100 (CET) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id D0AB3226A6; Wed, 24 Jan 2018 10:40:39 -0500 (EST) Received: from frontend1 ([10.202.2.160]) by compute1.internal (MEProxy); Wed, 24 Jan 2018 10:40:39 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fridaylinux.org; h=cc:date:from:in-reply-to:message-id:references:subject:to :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=JLnhcbVTh1SZB6XLR rEIyMTG6ME26CuQU7vtNbWwZis=; b=ZJMyoEn1Lnsot6VfW4GicyflckObY0nEe 0gV6TcR41u9gOBWjLHzf1Xqf7OgmQjm9Slac3oYNLch85cucSufV1RMcmJio6KHm YWGVUec2rYRaK1P9hopvIsjTm/5f0NBkHVO9AND4ie+EfHCv+Lml/YsVbpqioli6 yozijB7bWnTAk5jmAdYd+T3jSTDoNGuS3nvO8kLLUrBqiuZBjIDaPA6eL9+N5ngi gsfkUb+taKzfw4k90mxPs8M/Cz0WEacKsk61w4ElUatPjqiD0HmK/pyBKpbYY2t3 ax6s4gX35uisaoQ/5mSLfJT0AV3JRblSClsO4vmVoGlEoAWBDcVpQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; bh=JLnhcbVTh1SZB6XLRrEIyMTG6ME26CuQU7vtNbWwZis=; b=dLxThaHn /mtI/Fl29+pIbuVhUXBaJ2B9D/6TyLDX665XmWhV3pLnxVSSBk9QP5M8YnHKrACv gLqLnLCfTqCsRcBNnBZcqLJ3PERDT9nIR/upX4VHfijHkYzl1bBlxQRHt7vlphha NoXpc3rtmvycaNOrwQWV8KMPqbKX9hJs6mp+jF7nqlM4+Qam4bHIvyrbefg2AwHh xzr1n6s5TA19rYVUJkjcSxr7BQFT5u6nE7MQaDjzd0cMXiJVQhlACdWvzSOKxc1J 12+4R5SganHc0K5pKZpIKpKZfv5AKCNZgTxUj91wfNOOnAzK5IFyGsNE0yR1E6ug bIIkZebYrjrNGQ== X-ME-Sender: Received: from localhost.localdomain (unknown [115.150.27.206]) by mail.messagingengine.com (Postfix) with ESMTPA id ABD5D7E1A2; Wed, 24 Jan 2018 10:40:37 -0500 (EST) From: Yuanhan Liu To: Yongseok Koh Cc: Nelio Laranjeiro , dpdk stable Date: Wed, 24 Jan 2018 23:32:55 +0800 Message-Id: <1516808026-25523-107-git-send-email-yliu@fridaylinux.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1516808026-25523-1-git-send-email-yliu@fridaylinux.org> References: <1516808026-25523-1-git-send-email-yliu@fridaylinux.org> Subject: [dpdk-stable] patch 'net/mlx5: fix deadlock of link status alarm' has been queued to LTS release 17.11.1 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: Wed, 24 Jan 2018 15:40:40 -0000 Hi, FYI, your patch has been queued to LTS release 17.11.1 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 01/26/18. So please shout if anyone has objections. Thanks. --yliu --- >>From 1a408b8a82bdddaa33c69a7c890b9b1cfea6d5f2 Mon Sep 17 00:00:00 2001 From: Yongseok Koh Date: Wed, 10 Jan 2018 09:46:49 -0800 Subject: [PATCH] net/mlx5: fix deadlock of link status alarm [ upstream commit 6817ad38718451849b672b0584176c14a8b55b88 ] If mlx5_dev_link_status_handler() is executed while canceling the alarm, deadlock can happen because rte_eal_alarm_cancel() waits for all callbackes to finish execution and both calls are protected by priv->lock. Fixes: 198a3c339a8f ("mlx5: handle link status interrupts") Signed-off-by: Yongseok Koh Acked-by: Nelio Laranjeiro --- drivers/net/mlx5/mlx5.h | 16 ++++++++++++++++ drivers/net/mlx5/mlx5_ethdev.c | 13 +++++++++---- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h index e6a69b8..1a4f444 100644 --- a/drivers/net/mlx5/mlx5.h +++ b/drivers/net/mlx5/mlx5.h @@ -165,6 +165,22 @@ priv_lock(struct priv *priv) } /** + * Try to lock private structure to protect it from concurrent access in the + * control path. + * + * @param priv + * Pointer to private structure. + * + * @return + * 1 if the lock is successfully taken; 0 otherwise. + */ +static inline int +priv_trylock(struct priv *priv) +{ + return rte_spinlock_trylock(&priv->lock); +} + +/** * Unlock private structure. * * @param priv diff --git a/drivers/net/mlx5/mlx5_ethdev.c b/drivers/net/mlx5/mlx5_ethdev.c index b518083..ce0d769 100644 --- a/drivers/net/mlx5/mlx5_ethdev.c +++ b/drivers/net/mlx5/mlx5_ethdev.c @@ -1224,8 +1224,12 @@ mlx5_dev_link_status_handler(void *arg) struct priv *priv = dev->data->dev_private; int ret; - priv_lock(priv); - assert(priv->pending_alarm == 1); + while (!priv_trylock(priv)) { + /* Alarm is being canceled. */ + if (priv->pending_alarm == 0) + return; + rte_pause(); + } priv->pending_alarm = 0; ret = priv_link_status_update(priv); priv_unlock(priv); @@ -1295,9 +1299,10 @@ priv_dev_interrupt_handler_uninstall(struct priv *priv, struct rte_eth_dev *dev) if (priv->primary_socket) rte_intr_callback_unregister(&priv->intr_handle_socket, mlx5_dev_handler_socket, dev); - if (priv->pending_alarm) + if (priv->pending_alarm) { + priv->pending_alarm = 0; rte_eal_alarm_cancel(mlx5_dev_link_status_handler, dev); - priv->pending_alarm = 0; + } priv->intr_handle.fd = 0; priv->intr_handle.type = RTE_INTR_HANDLE_UNKNOWN; priv->intr_handle_socket.fd = 0; -- 2.7.4