summaryrefslogtreecommitdiff
path: root/drivers/net/mlx5/mlx5_ethdev.c
diff options
context:
space:
mode:
authorYongseok Koh <yskoh@mellanox.com>2018-01-10 09:46:49 -0800
committerFerruh Yigit <ferruh.yigit@intel.com>2018-01-16 18:47:49 +0100
commit6817ad38718451849b672b0584176c14a8b55b88 (patch)
treecdb368c95adea0e6dbafa6f4090869ab1826957e /drivers/net/mlx5/mlx5_ethdev.c
parentdd18b06a32833543c6951b6206ac39896eaac154 (diff)
downloaddpdk-6817ad38718451849b672b0584176c14a8b55b88.zip
dpdk-6817ad38718451849b672b0584176c14a8b55b88.tar.gz
dpdk-6817ad38718451849b672b0584176c14a8b55b88.tar.xz
net/mlx5: fix deadlock of link status alarm
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") Cc: stable@dpdk.org Signed-off-by: Yongseok Koh <yskoh@mellanox.com> Acked-by: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>
Diffstat (limited to 'drivers/net/mlx5/mlx5_ethdev.c')
-rw-r--r--drivers/net/mlx5/mlx5_ethdev.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/drivers/net/mlx5/mlx5_ethdev.c b/drivers/net/mlx5/mlx5_ethdev.c
index 79a0248..6f78adc 100644
--- a/drivers/net/mlx5/mlx5_ethdev.c
+++ b/drivers/net/mlx5/mlx5_ethdev.c
@@ -1187,8 +1187,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);
@@ -1255,9 +1259,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;