Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 16 May 2019 18:12:14 +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-11@freebsd.org
Subject:   svn commit: r347861 - in stable/11/sys/dev/mlx5: . mlx5_core mlx5_en
Message-ID:  <201905161812.x4GICEdx033616@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: hselasky
Date: Thu May 16 18:12:14 2019
New Revision: 347861
URL: https://svnweb.freebsd.org/changeset/base/347861

Log:
  MFC r347305:
  Move workqueue from mlx5en(4) to mlx5core.
  
  This avoids creating more workqueues in mlx5core to do
  simple firmware command polling tasks.
  
  Sponsored by:	Mellanox Technologies

Modified:
  stable/11/sys/dev/mlx5/driver.h
  stable/11/sys/dev/mlx5/mlx5_core/mlx5_health.c
  stable/11/sys/dev/mlx5/mlx5_en/mlx5_en_main.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/dev/mlx5/driver.h
==============================================================================
--- stable/11/sys/dev/mlx5/driver.h	Thu May 16 18:11:25 2019	(r347860)
+++ stable/11/sys/dev/mlx5/driver.h	Thu May 16 18:12:14 2019	(r347861)
@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 2013-2017, Mellanox Technologies, Ltd.  All rights reserved.
+ * Copyright (c) 2013-2019, Mellanox Technologies, Ltd.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -503,6 +503,7 @@ struct mlx5_core_health {
 	u32				prev;
 	int				miss_counter;
 	u32				fatal_error;
+	struct workqueue_struct	       *wq_watchdog;
 	/* wq spinlock to synchronize draining */
 	spinlock_t			wq_lock;
 	struct workqueue_struct	       *wq;

Modified: stable/11/sys/dev/mlx5/mlx5_core/mlx5_health.c
==============================================================================
--- stable/11/sys/dev/mlx5/mlx5_core/mlx5_health.c	Thu May 16 18:11:25 2019	(r347860)
+++ stable/11/sys/dev/mlx5/mlx5_core/mlx5_health.c	Thu May 16 18:12:14 2019	(r347861)
@@ -604,26 +604,27 @@ void mlx5_health_cleanup(struct mlx5_core_dev *dev)
 	struct mlx5_core_health *health = &dev->priv.health;
 
 	destroy_workqueue(health->wq);
+	destroy_workqueue(health->wq_watchdog);
 }
 
-#define HEALTH_NAME "mlx5_health"
 int mlx5_health_init(struct mlx5_core_dev *dev)
 {
 	struct mlx5_core_health *health;
-	char *name;
-	int len;
+	char name[64];
 
 	health = &dev->priv.health;
-	len = strlen(HEALTH_NAME) + strlen(dev_name(&dev->pdev->dev));
-	name = kmalloc(len + 1, GFP_KERNEL);
-	if (!name)
-		return -ENOMEM;
 
-	snprintf(name, len, "%s:%s", HEALTH_NAME, dev_name(&dev->pdev->dev));
+	snprintf(name, sizeof(name), "%s-rec", dev_name(&dev->pdev->dev));
 	health->wq = create_singlethread_workqueue(name);
-	kfree(name);
 	if (!health->wq)
 		return -ENOMEM;
+
+	snprintf(name, sizeof(name), "%s-wdg", dev_name(&dev->pdev->dev));
+	health->wq_watchdog = create_singlethread_workqueue(name);
+	if (!health->wq_watchdog) {
+		destroy_workqueue(health->wq);
+		return -ENOMEM;
+	}
 
 	spin_lock_init(&health->wq_lock);
 	INIT_WORK(&health->work, health_care);

Modified: stable/11/sys/dev/mlx5/mlx5_en/mlx5_en_main.c
==============================================================================
--- stable/11/sys/dev/mlx5/mlx5_en/mlx5_en_main.c	Thu May 16 18:11:25 2019	(r347860)
+++ stable/11/sys/dev/mlx5/mlx5_en/mlx5_en_main.c	Thu May 16 18:12:14 2019	(r347861)
@@ -3875,13 +3875,8 @@ mlx5e_create_ifp(struct mlx5_core_dev *mdev)
 		goto err_free_sysctl;
 	}
 
-	snprintf(unit, sizeof(unit), "mce%u_wq",
-	    device_get_unit(mdev->pdev->dev.bsddev));
-	priv->wq = alloc_workqueue(unit, 0, 1);
-	if (priv->wq == NULL) {
-		if_printf(ifp, "%s: alloc_workqueue failed\n", __func__);
-		goto err_free_sysctl;
-	}
+	/* reuse mlx5core's watchdog workqueue */
+	priv->wq = mdev->priv.health.wq_watchdog;
 
 	err = mlx5_alloc_map_uar(mdev, &priv->cq_uar);
 	if (err) {
@@ -4013,7 +4008,7 @@ err_unmap_free_uar:
 	mlx5_unmap_free_uar(mdev, &priv->cq_uar);
 
 err_free_wq:
-	destroy_workqueue(priv->wq);
+	flush_workqueue(priv->wq);
 
 err_free_sysctl:
 	sysctl_ctx_free(&priv->sysctl_ctx);
@@ -4069,7 +4064,7 @@ mlx5e_destroy_ifp(struct mlx5_core_dev *mdev, void *vp
 	mlx5_core_dealloc_pd(priv->mdev, priv->pdn);
 	mlx5_unmap_free_uar(priv->mdev, &priv->cq_uar);
 	mlx5e_disable_async_events(priv);
-	destroy_workqueue(priv->wq);
+	flush_workqueue(priv->wq);
 	mlx5e_priv_mtx_destroy(priv);
 	free(priv, M_MLX5EN);
 }



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