svn commit: r347305 - in head/sys/dev/mlx5: . mlx5_core mlx5_en
Hans Petter Selasky
hselasky at FreeBSD.org
Wed May 8 10:57:39 UTC 2019
Author: hselasky
Date: Wed May 8 10:57:37 2019
New Revision: 347305
URL: https://svnweb.freebsd.org/changeset/base/347305
Log:
Move workqueue from mlx5en(4) to mlx5core.
This avoids creating more workqueues in mlx5core to do
simple firmware command polling tasks.
MFC after: 3 days
Sponsored by: Mellanox Technologies
Modified:
head/sys/dev/mlx5/driver.h
head/sys/dev/mlx5/mlx5_core/mlx5_health.c
head/sys/dev/mlx5/mlx5_en/mlx5_en_main.c
Modified: head/sys/dev/mlx5/driver.h
==============================================================================
--- head/sys/dev/mlx5/driver.h Wed May 8 10:57:16 2019 (r347304)
+++ head/sys/dev/mlx5/driver.h Wed May 8 10:57:37 2019 (r347305)
@@ -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: head/sys/dev/mlx5/mlx5_core/mlx5_health.c
==============================================================================
--- head/sys/dev/mlx5/mlx5_core/mlx5_health.c Wed May 8 10:57:16 2019 (r347304)
+++ head/sys/dev/mlx5/mlx5_core/mlx5_health.c Wed May 8 10:57:37 2019 (r347305)
@@ -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: head/sys/dev/mlx5/mlx5_en/mlx5_en_main.c
==============================================================================
--- head/sys/dev/mlx5/mlx5_en/mlx5_en_main.c Wed May 8 10:57:16 2019 (r347304)
+++ head/sys/dev/mlx5/mlx5_en/mlx5_en_main.c Wed May 8 10:57:37 2019 (r347305)
@@ -4134,13 +4134,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) {
@@ -4297,7 +4292,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);
@@ -4383,7 +4378,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);
}
More information about the svn-src-all
mailing list