svn commit: r347249 - in head/sys/dev/mlx5: . mlx5_core

Hans Petter Selasky hselasky at FreeBSD.org
Wed May 8 10:27:31 UTC 2019


Author: hselasky
Date: Wed May  8 10:27:29 2019
New Revision: 347249
URL: https://svnweb.freebsd.org/changeset/base/347249

Log:
  Correctly define the interface state bits in mlx5en(4).
  
  While at it remove unused interface state bits. This also fixes and issue
  during shutdown:
  
  There is an issue where the firmware fails during mlx5_load_one,
  the health_care timer detects the issue and schedules a health_care call.
  Then the mlx5_load_one detects the issue, cleans up and quits. Then
  the health_care starts and calls mlx5_unload_one to clean up the resources
  that no longer exist and causes kernel panic.
  
  The root cause is that the bit MLX5_INTERFACE_STATE_DOWN is not set
  after mlx5_load_one fails. The solution is removing the bit
  MLX5_INTERFACE_STATE_DOWN and quit mlx5_unload_one if the
  bit MLX5_INTERFACE_STATE_UP is not set. The bit MLX5_INTERFACE_STATE_DOWN
  is redundant and we can use MLX5_INTERFACE_STATE_UP instead.
  
  Linux commit:
  10a8d00707082955b177164d4b4e758ffcbd4017
  b3cb5388499c5e219324bfe7da2e46cbad82bfcf
  
  MFC after:	3 days
  Sponsored by:	Mellanox Technologies

Modified:
  head/sys/dev/mlx5/driver.h
  head/sys/dev/mlx5/mlx5_core/mlx5_main.c

Modified: head/sys/dev/mlx5/driver.h
==============================================================================
--- head/sys/dev/mlx5/driver.h	Wed May  8 10:26:33 2019	(r347248)
+++ head/sys/dev/mlx5/driver.h	Wed May  8 10:27:29 2019	(r347249)
@@ -662,9 +662,7 @@ enum mlx5_device_state {
 };
 
 enum mlx5_interface_state {
-	MLX5_INTERFACE_STATE_DOWN = BIT(0),
-	MLX5_INTERFACE_STATE_UP = BIT(1),
-	MLX5_INTERFACE_STATE_SHUTDOWN = BIT(2),
+	MLX5_INTERFACE_STATE_UP,
 };
 
 enum mlx5_pci_status {

Modified: head/sys/dev/mlx5/mlx5_core/mlx5_main.c
==============================================================================
--- head/sys/dev/mlx5/mlx5_core/mlx5_main.c	Wed May  8 10:26:33 2019	(r347248)
+++ head/sys/dev/mlx5/mlx5_core/mlx5_main.c	Wed May  8 10:27:29 2019	(r347249)
@@ -1096,7 +1096,6 @@ static int mlx5_load_one(struct mlx5_core_dev *dev, st
 		goto err_fs;
 	}
 
-	clear_bit(MLX5_INTERFACE_STATE_DOWN, &dev->intf_state);
 	set_bit(MLX5_INTERFACE_STATE_UP, &dev->intf_state);
 
 out:
@@ -1159,7 +1158,7 @@ static int mlx5_unload_one(struct mlx5_core_dev *dev, 
 		mlx5_drain_health_recovery(dev);
 
 	mutex_lock(&dev->intf_state_mutex);
-	if (test_bit(MLX5_INTERFACE_STATE_DOWN, &dev->intf_state)) {
+	if (!test_bit(MLX5_INTERFACE_STATE_UP, &dev->intf_state)) {
 		dev_warn(&dev->pdev->dev, "%s: interface is down, NOP\n", __func__);
                 if (cleanup)
                         mlx5_cleanup_once(dev);
@@ -1191,7 +1190,6 @@ static int mlx5_unload_one(struct mlx5_core_dev *dev, 
 
 out:
 	clear_bit(MLX5_INTERFACE_STATE_UP, &dev->intf_state);
-	set_bit(MLX5_INTERFACE_STATE_DOWN, &dev->intf_state);
 	mutex_unlock(&dev->intf_state_mutex);
 	return err;
 }
@@ -1451,7 +1449,6 @@ static void shutdown_one(struct pci_dev *pdev)
 	struct mlx5_priv *priv = &dev->priv;
 	int err;
 
-	set_bit(MLX5_INTERFACE_STATE_SHUTDOWN, &dev->intf_state);
 	err = mlx5_try_fast_unload(dev);
 	if (err)
 	        mlx5_unload_one(dev, priv, false);


More information about the svn-src-all mailing list