]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - queue-4.19/net-mlx5-avoid-reloading-already-removed-devices.patch-5846
fix up the 5.1 queue :(
[thirdparty/kernel/stable-queue.git] / queue-4.19 / net-mlx5-avoid-reloading-already-removed-devices.patch-5846
1 From 51e480eb6aba358e6f3f5be906574e3c2b122780 Mon Sep 17 00:00:00 2001
2 From: Alaa Hleihel <alaa@mellanox.com>
3 Date: Sun, 19 May 2019 11:11:49 +0300
4 Subject: net/mlx5: Avoid reloading already removed devices
5
6 Prior to reloading a device we must first verify that it was not already
7 removed. Otherwise, the attempt to remove the device will do nothing, and
8 in that case we will end up proceeding with adding an new device that no
9 one was expecting to remove, leaving behind used resources such as EQs that
10 causes a failure to destroy comp EQs and syndrome (0x30f433).
11
12 Fix that by making sure that we try to remove and add a device (based on a
13 protocol) only if the device is already added.
14
15 Fixes: c5447c70594b ("net/mlx5: E-Switch, Reload IB interface when switching devlink modes")
16 Signed-off-by: Alaa Hleihel <alaa@mellanox.com>
17 Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
18 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
19 ---
20 drivers/net/ethernet/mellanox/mlx5/core/dev.c | 25 +++++++++++++++++--
21 1 file changed, 23 insertions(+), 2 deletions(-)
22
23 diff --git a/drivers/net/ethernet/mellanox/mlx5/core/dev.c b/drivers/net/ethernet/mellanox/mlx5/core/dev.c
24 index 37ba7c78859d..1c225be9c7db 100644
25 --- a/drivers/net/ethernet/mellanox/mlx5/core/dev.c
26 +++ b/drivers/net/ethernet/mellanox/mlx5/core/dev.c
27 @@ -342,11 +342,32 @@ void mlx5_unregister_interface(struct mlx5_interface *intf)
28 }
29 EXPORT_SYMBOL(mlx5_unregister_interface);
30
31 +/* Must be called with intf_mutex held */
32 +static bool mlx5_has_added_dev_by_protocol(struct mlx5_core_dev *mdev, int protocol)
33 +{
34 + struct mlx5_device_context *dev_ctx;
35 + struct mlx5_interface *intf;
36 + bool found = false;
37 +
38 + list_for_each_entry(intf, &intf_list, list) {
39 + if (intf->protocol == protocol) {
40 + dev_ctx = mlx5_get_device(intf, &mdev->priv);
41 + if (dev_ctx && test_bit(MLX5_INTERFACE_ADDED, &dev_ctx->state))
42 + found = true;
43 + break;
44 + }
45 + }
46 +
47 + return found;
48 +}
49 +
50 void mlx5_reload_interface(struct mlx5_core_dev *mdev, int protocol)
51 {
52 mutex_lock(&mlx5_intf_mutex);
53 - mlx5_remove_dev_by_protocol(mdev, protocol);
54 - mlx5_add_dev_by_protocol(mdev, protocol);
55 + if (mlx5_has_added_dev_by_protocol(mdev, protocol)) {
56 + mlx5_remove_dev_by_protocol(mdev, protocol);
57 + mlx5_add_dev_by_protocol(mdev, protocol);
58 + }
59 mutex_unlock(&mlx5_intf_mutex);
60 }
61
62 --
63 2.20.1
64