Commit 3c461911 authored by Moshe Lazer's avatar Moshe Lazer Committed by Roland Dreier

IB/mlx5: Flush cache workqueue before destroying it

Destroying the workqueue without flushing it first can lead to a case
in which the kernel tries to push a delayed work to the workqueue
which does not exist anymore.
Signed-off-by: default avatarMoshe Lazer <moshel@mellanox.com>
Signed-off-by: default avatarEli Cohen <eli@mellanox.com>
Signed-off-by: default avatarRoland Dreier <roland@purestorage.com>
parent b125a54b
...@@ -415,6 +415,7 @@ static void clean_keys(struct mlx5_ib_dev *dev, int c) ...@@ -415,6 +415,7 @@ static void clean_keys(struct mlx5_ib_dev *dev, int c)
int size; int size;
int err; int err;
cancel_delayed_work(&ent->dwork);
while (1) { while (1) {
spin_lock(&ent->lock); spin_lock(&ent->lock);
if (list_empty(&ent->head)) { if (list_empty(&ent->head)) {
...@@ -540,13 +541,15 @@ int mlx5_mr_cache_cleanup(struct mlx5_ib_dev *dev) ...@@ -540,13 +541,15 @@ int mlx5_mr_cache_cleanup(struct mlx5_ib_dev *dev)
int i; int i;
dev->cache.stopped = 1; dev->cache.stopped = 1;
destroy_workqueue(dev->cache.wq); flush_workqueue(dev->cache.wq);
mlx5_mr_cache_debugfs_cleanup(dev); mlx5_mr_cache_debugfs_cleanup(dev);
for (i = 0; i < MAX_MR_CACHE_ENTRIES; i++) for (i = 0; i < MAX_MR_CACHE_ENTRIES; i++)
clean_keys(dev, i); clean_keys(dev, i);
destroy_workqueue(dev->cache.wq);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment