Author: hselasky
Date: Thu May 16 16:31:03 2019
New Revision: 347770
URL: https://svnweb.freebsd.org/changeset/base/347770

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/12/sys/dev/mlx5/driver.h
  stable/12/sys/dev/mlx5/mlx5_core/mlx5_health.c
  stable/12/sys/dev/mlx5/mlx5_en/mlx5_en_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 16:30:25 2019        
(r347769)
+++ stable/12/sys/dev/mlx5/driver.h     Thu May 16 16:31:03 2019        
(r347770)
@@ -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
@@ -505,6 +505,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/12/sys/dev/mlx5/mlx5_core/mlx5_health.c
==============================================================================
--- stable/12/sys/dev/mlx5/mlx5_core/mlx5_health.c      Thu May 16 16:30:25 
2019        (r347769)
+++ stable/12/sys/dev/mlx5/mlx5_core/mlx5_health.c      Thu May 16 16:31:03 
2019        (r347770)
@@ -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/12/sys/dev/mlx5/mlx5_en/mlx5_en_main.c
==============================================================================
--- stable/12/sys/dev/mlx5/mlx5_en/mlx5_en_main.c       Thu May 16 16:30:25 
2019        (r347769)
+++ stable/12/sys/dev/mlx5/mlx5_en/mlx5_en_main.c       Thu May 16 16:31:03 
2019        (r347770)
@@ -4133,13 +4133,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) {
@@ -4290,7 +4285,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);
@@ -4370,7 +4365,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);
 }
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to