[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240630222904.627462-26-bvanassche@acm.org>
Date: Sun, 30 Jun 2024 15:26:43 -0700
From: Bart Van Assche <bvanassche@....org>
To: Tejun Heo <tj@...nel.org>
Cc: Lai Jiangshan <jiangshanlai@...il.com>,
"Martin K . Petersen" <martin.petersen@...cle.com>,
linux-kernel@...r.kernel.org,
Bart Van Assche <bvanassche@....org>,
Saeed Mahameed <saeedm@...dia.com>,
Leon Romanovsky <leon@...nel.org>,
Tariq Toukan <tariqt@...dia.com>,
"David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>,
Wei Zhang <weizhang@...dia.com>,
Jacob Keller <jacob.e.keller@...el.com>,
Shay Drory <shayd@...dia.com>
Subject: [PATCH 25/53] net/mlx5: Simplify the create*_workqueue() calls
Pass a format string to create*_workqueue2() instead of formatting the
workqueue name before create*_workqueue() is called.
Signed-off-by: Bart Van Assche <bvanassche@....org>
---
drivers/net/ethernet/mellanox/mlx5/core/cmd.c | 12 ++----------
drivers/net/ethernet/mellanox/mlx5/core/health.c | 10 ++--------
.../net/ethernet/mellanox/mlx5/core/sf/vhca_event.c | 5 ++---
include/linux/mlx5/driver.h | 5 -----
4 files changed, 6 insertions(+), 26 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/cmd.c b/drivers/net/ethernet/mellanox/mlx5/core/cmd.c
index 20768ef2e9d2..bbc7d0f2fd40 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/cmd.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/cmd.c
@@ -1560,14 +1560,6 @@ static const struct file_operations olfops = {
.read = outlen_read,
};
-static void set_wqname(struct mlx5_core_dev *dev)
-{
- struct mlx5_cmd *cmd = &dev->cmd;
-
- snprintf(cmd->wq_name, sizeof(cmd->wq_name), "mlx5_cmd_%s",
- dev_name(dev->device));
-}
-
static void clean_debug_files(struct mlx5_core_dev *dev)
{
struct mlx5_cmd_debug *dbg = &dev->cmd.dbg;
@@ -2292,8 +2284,8 @@ int mlx5_cmd_init(struct mlx5_core_dev *dev)
spin_lock_init(&cmd->alloc_lock);
spin_lock_init(&cmd->token_lock);
- set_wqname(dev);
- cmd->wq = create_singlethread_workqueue(cmd->wq_name);
+ cmd->wq = create_singlethread_workqueue2("mlx5_cmd_%s",
+ dev_name(dev->device));
if (!cmd->wq) {
mlx5_core_err(dev, "failed to create command workqueue\n");
return -ENOMEM;
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/health.c b/drivers/net/ethernet/mellanox/mlx5/core/health.c
index a6329ca2d9bf..1c46bced73cd 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/health.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/health.c
@@ -869,7 +869,6 @@ int mlx5_health_init(struct mlx5_core_dev *dev)
{
struct devlink *devlink = priv_to_devlink(dev);
struct mlx5_core_health *health;
- char *name;
if (!mlx5_dev_is_lightweight(dev)) {
devl_lock(devlink);
@@ -879,14 +878,9 @@ int mlx5_health_init(struct mlx5_core_dev *dev)
mlx5_reporter_vnic_create(dev);
health = &dev->priv.health;
- name = kmalloc(64, GFP_KERNEL);
- if (!name)
- goto out_err;
- strcpy(name, "mlx5_health");
- strcat(name, dev_name(dev->device));
- health->wq = create_singlethread_workqueue(name);
- kfree(name);
+ health->wq = create_singlethread_workqueue2("mlx5_health%s",
+ dev_name(dev->device));
if (!health->wq)
goto out_err;
INIT_WORK(&health->fatal_report_work, mlx5_fw_fatal_reporter_err_work);
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/sf/vhca_event.c b/drivers/net/ethernet/mellanox/mlx5/core/sf/vhca_event.c
index cda01ba441ae..b761350617df 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/sf/vhca_event.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/sf/vhca_event.c
@@ -148,7 +148,6 @@ void mlx5_vhca_state_cap_handle(struct mlx5_core_dev *dev, void *set_hca_cap)
int mlx5_vhca_event_init(struct mlx5_core_dev *dev)
{
struct mlx5_vhca_state_notifier *notifier;
- char wq_name[MLX5_CMD_WQ_MAX_NAME];
struct mlx5_vhca_events *events;
int err, i;
@@ -162,8 +161,8 @@ int mlx5_vhca_event_init(struct mlx5_core_dev *dev)
events->dev = dev;
dev->priv.vhca_events = events;
for (i = 0; i < MLX5_DEV_MAX_WQS; i++) {
- snprintf(wq_name, MLX5_CMD_WQ_MAX_NAME, "mlx5_vhca_event%d", i);
- events->handler[i].wq = create_singlethread_workqueue(wq_name);
+ events->handler[i].wq =
+ create_singlethread_workqueue2("mlx5_vhca_event%d", i);
if (!events->handler[i].wq) {
err = -ENOMEM;
goto err_create_wq;
diff --git a/include/linux/mlx5/driver.h b/include/linux/mlx5/driver.h
index 779cfdf2e9d6..835b960b9fdc 100644
--- a/include/linux/mlx5/driver.h
+++ b/include/linux/mlx5/driver.h
@@ -66,10 +66,6 @@ enum {
MLX5_BOARD_ID_LEN = 64,
};
-enum {
- MLX5_CMD_WQ_MAX_NAME = 32,
-};
-
enum {
CMD_OWNER_SW = 0x0,
CMD_OWNER_HW = 0x1,
@@ -317,7 +313,6 @@ struct mlx5_cmd {
*/
spinlock_t token_lock;
u8 token;
- char wq_name[MLX5_CMD_WQ_MAX_NAME];
struct workqueue_struct *wq;
int mode;
u16 allowed_opcode;
Powered by blists - more mailing lists