]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - queue-4.19/net-mlx5-avoid-reloading-already-removed-devices.patch
Linux 5.1.13
[thirdparty/kernel/stable-queue.git] / queue-4.19 / net-mlx5-avoid-reloading-already-removed-devices.patch
1 From foo@baz Wed 19 Jun 2019 02:34:37 PM CEST
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 From: Alaa Hleihel <alaa@mellanox.com>
7
8 Prior to reloading a device we must first verify that it was not already
9 removed. Otherwise, the attempt to remove the device will do nothing, and
10 in that case we will end up proceeding with adding an new device that no
11 one was expecting to remove, leaving behind used resources such as EQs that
12 causes a failure to destroy comp EQs and syndrome (0x30f433).
13
14 Fix that by making sure that we try to remove and add a device (based on a
15 protocol) only if the device is already added.
16
17 Fixes: c5447c70594b ("net/mlx5: E-Switch, Reload IB interface when switching devlink modes")
18 Signed-off-by: Alaa Hleihel <alaa@mellanox.com>
19 Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
20 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
21 ---
22 drivers/net/ethernet/mellanox/mlx5/core/dev.c | 25 +++++++++++++++++++++++--
23 1 file changed, 23 insertions(+), 2 deletions(-)
24
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 ml
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