Skip to content

Commit

Permalink
vdpa/mlx5: fix configuration mutex cleanup
Browse files Browse the repository at this point in the history
[ upstream commit f00e5a1 ]

When the vDPA device is closed, the driver polling thread is canceled.
The polling thread locks the configuration mutex while it polls the CQs.

When the cancellation happens, it may terminate the thread inside the
critical section what remains the configuration mutex locked.

After device close, the driver may be configured again, in this case,
for example, when the first queue state is updated, the driver tries to
lock the mutex again and deadlock appears.

Initialize the mutex after the polling thread cancellation.

Fixes: 99abbd6 ("vdpa/mlx5: fix queue update synchronization")

Signed-off-by: Matan Azrad <matan@nvidia.com>
Acked-by: Xueming Li <xuemingl@nvidia.com>
Acked-by: Maxime Coquelin <maxime.coquelin@redhat.com>
  • Loading branch information
matan1559 authored and bluca committed Feb 4, 2021
1 parent ae38535 commit 9bf462a
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions drivers/vdpa/mlx5/mlx5_vdpa.c
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,8 @@ mlx5_vdpa_dev_close(int vid)
}
priv->configured = 0;
priv->vid = 0;
/* The mutex may stay locked after event thread cancel - initiate it. */
pthread_mutex_init(&priv->vq_config_lock, NULL);
DRV_LOG(INFO, "vDPA device %d was closed.", vid);
return ret;
}
Expand Down

0 comments on commit 9bf462a

Please sign in to comment.