Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 16 May 2019 15:42:48 +0000 (UTC)
From:      Hans Petter Selasky <hselasky@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org
Subject:   svn commit: r347713 - in stable/12/sys/dev/mlx5: . mlx5_core
Message-ID:  <201905161542.x4GFgmh6045899@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: hselasky
Date: Thu May 16 15:42:47 2019
New Revision: 347713
URL: https://svnweb.freebsd.org/changeset/base/347713

Log:
  MFC r347249:
  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
  
  Sponsored by:	Mellanox Technologies

Modified:
  stable/12/sys/dev/mlx5/driver.h
  stable/12/sys/dev/mlx5/mlx5_core/mlx5_main.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/dev/mlx5/driver.h
==============================================================================
--- stable/12/sys/dev/mlx5/driver.h	Thu May 16 15:42:00 2019	(r347712)
+++ stable/12/sys/dev/mlx5/driver.h	Thu May 16 15:42:47 2019	(r347713)
@@ -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: stable/12/sys/dev/mlx5/mlx5_core/mlx5_main.c
==============================================================================
--- stable/12/sys/dev/mlx5/mlx5_core/mlx5_main.c	Thu May 16 15:42:00 2019	(r347712)
+++ stable/12/sys/dev/mlx5/mlx5_core/mlx5_main.c	Thu May 16 15:42:47 2019	(r347713)
@@ -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);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201905161542.x4GFgmh6045899>