Netdev Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH net] net/mlx5: Don't skip subfunction cleanup in case of error in module init
@ 2021-08-02 13:39 Leon Romanovsky
  2021-08-03  2:58 ` Parav Pandit
  2021-08-03  3:48 ` Saeed Mahameed
  0 siblings, 2 replies; 3+ messages in thread
From: Leon Romanovsky @ 2021-08-02 13:39 UTC (permalink / raw)
  To: Jakub Kicinski, David S . Miller
  Cc: Leon Romanovsky, netdev, Parav Pandit, Saeed Mahameed, Vu Pham

From: Leon Romanovsky <leonro@nvidia.com>

Clean SF resources if mlx5 eth failed to initialize.

Fixes: 1958fc2f0712 ("net/mlx5: SF, Add auxiliary device driver")
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
---
 drivers/net/ethernet/mellanox/mlx5/core/main.c      | 12 ++++--------
 drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h |  5 +++++
 2 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/main.c b/drivers/net/ethernet/mellanox/mlx5/core/main.c
index eb1b316560a8..c84ad87c99bb 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/main.c
@@ -1784,16 +1784,14 @@ static int __init init(void)
 	if (err)
 		goto err_sf;
 
-#ifdef CONFIG_MLX5_CORE_EN
 	err = mlx5e_init();
-	if (err) {
-		pci_unregister_driver(&mlx5_core_driver);
-		goto err_debug;
-	}
-#endif
+	if (err)
+		goto err_en;
 
 	return 0;
 
+err_en:
+	mlx5_sf_driver_unregister();
 err_sf:
 	pci_unregister_driver(&mlx5_core_driver);
 err_debug:
@@ -1803,9 +1801,7 @@ static int __init init(void)
 
 static void __exit cleanup(void)
 {
-#ifdef CONFIG_MLX5_CORE_EN
 	mlx5e_cleanup();
-#endif
 	mlx5_sf_driver_unregister();
 	pci_unregister_driver(&mlx5_core_driver);
 	mlx5_unregister_debugfs();
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h b/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h
index 343807ac2036..da365b8f0141 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h
@@ -206,8 +206,13 @@ int mlx5_firmware_flash(struct mlx5_core_dev *dev, const struct firmware *fw,
 int mlx5_fw_version_query(struct mlx5_core_dev *dev,
 			  u32 *running_ver, u32 *stored_ver);
 
+#ifdef CONFIG_MLX5_CORE_EN
 int mlx5e_init(void);
 void mlx5e_cleanup(void);
+#else
+static inline int mlx5e_init(void){ return 0; }
+static inline void mlx5e_cleanup(void){}
+#endif
 
 static inline bool mlx5_sriov_is_enabled(struct mlx5_core_dev *dev)
 {
-- 
2.31.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: [PATCH net] net/mlx5: Don't skip subfunction cleanup in case of error in module init
  2021-08-02 13:39 [PATCH net] net/mlx5: Don't skip subfunction cleanup in case of error in module init Leon Romanovsky
@ 2021-08-03  2:58 ` Parav Pandit
  2021-08-03  3:48 ` Saeed Mahameed
  1 sibling, 0 replies; 3+ messages in thread
From: Parav Pandit @ 2021-08-03  2:58 UTC (permalink / raw)
  To: Leon Romanovsky, Jakub Kicinski, David S . Miller
  Cc: Leon Romanovsky, netdev, Saeed Mahameed, Vu Pham



> From: Leon Romanovsky <leon@kernel.org>
> Sent: Monday, August 2, 2021 7:10 PM


> From: Leon Romanovsky <leonro@nvidia.com>
> 
> Clean SF resources if mlx5 eth failed to initialize.
> 
> Fixes: 1958fc2f0712 ("net/mlx5: SF, Add auxiliary device driver")
> Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
> ---
>  drivers/net/ethernet/mellanox/mlx5/core/main.c      | 12 ++++--------
>  drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h |  5 +++++
>  2 files changed, 9 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/main.c
> b/drivers/net/ethernet/mellanox/mlx5/core/main.c
> index eb1b316560a8..c84ad87c99bb 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/main.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/main.c
> @@ -1784,16 +1784,14 @@ static int __init init(void)
>  	if (err)
>  		goto err_sf;
> 
> -#ifdef CONFIG_MLX5_CORE_EN
>  	err = mlx5e_init();
> -	if (err) {
> -		pci_unregister_driver(&mlx5_core_driver);
> -		goto err_debug;
> -	}
> -#endif
> +	if (err)
> +		goto err_en;
> 
>  	return 0;
> 
> +err_en:
> +	mlx5_sf_driver_unregister();
>  err_sf:
>  	pci_unregister_driver(&mlx5_core_driver);
>  err_debug:
> @@ -1803,9 +1801,7 @@ static int __init init(void)
> 
>  static void __exit cleanup(void)
>  {
> -#ifdef CONFIG_MLX5_CORE_EN
>  	mlx5e_cleanup();
> -#endif
>  	mlx5_sf_driver_unregister();
>  	pci_unregister_driver(&mlx5_core_driver);
>  	mlx5_unregister_debugfs();
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h
> b/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h
> index 343807ac2036..da365b8f0141 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h
> @@ -206,8 +206,13 @@ int mlx5_firmware_flash(struct mlx5_core_dev
> *dev, const struct firmware *fw,  int mlx5_fw_version_query(struct
> mlx5_core_dev *dev,
>  			  u32 *running_ver, u32 *stored_ver);
> 
> +#ifdef CONFIG_MLX5_CORE_EN
>  int mlx5e_init(void);
>  void mlx5e_cleanup(void);
> +#else
> +static inline int mlx5e_init(void){ return 0; } static inline void
> +mlx5e_cleanup(void){} #endif
> 
mlx5e_*() functionality is provided by core/en.h and core/en_main.c
So above declaration should come from en_main.h, instead of mlx5_core.h, but we don't have en_main.h currently.
Including en.h is too much given rest of the other declarations in it.
So for net fix, this is ok, for net-next en.h should be improved and above declaration should move to en_main.h.

Reviewed-by: Parav Pandit <parav@nvidia.com>


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net] net/mlx5: Don't skip subfunction cleanup in case of error in module init
  2021-08-02 13:39 [PATCH net] net/mlx5: Don't skip subfunction cleanup in case of error in module init Leon Romanovsky
  2021-08-03  2:58 ` Parav Pandit
@ 2021-08-03  3:48 ` Saeed Mahameed
  1 sibling, 0 replies; 3+ messages in thread
From: Saeed Mahameed @ 2021-08-03  3:48 UTC (permalink / raw)
  To: Leon Romanovsky, Jakub Kicinski, David S . Miller
  Cc: Leon Romanovsky, netdev, Parav Pandit, Vu Pham

On Mon, 2021-08-02 at 16:39 +0300, Leon Romanovsky wrote:
> From: Leon Romanovsky <leonro@nvidia.com>
> 
> Clean SF resources if mlx5 eth failed to initialize.
> 
> Fixes: 1958fc2f0712 ("net/mlx5: SF, Add auxiliary device driver")
> Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
> ---

applied to net-mlx5 


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-08-03  3:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-02 13:39 [PATCH net] net/mlx5: Don't skip subfunction cleanup in case of error in module init Leon Romanovsky
2021-08-03  2:58 ` Parav Pandit
2021-08-03  3:48 ` Saeed Mahameed

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).